2007-02-23 Nagappan A <anagappan@novell.com>
[mono.git] / mcs / tools / monop / monop.cs
index 8840975980f617b255ed8e93431180196c651720..df046cd903e714f42bdd7ddaa9c785433b9a8ae0 100644 (file)
@@ -121,7 +121,13 @@ class MonoP {
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.FileName = "gacutil";
                p.StartInfo.Arguments = "-l";
-               p.Start ();
+               try {
+                       p.Start ();
+               }
+               catch {
+                       Console.WriteLine ("WARNING: gacutil could not be found.");
+                       return new string[0];
+               }
 
                string s;
                ArrayList names = new ArrayList ();
@@ -192,7 +198,14 @@ class MonoP {
                return GetType (tname, false);
        }
 
-       static void PrintTypes (string assembly, bool show_private)
+       static void PrintRefs (string assembly)
+       {
+               Assembly a = GetAssembly (assembly, true);
+               foreach (AssemblyName an in a.GetReferencedAssemblies ())
+                       Console.WriteLine (an);
+       }
+
+       static void PrintTypes (string assembly, bool show_private, bool filter_obsolete)
        {
                Assembly a = GetAssembly (assembly, true);
 
@@ -213,10 +226,15 @@ class MonoP {
                Type [] types = show_private ? a.GetTypes () : a.GetExportedTypes ();
                Array.Sort (types, new TypeSorter ());
 
-               foreach (Type t in types)
-                       Console.WriteLine (t.FullName);
+               int obsolete_count = 0;
+               foreach (Type t in types) {
+                       if (filter_obsolete && t.IsDefined (typeof (ObsoleteAttribute), false))
+                               obsolete_count ++;
+                       else
+                               Console.WriteLine (t.FullName);
+               }
 
-               Console.WriteLine ("\nTotal: {0} types.", types.Length);
+               Console.WriteLine ("\nTotal: {0} types.", types.Length - obsolete_count);
        }
        
        internal static void Completion (string prefix)
@@ -268,7 +286,10 @@ class MonoP {
                        assembly = options.AssemblyReference;
                        
                        if (options.Type == null) {
-                               PrintTypes (assembly, options.ShowPrivate);
+                               if (options.PrintRefs)
+                                       PrintRefs (assembly);
+                               else
+                                       PrintTypes (assembly, options.ShowPrivate, options.FilterObsolete);
                                return;
                        }
                }