diff options
Diffstat (limited to 'mcs/tools/security/permview.cs')
-rw-r--r-- | mcs/tools/security/permview.cs | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/mcs/tools/security/permview.cs b/mcs/tools/security/permview.cs index 0f20d1f880d..cfe379c11de 100644 --- a/mcs/tools/security/permview.cs +++ b/mcs/tools/security/permview.cs @@ -20,22 +20,22 @@ using Mono.Cecil; [assembly: AssemblyTitle ("Mono PermView")] [assembly: AssemblyDescription ("Managed Permission Viewer for .NET assemblies")] -namespace Mono.Tools {
-
- class SecurityElementComparer : IComparer {
-
- public int Compare (object x, object y)
- {
- SecurityElement sx = (x as SecurityElement);
- SecurityElement sy = (y as SecurityElement);
- if (sx == null)
- return (sy == null) ? 0 : -1;
- else if (sy == null)
- return 1;
-
- // compare by name (type name, method name, action name)
- return String.Compare (sx.Attribute ("Name"), sy.Attribute ("Name"));
- }
+namespace Mono.Tools { + + class SecurityElementComparer : IComparer { + + public int Compare (object x, object y) + { + SecurityElement sx = (x as SecurityElement); + SecurityElement sy = (y as SecurityElement); + if (sx == null) + return (sy == null) ? 0 : -1; + else if (sy == null) + return 1; + + // compare by name (type name, method name, action name) + return String.Compare (sx.Attribute ("Name"), sy.Attribute ("Name")); + } } class PermView { @@ -47,8 +47,8 @@ namespace Mono.Tools { Console.WriteLine ("Usage: permview [options] assembly{0}", Environment.NewLine); Console.WriteLine ("where options are:"); Console.WriteLine (" -output filename Output information into specified file."); - Console.WriteLine (" -decl Show declarative security attributes on classes and methods.");
- Console.WriteLine (" -xml Output in XML format");
+ Console.WriteLine (" -decl Show declarative security attributes on classes and methods."); + Console.WriteLine (" -xml Output in XML format"); Console.WriteLine (" -help Show help informations (this text)"); Console.WriteLine (); } @@ -165,15 +165,15 @@ namespace Mono.Tools { } static SecurityElement AddSecurityXml (SecurityDeclarationCollection declarations) - {
- ArrayList list = new ArrayList ();
- foreach (SecurityDeclaration declsec in declarations) {
- SecurityElement child = new SecurityElement ("Action");
- AddAttribute (child, "Name", declsec.Action.ToString ());
- child.AddChild (declsec.PermissionSet.ToXml ());
- list.Add (child);
- }
- // sort actions
+ { + ArrayList list = new ArrayList (); + foreach (SecurityDeclaration declsec in declarations) { + SecurityElement child = new SecurityElement ("Action"); + AddAttribute (child, "Name", declsec.Action.ToString ()); + child.AddChild (declsec.PermissionSet.ToXml ()); + list.Add (child); + } + // sort actions list.Sort (Comparer); SecurityElement se = new SecurityElement ("Actions"); @@ -181,8 +181,8 @@ namespace Mono.Tools { se.AddChild (child); } return se; - }
-
+ } + static SecurityElementComparer comparer; static IComparer Comparer { get { @@ -193,7 +193,7 @@ namespace Mono.Tools { } static bool ProcessAssemblyXml (TextWriter tw, AssemblyDefinition ad) - {
+ { SecurityElement se = new SecurityElement ("Assembly"); se.AddAttribute ("Name", ad.Name.FullName); @@ -201,7 +201,7 @@ namespace Mono.Tools { se.AddChild (AddSecurityXml (ad.SecurityDeclarations)); } - ArrayList tlist = new ArrayList ();
+ ArrayList tlist = new ArrayList (); ArrayList mlist = new ArrayList (); foreach (ModuleDefinition module in ad.Modules) { @@ -214,13 +214,13 @@ namespace Mono.Tools { SecurityElement typelem = null; if (type.SecurityDeclarations.Count > 0) { typelem = AddSecurityXml (type.SecurityDeclarations); - }
-
- if (mlist.Count > 0)
+ } + + if (mlist.Count > 0) mlist.Clear (); foreach (MethodDefinition method in type.Methods) { - if (method.SecurityDeclarations.Count > 0) {
+ if (method.SecurityDeclarations.Count > 0) { SecurityElement meth = new SecurityElement ("Method"); AddAttribute (meth, "Name", method.ToString ()); meth.AddChild (AddSecurityXml (method.SecurityDeclarations)); @@ -228,14 +228,14 @@ namespace Mono.Tools { } } - // sort methods
- mlist.Sort (Comparer);
- foreach (SecurityElement method in mlist) {
- methods.AddChild (method);
+ // sort methods + mlist.Sort (Comparer); + foreach (SecurityElement method in mlist) { + methods.AddChild (method); } if ((typelem != null) || ((methods.Children != null) && (methods.Children.Count > 0))) { - AddAttribute (klass, "Name", type.ToString ());
+ AddAttribute (klass, "Name", type.ToString ()); if (typelem != null) klass.AddChild (typelem); if ((methods.Children != null) && (methods.Children.Count > 0)) @@ -245,9 +245,9 @@ namespace Mono.Tools { } // sort types - tlist.Sort (Comparer);
- foreach (SecurityElement type in tlist) {
- se.AddChild (type);
+ tlist.Sort (Comparer); + foreach (SecurityElement type in tlist) { + se.AddChild (type); } } |