I had a week of no internet access, so I had far too much time on my hands.
authorJonathan Pryor <jpryor@novell.com>
Tue, 31 Dec 2002 18:45:12 +0000 (18:45 -0000)
committerJonathan Pryor <jpryor@novell.com>
Tue, 31 Dec 2002 18:45:12 +0000 (18:45 -0000)
When I wasn't recovering from stomach flu, anyway...

All in all, a good Christmas.

Summary:
  - Made tools/makefile.gnu recursive, much like the top-level makefile.gnu.
    This was principally done so that the type-reflector install target could
    install additional files (currently it installs type-reflector.exe and
    type-reflector.exe.config; this may expand in the future).
  - Massive cleanup/improvements to type-reflector

The biggest news is that a Gtk# front-end exists for type-reflector now.  It
is incomplete (due to my learning Gtk# with this program) and needs
improvement, but it works...  Sort of.

It's not enabled by default, as I don't want to require that the
Gtk#/Gnome#/Glade# assemblies be available to build mcs from CVS.

To enable the type-reflector Gtk# front-end, do two things:
  - Rebuild type-reflector: cd tools/type-reflector && make -f makefile.gnu gui
  - When running, specify the --displayer=gtk parameter, e.g.
      type-reflector.exe --displayer=gtk -S .

svn path=/trunk/mcs/; revision=10020

48 files changed:
mcs/tools/ChangeLog
mcs/tools/makefile.gnu
mcs/tools/type-reflector/CSharpNodeFormatter.cs
mcs/tools/type-reflector/ChangeLog
mcs/tools/type-reflector/ConsoleOutput.cs [deleted file]
mcs/tools/type-reflector/ConsoleTypeDisplayer.cs [new file with mode: 0644]
mcs/tools/type-reflector/ExplicitNodeFinder.cs
mcs/tools/type-reflector/Factories.cs
mcs/tools/type-reflector/ITypeDisplayer.cs [new file with mode: 0644]
mcs/tools/type-reflector/IndentingTextWriter.cs
mcs/tools/type-reflector/LanguageNodeFormatter.cs
mcs/tools/type-reflector/Makefile
mcs/tools/type-reflector/Node.cs
mcs/tools/type-reflector/NodeFinder.cs
mcs/tools/type-reflector/NodeFormatter.cs
mcs/tools/type-reflector/NodeInfo.cs
mcs/tools/type-reflector/ProgramOptions.cs
mcs/tools/type-reflector/README
mcs/tools/type-reflector/ReflectionNodeFinder.cs
mcs/tools/type-reflector/TestTypes.cs
mcs/tools/type-reflector/TypeDisplayer.cs [new file with mode: 0644]
mcs/tools/type-reflector/TypeFactory.cs
mcs/tools/type-reflector/TypeLoader.cs
mcs/tools/type-reflector/TypeReflectorApp.cs [new file with mode: 0644]
mcs/tools/type-reflector/TypeReflectorOptions.cs
mcs/tools/type-reflector/VBNodeFormatter.cs [new file with mode: 0644]
mcs/tools/type-reflector/displayers/ConsoleTypeDisplayer.cs [new file with mode: 0644]
mcs/tools/type-reflector/displayers/ITypeDisplayer.cs [new file with mode: 0644]
mcs/tools/type-reflector/displayers/IndentingTextWriter.cs
mcs/tools/type-reflector/displayers/TypeDisplayer.cs [new file with mode: 0644]
mcs/tools/type-reflector/displayers/gtk/ChangeLog [new file with mode: 0644]
mcs/tools/type-reflector/displayers/gtk/GtkTypeDisplayer.cs [new file with mode: 0644]
mcs/tools/type-reflector/displayers/gtk/type-reflector.glade [new file with mode: 0644]
mcs/tools/type-reflector/displayers/gtk/type-reflector.gladep [new file with mode: 0644]
mcs/tools/type-reflector/finders/ExplicitNodeFinder.cs
mcs/tools/type-reflector/finders/NodeFinder.cs
mcs/tools/type-reflector/finders/ReflectionNodeFinder.cs
mcs/tools/type-reflector/formatters/CSharpNodeFormatter.cs
mcs/tools/type-reflector/formatters/LanguageNodeFormatter.cs
mcs/tools/type-reflector/formatters/NodeFormatter.cs
mcs/tools/type-reflector/formatters/VBNodeFormatter.cs [new file with mode: 0644]
mcs/tools/type-reflector/gtk/ChangeLog [new file with mode: 0644]
mcs/tools/type-reflector/gtk/GtkTypeDisplayer.cs [new file with mode: 0644]
mcs/tools/type-reflector/gtk/type-reflector.glade [new file with mode: 0644]
mcs/tools/type-reflector/gtk/type-reflector.gladep [new file with mode: 0644]
mcs/tools/type-reflector/makefile.core [new file with mode: 0644]
mcs/tools/type-reflector/makefile.gnu [new file with mode: 0644]
mcs/tools/type-reflector/type-reflector.exe.config

index 7959222f5eec3e5ad5ff8d3646d008affe48fb7d..60bbd688ab7135bc126cc00432408eb07d9f542d 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-31  Jonathan Pryor <jonpryor@vt.edu>
+
+  * makefile.gnu: Add support for DIRS to all, install targets.  This was done
+    so type-reflector's install target could be independent/self-contained.
+
 2002-12-27  Sebastien Pouliot  <spouliot@videotron.ca>
 
        * ASN1.cs: New. Classes to manipulate Abstract Syntax Notation 1
index 98aa27c2add129f17aa86c1544df2ea2899d1e9c..918a97b81ba6ed420b485b94ec9a75a15b13952b 100644 (file)
@@ -5,12 +5,19 @@ INSTALL = /usr/bin/install
 
 MONO_TOOLS = monostyle.exe GenerateDelegate.exe EnumCheck.exe IFaceDisco.exe ./SqlSharp/sqlsharp.exe secutil.exe Cert2Spc.exe
 
+DIRS = type-reflector
+
 # tools commented here because they were unable to build under linux
 #MONO_TOOLS = monostyle.exe verifier.exe GenerateDelegate.exe EnumCheck.exe IFaceDisco.exe ./type-reflector/type-reflector.exe ./corcompare/CorCompare.exe ./SqlSharp/SqlSharpCli.exe
 
+all: tools
+       for i in $(DIRS) ; do \
+               $(MAKE) -C $$i -f makefile.gnu $@ || exit 1; \
+       done
+
 linx: $(MONO_TOOLS)
 
-all: $(MONO_TOOLS)
+tools: $(MONO_TOOLS)
 
 windows: $(MONO_TOOLS)
 
@@ -23,6 +30,9 @@ install: all
        for i in $(MONO_TOOLS) ; do \
                ($(INSTALL) -m 755 $$i $(prefix)/bin/) || exit 1; \
        done
+       for i in $(DIRS) ; do \
+               $(MAKE) -C $$i -f makefile.gnu $@ || exit 1; \
+       done
 
 monostyle.exe: monostyle.cs
        $(CSC) $(CSCFLAGS) monostyle.cs
@@ -33,9 +43,6 @@ GenerateDelegate.exe: GenerateDelegate.cs
 verifier.exe: verifier.cs
        $(CSC) $(CSCFLAGS) verifier.cs
 
-./type-reflector/type-reflector.exe: dummy
-       (cd type-reflector; make CSC=$(CSC))
-
 ./SqlSharp/sqlsharp.exe: dummy
        (cd SqlSharp; make CSC=$(CSC))
 
@@ -67,11 +74,13 @@ Cert2Spc.exe: cert2spc.cs ASN1.cs
 
 clean:
        (cd corcompare; make clean)
-       (cd type-reflector; make clean)
        (cd SqlSharp; make clean)
        rm -f *.exe *.pdb *.dbg *.dll
        rm -f cormissing.xml
        rm -f ../../mono/doc/pending-classes.in
+       for i in $(DIRS) ; do \
+               $(MAKE) -C $$i -f makefile.gnu $@ || exit 1; \
+       done
 
 dummy:
 
index f972905e8b9dcf2eef89d6557a4465696760e5a9..9ef10d1679a980dd42e53e3d611a23b5ec1da53b 100644 (file)
@@ -22,230 +22,37 @@ namespace Mono.TypeReflector
                {
                }
 
-               protected override string GetTypeDescription (Type type, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetAttributes (sb, type);
-                       sb.Append (base.GetTypeDescription (type, instance));
-                       return sb.ToString();
-               }
-
-               private void GetAttributes (StringBuilder sb, MemberInfo m)
-               {
-                       GetAttributes (sb, m, true);
-               }
-
-               private void GetAttributes (StringBuilder sb, MemberInfo m, bool newline)
-               {
-                       GetCilAttributes (sb, m, newline);
-                       sb.Append (GetCustomAttributes (m, "", newline));
-               }
-
-               private void GetCilAttributes (StringBuilder sb, MemberInfo m, bool newline)
-               {
-                       Type t = m as Type;
-                       MethodBase mb = m as MethodBase;
-                       if (t != null)
-                               GetCilAttributes (sb, t, newline);
-                       else if (mb != null)
-                               GetCilAttributes (sb, mb, newline);
-               }
-
-               private void GetCilAttributes (StringBuilder sb, Type t, bool newline)
-               {
-                       if (t.IsSerializable) {
-                               sb.Append ("[Serializable]");
-                               if (newline)
-                                       sb.Append ("\n");
-                       }
-               }
-
-               private void GetCilAttributes (StringBuilder sb, MethodBase m, bool newline)
-               {
-                       MethodImplAttributes attr = m.GetMethodImplementationFlags ();
-                       if ((attr & MethodImplAttributes.InternalCall) != 0) {
-                               sb.Append ("[MethodImplAttribute(MethodImplOptions.InternalCall)]");
-                               if (newline)
-                                       sb.Append ("\n");
-                       }
-               }
-
-               protected override string GetBaseTypeDescription (Type type, object instance)
-               {
-                       return ": " + type.Name;
-               }
-
-               protected override string GetInterfaceDescription (Type type, object instance)
-               {
-                       return ", " + type.Name;
-               }
-
-               protected override string GetConstructorDescription (ConstructorInfo ctor, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetAttributes (sb, ctor);
-                       GetMethodQualifiers (sb, ctor);
-                       sb.AppendFormat ("{0} ", ctor.DeclaringType.Name);
-                       GetMethodArgs (sb, ctor);
-
-                       return sb.ToString();
-               }
-
-               private void GetMethodQualifiers (StringBuilder sb, MethodBase m)
-               {
-                       if (m.IsPublic)
-                               sb.Append ("public ");
-                       if (m.IsFamily)
-                               sb.Append ("protected ");
-                       if (m.IsAssembly)
-                               sb.Append ("internal ");
-                       if (m.IsPrivate)
-                               sb.Append ("private ");
-                       if (m.IsStatic)
-                               sb.Append ("static ");
-                       if (m.IsFinal)
-                               sb.Append ("sealed ");
-                       if (m.IsAbstract)
-                               sb.Append ("abstract ");
-                       else if (m.IsVirtual)
-                               sb.Append ("virtual ");
-               }
-
-               private void GetMethodArgs (StringBuilder sb, MethodBase m)
-               {
-                       sb.Append ("(");
-                       ParameterInfo[] parms = m.GetParameters ();
-                       if (parms.Length != 0) {
-                               int cur = 0;
-                               foreach (ParameterInfo pi in parms) {
-                                       sb.Append (GetParameterDescription (pi, pi));
-                                       if (cur++ != (parms.Length-1))
-                                               sb.Append (", ");
-                               }
-                       }
-                       sb.Append (")");
-               }
+               protected override string LineComment       {get {return "//";}}
 
-               protected override string GetEventDescription (EventInfo e, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetMethodQualifiers (sb, e.GetAddMethod (true));
-                       return String.Format ("{0}{1}{2} {3}", 
-                                       sb.ToString(),
-                                       e.IsMulticast ? "event " : "",
-                                       e.EventHandlerType,
-                                       e.Name);
-               }
-
-               protected override string GetFieldDescription (FieldInfo field, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
+               protected override string KeywordClass      {get {return "class";}}
+               protected override string KeywordEnum       {get {return "enum";}}
+               protected override string KeywordValueType  {get {return "struct";}}
+               protected override string KeywordInterface  {get {return "interface";}}
+               protected override string KeywordInherits   {get {return ":";}}
+               protected override string KeywordImplements {get {return ",";}}
+               protected override string KeywordMulticast  {get {return "event";}}
+               protected override string KeywordStatementTerminator {get {return ";";}}
+               protected override string KeywordStatementSeparator  {get {return ",";}}
 
-                       GetAttributes (sb, field);
-
-                       if (!field.DeclaringType.IsEnum || field.IsSpecialName) {
-                               if (field.IsPublic)
-                                       sb.Append ("public ");
-                               if (field.IsPrivate)
-                                       sb.Append ("private ");
-                               if (field.IsAssembly)
-                                       sb.Append ("internal ");
-                               if (field.IsFamily)
-                                       sb.Append ("protected ");
-                               if (field.IsLiteral)
-                                       sb.Append ("const ");
-                               else if (field.IsStatic)
-                                       sb.Append ("static ");
-
-                               sb.AppendFormat ("{0} ", field.FieldType);
-                       }
-
-                       sb.AppendFormat ("{0}", field.Name);
-
-                       try {
-                               sb.AppendFormat (" = {0}", GetValue (field.GetValue (instance)));
-                       }
-                       catch {
-                       }
-
-                       if (!field.DeclaringType.IsEnum || field.IsSpecialName)
-                               sb.Append (";");
-                       else
-                               sb.Append (",");
-
-                       return sb.ToString ();
-               }
-
-               protected override string GetMethodDescription (MethodInfo method, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-
-                       if (method.IsSpecialName)
-                               sb.Append ("/* Method is a specially named method:\n");
-
-                       GetAttributes (sb, method);
-                       if (method.ReturnTypeCustomAttributes != null) {
-                               sb.Append (GetCustomAttributes (method.ReturnTypeCustomAttributes, "return: ", true));
-                       }
-                       GetMethodQualifiers (sb, method);
-                       sb.AppendFormat ("{0} {1} ", method.ReturnType, method.Name);
-                       GetMethodArgs (sb, method);
-                       
-                       if (method.GetParameters().Length == 0) {
-                               try {
-                                       object r = method.Invoke (instance, null);
-                                       string s = GetValue (r);
-                                       sb.AppendFormat ("={0}", s);
-                               }
-                               catch {
-                               }
-                       }
-
-                       if (method.IsSpecialName) {
-                               sb.Append ("\n */");
-                       }
-
-                       return sb.ToString();
-               }
-
-               protected override string GetParameterDescription (ParameterInfo param, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-
-                       sb.Append (GetCustomAttributes (param, "", false));
-                       if (param.IsOut)
-                               sb.Append ("out ");
-                       sb.AppendFormat ("{0} {1}", param.ParameterType, param.Name);
-
-                       return sb.ToString();
-               }
-
-               protected override string GetPropertyDescription (PropertyInfo property, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetAttributes (sb, property);
-                       GetMethodQualifiers (sb, property.GetAccessors(true)[0]);
+               protected override string QualifierPublic   {get {return "public";}}
+               protected override string QualifierFamily   {get {return "protected";}}
+               protected override string QualifierAssembly {get {return "internal";}}
+               protected override string QualifierPrivate  {get {return "private";}}
+               protected override string QualifierFinal    {get {return "sealed";}}
+               protected override string QualifierStatic   {get {return "static";}}
+               protected override string QualifierLiteral  {get {return "const";}}
+               protected override string QualifierAbstract {get {return "abstract";}}
+               protected override string QualifierVirtual  {get {return "virtual";}}
 
-                       sb.AppendFormat ("{0} {1} {{", property.PropertyType, property.Name);
-                       if (property.CanRead) {
-                               sb.Append ("get");
-                               try {
-                                       sb.AppendFormat (" /* = {0} */", GetValue (property.GetValue (instance, null)));
-                               }
-                               catch {
-                               }
-                               sb.Append ("; ");
-                       }
-                       if (property.CanWrite)
-                               sb.Append ("set; ");
-                       sb.Append ("}}");
+               private static readonly string[] attributeDelimeters = new string[]{"[", "]"};
 
-                       return sb.ToString();
+               protected override string[] AttributeDelimeters {
+                       get {return attributeDelimeters;}
                }
 
-               protected override string GetReturnValueDescription (NodeInfo n)
+               protected override string GetConstructorName (ConstructorInfo ctor)
                {
-                       return string.Format ("/* ReturnValue={0} */", GetOtherDescription (n));
+                       return ctor.DeclaringType.Name;
                }
        }
 }
index 3fd7e821818653e3be4eb19044c2a412d298f19d..0b0fd0138ba8448854120afd4a812c30fded1e5b 100644 (file)
@@ -1,3 +1,51 @@
+2002-12-31  Jonathan Pryor <jonpryor@vt.edu>
+       * ConsoleTypeDisplayer.cs: New; Display reflection information to the console
+       * CSharpNodeFormatter.cs: Most formatting information was moved to
+         LanguageNodeFormatter.cs (to permit sharing with the VBNodeFormatter)
+       * ExplicitNodeFinder.cs: Updates due to NodeFinder changes.
+       * Factories.cs: Add new "Displayer" factory, remove "Factory" from name of
+         factory objects; the fact they're in a "Factories" class should be
+               sufficient.
+       * IndentingTextWriter.cs: Ensure that if a string sent to Write or WriteLine
+         contains embedded newlines, that we indent the text after the newlines
+               appropriately.
+       * ITypeDisplayer.cs: New; Abstraction for displaying reflection information
+       * LanguageNodeFormatter.cs: Massive cleanup & Consolidation of features.
+         Now works as a control class for generating Language-like output,
+               simplifying C# and VB.NET language formatting.
+       * Makefile: Most contents moved to `makefile.core'; just sets variables and
+         forwards operation to `makefile.core'.
+       * Node.cs: Debugging ToString() implementation
+       * NodeFinder.cs: Change virtual Get* methods to Add* methods, as
+         they're supposed to Add stuff to the Collection object passed as the first
+               paramter, not actually return ("get") anything; Removed `maxDepth', as
+               it's not used in the NodeFinder.
+       * NodeFormatter.cs: Move language-like attribute formatting to
+         LanguageNodeFormatter; check that base type isn't null before accessing
+               its name; recent CVS snapshots have the base object of interfaces as the
+               null object (before it was System.Object); this may be a mono bug.
+       * NodeInfo.cs: Debugging ToString() implementation
+       * ProgramOptions.cs: Make classes public, not internal
+       * README: Updates
+       * ReflectionNodeFinder.cs: Updates due to NodeFinder changes.
+       * TestTypes.cs: More tests
+       * TypeDisplayer.cs: New; Helper implementation for ITypeDisplayer
+       * TypeFactory.cs: Trace/log the exception generated when creating a new
+         object
+       * TypeLoader.cs: Take a list of types to search for, not just a single type.
+         This simplifies looking for types, as we can do a single search for all
+               types, instead of separate searches for each type.  Also improves
+               performance.
+       * TypeReflectorApp.cs: New; Formerly ConsoleOutput.cs; sets things in motion
+       * TypeReflectorOptions.cs: Make public; Add --displayer argument
+       * VBNodeFormatter.cs: New; Displayer reflection information in VB.NET
+       * gtk: new directory for Gtk# front-end
+       * makefile.core: New; Common makefile rules shared between Makefile,
+         makefile.gnu
+       * makefile.gnu: New; makefile used on Linux, used by tools/makefile.gnu for
+         recursive makes.
+       * type-reflector.exe.config: Add new switch, sample listener
+
 2002-12-21  Jonathan Pryor <jonpryor@vt.edu>
        * ConsoleOutput.cs: Use a Switch for trace messages.
        * ExplicitNodeFinder.cs: Use a Switch for trace messages.
diff --git a/mcs/tools/type-reflector/ConsoleOutput.cs b/mcs/tools/type-reflector/ConsoleOutput.cs
deleted file mode 100644 (file)
index fc84246..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-//
-// ConsoleOutput.cs: 
-//   Finds types and (optionally) shows reflection information about 
-//   the types.
-//
-// Author: Jonathan Pryor (jonpryor@vt.edu)
-//
-// (C) 2002 Jonathan Pryor
-//
-
-// #define TRACE
-
-using System;
-using System.Collections;
-using System.IO;
-using System.Diagnostics;
-using System.Reflection;
-using System.Text;
-using System.Text.RegularExpressions;
-
-namespace Mono.TypeReflector
-{
-       public class ConsoleOutput {
-
-               private static BooleanSwitch console = new BooleanSwitch ("console",
-                               "console-specific and command-line handling output");
-
-               private static void TraceStringArray (string message, IEnumerable contents)
-               {
-                       Trace.WriteLineIf (console.Enabled, message);
-                       foreach (string s in contents) {
-                               Trace.WriteLineIf (console.Enabled, "  " + s);
-                       }
-               }
-
-               private static void PrintVersion ()
-               {
-                       Console.WriteLine ("type-reflector 0.5");
-                       Console.WriteLine ("Written by Jonathan Pryor.");
-                       Console.WriteLine ();
-                       Console.WriteLine ("Copyright (C) 2002 Jonathan Pryor.");
-               }
-
-               private static void InitFactory ()
-               {
-                       // TypeDisplayerFactory.Add ("explicit", typeof(ExplicitTypeDisplayer));
-                       // TypeDisplayerFactory.Add ("reflection", typeof(ReflectionTypeDisplayer));
-                       // TypeDisplayerFactory.Add ("c#", typeof(CSharpTypeDisplayer));
-                       Factories.FormatterFactory.Add ("default", typeof (DefaultNodeFormatter));
-                       Factories.FormatterFactory.Add ("csharp", typeof (CSharpNodeFormatter));
-                       Factories.FinderFactory.Add ("explicit", typeof (ExplicitNodeFinder));
-                       Factories.FinderFactory.Add ("reflection", typeof (ReflectionNodeFinder));
-               }
-
-               public static void Main (string[] args)
-               {
-                       InitFactory ();
-
-                       TypeReflectorOptions options = new TypeReflectorOptions ();
-
-                       try {
-                               options.ParseOptions (args);
-                       } catch (Exception e) {
-                               Console.WriteLine (e.Message);
-                               Console.WriteLine ("See `{0} --help' for more information", ProgramOptions.ProgramName);
-                               // Console.WriteLine ("** Full Message continues:\n" + e);
-                               return;
-                       }
-
-                       if (options.FoundHelp) {
-                               Console.WriteLine (options.OptionsHelp);
-                               return;
-                       }
-
-                       if (options.DefaultAssemblies) {
-                               Console.WriteLine ("The default search assemblies are:");
-                               foreach (string s in TypeReflectorOptions.GetDefaultAssemblies ()) {
-                                       Console.WriteLine ("  {0}", s);
-                               }
-                               return;
-                       }
-
-                       if (options.Version) {
-                               PrintVersion ();
-                               return;
-                       }
-
-                       if (options.Types.Count == 0) {
-                               Console.WriteLine ("No types specified.");
-                               Console.WriteLine ("See `{0} --help' for more information", ProgramOptions.ProgramName);
-                               return;
-                       }
-
-                       TraceStringArray ("Search Assemblies: ", options.Assemblies);
-                       TraceStringArray ("Search for Types: ", options.Types);
-
-                       TypeLoader loader = new TypeLoader (options.Assemblies);
-                       loader.MatchBase = options.MatchBase;
-                       loader.MatchFullName = options.MatchFullName;
-                       loader.MatchClassName = options.MatchClassName;
-                       loader.MatchNamespace = options.MatchNamespace;
-                       loader.MatchMethodReturnType = options.MatchReturnType;
-
-                       IndentingTextWriter writer = new IndentingTextWriter (Console.Out);
-
-                       int depth = options.MaxDepth;
-
-                       INodeFormatter formatter = Factories.FormatterFactory.Create (options.Formatter);
-                       if (formatter == null) {
-                               Console.WriteLine ("Error: invalid formatter: " + options.Formatter);
-                               return;
-                       }
-
-                       NodeFinder f = (NodeFinder) Factories.FinderFactory.Create (options.Finder);
-                       if (f == null) {
-                               Console.WriteLine ("Error: invalid finder: " + options.Finder);
-                               return;
-                       }
-
-                       f.VerboseOutput = options.VerboseOutput;
-                       f.ShowBase = options.ShowBase;
-                       f.ShowConstructors = options.ShowConstructors;
-                       f.ShowEvents = options.ShowEvents;
-                       f.ShowFields = options.ShowFields;
-                       f.ShowInterfaces = options.ShowInterfaces;
-                       f.ShowMethods = options.ShowMethods;
-                       f.ShowProperties = options.ShowProperties;
-                       f.ShowTypeProperties = options.ShowTypeProperties;
-                       f.ShowInheritedMembers = options.ShowInheritedMembers;
-                       f.ShowNonPublic = options.ShowNonPublic;
-                       f.ShowMonoBroken = options.ShowMonoBroken;
-                       f.FlattenHierarchy = options.FlattenHierarchy;
-                       f.MaxDepth = options.MaxDepth;
-
-                       foreach (string t in options.Types) {
-                               try {
-                                       ICollection typesFound = loader.LoadTypes (t);
-                                       if (typesFound.Count > 0)
-                                               foreach (Type type in loader.LoadTypes(t)) {
-                                                       // Console.WriteLine ("** displaying type: " + type);
-                                                       Node root = new Node (formatter, 
-                                                                       f);
-                                                                       // new GroupingNodeFinder (f));
-                                                                       // new ExplicitNodeFinder());
-                                                       // root.Extra = new NodeInfo (null, type, NodeTypes.Type);
-                                                       root.NodeInfo = new NodeInfo (null, type);
-                                                       ShowNode (root, writer, depth);
-                                               }
-                                       else
-                                               Console.WriteLine ("Unable to find type `{0}'.", t);
-                               } catch (Exception e) {
-                                       Console.WriteLine ("Unable to display type `{0}': {1}.", t, e.ToString());
-                               }
-                       }
-               }
-
-               private static void ShowNode (Node root, IndentingTextWriter writer, int maxDepth)
-               {
-                       // Console.WriteLine ("** current max depth: " + maxDepth);
-                       writer.WriteLine (root.Description);
-                       if (maxDepth > 0) {
-                               using (Indenter i = new Indenter (writer)) {
-                                       foreach (Node child in root.GetChildren()) {
-                                               ShowNode (child, writer, maxDepth-1);
-                                       }
-                               }
-                       }
-               }
-       }
-}
-
diff --git a/mcs/tools/type-reflector/ConsoleTypeDisplayer.cs b/mcs/tools/type-reflector/ConsoleTypeDisplayer.cs
new file mode 100644 (file)
index 0000000..f18783f
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// ConsoleTypeDisplayer.cs: 
+//   Display types on the console.
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+// #define TRACE
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Mono.TypeReflector
+{
+       public class ConsoleTypeDisplayer : TypeDisplayer
+       {
+               private IndentingTextWriter writer = new IndentingTextWriter (Console.Out);
+
+               // `ReflectionTypeDisplayer.PrintTypeProperties' is recursive, but refrains 
+    // from printing duplicates.  Despite duplicate removal, the output for 
+    // printing the Properties of System.Type is > 800K of text.
+               //
+               // 3 levels permits viewing Attribute values, but not the attributes of
+               // those attribute values.
+               //
+               // For example, 3 levels permits:
+               //              class           System.Type                           {depth 0}
+               //                      Properties:                                 {depth 1}
+               //                              System.Reflection.MemberTypes MemberType  {depth 2}
+               //                                      - CanRead=True                          {depth 3}
+               //                                      - CanWrite=False                        {depth 3}
+               //                                      ...
+               private int maxDepth = 3;
+
+               public override int MaxDepth {
+                       set {maxDepth = value;}
+               }
+
+               public override bool RequireTypes {
+                       get {return true;}
+               }
+
+               public ConsoleTypeDisplayer ()
+               {
+               }
+
+               public override void Run ()
+               {
+                       foreach (Assembly a in Assemblies) {
+                               writer.WriteLine ("Assembly: FullName='{0}'; Location='{1}'", 
+                                               a.FullName, a.Location);
+                               using (Indenter i = Indent()) {
+                                       foreach (string ns in Namespaces(a)) {
+                                               writer.WriteLine ("Namespace: {0}", ns);
+                                               using (Indenter i2 = Indent()) {
+                                                       foreach (Type type in Types (a, ns)) {
+                                                               Node root = new Node (Formatter, Finder);
+                                                                               // new GroupingNodeFinder (f));
+                                                                               // new ExplicitNodeFinder());
+                                                               // root.Extra = new NodeInfo (null, type, NodeTypes.Type);
+                                                               root.NodeInfo = new NodeInfo (null, type);
+                                                               ShowNode (root, writer, maxDepth);
+                                                               writer.WriteLine ();
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               private static void ShowNode (Node root, IndentingTextWriter writer, int maxDepth)
+               {
+                       writer.WriteLine (root.Description);
+                       if (maxDepth > 0) {
+                               using (Indenter i = new Indenter (writer)) {
+                                       foreach (Node child in root.GetChildren()) {
+                                               ShowNode (child, writer, maxDepth-1);
+                                       }
+                               }
+                       }
+               }
+
+               private Indenter Indent ()
+               {
+                       return new Indenter (writer);
+               }
+       }
+}
+
index d0dff404411e4d469baada853bcdb10eed13e0b3..40827ce5d8b6a14b84ac82421cc943f3a5c8fed2 100644 (file)
@@ -83,7 +83,7 @@ namespace Mono.TypeReflector
                        return count;
                }
 
-               protected override void GetTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type)
+               protected override void AddTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type)
                {
                        object instance = parent.ReflectionInstance;
 
@@ -230,7 +230,7 @@ namespace Mono.TypeReflector
                        }
                }
 
-               protected override void GetFieldChildren (NodeInfoCollection c, NodeInfo parent, FieldInfo field)
+               protected override void AddFieldChildren (NodeInfoCollection c, NodeInfo parent, FieldInfo field)
                {
                        Trace.WriteLineIf (info.Enabled, "Getting Field Children");
                        AddMemberChildren (parent, field, c);
@@ -293,7 +293,7 @@ namespace Mono.TypeReflector
                        }
                }
 
-               protected override void GetParameterChildren (NodeInfoCollection c, NodeInfo parent, ParameterInfo pi)
+               protected override void AddParameterChildren (NodeInfoCollection c, NodeInfo parent, ParameterInfo pi)
                {
                        // TODO: handle custom attributes...
                        // c.Add (new NodeInfo (parent, pi, customAttributes, NodeTypes.Other));
@@ -311,12 +311,12 @@ namespace Mono.TypeReflector
                        AddMembers (parent, pi, "Position", c);
                }
 
-               protected override void GetConstructorChildren (NodeInfoCollection c, NodeInfo parent, ConstructorInfo node)
+               protected override void AddConstructorChildren (NodeInfoCollection c, NodeInfo parent, ConstructorInfo node)
                {
                        AddMethodBaseChildren (parent, node, c);
                }
 
-               protected override void GetEventChildren (NodeInfoCollection c, NodeInfo parent, EventInfo node)
+               protected override void AddEventChildren (NodeInfoCollection c, NodeInfo parent, EventInfo node)
                {
                        AddMemberChildren (parent, node, c);
                        AddMembers (parent, node, "Attributes", c);
@@ -325,7 +325,7 @@ namespace Mono.TypeReflector
                        AddMembers (parent, node, "IsSpecialName", c);
                }
 
-               protected override void GetMethodChildren (NodeInfoCollection c, NodeInfo parent, MethodInfo node)
+               protected override void AddMethodChildren (NodeInfoCollection c, NodeInfo parent, MethodInfo node)
                {
                        AddMethodBaseChildren (parent, node, c);
                        AddMembers (parent, node, "ReturnType", c);
@@ -347,7 +347,7 @@ namespace Mono.TypeReflector
                        }
                }
 
-               protected override void GetPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo node)
+               protected override void AddPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo node)
                {
                        AddMemberChildren (parent, node, c);
                        AddMembers (parent, node, "Attributes", c);
index 000cf89e5505dc0b73ca44117df7851e32b8b966..1a271ee25dfabad2ebff988d9b10a8e8841c7898 100644 (file)
@@ -31,8 +31,17 @@ namespace Mono.TypeReflector
                        }
                }
 
-               public static FinderTypeFactory FinderFactory = new FinderTypeFactory ();
-               public static FormatterTypeFactory FormatterFactory = new FormatterTypeFactory ();
+               public sealed class DisplayerTypeFactory : TypeFactory
+               {
+                       public new ITypeDisplayer Create (object key)
+                       {
+                               return (ITypeDisplayer) base.Create (key);
+                       }
+               }
+
+               public static FinderTypeFactory Finder = new FinderTypeFactory ();
+               public static FormatterTypeFactory Formatter = new FormatterTypeFactory ();
+               public static DisplayerTypeFactory Displayer = new DisplayerTypeFactory ();
        }
 }
 
diff --git a/mcs/tools/type-reflector/ITypeDisplayer.cs b/mcs/tools/type-reflector/ITypeDisplayer.cs
new file mode 100644 (file)
index 0000000..0d2e450
--- /dev/null
@@ -0,0 +1,28 @@
+//
+// ITypeDisplayer.cs: 
+//   Framework interface for the displaying of types to a display device (e.g.
+//   console or GUI program).
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+using System;
+
+namespace Mono.TypeReflector
+{
+       public interface ITypeDisplayer
+       {
+               INodeFormatter Formatter {set;}
+               INodeFinder Finder {set;}
+               TypeReflectorOptions Options {set;}
+               int MaxDepth {set;}
+               bool RequireTypes {get;}
+
+               void AddType (Type n);
+
+               void Run ();
+       }
+}
+
index aac18d902ee3ccb46ce52eff2981b66473c57f38..5369db16876c128579e70dd2283fd9efa8bd4013 100644 (file)
@@ -86,10 +86,21 @@ namespace Mono.TypeReflector
 
                public override void Write (string value)
                {
+      string[] lines = value.Split ('\n');
+      _Write (lines[0]);
+      if (lines.Length > 1) {
+        WriteLine ();
+        for (int i = 1; i != lines.Length; ++i)
+          _WriteLine (lines[i]);
+      }
+               }
+
+    private void _Write (string value)
+    {
                        if (NeedIndent)
                                WriteIndent ();
                        _writer.Write (value);
-               }
+    }
 
                public override void WriteLine ()
                {
@@ -101,13 +112,20 @@ namespace Mono.TypeReflector
 
                public override void WriteLine (string value)
                {
+      string[] lines = value.Split ('\n');
+      foreach (string s in lines)
+        _WriteLine (s);
+               }
+
+    private void _WriteLine (string value)
+    {
                        Trace.WriteLineIf (info.Enabled, String.Format(
                                "WriteLine: NeedIndent={0}", NeedIndent));
                        if (NeedIndent)
                                WriteIndent ();
                        _writer.WriteLine (value);
                        NeedIndent = true;
-               }
+    }
        }
 
        public class Indenter : IDisposable {
index 6d80989fb835d2117c76a298787d790e235adce7..18407ecc1fcbadb164c4dc6541f134d22148db12 100644 (file)
@@ -17,147 +17,375 @@ using System.Text.RegularExpressions;
 
 namespace Mono.TypeReflector
 {
-       public class LanguageNodeFormatter : NodeFormatter {
+       public abstract class LanguageNodeFormatter : NodeFormatter {
+
+               protected abstract string LineComment {get;}
+
+               // [0] is open, [1] is close
+               protected abstract string[] AttributeDelimeters {get;}
+
+               protected abstract string KeywordClass {get;}
+               protected abstract string KeywordEnum {get;}
+               protected abstract string KeywordValueType {get;}
+               protected abstract string KeywordInterface {get;}
+               protected abstract string KeywordInherits {get;}
+               protected abstract string KeywordImplements {get;}
+               protected abstract string KeywordMulticast {get;}
+               protected abstract string KeywordStatementTerminator {get;}
+               protected abstract string KeywordStatementSeparator {get;}
+
+               protected abstract string QualifierPublic {get;}
+               protected abstract string QualifierFamily {get;}
+               protected abstract string QualifierAssembly {get;}
+               protected abstract string QualifierPrivate {get;}
+               protected abstract string QualifierStatic {get;}
+               protected abstract string QualifierFinal {get;}
+               protected abstract string QualifierAbstract {get;}
+               protected abstract string QualifierVirtual {get;}
+               protected abstract string QualifierLiteral {get;}
 
                protected override string GetTypeDescription (Type type, object instance)
                {
-                       return string.Format ("{0} {1}", GetTypeKeyword(type), type.Name);
+                       StringBuilder sb = new StringBuilder ();
+                       AddAttributes (sb, type);
+                       AddTypeQualifiers (sb, type);
+                       sb.AppendFormat ("{0} {1}", GetTypeKeyword(type), type.FullName);
+                       return sb.ToString ();
+               }
+
+               protected void AddAttribute (StringBuilder sb, string attribute)
+               {
+                       sb.AppendFormat ("{0}{1}{2}", 
+                                               AttributeDelimeters[0], attribute, AttributeDelimeters[1]);
+               }
+
+               protected void AddAttributes (StringBuilder sb, MemberInfo m)
+               {
+                       AddAttributes (sb, m, true);
+               }
+
+               protected void AddAttributes (StringBuilder sb, MemberInfo m, bool newline)
+               {
+                       AddCilAttributes (sb, m, newline);
+                       AddCustomAttributes (sb, m, "", newline);
+               }
+
+               private void AddCilAttributes (StringBuilder sb, MemberInfo m, bool newline)
+               {
+                       Type t = m as Type;
+                       MethodBase mb = m as MethodBase;
+                       if (t != null)
+                               AddCilAttributes (sb, t, newline);
+                       else if (mb != null)
+                               AddCilAttributes (sb, mb, newline);
+               }
+
+               private void AddCilAttributes (StringBuilder sb, Type t, bool newline)
+               {
+                       if (t.IsSerializable) {
+                               AddAttribute (sb, "Serializable");
+                               if (newline)
+                                       sb.Append ("\n");
+                       }
+               }
+
+               private void AddCilAttributes (StringBuilder sb, MethodBase m, bool newline)
+               {
+                       MethodImplAttributes attr = m.GetMethodImplementationFlags ();
+                       if ((attr & MethodImplAttributes.InternalCall) != 0) {
+                               AddAttribute (sb, "MethodImplAttribute(MethodImplOptions.InternalCall)");
+                               if (newline)
+                                       sb.Append ("\n");
+                       }
+               }
+
+               protected void AddTypeQualifiers (StringBuilder sb, Type type)
+               {
+                       if (type.IsPublic)
+                               sb.Append (QualifierPublic + " ");
+                       if (type.IsSealed && !type.IsValueType)
+                               sb.Append (QualifierFinal + " ");
+                       if (type.IsAbstract && !type.IsInterface)
+                               sb.Append (QualifierAbstract + " ");
+               }
+
+               new protected string GetTypeKeyword (Type type)
+               {
+                       if (type.IsClass)
+                               return KeywordClass;
+                       if (type.IsEnum)
+                               return KeywordEnum;
+                       if (type.IsValueType)
+                               return KeywordValueType;
+                       if (type.IsInterface)
+                               return KeywordInterface;
+
+                       // unknown type
+                       return "type";
                }
 
                protected override string GetBaseTypeDescription (Type type, object instance)
                {
-                       return type.Name;
+                       if (type != null)
+                               return string.Format ("{0} {1}", KeywordInherits, type.Name);
+                       return string.Format ("{0} No Base Type", LineComment);
                }
 
                protected override string GetInterfaceDescription (Type type, object instance)
                {
-                       return type.Name;
+                       return string.Format ("{0} {1}", KeywordImplements, type.Name);
                }
 
                protected override string GetConstructorDescription (ConstructorInfo ctor, object instance)
                {
-                       return string.Format ("{0} ({1})", ctor.Name, ctor.GetParameters().Length);
-                       // return ctor.Name;
+                       StringBuilder sb = new StringBuilder ();
+                       AddAttributes (sb, ctor);
+                       AddMethodQualifiers (sb, ctor);
+                       sb.AppendFormat ("{0} ", GetConstructorName (ctor));
+                       AddMethodArgs (sb, ctor);
+
+                       return sb.ToString();
+               }
+
+               protected void AddMethodQualifiers (StringBuilder sb, MethodBase m)
+               {
+                       if (m.IsPublic)
+                               sb.AppendFormat ("{0} ", QualifierPublic);
+                       if (m.IsFamily)
+                               sb.AppendFormat ("{0} ", QualifierFamily);
+                       if (m.IsAssembly)
+                               sb.AppendFormat ("{0} ", QualifierAssembly);
+                       if (m.IsPrivate)
+                               sb.AppendFormat ("{0} ", QualifierPrivate);
+                       if (m.IsStatic)
+                               sb.AppendFormat ("{0} ", QualifierStatic);
+                       if (m.IsFinal)
+                               sb.AppendFormat ("{0} ", QualifierFinal);
+                       if (m.IsAbstract)
+                               sb.AppendFormat ("{0} ", QualifierAbstract);
+                       else if (m.IsVirtual)
+                               sb.AppendFormat ("{0} ", QualifierVirtual);
+               }
+
+               protected abstract string GetConstructorName (ConstructorInfo ctor);
+
+               protected void AddMethodArgs (StringBuilder sb, MethodBase m)
+               {
+                       sb.Append ("(");
+                       ParameterInfo[] parms = m.GetParameters ();
+                       if (parms.Length != 0) {
+                               int cur = 0;
+                               foreach (ParameterInfo pi in parms) {
+                                       sb.Append (GetParameterDescription (pi, pi));
+                                       if (cur++ != (parms.Length-1))
+                                               sb.Append (", ");
+                               }
+                       }
+                       sb.Append (")");
                }
 
                protected override string GetEventDescription (EventInfo e, object instance)
                {
-                       return e.Name;
+                       StringBuilder sb = new StringBuilder ();
+                       AddMethodQualifiers (sb, e.GetAddMethod(true));
+                       return string.Format ("{0}{1}{2} {3}",
+                                       sb.ToString (),
+                                       e.IsMulticast ? KeywordMulticast + " " : "",
+                                       e.EventHandlerType,
+                                       e.Name);
                }
 
                protected override string GetFieldDescription (FieldInfo field, object instance)
                {
+                       StringBuilder sb = new StringBuilder ();
+                       AddAttributes (sb, field);
+
+                       if (!field.DeclaringType.IsEnum || field.IsSpecialName) {
+                               AddFieldQualifiers (sb, field);
+                               sb.AppendFormat ("{0} ", field.FieldType);
+                       }
+
+                       sb.Append (field.Name);
+
                        try {
-                               return string.Format ("{0}={1}", field.Name, 
-                                               // GetValue (field, instance));
-                                               GetValue (instance));
-                       } catch {
-                               return field.Name;
+                               sb.AppendFormat (" = {0}", GetValue (field.GetValue (instance)));
+                       }
+                       catch {
                        }
+
+                       if (!field.DeclaringType.IsEnum || field.IsSpecialName)
+                               sb.Append (KeywordStatementTerminator);
+                       else
+                               sb.Append (KeywordStatementSeparator);
+
+                       return sb.ToString();
                }
 
-               protected override string GetMethodDescription (MethodInfo mb, object instance)
+               protected void AddFieldQualifiers (StringBuilder sb, FieldInfo field)
                {
-                       if (mb.GetParameters().Length == 0) {
+                       if (field.IsPublic)
+                               sb.AppendFormat ("{0} ", QualifierPublic);
+                       if (field.IsPrivate)
+                               sb.AppendFormat ("{0} ", QualifierPrivate);
+                       if (field.IsAssembly)
+                               sb.AppendFormat ("{0} ", QualifierAssembly);
+                       if (field.IsFamily)
+                               sb.AppendFormat ("{0} ", QualifierFamily);
+                       if (field.IsLiteral)
+                               sb.AppendFormat ("{0} ", QualifierLiteral);
+                       else if (field.IsStatic)
+                               sb.AppendFormat ("{0} ", QualifierStatic);
+               }
+
+               protected override string GetMethodDescription (MethodInfo method, object instance)
+               {
+                       StringBuilder sb = new StringBuilder ();
+
+                       if (method.IsSpecialName)
+                               sb.AppendFormat ("{0} Method is a specially named method:\n", LineComment);
+
+                       AddAttributes (sb, method);
+                       if (method.ReturnTypeCustomAttributes != null)
+                               AddCustomAttributes (sb, method.ReturnTypeCustomAttributes, "return: ", true);
+
+                       AddMethodQualifiers (sb, method);
+
+      AddMethodDeclaration (sb, method);
+
+                       if (method.GetParameters().Length == 0) {
                                try {
-                                       object r = mb.Invoke (instance, null);
+                                       object r = method.Invoke (instance, null);
                                        string s = GetValue (r);
-                                       return string.Format ("{0}()={1}", mb.Name, s);
+                                       sb.AppendFormat (" {0} = {1}", LineComment, s);
                                }
                                catch {
                                }
                        }
-                       return string.Format ("{0} ({1})", mb.Name, mb.GetParameters().Length);
+
+                       string r = sb.ToString();
+
+                       if (method.IsSpecialName)
+                               return r.Replace ("\n", "\n" + LineComment + "\t");
+                       return r;
+               }
+
+               protected virtual void AddMethodDeclaration (StringBuilder sb, MethodInfo method)
+               {
+                       sb.AppendFormat ("{0} {1} ", method.ReturnType, method.Name);
+
+                       AddMethodArgs (sb, method);
                }
 
                protected override string GetParameterDescription (ParameterInfo param, object instance)
                {
-                       return param.Name;
+                       StringBuilder sb = new StringBuilder ();
+
+                       AddCustomAttributes (sb, param, "", false);
+                       AddParameterAttributes (sb, param.Attributes);
+
+                       sb.AppendFormat ("{0} {1}", param.ParameterType, param.Name);
+
+                       return sb.ToString();
                }
 
-               protected override string GetPropertyDescription (PropertyInfo property, object instance)
+               protected void AddParameterAttributes (StringBuilder sb, ParameterAttributes attrs)
                {
-                       string v = "";
-                       try {
-                               // object o = property.GetGetMethod(true).Invoke(instance, null);
-                               object o = property.GetValue (instance, null);
-                               v = string.Format ("={0}", GetValue (o));
-                       } catch {
-                               v = "";
-                       }
-                       return string.Format ("{0}{1}", property.Name, v);
-                       // return property.Name;
-                       // return string.Format ("{0}={1}", property.Name, property.GetValue(null));
+                       if ((attrs & ParameterAttributes.In) != 0)
+                               sb.Append ("in");
+                       if ((attrs & ParameterAttributes.Out) != 0)
+                               sb.Append ("out");
+                       if ((attrs & ParameterAttributes.Lcid) != 0)
+                               sb.Append ("lcid");
+                       if ((attrs & ParameterAttributes.Retval) != 0)
+                               sb.Append ("retval");
+                       if ((attrs & ParameterAttributes.Optional) != 0)
+                               sb.Append ("optional");
+                       if ((attrs & ParameterAttributes.HasDefault) != 0)
+                               sb.Append ("hasdefault");
+                       if ((attrs & ParameterAttributes.HasFieldMarshal) != 0)
+                               sb.Append ("hasfieldmarshal");
+                       if ((attrs & ParameterAttributes.ReservedMask) != 0)
+                               sb.Append ("reservedmask");
+                       if ((attrs & ParameterAttributes.Reserved3) != 0)
+                               sb.Append ("reserved3");
+                       if ((attrs & ParameterAttributes.Reserved4) != 0)
+                               sb.Append ("reserved4");
                }
 
-               protected override string GetCustomAttributeProviderDescription (ICustomAttributeProvider m, object instance)
+               protected override string GetPropertyDescription (PropertyInfo property, object instance)
                {
                        StringBuilder sb = new StringBuilder ();
-                       foreach (object a in m.GetCustomAttributes(true)) {
-                               sb.Append (string.Format ("\n\t{0}", GetCustomAttribute(a)));
+                       AddAttributes (sb, property);
+                       AddMethodQualifiers (sb, property.GetAccessors(true)[0]);
+
+                       sb.AppendFormat ("{0} {1} {{", property.PropertyType, property.Name);
+                       if (property.CanRead) {
+                               sb.Append ("get");
+                               try {
+                                       sb.AppendFormat (" /* = {0} */", GetValue (property.GetValue (instance, null)));
+                               }
+                               catch {
+                               }
+                               sb.Append (";");
                        }
-                       return string.Format ("GetCustomAttributes()={0}{1}", 
-                                       sb.Length == 0 ? "<none/>" : "",
-                                       sb.ToString());
+                       if (property.CanWrite)
+                               sb.Append ("set;");
+                       sb.Append ("}}");
+
+                       return sb.ToString();
                }
 
-               protected override string GetCustomAttributes (ICustomAttributeProvider m, string attributeType, bool newLine)
+               protected override string GetReturnValueDescription (NodeInfo n)
                {
-                       StringBuilder sb = new StringBuilder ();
+                       return string.Format ("{0} ReturnValue={1}", 
+                                       LineComment, GetOtherDescription (n));
+               }
+
+               protected override string GetOtherDescription (NodeInfo node)
+               {
+                       if (node.Description != null)
+                               return node.Description.ToString();
+                       return "<null other description/>";
+               }
 
+               protected void AddCustomAttributes (StringBuilder sb, ICustomAttributeProvider m, string attributeType, bool newLine)
+               {
                        object[] attrs = m.GetCustomAttributes (true);
 
                        foreach (object a in attrs) {
 
-                               GetCustomAttribute (sb, a, attributeType);
+                               AddCustomAttribute (sb, a, attributeType);
 
                                if (newLine)
                                        sb.Append ("\n");
                        }
-
-                       return sb.ToString ();
                }
 
-               protected override string GetCustomAttribute (object attribute)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetCustomAttribute (sb, attribute, "");
-                       return sb.ToString();
-               }
-
-               protected override void GetCustomAttribute (StringBuilder sb, object attribute, string attributeType)
+               protected virtual void AddCustomAttribute (StringBuilder sb, object attribute, string attributeType)
                {
                        Type type = attribute.GetType();
-                       char[] delims = GetAttributeDelimeters ();
-                       sb.AppendFormat ("{0}{1}{2}", delims[0], attributeType, type.FullName);
+                       sb.AppendFormat ("{0}{1}{2}", AttributeDelimeters[0], attributeType, type.FullName);
 
-                       string p = GetPropertyValues (type.GetProperties(), attribute);
-                       string f = GetFieldValues (type.GetFields(), attribute);
+                       PropertyInfo[] props = type.GetProperties();
+                       FieldInfo[] fields = type.GetFields();
 
-                       if ((p.Length > 0) || (f.Length > 0)) {
+                       if (props.Length > 0 || fields.Length > 0) {
                                sb.Append ("(");
-                               if (p.Length > 0) {
-                                       sb.Append (p);
-                                       if (f.Length > 0)
+                               if (props.Length > 0) {
+                                       AddPropertyValues (sb, props, attribute);
+                                       if (fields.Length > 0)
                                                sb.Append (", ");
                                }
-                               if (f.Length > 0)
-                                       sb.Append (f);
+                               if (fields.Length > 0)
+                                       AddFieldValues (sb, fields, attribute);
                                sb.Append (")");
                        }
-
-                       sb.Append (delims[1]);
+                       sb.Append (AttributeDelimeters[1]);
                }
 
-               protected override char[] GetAttributeDelimeters ()
-               {
-                       return new char[]{'[', ']'};
-               }
-
-               private string GetPropertyValues (PropertyInfo[] props, object instance)
+               private void AddPropertyValues (StringBuilder sb, PropertyInfo[] props, object instance)
                {
                        int len = props.Length;
-                       StringBuilder sb = new StringBuilder ();
                        for (int i = 0; i != len; ++i) {
                                sb.Append (props[i].Name);
                                sb.Append ("=");
@@ -169,13 +397,11 @@ namespace Mono.TypeReflector
                                if (i != (len-1))
                                        sb.Append (", ");
                        }
-                       return sb.ToString();
                }
 
-               private string GetFieldValues (FieldInfo[] fields, object instance)
+               private void AddFieldValues (StringBuilder sb, FieldInfo[] fields, object instance)
                {
                        int len = fields.Length;
-                       StringBuilder sb = new StringBuilder ();
                        for (int i = 0; i != len; ++i) {
                                sb.Append (fields[i].Name);
                                sb.Append ("=");
@@ -183,10 +409,9 @@ namespace Mono.TypeReflector
                                if (i != (len-1))
                                        sb.Append (", ");
                        }
-                       return sb.ToString();
                }
 
-               protected override string GetEncodedValue (object value)
+               protected virtual string GetEncodedValue (object value)
                {
                        if (value == null)
                                return "null";
@@ -215,57 +440,50 @@ namespace Mono.TypeReflector
                        return value.ToString();
                }
 
-               protected override string GetEncodedCharValue (object value)
+               protected virtual string GetEncodedCharValue (object value)
                {
                        return String.Format ("'{0}'", value.ToString());
                }
 
-               protected override string GetEncodedDecimalValue (object value)
+               protected virtual string GetEncodedDecimalValue (object value)
                {
                        return String.Format ("{0}m", value.ToString());
                }
 
-               protected override string GetEncodedDoubleValue (object value)
+               protected virtual string GetEncodedDoubleValue (object value)
                {
                        return String.Format ("{0}d", value.ToString());
                }
 
-               protected override string GetEncodedInt64Value (object value)
+               protected virtual string GetEncodedInt64Value (object value)
                {
                        return String.Format ("{0}L", value.ToString());
                }
 
-               protected override string GetEncodedSingleValue (object value)
+               protected virtual string GetEncodedSingleValue (object value)
                {
                        return String.Format ("{0}f", value.ToString());
                }
 
-               protected override string GetEncodedStringValue (object value)
+               protected virtual string GetEncodedStringValue (object value)
                {
                        return String.Format ("\"{0}\"", value.ToString());
                }
 
-               protected override string GetEncodedUInt32Value (object value)
+               protected virtual string GetEncodedUInt32Value (object value)
                {
                        return String.Format ("{0}U", value.ToString());
                }
 
-               protected override string GetEncodedUInt64Value (object value)
+               protected virtual string GetEncodedUInt64Value (object value)
                {
                        return String.Format ("{0}UL", value.ToString());
                }
 
-               protected override string GetEncodedObjectValue (object value)
+               protected virtual string GetEncodedObjectValue (object value)
                {
                        return String.Format ("typeof({0})", value.ToString());
                }
-
-               protected override string GetOtherDescription (NodeInfo node)
-               {
-                       if (node.Description != null)
-                               return node.Description.ToString();
-                       return "<null other description/>";
-               }
        }
 }
 
index ce9e528fada01a495c466c17e7db97c7ea9bedc5..13c5e27df0f8ae77c0e086a333bc521c82b7a9c9 100644 (file)
@@ -1,62 +1,4 @@
 CSC = csc
 
-TRACE_ARGS = /out:$(PROGRAM) /d:TRACE /d:DEBUG
-
-# CSCFLAGS = $(TRACE_ARGS) /debug+ /debug:full
-CSCFLAGS = $(TRACE_ARGS)
-
-PROGRAM = type-reflector.exe
-
-MONO = mono
-
-PROGRAM_FILES =  \
-       ConsoleOutput.cs \
-       CSharpNodeFormatter.cs \
-       DefaultNodeFormatter.cs \
-       ExplicitNodeFinder.cs \
-       Factories.cs \
-  GroupingNodeFinder.cs \
-       IndentingTextWriter.cs \
-       INodeFinder.cs \
-       INodeFormatter.cs \
-       LanguageNodeFormatter.cs \
-       Node.cs \
-       NodeFinder.cs \
-       NodeFormatter.cs \
-  NodeGrouper.cs \
-       NodeInfo.cs \
-       NodeTypes.cs \
-       ProgramOptions.cs \
-  ReflectionNodeFinder.cs \
-       TestTypes.cs \
-       TextFormatter.cs \
-       TypeLoader.cs \
-       TypeFactory.cs \
-       TypeReflectorOptions.cs \
-
-all: $(PROGRAM)
-
-$(PROGRAM) : $(PROGRAM_FILES)
-       $(CSC) $(CSCFLAGS) $(PROGRAM_FILES)
-
-test-run : $(PROGRAM)
-       $(MONO) $(PROGRAM) -A $(PROGRAM) $(ARGS)
-
-test-type : $(PROGRAM)
-       $(MONO) $(PROGRAM) -A $(PROGRAM) --max-depth=10000 $(ARGS) TestClass$$
-
-run : $(PROGRAM)
-       $(MONO) $(PROGRAM) $(ARGS)
-
-windows:
-       NAnt -buildfile:type-reflector.build
-
-linux: 
-       mcs @unix.args
-
-clean:
-       rm -f *.exe *.pdb *.dll *.dbg *~
-
-linecount:
-       wc -l $(PROGRAM_FILES)
+include makefile.core
 
index 43da049dc47a78aa5c444e25fc479b9e1ad9e63c..066ca43f19f4c8dda3936f0c77913bc69c5a146a 100644 (file)
@@ -52,22 +52,6 @@ namespace Mono.TypeReflector
                        get {return nodeInfo;}
                        set {nodeInfo = value;}
                }
-
-               /*
-               public override string ToString ()
-               {
-                       Console.Write ("(Description='{0}'", Description);
-                       if (Children.Count > 0) {
-                               Console.Write (" Children={{");
-                               foreach (Node node in Children)
-                                       Console.Write (node);
-                               Console.Write ("}}");
-                       }
-                       Console.Write (")");
-                       return "foo!";
-                       return new StackTrace().ToString();
-               }
-                */
        }
 
        public class NodeCollection : CollectionBase {
index 26d89fae596147db1ba725483292181f1a5ee977..0c0e350bc063a390b93ece93bcdfdd01713f9c7f 100644 (file)
@@ -169,27 +169,6 @@ namespace Mono.TypeReflector
                private bool verboseOutput = false;
                private bool showMonoBroken = false;
 
-               // `ReflectionTypeDisplayer.PrintTypeProperties' is recursive, but refrains 
-    // from printing duplicates.  Despite duplicate removal, the output for 
-    // printing the Properties of System.Type is > 800K of text.
-               //
-               // 3 levels permits viewing Attribute values, but not the attributes of
-               // those attribute values.
-               //
-               // For example, 3 levels permits:
-               //              class           System.Type                           {depth 0}
-               //                      Properties:                                 {depth 1}
-               //                              System.Reflection.MemberTypes MemberType  {depth 2}
-               //                                      - CanRead=True                          {depth 3}
-               //                                      - CanWrite=False                        {depth 3}
-               //                                      ...
-               private int maxDepth = 3;
-
-               public int MaxDepth {
-                       get {return maxDepth;}
-                       set {maxDepth = value;}
-               }
-
                public bool ShowBase {
                        get {return showBase;}
                        set {showBase = value;}
@@ -287,92 +266,91 @@ namespace Mono.TypeReflector
 
                        // always handle NodeTypes.Type
                        if (root.NodeType == NodeTypes.Type)
-                               GetTypeChildren (c, root, (Type) root.ReflectionObject);
+                               AddTypeChildren (c, root, (Type) root.ReflectionObject);
                        else if (VerboseOutput) {
                                switch (root.NodeType) {
                                        case NodeTypes.BaseType:
-                                               GetBaseTypeChildren (c, root, (Type) root.ReflectionObject);
+                                               AddBaseTypeChildren (c, root, (Type) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Interface:
-                                               GetInterfaceChildren (c, root, (Type) root.ReflectionObject);
+                                               AddInterfaceChildren (c, root, (Type) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Field:
-                                               GetFieldChildren (c, root, (FieldInfo) root.ReflectionObject);
+                                               AddFieldChildren (c, root, (FieldInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Constructor:
-                                               GetConstructorChildren (c, root, (ConstructorInfo) root.ReflectionObject);
+                                               AddConstructorChildren (c, root, (ConstructorInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Method:
-                                               GetMethodChildren (c, root, (MethodInfo) root.ReflectionObject);
+                                               AddMethodChildren (c, root, (MethodInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Parameter:
-                                               GetParameterChildren (c, root, (ParameterInfo) root.ReflectionObject);
+                                               AddParameterChildren (c, root, (ParameterInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Property:
-                                               GetPropertyChildren (c, root, (PropertyInfo) root.ReflectionObject);
+                                               AddPropertyChildren (c, root, (PropertyInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Event:
-                                               GetEventChildren (c, root, (EventInfo) root.ReflectionObject);
+                                               AddEventChildren (c, root, (EventInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.ReturnValue:
-                                               GetReturnValueChildren (c, root);
+                                               AddReturnValueChildren (c, root);
                                                break;
                                        case NodeTypes.Other:
                                        case NodeTypes.Alias:
-                                               GetOtherChildren (c, root);
+                                               AddOtherChildren (c, root);
                                                break;
                                        default:
-                                               GetUnhandledChildren (c, root);
+                                               AddUnhandledChildren (c, root);
                                                break;
                                }
                        }
                        return c;
                }
 
-               protected virtual void GetTypeChildren (NodeInfoCollection c, NodeInfo root, Type type)
+               protected virtual void AddTypeChildren (NodeInfoCollection c, NodeInfo root, Type type)
                {
                }
 
-               protected virtual void GetBaseTypeChildren (NodeInfoCollection c, NodeInfo root, Type baseType)
+               protected virtual void AddBaseTypeChildren (NodeInfoCollection c, NodeInfo root, Type baseType)
                {
                }
 
-               protected virtual void GetInterfaceChildren (NodeInfoCollection c, NodeInfo root, Type iface)
+               protected virtual void AddInterfaceChildren (NodeInfoCollection c, NodeInfo root, Type iface)
                {
                }
 
-               protected virtual void GetFieldChildren (NodeInfoCollection c, NodeInfo root, FieldInfo field)
+               protected virtual void AddFieldChildren (NodeInfoCollection c, NodeInfo root, FieldInfo field)
                {
-                       Console.WriteLine ("** field children b");
                }
 
-               protected virtual void GetConstructorChildren (NodeInfoCollection c, NodeInfo root, ConstructorInfo ctor)
+               protected virtual void AddConstructorChildren (NodeInfoCollection c, NodeInfo root, ConstructorInfo ctor)
                {
                }
 
-               protected virtual void GetMethodChildren (NodeInfoCollection c, NodeInfo root, MethodInfo method)
+               protected virtual void AddMethodChildren (NodeInfoCollection c, NodeInfo root, MethodInfo method)
                {
                }
 
-               protected virtual void GetParameterChildren (NodeInfoCollection c, NodeInfo root, ParameterInfo param)
+               protected virtual void AddParameterChildren (NodeInfoCollection c, NodeInfo root, ParameterInfo param)
                {
                }
 
-               protected virtual void GetPropertyChildren (NodeInfoCollection c, NodeInfo root, PropertyInfo property)
+               protected virtual void AddPropertyChildren (NodeInfoCollection c, NodeInfo root, PropertyInfo property)
                {
                }
 
-               protected virtual void GetEventChildren (NodeInfoCollection c, NodeInfo root, EventInfo e)
+               protected virtual void AddEventChildren (NodeInfoCollection c, NodeInfo root, EventInfo e)
                {
                }
 
-               protected virtual void GetReturnValueChildren (NodeInfoCollection c, NodeInfo root)
+               protected virtual void AddReturnValueChildren (NodeInfoCollection c, NodeInfo root)
                {
                        if (root.ReflectionObject != null)
-                               GetTypeChildren (c, root, (Type) root.ReflectionObject);
+                               AddTypeChildren (c, root, (Type) root.ReflectionObject);
                }
 
-               protected virtual void GetOtherChildren (NodeInfoCollection c, NodeInfo root)
+               protected virtual void AddOtherChildren (NodeInfoCollection c, NodeInfo root)
                {
                        if (root.Description is NodeGroup) {
                                NodeGroup g = (NodeGroup) root.Description;
@@ -380,7 +358,7 @@ namespace Mono.TypeReflector
                        }
                }
 
-               protected virtual void GetUnhandledChildren (NodeInfoCollection c, NodeInfo root)
+               protected virtual void AddUnhandledChildren (NodeInfoCollection c, NodeInfo root)
                {
                        c.Add (new NodeInfo (root, "Unhandled child: NodeType=" + root.NodeType));
                }
index 911a778034bc0440700ddb8109a872aacaee73bd..459d7dedd3d2ed20a2322f0575fd3fa633b64a50 100644 (file)
@@ -49,9 +49,11 @@ namespace Mono.TypeReflector
                        case NodeTypes.Event:
                                r = GetEventDescription ((EventInfo) node.ReflectionObject, node.ReflectionInstance);
                                break;
+        /*
                        case NodeTypes.CustomAttributeProvider:
                                r = GetCustomAttributeProviderDescription ((ICustomAttributeProvider) node.ReflectionObject, node.ReflectionInstance);
                                break;
+         */
                        case NodeTypes.Other:
                        case NodeTypes.Alias:
                                r = GetOtherDescription (node);
@@ -106,12 +108,15 @@ namespace Mono.TypeReflector
 
                protected virtual string GetTypeDescription (Type type, object instance)
                {
-                       return string.Format ("{0} {1}", GetTypeKeyword(type), type.FullName);
+                       return string.Format ("{0} {1}", 
+                                       GetTypeKeyword(type), type.FullName);
                }
 
                protected virtual string GetBaseTypeDescription (Type type, object instance)
                {
-                       return type.Name;
+      if (type != null)
+        return type.Name;
+      return "No Base Type";
                }
 
                protected virtual string GetInterfaceDescription (Type type, object instance)
@@ -149,176 +154,6 @@ namespace Mono.TypeReflector
                        return property.Name;
                }
 
-               protected virtual string GetCustomAttributeProviderDescription (ICustomAttributeProvider m, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       foreach (object a in m.GetCustomAttributes(true)) {
-                               sb.Append (string.Format ("\n\t{0}", GetCustomAttribute(a)));
-                       }
-                       return string.Format ("GetCustomAttributes()={0}{1}", 
-                                       sb.Length == 0 ? "<none/>" : "",
-                                       sb.ToString());
-               }
-
-               protected virtual string GetCustomAttributes (ICustomAttributeProvider m, string attributeType, bool newLine)
-               {
-                       StringBuilder sb = new StringBuilder ();
-
-                       object[] attrs = m.GetCustomAttributes (true);
-
-                       foreach (object a in attrs) {
-
-                               GetCustomAttribute (sb, a, attributeType);
-
-                               if (newLine)
-                                       sb.Append ("\n");
-                       }
-
-                       return sb.ToString ();
-               }
-
-               protected virtual string GetCustomAttribute (object attribute)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetCustomAttribute (sb, attribute, "");
-                       return sb.ToString();
-               }
-
-               protected virtual void GetCustomAttribute (StringBuilder sb, object attribute, string attributeType)
-               {
-                       Type type = attribute.GetType();
-                       char[] delims = GetAttributeDelimeters ();
-                       sb.AppendFormat ("{0}{1}{2}", delims[0], attributeType, type.FullName);
-
-                       string p = GetPropertyValues (type.GetProperties(), attribute);
-                       string f = GetFieldValues (type.GetFields(), attribute);
-
-                       if ((p.Length > 0) || (f.Length > 0)) {
-                               sb.Append ("(");
-                               if (p.Length > 0) {
-                                       sb.Append (p);
-                                       if (f.Length > 0)
-                                               sb.Append (", ");
-                               }
-                               if (f.Length > 0)
-                                       sb.Append (f);
-                               sb.Append (")");
-                       }
-
-                       sb.Append (delims[1]);
-               }
-
-               protected virtual char[] GetAttributeDelimeters ()
-               {
-                       return new char[]{'[', ']'};
-               }
-
-               private string GetPropertyValues (PropertyInfo[] props, object instance)
-               {
-                       int len = props.Length;
-                       StringBuilder sb = new StringBuilder ();
-                       for (int i = 0; i != len; ++i) {
-                               sb.Append (props[i].Name);
-                               sb.Append ("=");
-                               try {
-                                       sb.Append (GetEncodedValue (props[i].GetValue (instance, null)));
-                               } catch {
-                                       sb.Append ("<exception/>");
-                               }
-                               if (i != (len-1))
-                                       sb.Append (", ");
-                       }
-                       return sb.ToString();
-               }
-
-               private string GetFieldValues (FieldInfo[] fields, object instance)
-               {
-                       int len = fields.Length;
-                       StringBuilder sb = new StringBuilder ();
-                       for (int i = 0; i != len; ++i) {
-                               sb.Append (fields[i].Name);
-                               sb.Append ("=");
-                               sb.Append (GetEncodedValue (fields[i].GetValue (instance)));
-                               if (i != (len-1))
-                                       sb.Append (", ");
-                       }
-                       return sb.ToString();
-               }
-
-               protected virtual string GetEncodedValue (object value)
-               {
-                       if (value == null)
-                               return "null";
-
-                       switch (Type.GetTypeCode(value.GetType())) {
-                               case TypeCode.Char:
-                                       return GetEncodedCharValue (value);
-                               case TypeCode.Decimal:
-                                       return GetEncodedDecimalValue (value);
-                               case TypeCode.Double:
-                                       return GetEncodedDoubleValue (value);
-                               case TypeCode.Int64:
-                                       return GetEncodedInt64Value (value);
-                               case TypeCode.Single:
-                                       return GetEncodedSingleValue (value);
-                               case TypeCode.String:
-                                       return GetEncodedStringValue (value);
-                               case TypeCode.UInt32:
-                                       return GetEncodedUInt32Value (value);
-                               case TypeCode.UInt64:
-                                       return GetEncodedUInt64Value (value);
-                               case TypeCode.Object:
-                                       return GetEncodedObjectValue (value);
-                       }
-                       // not special-cased; just return it's value
-                       return value.ToString();
-               }
-
-               protected virtual string GetEncodedCharValue (object value)
-               {
-                       return String.Format ("'{0}'", value.ToString());
-               }
-
-               protected virtual string GetEncodedDecimalValue (object value)
-               {
-                       return String.Format ("{0}m", value.ToString());
-               }
-
-               protected virtual string GetEncodedDoubleValue (object value)
-               {
-                       return String.Format ("{0}d", value.ToString());
-               }
-
-               protected virtual string GetEncodedInt64Value (object value)
-               {
-                       return String.Format ("{0}L", value.ToString());
-               }
-
-               protected virtual string GetEncodedSingleValue (object value)
-               {
-                       return String.Format ("{0}f", value.ToString());
-               }
-
-               protected virtual string GetEncodedStringValue (object value)
-               {
-                       return String.Format ("\"{0}\"", value.ToString());
-               }
-
-               protected virtual string GetEncodedUInt32Value (object value)
-               {
-                       return String.Format ("{0}U", value.ToString());
-               }
-
-               protected virtual string GetEncodedUInt64Value (object value)
-               {
-                       return String.Format ("{0}UL", value.ToString());
-               }
-
-               protected virtual string GetEncodedObjectValue (object value)
-               {
-                       return String.Format ("typeof({0})", value.ToString());
-               }
-
                protected virtual string GetOtherDescription (NodeInfo node)
                {
                        if (node.Description != null)
index 569b74b4da8c8738fa1b2dbaf29fa6f3accd79d6..1df85780b89c767840e43712fd16c7266c171625 100644 (file)
@@ -133,6 +133,15 @@ namespace Mono.TypeReflector
                        get {return description;}
                        set {description = value;}
                }
+
+               /*
+               public override string ToString ()
+               {
+                       Console.WriteLine ("** (NodeInfo (parent {0}) (type {1}) (rObj {2}) (rIns {3}) (description {4}))",
+                                       parent, type, reflectionObject, reflectionInstance, description);
+                       return base.ToString ();
+               }
+                */
        }
 
        public sealed class NodeInfoCollection : CollectionBase {
index a0a4d01ee3494bb6ab59db784987b19f702909e2..8a9ebe950b7f2bc5e54cb19d18cc92924e85025c 100644 (file)
@@ -91,7 +91,7 @@ using System.Text.RegularExpressions;
 
 namespace Mono.TypeReflector
 {
-       internal class OptionException : Exception {
+       public class OptionException : Exception {
 
                public char ShortForm;
 
@@ -112,7 +112,7 @@ namespace Mono.TypeReflector
                }
        }
 
-       internal class ProgramOptions {
+       public class ProgramOptions {
 
                private class Option {
                        public char   ShortForm = '\0';
index b7f5cee80a1c57ccea9e229a379caf7a382a2301..f0820d3f34abddfb8ec67692bf12b345570e297d 100644 (file)
@@ -1,3 +1,5 @@
+Overview
+========
 ``type-reflector'' is a program similar in spirit to the .NET ``TypeFinder'' 
 SDK Sample.  As is often the case with Unix-style programs, it has more
 program options and more flexibility.
@@ -22,6 +24,7 @@ The other policy is the "formatter" policy, which dictates how a member is
 displayed.  There are currently two such policies:
   default - typically the result of .ToString() on the member reflection object
   csharp - attempts to display the member as if it were from C# source code.
+  vb - attempts to display the member as if it were from VB.NET source code.
 
 Finally, it shows (virtually) everything about a type that is available
 through the System.Reflection facility.  Everthing from the actual Attributes
@@ -30,3 +33,13 @@ it was declared...  This constitutes a great deal of information that isn't
 normally present without writing test programs to view the available
 information.
 
+GUI Support
+===========
+type-reflector has a prototype GUI using Gtk#.  To compile it, run:
+
+  make -f makefile.gnu gui
+
+To run it, pass ``--displayer=gtk'' on the command line:
+
+  type-reflector.exe --displayer-gtk .
+
index 462e13eeece54816dca580f7e255ea57bb5f9ac1..4c9e1f96f3ebd2774d06e0152d9856c2a0b4a5ca 100644 (file)
@@ -53,7 +53,7 @@ namespace Mono.TypeReflector
 
                private static readonly IComparer NameComparer = new MemberInfoNameComparer ();
 
-               protected override void GetTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type)
+               protected override void AddTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type)
                {
                        foreach (MemberInfo mi in GetMembers (type)) {
                                AddNode (c, parent, mi, mi);
@@ -121,17 +121,17 @@ namespace Mono.TypeReflector
                        }
                }
 
-               protected override void GetFieldChildren (NodeInfoCollection c, NodeInfo parent, FieldInfo field)
+               protected override void AddFieldChildren (NodeInfoCollection c, NodeInfo parent, FieldInfo field)
                {
                        AddSubnodes (c, parent, field.GetType(), field);
                }
 
-               protected override void GetConstructorChildren (NodeInfoCollection c, NodeInfo parent, ConstructorInfo ctor)
+               protected override void AddConstructorChildren (NodeInfoCollection c, NodeInfo parent, ConstructorInfo ctor)
                {
                        GetMethodBaseChildren (c, parent, ctor);
                }
 
-               protected override void GetMethodChildren (NodeInfoCollection c, NodeInfo parent, MethodInfo method)
+               protected override void AddMethodChildren (NodeInfoCollection c, NodeInfo parent, MethodInfo method)
                {
                        GetMethodBaseChildren (c, parent, method);
                }
@@ -141,25 +141,25 @@ namespace Mono.TypeReflector
                        AddSubnodes (c, parent, mb.GetType(), mb);
                }
 
-               protected override void GetParameterChildren (NodeInfoCollection c, NodeInfo parent, ParameterInfo param)
+               protected override void AddParameterChildren (NodeInfoCollection c, NodeInfo parent, ParameterInfo param)
                {
                        AddSubnodes (c, parent, param.GetType(), param);
                }
 
-               protected override void GetPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo pi)
+               protected override void AddPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo pi)
                {
                        AddSubnodes (c, parent, pi.GetType(), pi);
                }
 
-               protected override void GetEventChildren (NodeInfoCollection c, NodeInfo parent, EventInfo e)
+               protected override void AddEventChildren (NodeInfoCollection c, NodeInfo parent, EventInfo e)
                {
                        AddSubnodes (c, parent, e.GetType(), e);
                }
 
-               protected override void GetReturnValueChildren (NodeInfoCollection c, NodeInfo parent)
+               protected override void AddReturnValueChildren (NodeInfoCollection c, NodeInfo parent)
                {
                        if (parent.ReflectionObject != null)
-                               GetTypeChildren (c, parent, (Type) parent.ReflectionObject);
+                               AddTypeChildren (c, parent, (Type) parent.ReflectionObject);
                }
        }
 }
index 3c56a716812129f2c7c99e02f56792c449ffde83..e9630fbcf03882d53c4c62a4493b8fe80c5440e0 100644 (file)
@@ -12,7 +12,7 @@ namespace Testing
 {
        public interface IFoo {}
        public interface IBar {}
-       public interface IBaz {}
+       public interface IBaz : IFoo, IBar {}
 
        public delegate void FooEventHandler ();
 
diff --git a/mcs/tools/type-reflector/TypeDisplayer.cs b/mcs/tools/type-reflector/TypeDisplayer.cs
new file mode 100644 (file)
index 0000000..9b182ec
--- /dev/null
@@ -0,0 +1,127 @@
+//
+// TypeDisplayer.cs: 
+//   Common ITypeDisplayer operations
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+// #define TRACE
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Mono.TypeReflector
+{
+       sealed class DisplayerComparer : IComparer
+       {
+               public static readonly DisplayerComparer Default;
+
+               static DisplayerComparer ()
+               {
+                       Default = new DisplayerComparer ();
+               }
+
+               // we store either Assembly's or strings; handle both.
+               public int Compare (object a, object b)
+               {
+                       if (a is Assembly) {
+                               Assembly aa = (Assembly) a;
+                               Assembly ab = (Assembly) b;
+                               return aa.FullName.CompareTo (ab.FullName);
+                       }
+      if (a is Type) {
+        Type ta = (Type) a;
+        Type tb = (Type) b;
+        return ta.FullName.CompareTo (tb.FullName);
+      }
+                       return Comparer.Default.Compare (a, b);
+               }
+       }
+
+       public abstract class TypeDisplayer : ITypeDisplayer
+       {
+               private INodeFormatter formatter;
+               private INodeFinder finder;
+               private TypeReflectorOptions options;
+
+               // type: map<Assembly, map<Namespace, list<Type> > >
+               private IDictionary types = CreateDictionary ();
+
+               public TypeDisplayer ()
+               {
+               }
+
+               public INodeFormatter Formatter {
+                       get {return formatter;}
+                       set {formatter = value;}
+               }
+
+               public INodeFinder Finder {
+                       get {return finder;}
+                       set {finder = value;}
+               }
+
+               public TypeReflectorOptions Options {
+                       get {return options;}
+                       set {options = value;}
+               }
+
+               public abstract int MaxDepth {set;}
+               public abstract bool RequireTypes {get;}
+
+               protected ICollection Assemblies {
+                       get {return types.Keys;}
+               }
+
+               private static IDictionary CreateDictionary ()
+               {
+                       return new SortedList (DisplayerComparer.Default);
+               }
+
+               protected ICollection Namespaces (Assembly a)
+               {
+                       return _Namespaces(a).Keys;
+               }
+
+               protected ICollection Types (Assembly a, string ns)
+               {
+                       // return (ICollection) _Namespaces(a)[ns];
+                       return _Types (_Namespaces(a), ns).Keys;
+               }
+
+               private IDictionary _Namespaces (Assembly a)
+               {
+                       IDictionary d = (IDictionary) types[a];
+                       if (d == null) {
+                               d = CreateDictionary ();
+                               types[a] = d;
+                       }
+                       return d;
+               }
+
+               private IDictionary _Types (IDictionary namespaces, string ns)
+               {
+                       IDictionary list = (IDictionary) namespaces[ns];
+                       if (list == null) {
+                               list = CreateDictionary ();
+                               namespaces[ns] = list;
+                       }
+                       return list;
+               }
+
+               public virtual void AddType (Type type)
+               {
+                       _Types(_Namespaces(type.Assembly), type.Namespace)[type] = null;
+               }
+
+               public abstract void Run ();
+       }
+}
+
index ba49782d1cca62ce344d1286e5344c7012fa2843..01de0440e82e28700f1403fa2f38d3e6e2ecca85 100644 (file)
@@ -15,6 +15,9 @@ namespace Mono.TypeReflector
 {
        public class TypeFactory
        {
+               private static BooleanSwitch info = new BooleanSwitch ("type-factory",
+                               "Information about creating types.");
+
                private IDictionary entries = new Hashtable ();
 
                public void Add (object key, Type value)
@@ -38,11 +41,17 @@ namespace Mono.TypeReflector
 
                public object Create (object key)
                {
+                       Type type = null;
                        try {
-                               Type type = (Type) entries[key];
+                               type = (Type) entries[key];
                                return CreateInstance (type);
                        }
-                       catch {
+                       catch (Exception e) {
+                               Console.WriteLine ("TypeFactory trace: {0}", info.Enabled);
+                               Console.WriteLine (
+                                               "Exception creating ({0}, {1}): {2}", key, type, e.ToString());
+                               Trace.WriteLineIf (info.Enabled, string.Format (
+                                               "Exception creating ({0}, {1}): {2}", key, type, e.ToString()));
                                return null;
                        }
                }
index 1ef4df4295b749906c212e2b04d886c3bc391f41..162c262b42cf0a3a9ce90bbb74ada05b350232fa 100644 (file)
@@ -61,7 +61,6 @@ namespace Mono.TypeReflector
 
                public TypeLoader (ICollection assemblies)
                {
-                       Console.WriteLine ("type-loader: " + info.Level);
                        this.assemblies = assemblies;
                }
 
@@ -70,23 +69,34 @@ namespace Mono.TypeReflector
                        set {assemblies = value;}
                }
 
-               public ICollection LoadTypes (string match)
+               public ICollection LoadTypes (IList match)
                {
                        if (assemblies == null)
                                throw new ArgumentNullException ("Assemblies");
+                       if (match == null || match.Count == 0)
+                               throw new ArgumentNullException ("match");
+
+                       StringBuilder regex = new StringBuilder ();
+                       regex.Append (match[0]);
+                       for (int i = 1; i < match.Count; ++i)
+                               regex.AppendFormat ("|{0}", match[i]);
+
+                       Regex re = new Regex (regex.ToString());
+
+                       Trace.WriteLineIf (info.TraceInfo, 
+                                       string.Format ("using regex: '{0}'", regex.ToString()));
 
                        IList found = new ArrayList ();
 
                        foreach (string a in assemblies) {
-                               LoadMatchingTypesFrom (a, match, found);
+                               LoadMatchingTypesFrom (a, regex.ToString(), re, found);
                        }
 
                        return found;
                }
 
-               private void LoadMatchingTypesFrom (string where, string match, IList types)
+               private void LoadMatchingTypesFrom (string where, string regex, Regex re, IList types)
                {
-                       Regex re = new Regex (match);
                        try {
                                Assembly a = Assembly.LoadFrom (where);
                                Type[] _types = a.GetTypes();
@@ -97,7 +107,7 @@ namespace Mono.TypeReflector
                        } catch (Exception e) {
                                Trace.WriteLineIf (info.TraceError, String.Format (
                                        "Unable to load type regex `{0}' from `{1}'.",
-                                       match, where));
+                                       regex, where));
                                Trace.WriteLineIf (info.TraceError, e.ToString());
                        }
                }
@@ -108,9 +118,9 @@ namespace Mono.TypeReflector
                        f = c = b = rt = n = false;
                        if (MatchFullName)
                                f = r.Match(t.FullName).Success;
-                       if (MatchClassName)
+                       else if (MatchClassName)
                                c = r.Match(t.Name).Success;
-                       if (MatchNamespace)
+                       else if (MatchNamespace)
                                n = r.Match(t.Namespace).Success;
                        if (MatchBase) {
                                b = (!MatchFullName ? false : r.Match (t.BaseType.FullName).Success) ||
diff --git a/mcs/tools/type-reflector/TypeReflectorApp.cs b/mcs/tools/type-reflector/TypeReflectorApp.cs
new file mode 100644 (file)
index 0000000..f228419
--- /dev/null
@@ -0,0 +1,201 @@
+//
+// TypeReflectorApp.cs: 
+//   Finds types and sends them to a displayer.
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+// #define TRACE
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Mono.TypeReflector
+{
+       public class TypeReflectorApp
+       {
+               private static BooleanSwitch console = new BooleanSwitch ("console",
+                               "console-specific and command-line handling output");
+
+               private static void TraceStringArray (string message, IEnumerable contents)
+               {
+                       Trace.WriteLineIf (console.Enabled, message);
+                       foreach (string s in contents) {
+                               Trace.WriteLineIf (console.Enabled, "  " + s);
+                       }
+               }
+
+               public static void PrintVersion ()
+               {
+                       Console.WriteLine ("type-reflector 0.6");
+                       Console.WriteLine ("Written by Jonathan Pryor.");
+                       Console.WriteLine ();
+                       Console.WriteLine ("Copyright (C) 2002 Jonathan Pryor.");
+               }
+
+               private static void InitFactory ()
+               {
+                       Factories.Formatter.Add ("default", typeof (DefaultNodeFormatter));
+                       Factories.Formatter.Add ("csharp", typeof (CSharpNodeFormatter));
+                       Factories.Formatter.Add ("vb", typeof (VBNodeFormatter));
+                       Factories.Finder.Add ("explicit", typeof (ExplicitNodeFinder));
+                       Factories.Finder.Add ("reflection", typeof (ReflectionNodeFinder));
+                       Factories.Displayer.Add ("console", typeof (ConsoleTypeDisplayer));
+#if HAVE_GUI_GTK
+                       Factories.Displayer.Add ("gtk", typeof (GtkTypeDisplayer));
+#endif
+               }
+
+               public static void Main (string[] args)
+               {
+                       InitFactory ();
+
+                       TypeReflectorOptions options = new TypeReflectorOptions ();
+
+                       bool quit = false;
+
+                       try {
+                               options.ParseOptions (args);
+                       } catch (Exception e) {
+                               Console.WriteLine (e.Message);
+                               Console.WriteLine ("See `{0} --help' for more information", ProgramOptions.ProgramName);
+                               // Console.WriteLine ("** Full Message continues:\n" + e);
+                               return;
+                       }
+
+                       if (options.FoundHelp) {
+                               Console.WriteLine (options.OptionsHelp);
+                               quit = true;
+                       }
+
+                       if (options.DefaultAssemblies) {
+                               Console.WriteLine ("The default search assemblies are:");
+                               foreach (string s in TypeReflectorOptions.GetDefaultAssemblies ()) {
+                                       Console.WriteLine ("  {0}", s);
+                               }
+                               quit = true;
+                       }
+
+                       if (options.Version) {
+                               PrintVersion ();
+                               quit = true;
+                       }
+
+                       if (quit)
+                               return;
+
+                       TraceStringArray ("Search Assemblies: ", options.Assemblies);
+                       TraceStringArray ("Search for Types: ", options.Types);
+
+                       TypeLoader loader = CreateLoader (options);
+
+                       INodeFormatter formatter = CreateFormatter (options);
+                       if (formatter == null) {
+                               Console.WriteLine ("Error: invalid formatter: " + options.Formatter);
+                               return;
+                       }
+
+                       INodeFinder finder = CreateFinder (options);
+                       if (finder == null) {
+                               Console.WriteLine ("Error: invalid finder: " + options.Finder);
+                               return;
+                       }
+
+                       ITypeDisplayer displayer = CreateDisplayer (options);
+                       if (displayer == null) {
+                               Console.WriteLine ("Error: invalid displayer: " + options.Displayer);
+                               return;
+                       }
+
+                       if (options.Types.Count == 0) {
+                               Console.WriteLine ("No types specified.");
+                               Console.WriteLine ("See `{0} --help' for more information", ProgramOptions.ProgramName);
+                               return;
+                       }
+
+                       displayer.Finder = finder;
+                       displayer.Formatter = formatter;
+                       displayer.Options = options;
+
+                       // Find the requested types and display them.
+                       FindTypes (displayer, loader, options.Types);
+
+                       displayer.Run ();
+               }
+               
+               public static void FindTypes (ITypeDisplayer displayer, TypeLoader loader, IList types)
+               {
+                       try {
+                               ICollection typesFound = loader.LoadTypes (types);
+                               if (typesFound.Count > 0)
+                                       foreach (Type type in typesFound) {
+                                               displayer.AddType (type);
+                                       }
+                               else
+                                       Console.WriteLine ("Unable to find types.");
+                       } catch (Exception e) {
+                               Console.WriteLine ("Unable to display type: {0}.", e.ToString());
+                       }
+               }
+
+               public static TypeLoader CreateLoader (TypeReflectorOptions options)
+               {
+                       TypeLoader loader = new TypeLoader (options.Assemblies);
+                       loader.MatchBase = options.MatchBase;
+                       loader.MatchFullName = options.MatchFullName;
+                       loader.MatchClassName = options.MatchClassName;
+                       loader.MatchNamespace = options.MatchNamespace;
+                       loader.MatchMethodReturnType = options.MatchReturnType;
+                       return loader;
+               }
+
+               public static ITypeDisplayer CreateDisplayer (TypeReflectorOptions options)
+               {
+                       ITypeDisplayer d = Factories.Displayer.Create (options.Displayer);
+                       Console.WriteLine ("creating displayer: {0}", d);
+
+                       if (d != null) {
+                               d.MaxDepth = options.MaxDepth;
+                       }
+
+                       return d;
+               }
+
+               public static INodeFinder CreateFinder (TypeReflectorOptions options)
+               {
+                       INodeFinder finder = Factories.Finder.Create (options.Finder);
+                       NodeFinder f = finder as NodeFinder;
+
+                       if (f != null) {
+                               f.VerboseOutput = options.VerboseOutput;
+                               f.ShowBase = options.ShowBase;
+                               f.ShowConstructors = options.ShowConstructors;
+                               f.ShowEvents = options.ShowEvents;
+                               f.ShowFields = options.ShowFields;
+                               f.ShowInterfaces = options.ShowInterfaces;
+                               f.ShowMethods = options.ShowMethods;
+                               f.ShowProperties = options.ShowProperties;
+                               f.ShowTypeProperties = options.ShowTypeProperties;
+                               f.ShowInheritedMembers = options.ShowInheritedMembers;
+                               f.ShowNonPublic = options.ShowNonPublic;
+                               f.ShowMonoBroken = options.ShowMonoBroken;
+                               f.FlattenHierarchy = options.FlattenHierarchy;
+                       }
+
+                       return finder;
+               }
+
+               public static INodeFormatter CreateFormatter (TypeReflectorOptions options)
+               {
+                       return Factories.Formatter.Create (options.Formatter);
+               }
+       }
+}
+
index 92b7169997d3f660327cc82bcaefc4ed763ce2ba..2047e841080d69a02a657ccca4105efb696282d0 100644 (file)
@@ -16,7 +16,7 @@ using System.Text.RegularExpressions;
 
 namespace Mono.TypeReflector
 {
-       internal class TypeReflectorOptions : ProgramOptions {
+       public class TypeReflectorOptions : ProgramOptions {
 
                private static char onlyAssemblies      = 'A';
                private static char addAssemblies       = 'a';
@@ -44,6 +44,7 @@ namespace Mono.TypeReflector
                private static string version           = "version";
                private static string formatter         = "formatter";
                private static string finder            = "finder";
+               private static string displayer         = "displayer";
                private static string maxDepth          = "max-depth";
 
                public TypeReflectorOptions ()
@@ -111,22 +112,29 @@ namespace Mono.TypeReflector
                        AddOption (showAll,                 "show-all",
                                "Show everything except System.Type "+
                                "properties, inherited members, non-public "+
-                               "members, and \"broken\" Mono attributes.");
+                               "members, and \"broken\" Mono attributes.  " +
+        "Equivalent to -bcefimp.");
                        AddOption (flattenHierarchy,        "flatten-hierarchy",
                                "Static members of base types should be " + 
                                "displayed.");
                        StringBuilder formatterDescription = new StringBuilder ();
                        formatterDescription.Append ("Experimental.  Specify the output style touse.  Available values are:");
-                       foreach (object o in Factories.FormatterFactory.Keys)
+                       foreach (object o in Factories.Formatter.Keys)
                                formatterDescription.Append (string.Format ("\n{0}", o));
                        AddArgumentOption (formatter, formatterDescription.ToString(), "<formatter>");
 
                        StringBuilder finderDescription = new StringBuilder ();
                        finderDescription.Append ("Experimental.  Specify how nodes are found.  Available values are:");
-                       foreach (object o  in Factories.FinderFactory.Keys)
+                       foreach (object o in Factories.Finder.Keys)
                                finderDescription.Append (string.Format ("\n{0}", o));
                        AddArgumentOption (finder, finderDescription.ToString(), "<finder>");
 
+                       StringBuilder displayerDescription = new StringBuilder ();
+                       displayerDescription.Append ("Experimental.  Specify where output should be displayed.  Available values are:");
+                       foreach (object o in Factories.Displayer.Keys)
+                               displayerDescription.Append (string.Format ("\n{0}", o));
+                       AddArgumentOption (displayer, displayerDescription.ToString(), "<displayer>");
+
                        AddOption (verboseOutput,           "verbose-output",
                                "Print the contents of all the public " + 
                                "attributes of the reflection information " +
@@ -356,6 +364,15 @@ namespace Mono.TypeReflector
                        }
                }
 
+               public string Displayer {
+                       get {
+                               string s = base.FoundOptionValue (displayer);
+                               if (s == null)
+                                       return "console";
+                               return s;
+                       }
+               }
+
                public override string OptionsHelp {
                        get {
                                StringBuilder sb = new StringBuilder ();
@@ -370,17 +387,20 @@ namespace Mono.TypeReflector
                                sb.Append (base.OptionsHelp);
                                sb.Append (
                                        "\n" + 
+                                       tg0.Group (
+                                               "<types> is interpreted as a regular expression.  As regular expression " + 
+                                               "meta-characters are seldom used in class names, specifying a type name " +
+                                               "looks for all types that have the specified type name as a substring.  " +
+            "To get a listing of all available types, pass '.' as the type.  (Since " +
+            "regular expressions are used, '.' will match any character, thus matching " +
+            "all possible types.)") +
+                                       "\n\n" +
                                        tg0.Group (
                                                "<assembly-list> is a `" + Path.PathSeparator + "'-delimited list.  " + 
                                                "For example, `" + 
                                                String.Format ("foo{0}bar{0}baz", 
                                                        Path.PathSeparator) + "' is a valid list.\n") +
-                                       "\n" +
-                                       tg0.Group (
-                                               "<types> is interpreted as a regular expression.  As regular expression " + 
-                                               "meta-characters are seldom used in class names, specifying a type name " +
-                                               "looks for all types that have the specified type name as a substring.") +
-                                       "\n\n"
+                                       "\n"
                                        );
                                sb.Append (String.Format (
                                        "Examples:\n" +
diff --git a/mcs/tools/type-reflector/VBNodeFormatter.cs b/mcs/tools/type-reflector/VBNodeFormatter.cs
new file mode 100644 (file)
index 0000000..7155a23
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// VBNodeFormatter.cs: Formats nodes with VB.NET syntax
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Mono.TypeReflector
+{
+       public class VBNodeFormatter : LanguageNodeFormatter {
+
+               public VBNodeFormatter ()
+               {
+               }
+
+               protected override string LineComment       {get {return "'";}}
+
+               protected override string KeywordClass      {get {return "Class";}}
+               protected override string KeywordEnum       {get {return "Enum";}}
+               protected override string KeywordValueType  {get {return "Struct";}}
+               protected override string KeywordInterface  {get {return "Interface";}}
+               protected override string KeywordInherits   {get {return "Inherits";}}
+               protected override string KeywordImplements {get {return "Implements";}}
+               protected override string KeywordMulticast  {get {return "Event";}}
+               protected override string KeywordStatementTerminator {get {return "";}}
+               protected override string KeywordStatementSeparator  {get {return ",";}}
+
+               protected override string QualifierPublic   {get {return "Public";}}
+               protected override string QualifierFamily   {get {return "Family";}}
+               protected override string QualifierAssembly {get {return "Internal";}}
+               protected override string QualifierPrivate  {get {return "Private";}}
+               protected override string QualifierFinal    {get {return "Final";}}
+               protected override string QualifierStatic   {get {return "Shared";}}
+               protected override string QualifierLiteral  {get {return "Const";}}
+               protected override string QualifierAbstract {get {return "Abstract";}}
+               protected override string QualifierVirtual  {get {return "Overridable";}}
+
+               private static readonly string[] attributeDelimeters = new string[]{"<", ">"};
+
+               protected override string[] AttributeDelimeters {
+                       get {return attributeDelimeters;}
+               }
+
+               protected override string GetConstructorName (ConstructorInfo ctor)
+               {
+      return "Sub New";
+               }
+
+               protected override void AddMethodDeclaration (StringBuilder sb, MethodInfo method)
+               {
+                       string type = "Function";
+
+                       bool sub = method.ReturnType == typeof(System.Void);
+
+                       if (sub) {
+                               type = "Sub";
+                       }
+
+                       sb.AppendFormat ("{0} {1}", type, method.Name);
+                       AddMethodArgs (sb, method);
+
+                       if (!sub)
+                               sb.AppendFormat (" As {0}", method.ReturnType);
+               }
+       }
+}
+
diff --git a/mcs/tools/type-reflector/displayers/ConsoleTypeDisplayer.cs b/mcs/tools/type-reflector/displayers/ConsoleTypeDisplayer.cs
new file mode 100644 (file)
index 0000000..f18783f
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// ConsoleTypeDisplayer.cs: 
+//   Display types on the console.
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+// #define TRACE
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Mono.TypeReflector
+{
+       public class ConsoleTypeDisplayer : TypeDisplayer
+       {
+               private IndentingTextWriter writer = new IndentingTextWriter (Console.Out);
+
+               // `ReflectionTypeDisplayer.PrintTypeProperties' is recursive, but refrains 
+    // from printing duplicates.  Despite duplicate removal, the output for 
+    // printing the Properties of System.Type is > 800K of text.
+               //
+               // 3 levels permits viewing Attribute values, but not the attributes of
+               // those attribute values.
+               //
+               // For example, 3 levels permits:
+               //              class           System.Type                           {depth 0}
+               //                      Properties:                                 {depth 1}
+               //                              System.Reflection.MemberTypes MemberType  {depth 2}
+               //                                      - CanRead=True                          {depth 3}
+               //                                      - CanWrite=False                        {depth 3}
+               //                                      ...
+               private int maxDepth = 3;
+
+               public override int MaxDepth {
+                       set {maxDepth = value;}
+               }
+
+               public override bool RequireTypes {
+                       get {return true;}
+               }
+
+               public ConsoleTypeDisplayer ()
+               {
+               }
+
+               public override void Run ()
+               {
+                       foreach (Assembly a in Assemblies) {
+                               writer.WriteLine ("Assembly: FullName='{0}'; Location='{1}'", 
+                                               a.FullName, a.Location);
+                               using (Indenter i = Indent()) {
+                                       foreach (string ns in Namespaces(a)) {
+                                               writer.WriteLine ("Namespace: {0}", ns);
+                                               using (Indenter i2 = Indent()) {
+                                                       foreach (Type type in Types (a, ns)) {
+                                                               Node root = new Node (Formatter, Finder);
+                                                                               // new GroupingNodeFinder (f));
+                                                                               // new ExplicitNodeFinder());
+                                                               // root.Extra = new NodeInfo (null, type, NodeTypes.Type);
+                                                               root.NodeInfo = new NodeInfo (null, type);
+                                                               ShowNode (root, writer, maxDepth);
+                                                               writer.WriteLine ();
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               private static void ShowNode (Node root, IndentingTextWriter writer, int maxDepth)
+               {
+                       writer.WriteLine (root.Description);
+                       if (maxDepth > 0) {
+                               using (Indenter i = new Indenter (writer)) {
+                                       foreach (Node child in root.GetChildren()) {
+                                               ShowNode (child, writer, maxDepth-1);
+                                       }
+                               }
+                       }
+               }
+
+               private Indenter Indent ()
+               {
+                       return new Indenter (writer);
+               }
+       }
+}
+
diff --git a/mcs/tools/type-reflector/displayers/ITypeDisplayer.cs b/mcs/tools/type-reflector/displayers/ITypeDisplayer.cs
new file mode 100644 (file)
index 0000000..0d2e450
--- /dev/null
@@ -0,0 +1,28 @@
+//
+// ITypeDisplayer.cs: 
+//   Framework interface for the displaying of types to a display device (e.g.
+//   console or GUI program).
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+using System;
+
+namespace Mono.TypeReflector
+{
+       public interface ITypeDisplayer
+       {
+               INodeFormatter Formatter {set;}
+               INodeFinder Finder {set;}
+               TypeReflectorOptions Options {set;}
+               int MaxDepth {set;}
+               bool RequireTypes {get;}
+
+               void AddType (Type n);
+
+               void Run ();
+       }
+}
+
index aac18d902ee3ccb46ce52eff2981b66473c57f38..5369db16876c128579e70dd2283fd9efa8bd4013 100644 (file)
@@ -86,10 +86,21 @@ namespace Mono.TypeReflector
 
                public override void Write (string value)
                {
+      string[] lines = value.Split ('\n');
+      _Write (lines[0]);
+      if (lines.Length > 1) {
+        WriteLine ();
+        for (int i = 1; i != lines.Length; ++i)
+          _WriteLine (lines[i]);
+      }
+               }
+
+    private void _Write (string value)
+    {
                        if (NeedIndent)
                                WriteIndent ();
                        _writer.Write (value);
-               }
+    }
 
                public override void WriteLine ()
                {
@@ -101,13 +112,20 @@ namespace Mono.TypeReflector
 
                public override void WriteLine (string value)
                {
+      string[] lines = value.Split ('\n');
+      foreach (string s in lines)
+        _WriteLine (s);
+               }
+
+    private void _WriteLine (string value)
+    {
                        Trace.WriteLineIf (info.Enabled, String.Format(
                                "WriteLine: NeedIndent={0}", NeedIndent));
                        if (NeedIndent)
                                WriteIndent ();
                        _writer.WriteLine (value);
                        NeedIndent = true;
-               }
+    }
        }
 
        public class Indenter : IDisposable {
diff --git a/mcs/tools/type-reflector/displayers/TypeDisplayer.cs b/mcs/tools/type-reflector/displayers/TypeDisplayer.cs
new file mode 100644 (file)
index 0000000..9b182ec
--- /dev/null
@@ -0,0 +1,127 @@
+//
+// TypeDisplayer.cs: 
+//   Common ITypeDisplayer operations
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+// #define TRACE
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Mono.TypeReflector
+{
+       sealed class DisplayerComparer : IComparer
+       {
+               public static readonly DisplayerComparer Default;
+
+               static DisplayerComparer ()
+               {
+                       Default = new DisplayerComparer ();
+               }
+
+               // we store either Assembly's or strings; handle both.
+               public int Compare (object a, object b)
+               {
+                       if (a is Assembly) {
+                               Assembly aa = (Assembly) a;
+                               Assembly ab = (Assembly) b;
+                               return aa.FullName.CompareTo (ab.FullName);
+                       }
+      if (a is Type) {
+        Type ta = (Type) a;
+        Type tb = (Type) b;
+        return ta.FullName.CompareTo (tb.FullName);
+      }
+                       return Comparer.Default.Compare (a, b);
+               }
+       }
+
+       public abstract class TypeDisplayer : ITypeDisplayer
+       {
+               private INodeFormatter formatter;
+               private INodeFinder finder;
+               private TypeReflectorOptions options;
+
+               // type: map<Assembly, map<Namespace, list<Type> > >
+               private IDictionary types = CreateDictionary ();
+
+               public TypeDisplayer ()
+               {
+               }
+
+               public INodeFormatter Formatter {
+                       get {return formatter;}
+                       set {formatter = value;}
+               }
+
+               public INodeFinder Finder {
+                       get {return finder;}
+                       set {finder = value;}
+               }
+
+               public TypeReflectorOptions Options {
+                       get {return options;}
+                       set {options = value;}
+               }
+
+               public abstract int MaxDepth {set;}
+               public abstract bool RequireTypes {get;}
+
+               protected ICollection Assemblies {
+                       get {return types.Keys;}
+               }
+
+               private static IDictionary CreateDictionary ()
+               {
+                       return new SortedList (DisplayerComparer.Default);
+               }
+
+               protected ICollection Namespaces (Assembly a)
+               {
+                       return _Namespaces(a).Keys;
+               }
+
+               protected ICollection Types (Assembly a, string ns)
+               {
+                       // return (ICollection) _Namespaces(a)[ns];
+                       return _Types (_Namespaces(a), ns).Keys;
+               }
+
+               private IDictionary _Namespaces (Assembly a)
+               {
+                       IDictionary d = (IDictionary) types[a];
+                       if (d == null) {
+                               d = CreateDictionary ();
+                               types[a] = d;
+                       }
+                       return d;
+               }
+
+               private IDictionary _Types (IDictionary namespaces, string ns)
+               {
+                       IDictionary list = (IDictionary) namespaces[ns];
+                       if (list == null) {
+                               list = CreateDictionary ();
+                               namespaces[ns] = list;
+                       }
+                       return list;
+               }
+
+               public virtual void AddType (Type type)
+               {
+                       _Types(_Namespaces(type.Assembly), type.Namespace)[type] = null;
+               }
+
+               public abstract void Run ();
+       }
+}
+
diff --git a/mcs/tools/type-reflector/displayers/gtk/ChangeLog b/mcs/tools/type-reflector/displayers/gtk/ChangeLog
new file mode 100644 (file)
index 0000000..8e91335
--- /dev/null
@@ -0,0 +1,6 @@
+2002-12-31  Jonathan Pryor <jonpryor@vt.edu>
+       * ChangeLog: Added
+       * GtkTypeDisplayer.cs: Gtk# front-end for reflection information
+       * type-reflector.glade: Glade description for Gtk# front-end
+       * type-reflector.gladep: Glade Project file
+
diff --git a/mcs/tools/type-reflector/displayers/gtk/GtkTypeDisplayer.cs b/mcs/tools/type-reflector/displayers/gtk/GtkTypeDisplayer.cs
new file mode 100644 (file)
index 0000000..cd499b8
--- /dev/null
@@ -0,0 +1,307 @@
+//
+// GtkTypeDisplayer.cs: 
+//   Display types using Gtk#.
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+// #define TRACE
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+// for GUI support
+using GLib;
+using Glade;
+using Gtk;
+using GtkSharp;
+using System.Drawing;
+
+namespace Mono.TypeReflector
+{
+       delegate void OpenFileSuccess (string filename);
+
+       class OpenFileDialog
+       {
+               private FileSelection file = new FileSelection ("Open an Assembly");
+               private OpenFileSuccess onSuccess;
+
+               public OpenFileDialog (OpenFileSuccess success)
+               {
+                       onSuccess = success;
+                       file.DeleteEvent += new DeleteEventHandler (delete_event);
+                       file.CancelButton.Clicked += new EventHandler (cancel_event);
+                       file.OkButton.Clicked += new EventHandler (ok_event);
+                       file.Show ();
+               }
+
+               private void delete_event (object o, DeleteEventArgs args)
+               {
+                       cancel_event (o, args);
+               }
+
+               private void cancel_event (object o, EventArgs args)
+               {
+                       file.Hide ();
+               }
+
+               private void ok_event (object o, EventArgs args)
+               {
+                       file.Hide ();
+                       onSuccess (file.Filename);
+               }
+       }
+
+       public class GtkTypeDisplayer : TypeDisplayer
+       {
+               private TreeStore store;
+               private Window mainWindow;
+               private Statusbar statusbar;
+               private Window aboutWindow;
+               private static int windows = 0;
+
+               public override int MaxDepth {
+                       set {/* ignore */}
+               }
+
+               public override bool RequireTypes {
+                       get {return false;}
+               }
+
+               public GtkTypeDisplayer ()
+               {
+      Console.WriteLine ("GtkTypeDisplayer created");
+                       if (++windows == 1)
+                               Application.Init ();
+
+                       InitMainWindow ();
+               }
+
+               private void InitMainWindow ()
+               {
+                       Glade.XML gxml = new Glade.XML (null, "gtk/type-reflector.glade", "main_window", null);
+                       try {
+                               gxml.Autoconnect (this);
+                       } catch (Exception e) {
+                               Console.WriteLine ("** Error with glade: " + e.ToString());
+                               throw;
+                       }
+
+                       store = new TreeStore ((int) TypeFundamentals.TypeString);
+
+                       TreeView tv = (TreeView) gxml ["treeview"];
+                       tv.Model = store;
+                       // tv.HeadersVisible = true;
+                       tv.HeadersVisible = false;
+                       tv.RowExpanded += new RowExpandedHandler (RowExpanded);
+
+                       TreeViewColumn nameCol = new TreeViewColumn ();
+                       CellRenderer nameRenderer = new CellRendererText ();
+                       nameCol.Title = "Stuff";
+                       nameCol.PackStart (nameRenderer, true);
+                       nameCol.AddAttribute (nameRenderer, "text", 0);
+                       tv.AppendColumn (nameCol);
+
+                       mainWindow = (Window) gxml ["main_window"];
+                       statusbar = (Statusbar) gxml ["status_bar"];
+               }
+
+               private void RowExpanded (object o, RowExpandedArgs args)
+               {
+                       Console.WriteLine ("** row expanded!");
+                       Console.WriteLine ("  ** Iter={0}, Path={1}", args.Iter, args.Path);
+                       /*
+                       NodeValue v = new NodeValue ();
+                       store.GetValue (args.Iter, 0, v);
+                       string s = (string) v;
+                       Console.WriteLine ("  ** v.Node={0}; v={1}", v.Node, s);
+                       GLib.Value gv = new GLib.Value ();
+                       store.GetValue (args.Iter, 1, gv);
+                       GLib.Object go = (GLib.Object) gv;
+                       NodeInfo ni = (NodeInfo) go.GetData ("mykey");
+                       Console.WriteLine ("  ** ni={0}", ni);
+                        */
+               }
+
+               private Node CreateNode (Type type)
+               {
+                       Node root = new Node (Formatter, Finder);
+                       root.NodeInfo = new NodeInfo (null, type);
+                       return root;
+               }
+
+               public override void AddType (Type type)
+               {
+                       Console.WriteLine ("Adding Type: " + type.FullName);
+                       base.AddType (type);
+               }
+
+               public override void Run ()
+               {
+                       ShowTypes();
+                       Application.Run ();
+               }
+
+               private void ShowTypes ()
+               {
+                       Console.WriteLine ("Showing Types...");
+                       foreach (Assembly a in Assemblies) {
+                               Console.WriteLine ("Assembly: " + a.FullName);
+                               TreeIter ai;
+                               store.Append (out ai);
+                               store.SetValue (ai, 0, new GLib.Value (string.Format ("Assembly: {0}", a.FullName)));
+
+                               foreach (string ns in Namespaces (a)) {
+                                       Console.WriteLine ("Namespace: " + ns);
+                                       TreeIter ni;
+                                       store.Append (out ni, ai);
+                                       store.SetValue (ni, 0, new GLib.Value (string.Format ("Namespace: {0}", ns)));
+                                       foreach (Type type in Types (a, ns))
+                                               AddType (type, ni);
+                               }
+                       }
+                       Console.WriteLine ("----");
+
+                       mainWindow.ShowAll ();
+               }
+               
+               private void AddType (Type type, TreeIter parent)
+               {
+                       Console.WriteLine ("Type: " + type.FullName);
+                       TreeIter p;
+                       store.Append (out p, parent);
+                       // store.SetValue (p, 0, new NodeValue (CreateNode(type)));
+                       NodeInfo r = new NodeInfo (null, type);
+                       store.SetValue (p, 0, new GLib.Value (Formatter.GetDescription (r)));
+
+                       foreach (NodeInfo ni in Finder.GetChildren (r)) {
+                               TreeIter i;
+                               store.Append (out i, p);
+                               store.SetValue (i, 0, 
+                                       new GLib.Value (Formatter.GetDescription (ni)));
+                               TreeIter j;
+                               store.Append (out j, i);
+                               store.SetValue (j, 0, new GLib.Value ("Dummy"));
+                       }
+               }
+
+               // Gtk#/Glade# Required Functions...
+               public void on_main_window_delete_event (object o, DeleteEventArgs args) 
+               {
+                       on_file_quit_activate (o, args);
+               }
+
+               public void on_file_new_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_file_open_activate (object o, EventArgs args)
+               {
+                       OpenFileDialog ofd = new OpenFileDialog (new OpenFileSuccess (OpenAssembly));
+               }
+
+               private void OpenAssembly (string assembly)
+               {
+                       GtkTypeDisplayer d = new GtkTypeDisplayer ();
+                       d.Finder = Finder;
+                       d.Formatter = Formatter;
+                       d.Options = Options;
+                       TypeLoader tl = TypeReflectorApp.CreateLoader (Options);
+      tl.Assemblies = new string[]{assembly};
+                       try {
+                               TypeReflectorApp.FindTypes (d, tl, new string[]{"."});
+                               d.ShowTypes ();
+                       }
+                       catch (Exception e) {
+                               // should be an Alert.
+                               Console.WriteLine ("Unable to load Assembly '{0}': {1}",
+                                               assembly, e.ToString());
+                       }
+               }
+
+    public void on_ok_button_clicked (object o, EventArgs args)
+    {
+      Console.WriteLine ("ok clicked; args=" + args);
+    }
+
+               public void on_file_save_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_file_save_as_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_file_quit_activate (object o, EventArgs args)
+               {
+                       if (--windows == 0)
+                               Application.Quit ();
+               }
+
+               public void on_edit_cut_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_edit_copy_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_edit_paste_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_edit_delete_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_view_formatter_default_activate (object o, EventArgs args)
+               {
+               }
+
+               public void on_view_formatter_vb_activate (object o, EventArgs args)
+               {
+               }
+
+               public void on_view_formatter_csharp_activate (object o, EventArgs args)
+               {
+               }
+
+               public void on_view_finder_reflection_activate (object o, EventArgs args)
+               {
+               }
+
+               public void on_view_finder_explicit_activate (object o, EventArgs args)
+               {
+               }
+
+               public void on_help_about_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+                       TypeReflectorApp.PrintVersion ();
+                       Glade.XML gxml = new Glade.XML (null, "gtk/type-reflector.glade", "about_window", null);
+                       try {
+                               gxml.Autoconnect (this);
+                       } catch (Exception e) {
+                               Console.WriteLine ("** Error with glade: " + e.ToString());
+                               throw;
+                       }
+
+                       aboutWindow = (Window) gxml ["about_window"];
+               }
+       }
+}
+
diff --git a/mcs/tools/type-reflector/displayers/gtk/type-reflector.glade b/mcs/tools/type-reflector/displayers/gtk/type-reflector.glade
new file mode 100644 (file)
index 0000000..f1295e4
--- /dev/null
@@ -0,0 +1,496 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+<requires lib="gnome"/>
+
+<widget class="GtkWindow" id="main_window">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">Type Reflector</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="default_width">640</property>
+  <property name="default_height">480</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <accessibility>
+    <atkproperty name="AtkObject::accessible_name" translatable="yes">Type Reflector</atkproperty>
+  </accessibility>
+  <signal name="delete_event" handler="on_main_window_delete_event" last_modification_time="Fri, 27 Dec 2002 01:50:35 GMT"/>
+
+  <child>
+    <widget class="GtkVBox" id="vbox1">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child>
+       <widget class="GtkMenuBar" id="menu_bar">
+         <property name="visible">True</property>
+         <accessibility>
+           <atkproperty name="AtkObject::accessible_name" translatable="yes">Menu</atkproperty>
+         </accessibility>
+
+         <child>
+           <widget class="GtkMenuItem" id="file_menu">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_File</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="file_menu_menu">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="file_new">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-new</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_file_new_activate" last_modification_time="Fri, 27 Dec 2002 02:00:50 GMT"/>
+                     <accelerator key="N" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="file_open">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-open</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_file_open_activate" last_modification_time="Fri, 27 Dec 2002 02:01:00 GMT"/>
+                     <accelerator key="O" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="file_save">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-save</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_file_save_activate" last_modification_time="Fri, 27 Dec 2002 02:01:07 GMT"/>
+                     <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="file_save_as">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-save-as</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_file_save_as_activate" last_modification_time="Fri, 27 Dec 2002 02:01:14 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkMenuItem" id="file_separatormenuitem1">
+                     <property name="visible">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="file_quit">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-quit</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_file_quit_activate" last_modification_time="Fri, 27 Dec 2002 01:56:45 GMT"/>
+                     <accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="edit_menu">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Edit</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="edit_menu_menu">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="edit_cut">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-cut</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_edit_cut_activate" last_modification_time="Fri, 27 Dec 2002 02:30:09 GMT"/>
+                     <accelerator key="X" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="edit_copy">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-copy</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_edit_copy_activate" last_modification_time="Fri, 27 Dec 2002 02:30:35 GMT"/>
+                     <accelerator key="C" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="edit_paste">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-paste</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_edit_paste_activate" last_modification_time="Fri, 27 Dec 2002 02:30:46 GMT"/>
+                     <accelerator key="V" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="edit_delete">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-delete</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_edit_delete_activate" last_modification_time="Fri, 27 Dec 2002 02:31:06 GMT"/>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="view_menu">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_View</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="view_menu_menu">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="view_formatter">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">F_ormatter</property>
+                     <property name="use_underline">True</property>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image10">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-select-color</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+
+                     <child>
+                       <widget class="GtkMenu" id="view_formatter_menu">
+
+                         <child>
+                           <widget class="GtkRadioMenuItem" id="view_formatter_default">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Default</property>
+                             <property name="use_underline">True</property>
+                             <property name="active">True</property>
+                             <signal name="activate" handler="on_view_formatter_default_activate" last_modification_time="Fri, 27 Dec 2002 03:00:29 GMT"/>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkRadioMenuItem" id="view_formatter_vb">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Visual Basic .NET</property>
+                             <property name="use_underline">True</property>
+                             <property name="active">False</property>
+                             <property name="group">view_formatter_default</property>
+                             <signal name="activate" handler="on_view_formatter_vb_activate" last_modification_time="Fri, 27 Dec 2002 03:00:29 GMT"/>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkRadioMenuItem" id="view_formatter_csharp">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">C#</property>
+                             <property name="use_underline">True</property>
+                             <property name="active">False</property>
+                             <property name="group">view_formatter_default</property>
+                             <signal name="activate" handler="on_view_formatter_csharp_activate" last_modification_time="Fri, 27 Dec 2002 03:00:29 GMT"/>
+                           </widget>
+                         </child>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="view_finder">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">F_inder</property>
+                     <property name="use_underline">True</property>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image11">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-convert</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+
+                     <child>
+                       <widget class="GtkMenu" id="view_finder_menu">
+
+                         <child>
+                           <widget class="GtkRadioMenuItem" id="view_finder_explicit">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Explicit</property>
+                             <property name="use_underline">True</property>
+                             <property name="active">True</property>
+                             <signal name="activate" handler="on_view_finder_explicit_activate" last_modification_time="Fri, 27 Dec 2002 03:00:29 GMT"/>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkRadioMenuItem" id="view_finder_reflection">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Reflection</property>
+                             <property name="use_underline">True</property>
+                             <property name="active">False</property>
+                             <property name="group">view_finder_explicit</property>
+                             <signal name="activate" handler="on_view_finder_reflection_activate" last_modification_time="Fri, 27 Dec 2002 03:00:29 GMT"/>
+                           </widget>
+                         </child>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="help_menu">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Help</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="help_menu_menu">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="help_about">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">About</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_help_about_activate" last_modification_time="Fri, 27 Dec 2002 01:56:33 GMT"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image12">
+                         <property name="visible">True</property>
+                         <property name="stock">gnome-stock-about</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkHandleBox" id="handlebox1">
+         <property name="visible">True</property>
+         <property name="shadow_type">GTK_SHADOW_OUT</property>
+         <property name="handle_position">GTK_POS_LEFT</property>
+         <property name="snap_edge">GTK_POS_TOP</property>
+
+         <child>
+           <widget class="GtkToolbar" id="toolbar2">
+             <property name="visible">True</property>
+             <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
+             <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
+             <property name="tooltips">True</property>
+
+             <child>
+               <widget class="GtkButton" id="open_button">
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="relief">GTK_RELIEF_NORMAL</property>
+                 <signal name="clicked" handler="on_file_open_activate" last_modification_time="Fri, 27 Dec 2002 18:57:38 GMT"/>
+
+                 <child>
+                   <widget class="GtkHBox" id="hbox1">
+                     <property name="visible">True</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">0</property>
+
+                     <child>
+                       <widget class="GtkImage" id="image13">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-open</property>
+                         <property name="icon_size">4</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">True</property>
+                         <property name="fill">True</property>
+                       </packing>
+                     </child>
+
+                     <child>
+                       <widget class="GtkLabel" id="label1">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">Open</property>
+                         <property name="use_underline">False</property>
+                         <property name="use_markup">False</property>
+                         <property name="justify">GTK_JUSTIFY_LEFT</property>
+                         <property name="wrap">False</property>
+                         <property name="selectable">False</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+
+             <child>
+               <widget class="GtkButton" id="preferences_button">
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="relief">GTK_RELIEF_NORMAL</property>
+
+                 <child>
+                   <widget class="GtkHBox" id="hbox2">
+                     <property name="visible">True</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">0</property>
+
+                     <child>
+                       <widget class="GtkImage" id="image14">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-preferences</property>
+                         <property name="icon_size">4</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">True</property>
+                         <property name="fill">True</property>
+                       </packing>
+                     </child>
+
+                     <child>
+                       <widget class="GtkLabel" id="label2">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">Preferences</property>
+                         <property name="use_underline">False</property>
+                         <property name="use_markup">False</property>
+                         <property name="justify">GTK_JUSTIFY_LEFT</property>
+                         <property name="wrap">False</property>
+                         <property name="selectable">False</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkScrolledWindow" id="scrolledwindow1">
+         <property name="visible">True</property>
+         <property name="can_focus">True</property>
+         <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
+         <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+         <property name="shadow_type">GTK_SHADOW_NONE</property>
+         <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+         <child>
+           <widget class="GtkTreeView" id="treeview">
+             <property name="visible">True</property>
+             <property name="can_focus">True</property>
+             <property name="headers_visible">False</property>
+             <property name="rules_hint">True</property>
+             <property name="reorderable">False</property>
+             <property name="enable_search">True</property>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkStatusbar" id="status_bar">
+         <property name="visible">True</property>
+         <property name="has_resize_grip">True</property>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
+<widget class="GnomeAbout" id="about_window">
+  <property name="visible">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="copyright" translatable="yes">(C) 2002 Jonathan Pryor</property>
+  <property name="comments" translatable="yes">Displays System.Reflection information about .NET types.</property>
+  <property name="authors">Jonathan Pryor</property>
+  <property name="documenters">Jonathan Pryor</property>
+  <property name="translator_credits" translatable="yes">translator_credits</property>
+</widget>
+
+</glade-interface>
diff --git a/mcs/tools/type-reflector/displayers/gtk/type-reflector.gladep b/mcs/tools/type-reflector/displayers/gtk/type-reflector.gladep
new file mode 100644 (file)
index 0000000..c6bcf45
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
+
+<glade-project>
+  <name>Type Reflector</name>
+  <program_name>type-reflector</program_name>
+  <gnome_support>FALSE</gnome_support>
+</glade-project>
index d0dff404411e4d469baada853bcdb10eed13e0b3..40827ce5d8b6a14b84ac82421cc943f3a5c8fed2 100644 (file)
@@ -83,7 +83,7 @@ namespace Mono.TypeReflector
                        return count;
                }
 
-               protected override void GetTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type)
+               protected override void AddTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type)
                {
                        object instance = parent.ReflectionInstance;
 
@@ -230,7 +230,7 @@ namespace Mono.TypeReflector
                        }
                }
 
-               protected override void GetFieldChildren (NodeInfoCollection c, NodeInfo parent, FieldInfo field)
+               protected override void AddFieldChildren (NodeInfoCollection c, NodeInfo parent, FieldInfo field)
                {
                        Trace.WriteLineIf (info.Enabled, "Getting Field Children");
                        AddMemberChildren (parent, field, c);
@@ -293,7 +293,7 @@ namespace Mono.TypeReflector
                        }
                }
 
-               protected override void GetParameterChildren (NodeInfoCollection c, NodeInfo parent, ParameterInfo pi)
+               protected override void AddParameterChildren (NodeInfoCollection c, NodeInfo parent, ParameterInfo pi)
                {
                        // TODO: handle custom attributes...
                        // c.Add (new NodeInfo (parent, pi, customAttributes, NodeTypes.Other));
@@ -311,12 +311,12 @@ namespace Mono.TypeReflector
                        AddMembers (parent, pi, "Position", c);
                }
 
-               protected override void GetConstructorChildren (NodeInfoCollection c, NodeInfo parent, ConstructorInfo node)
+               protected override void AddConstructorChildren (NodeInfoCollection c, NodeInfo parent, ConstructorInfo node)
                {
                        AddMethodBaseChildren (parent, node, c);
                }
 
-               protected override void GetEventChildren (NodeInfoCollection c, NodeInfo parent, EventInfo node)
+               protected override void AddEventChildren (NodeInfoCollection c, NodeInfo parent, EventInfo node)
                {
                        AddMemberChildren (parent, node, c);
                        AddMembers (parent, node, "Attributes", c);
@@ -325,7 +325,7 @@ namespace Mono.TypeReflector
                        AddMembers (parent, node, "IsSpecialName", c);
                }
 
-               protected override void GetMethodChildren (NodeInfoCollection c, NodeInfo parent, MethodInfo node)
+               protected override void AddMethodChildren (NodeInfoCollection c, NodeInfo parent, MethodInfo node)
                {
                        AddMethodBaseChildren (parent, node, c);
                        AddMembers (parent, node, "ReturnType", c);
@@ -347,7 +347,7 @@ namespace Mono.TypeReflector
                        }
                }
 
-               protected override void GetPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo node)
+               protected override void AddPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo node)
                {
                        AddMemberChildren (parent, node, c);
                        AddMembers (parent, node, "Attributes", c);
index 26d89fae596147db1ba725483292181f1a5ee977..0c0e350bc063a390b93ece93bcdfdd01713f9c7f 100644 (file)
@@ -169,27 +169,6 @@ namespace Mono.TypeReflector
                private bool verboseOutput = false;
                private bool showMonoBroken = false;
 
-               // `ReflectionTypeDisplayer.PrintTypeProperties' is recursive, but refrains 
-    // from printing duplicates.  Despite duplicate removal, the output for 
-    // printing the Properties of System.Type is > 800K of text.
-               //
-               // 3 levels permits viewing Attribute values, but not the attributes of
-               // those attribute values.
-               //
-               // For example, 3 levels permits:
-               //              class           System.Type                           {depth 0}
-               //                      Properties:                                 {depth 1}
-               //                              System.Reflection.MemberTypes MemberType  {depth 2}
-               //                                      - CanRead=True                          {depth 3}
-               //                                      - CanWrite=False                        {depth 3}
-               //                                      ...
-               private int maxDepth = 3;
-
-               public int MaxDepth {
-                       get {return maxDepth;}
-                       set {maxDepth = value;}
-               }
-
                public bool ShowBase {
                        get {return showBase;}
                        set {showBase = value;}
@@ -287,92 +266,91 @@ namespace Mono.TypeReflector
 
                        // always handle NodeTypes.Type
                        if (root.NodeType == NodeTypes.Type)
-                               GetTypeChildren (c, root, (Type) root.ReflectionObject);
+                               AddTypeChildren (c, root, (Type) root.ReflectionObject);
                        else if (VerboseOutput) {
                                switch (root.NodeType) {
                                        case NodeTypes.BaseType:
-                                               GetBaseTypeChildren (c, root, (Type) root.ReflectionObject);
+                                               AddBaseTypeChildren (c, root, (Type) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Interface:
-                                               GetInterfaceChildren (c, root, (Type) root.ReflectionObject);
+                                               AddInterfaceChildren (c, root, (Type) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Field:
-                                               GetFieldChildren (c, root, (FieldInfo) root.ReflectionObject);
+                                               AddFieldChildren (c, root, (FieldInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Constructor:
-                                               GetConstructorChildren (c, root, (ConstructorInfo) root.ReflectionObject);
+                                               AddConstructorChildren (c, root, (ConstructorInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Method:
-                                               GetMethodChildren (c, root, (MethodInfo) root.ReflectionObject);
+                                               AddMethodChildren (c, root, (MethodInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Parameter:
-                                               GetParameterChildren (c, root, (ParameterInfo) root.ReflectionObject);
+                                               AddParameterChildren (c, root, (ParameterInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Property:
-                                               GetPropertyChildren (c, root, (PropertyInfo) root.ReflectionObject);
+                                               AddPropertyChildren (c, root, (PropertyInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.Event:
-                                               GetEventChildren (c, root, (EventInfo) root.ReflectionObject);
+                                               AddEventChildren (c, root, (EventInfo) root.ReflectionObject);
                                                break;
                                        case NodeTypes.ReturnValue:
-                                               GetReturnValueChildren (c, root);
+                                               AddReturnValueChildren (c, root);
                                                break;
                                        case NodeTypes.Other:
                                        case NodeTypes.Alias:
-                                               GetOtherChildren (c, root);
+                                               AddOtherChildren (c, root);
                                                break;
                                        default:
-                                               GetUnhandledChildren (c, root);
+                                               AddUnhandledChildren (c, root);
                                                break;
                                }
                        }
                        return c;
                }
 
-               protected virtual void GetTypeChildren (NodeInfoCollection c, NodeInfo root, Type type)
+               protected virtual void AddTypeChildren (NodeInfoCollection c, NodeInfo root, Type type)
                {
                }
 
-               protected virtual void GetBaseTypeChildren (NodeInfoCollection c, NodeInfo root, Type baseType)
+               protected virtual void AddBaseTypeChildren (NodeInfoCollection c, NodeInfo root, Type baseType)
                {
                }
 
-               protected virtual void GetInterfaceChildren (NodeInfoCollection c, NodeInfo root, Type iface)
+               protected virtual void AddInterfaceChildren (NodeInfoCollection c, NodeInfo root, Type iface)
                {
                }
 
-               protected virtual void GetFieldChildren (NodeInfoCollection c, NodeInfo root, FieldInfo field)
+               protected virtual void AddFieldChildren (NodeInfoCollection c, NodeInfo root, FieldInfo field)
                {
-                       Console.WriteLine ("** field children b");
                }
 
-               protected virtual void GetConstructorChildren (NodeInfoCollection c, NodeInfo root, ConstructorInfo ctor)
+               protected virtual void AddConstructorChildren (NodeInfoCollection c, NodeInfo root, ConstructorInfo ctor)
                {
                }
 
-               protected virtual void GetMethodChildren (NodeInfoCollection c, NodeInfo root, MethodInfo method)
+               protected virtual void AddMethodChildren (NodeInfoCollection c, NodeInfo root, MethodInfo method)
                {
                }
 
-               protected virtual void GetParameterChildren (NodeInfoCollection c, NodeInfo root, ParameterInfo param)
+               protected virtual void AddParameterChildren (NodeInfoCollection c, NodeInfo root, ParameterInfo param)
                {
                }
 
-               protected virtual void GetPropertyChildren (NodeInfoCollection c, NodeInfo root, PropertyInfo property)
+               protected virtual void AddPropertyChildren (NodeInfoCollection c, NodeInfo root, PropertyInfo property)
                {
                }
 
-               protected virtual void GetEventChildren (NodeInfoCollection c, NodeInfo root, EventInfo e)
+               protected virtual void AddEventChildren (NodeInfoCollection c, NodeInfo root, EventInfo e)
                {
                }
 
-               protected virtual void GetReturnValueChildren (NodeInfoCollection c, NodeInfo root)
+               protected virtual void AddReturnValueChildren (NodeInfoCollection c, NodeInfo root)
                {
                        if (root.ReflectionObject != null)
-                               GetTypeChildren (c, root, (Type) root.ReflectionObject);
+                               AddTypeChildren (c, root, (Type) root.ReflectionObject);
                }
 
-               protected virtual void GetOtherChildren (NodeInfoCollection c, NodeInfo root)
+               protected virtual void AddOtherChildren (NodeInfoCollection c, NodeInfo root)
                {
                        if (root.Description is NodeGroup) {
                                NodeGroup g = (NodeGroup) root.Description;
@@ -380,7 +358,7 @@ namespace Mono.TypeReflector
                        }
                }
 
-               protected virtual void GetUnhandledChildren (NodeInfoCollection c, NodeInfo root)
+               protected virtual void AddUnhandledChildren (NodeInfoCollection c, NodeInfo root)
                {
                        c.Add (new NodeInfo (root, "Unhandled child: NodeType=" + root.NodeType));
                }
index 462e13eeece54816dca580f7e255ea57bb5f9ac1..4c9e1f96f3ebd2774d06e0152d9856c2a0b4a5ca 100644 (file)
@@ -53,7 +53,7 @@ namespace Mono.TypeReflector
 
                private static readonly IComparer NameComparer = new MemberInfoNameComparer ();
 
-               protected override void GetTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type)
+               protected override void AddTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type)
                {
                        foreach (MemberInfo mi in GetMembers (type)) {
                                AddNode (c, parent, mi, mi);
@@ -121,17 +121,17 @@ namespace Mono.TypeReflector
                        }
                }
 
-               protected override void GetFieldChildren (NodeInfoCollection c, NodeInfo parent, FieldInfo field)
+               protected override void AddFieldChildren (NodeInfoCollection c, NodeInfo parent, FieldInfo field)
                {
                        AddSubnodes (c, parent, field.GetType(), field);
                }
 
-               protected override void GetConstructorChildren (NodeInfoCollection c, NodeInfo parent, ConstructorInfo ctor)
+               protected override void AddConstructorChildren (NodeInfoCollection c, NodeInfo parent, ConstructorInfo ctor)
                {
                        GetMethodBaseChildren (c, parent, ctor);
                }
 
-               protected override void GetMethodChildren (NodeInfoCollection c, NodeInfo parent, MethodInfo method)
+               protected override void AddMethodChildren (NodeInfoCollection c, NodeInfo parent, MethodInfo method)
                {
                        GetMethodBaseChildren (c, parent, method);
                }
@@ -141,25 +141,25 @@ namespace Mono.TypeReflector
                        AddSubnodes (c, parent, mb.GetType(), mb);
                }
 
-               protected override void GetParameterChildren (NodeInfoCollection c, NodeInfo parent, ParameterInfo param)
+               protected override void AddParameterChildren (NodeInfoCollection c, NodeInfo parent, ParameterInfo param)
                {
                        AddSubnodes (c, parent, param.GetType(), param);
                }
 
-               protected override void GetPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo pi)
+               protected override void AddPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo pi)
                {
                        AddSubnodes (c, parent, pi.GetType(), pi);
                }
 
-               protected override void GetEventChildren (NodeInfoCollection c, NodeInfo parent, EventInfo e)
+               protected override void AddEventChildren (NodeInfoCollection c, NodeInfo parent, EventInfo e)
                {
                        AddSubnodes (c, parent, e.GetType(), e);
                }
 
-               protected override void GetReturnValueChildren (NodeInfoCollection c, NodeInfo parent)
+               protected override void AddReturnValueChildren (NodeInfoCollection c, NodeInfo parent)
                {
                        if (parent.ReflectionObject != null)
-                               GetTypeChildren (c, parent, (Type) parent.ReflectionObject);
+                               AddTypeChildren (c, parent, (Type) parent.ReflectionObject);
                }
        }
 }
index f972905e8b9dcf2eef89d6557a4465696760e5a9..9ef10d1679a980dd42e53e3d611a23b5ec1da53b 100644 (file)
@@ -22,230 +22,37 @@ namespace Mono.TypeReflector
                {
                }
 
-               protected override string GetTypeDescription (Type type, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetAttributes (sb, type);
-                       sb.Append (base.GetTypeDescription (type, instance));
-                       return sb.ToString();
-               }
-
-               private void GetAttributes (StringBuilder sb, MemberInfo m)
-               {
-                       GetAttributes (sb, m, true);
-               }
-
-               private void GetAttributes (StringBuilder sb, MemberInfo m, bool newline)
-               {
-                       GetCilAttributes (sb, m, newline);
-                       sb.Append (GetCustomAttributes (m, "", newline));
-               }
-
-               private void GetCilAttributes (StringBuilder sb, MemberInfo m, bool newline)
-               {
-                       Type t = m as Type;
-                       MethodBase mb = m as MethodBase;
-                       if (t != null)
-                               GetCilAttributes (sb, t, newline);
-                       else if (mb != null)
-                               GetCilAttributes (sb, mb, newline);
-               }
-
-               private void GetCilAttributes (StringBuilder sb, Type t, bool newline)
-               {
-                       if (t.IsSerializable) {
-                               sb.Append ("[Serializable]");
-                               if (newline)
-                                       sb.Append ("\n");
-                       }
-               }
-
-               private void GetCilAttributes (StringBuilder sb, MethodBase m, bool newline)
-               {
-                       MethodImplAttributes attr = m.GetMethodImplementationFlags ();
-                       if ((attr & MethodImplAttributes.InternalCall) != 0) {
-                               sb.Append ("[MethodImplAttribute(MethodImplOptions.InternalCall)]");
-                               if (newline)
-                                       sb.Append ("\n");
-                       }
-               }
-
-               protected override string GetBaseTypeDescription (Type type, object instance)
-               {
-                       return ": " + type.Name;
-               }
-
-               protected override string GetInterfaceDescription (Type type, object instance)
-               {
-                       return ", " + type.Name;
-               }
-
-               protected override string GetConstructorDescription (ConstructorInfo ctor, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetAttributes (sb, ctor);
-                       GetMethodQualifiers (sb, ctor);
-                       sb.AppendFormat ("{0} ", ctor.DeclaringType.Name);
-                       GetMethodArgs (sb, ctor);
-
-                       return sb.ToString();
-               }
-
-               private void GetMethodQualifiers (StringBuilder sb, MethodBase m)
-               {
-                       if (m.IsPublic)
-                               sb.Append ("public ");
-                       if (m.IsFamily)
-                               sb.Append ("protected ");
-                       if (m.IsAssembly)
-                               sb.Append ("internal ");
-                       if (m.IsPrivate)
-                               sb.Append ("private ");
-                       if (m.IsStatic)
-                               sb.Append ("static ");
-                       if (m.IsFinal)
-                               sb.Append ("sealed ");
-                       if (m.IsAbstract)
-                               sb.Append ("abstract ");
-                       else if (m.IsVirtual)
-                               sb.Append ("virtual ");
-               }
-
-               private void GetMethodArgs (StringBuilder sb, MethodBase m)
-               {
-                       sb.Append ("(");
-                       ParameterInfo[] parms = m.GetParameters ();
-                       if (parms.Length != 0) {
-                               int cur = 0;
-                               foreach (ParameterInfo pi in parms) {
-                                       sb.Append (GetParameterDescription (pi, pi));
-                                       if (cur++ != (parms.Length-1))
-                                               sb.Append (", ");
-                               }
-                       }
-                       sb.Append (")");
-               }
+               protected override string LineComment       {get {return "//";}}
 
-               protected override string GetEventDescription (EventInfo e, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetMethodQualifiers (sb, e.GetAddMethod (true));
-                       return String.Format ("{0}{1}{2} {3}", 
-                                       sb.ToString(),
-                                       e.IsMulticast ? "event " : "",
-                                       e.EventHandlerType,
-                                       e.Name);
-               }
-
-               protected override string GetFieldDescription (FieldInfo field, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
+               protected override string KeywordClass      {get {return "class";}}
+               protected override string KeywordEnum       {get {return "enum";}}
+               protected override string KeywordValueType  {get {return "struct";}}
+               protected override string KeywordInterface  {get {return "interface";}}
+               protected override string KeywordInherits   {get {return ":";}}
+               protected override string KeywordImplements {get {return ",";}}
+               protected override string KeywordMulticast  {get {return "event";}}
+               protected override string KeywordStatementTerminator {get {return ";";}}
+               protected override string KeywordStatementSeparator  {get {return ",";}}
 
-                       GetAttributes (sb, field);
-
-                       if (!field.DeclaringType.IsEnum || field.IsSpecialName) {
-                               if (field.IsPublic)
-                                       sb.Append ("public ");
-                               if (field.IsPrivate)
-                                       sb.Append ("private ");
-                               if (field.IsAssembly)
-                                       sb.Append ("internal ");
-                               if (field.IsFamily)
-                                       sb.Append ("protected ");
-                               if (field.IsLiteral)
-                                       sb.Append ("const ");
-                               else if (field.IsStatic)
-                                       sb.Append ("static ");
-
-                               sb.AppendFormat ("{0} ", field.FieldType);
-                       }
-
-                       sb.AppendFormat ("{0}", field.Name);
-
-                       try {
-                               sb.AppendFormat (" = {0}", GetValue (field.GetValue (instance)));
-                       }
-                       catch {
-                       }
-
-                       if (!field.DeclaringType.IsEnum || field.IsSpecialName)
-                               sb.Append (";");
-                       else
-                               sb.Append (",");
-
-                       return sb.ToString ();
-               }
-
-               protected override string GetMethodDescription (MethodInfo method, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-
-                       if (method.IsSpecialName)
-                               sb.Append ("/* Method is a specially named method:\n");
-
-                       GetAttributes (sb, method);
-                       if (method.ReturnTypeCustomAttributes != null) {
-                               sb.Append (GetCustomAttributes (method.ReturnTypeCustomAttributes, "return: ", true));
-                       }
-                       GetMethodQualifiers (sb, method);
-                       sb.AppendFormat ("{0} {1} ", method.ReturnType, method.Name);
-                       GetMethodArgs (sb, method);
-                       
-                       if (method.GetParameters().Length == 0) {
-                               try {
-                                       object r = method.Invoke (instance, null);
-                                       string s = GetValue (r);
-                                       sb.AppendFormat ("={0}", s);
-                               }
-                               catch {
-                               }
-                       }
-
-                       if (method.IsSpecialName) {
-                               sb.Append ("\n */");
-                       }
-
-                       return sb.ToString();
-               }
-
-               protected override string GetParameterDescription (ParameterInfo param, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-
-                       sb.Append (GetCustomAttributes (param, "", false));
-                       if (param.IsOut)
-                               sb.Append ("out ");
-                       sb.AppendFormat ("{0} {1}", param.ParameterType, param.Name);
-
-                       return sb.ToString();
-               }
-
-               protected override string GetPropertyDescription (PropertyInfo property, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetAttributes (sb, property);
-                       GetMethodQualifiers (sb, property.GetAccessors(true)[0]);
+               protected override string QualifierPublic   {get {return "public";}}
+               protected override string QualifierFamily   {get {return "protected";}}
+               protected override string QualifierAssembly {get {return "internal";}}
+               protected override string QualifierPrivate  {get {return "private";}}
+               protected override string QualifierFinal    {get {return "sealed";}}
+               protected override string QualifierStatic   {get {return "static";}}
+               protected override string QualifierLiteral  {get {return "const";}}
+               protected override string QualifierAbstract {get {return "abstract";}}
+               protected override string QualifierVirtual  {get {return "virtual";}}
 
-                       sb.AppendFormat ("{0} {1} {{", property.PropertyType, property.Name);
-                       if (property.CanRead) {
-                               sb.Append ("get");
-                               try {
-                                       sb.AppendFormat (" /* = {0} */", GetValue (property.GetValue (instance, null)));
-                               }
-                               catch {
-                               }
-                               sb.Append ("; ");
-                       }
-                       if (property.CanWrite)
-                               sb.Append ("set; ");
-                       sb.Append ("}}");
+               private static readonly string[] attributeDelimeters = new string[]{"[", "]"};
 
-                       return sb.ToString();
+               protected override string[] AttributeDelimeters {
+                       get {return attributeDelimeters;}
                }
 
-               protected override string GetReturnValueDescription (NodeInfo n)
+               protected override string GetConstructorName (ConstructorInfo ctor)
                {
-                       return string.Format ("/* ReturnValue={0} */", GetOtherDescription (n));
+                       return ctor.DeclaringType.Name;
                }
        }
 }
index 6d80989fb835d2117c76a298787d790e235adce7..18407ecc1fcbadb164c4dc6541f134d22148db12 100644 (file)
@@ -17,147 +17,375 @@ using System.Text.RegularExpressions;
 
 namespace Mono.TypeReflector
 {
-       public class LanguageNodeFormatter : NodeFormatter {
+       public abstract class LanguageNodeFormatter : NodeFormatter {
+
+               protected abstract string LineComment {get;}
+
+               // [0] is open, [1] is close
+               protected abstract string[] AttributeDelimeters {get;}
+
+               protected abstract string KeywordClass {get;}
+               protected abstract string KeywordEnum {get;}
+               protected abstract string KeywordValueType {get;}
+               protected abstract string KeywordInterface {get;}
+               protected abstract string KeywordInherits {get;}
+               protected abstract string KeywordImplements {get;}
+               protected abstract string KeywordMulticast {get;}
+               protected abstract string KeywordStatementTerminator {get;}
+               protected abstract string KeywordStatementSeparator {get;}
+
+               protected abstract string QualifierPublic {get;}
+               protected abstract string QualifierFamily {get;}
+               protected abstract string QualifierAssembly {get;}
+               protected abstract string QualifierPrivate {get;}
+               protected abstract string QualifierStatic {get;}
+               protected abstract string QualifierFinal {get;}
+               protected abstract string QualifierAbstract {get;}
+               protected abstract string QualifierVirtual {get;}
+               protected abstract string QualifierLiteral {get;}
 
                protected override string GetTypeDescription (Type type, object instance)
                {
-                       return string.Format ("{0} {1}", GetTypeKeyword(type), type.Name);
+                       StringBuilder sb = new StringBuilder ();
+                       AddAttributes (sb, type);
+                       AddTypeQualifiers (sb, type);
+                       sb.AppendFormat ("{0} {1}", GetTypeKeyword(type), type.FullName);
+                       return sb.ToString ();
+               }
+
+               protected void AddAttribute (StringBuilder sb, string attribute)
+               {
+                       sb.AppendFormat ("{0}{1}{2}", 
+                                               AttributeDelimeters[0], attribute, AttributeDelimeters[1]);
+               }
+
+               protected void AddAttributes (StringBuilder sb, MemberInfo m)
+               {
+                       AddAttributes (sb, m, true);
+               }
+
+               protected void AddAttributes (StringBuilder sb, MemberInfo m, bool newline)
+               {
+                       AddCilAttributes (sb, m, newline);
+                       AddCustomAttributes (sb, m, "", newline);
+               }
+
+               private void AddCilAttributes (StringBuilder sb, MemberInfo m, bool newline)
+               {
+                       Type t = m as Type;
+                       MethodBase mb = m as MethodBase;
+                       if (t != null)
+                               AddCilAttributes (sb, t, newline);
+                       else if (mb != null)
+                               AddCilAttributes (sb, mb, newline);
+               }
+
+               private void AddCilAttributes (StringBuilder sb, Type t, bool newline)
+               {
+                       if (t.IsSerializable) {
+                               AddAttribute (sb, "Serializable");
+                               if (newline)
+                                       sb.Append ("\n");
+                       }
+               }
+
+               private void AddCilAttributes (StringBuilder sb, MethodBase m, bool newline)
+               {
+                       MethodImplAttributes attr = m.GetMethodImplementationFlags ();
+                       if ((attr & MethodImplAttributes.InternalCall) != 0) {
+                               AddAttribute (sb, "MethodImplAttribute(MethodImplOptions.InternalCall)");
+                               if (newline)
+                                       sb.Append ("\n");
+                       }
+               }
+
+               protected void AddTypeQualifiers (StringBuilder sb, Type type)
+               {
+                       if (type.IsPublic)
+                               sb.Append (QualifierPublic + " ");
+                       if (type.IsSealed && !type.IsValueType)
+                               sb.Append (QualifierFinal + " ");
+                       if (type.IsAbstract && !type.IsInterface)
+                               sb.Append (QualifierAbstract + " ");
+               }
+
+               new protected string GetTypeKeyword (Type type)
+               {
+                       if (type.IsClass)
+                               return KeywordClass;
+                       if (type.IsEnum)
+                               return KeywordEnum;
+                       if (type.IsValueType)
+                               return KeywordValueType;
+                       if (type.IsInterface)
+                               return KeywordInterface;
+
+                       // unknown type
+                       return "type";
                }
 
                protected override string GetBaseTypeDescription (Type type, object instance)
                {
-                       return type.Name;
+                       if (type != null)
+                               return string.Format ("{0} {1}", KeywordInherits, type.Name);
+                       return string.Format ("{0} No Base Type", LineComment);
                }
 
                protected override string GetInterfaceDescription (Type type, object instance)
                {
-                       return type.Name;
+                       return string.Format ("{0} {1}", KeywordImplements, type.Name);
                }
 
                protected override string GetConstructorDescription (ConstructorInfo ctor, object instance)
                {
-                       return string.Format ("{0} ({1})", ctor.Name, ctor.GetParameters().Length);
-                       // return ctor.Name;
+                       StringBuilder sb = new StringBuilder ();
+                       AddAttributes (sb, ctor);
+                       AddMethodQualifiers (sb, ctor);
+                       sb.AppendFormat ("{0} ", GetConstructorName (ctor));
+                       AddMethodArgs (sb, ctor);
+
+                       return sb.ToString();
+               }
+
+               protected void AddMethodQualifiers (StringBuilder sb, MethodBase m)
+               {
+                       if (m.IsPublic)
+                               sb.AppendFormat ("{0} ", QualifierPublic);
+                       if (m.IsFamily)
+                               sb.AppendFormat ("{0} ", QualifierFamily);
+                       if (m.IsAssembly)
+                               sb.AppendFormat ("{0} ", QualifierAssembly);
+                       if (m.IsPrivate)
+                               sb.AppendFormat ("{0} ", QualifierPrivate);
+                       if (m.IsStatic)
+                               sb.AppendFormat ("{0} ", QualifierStatic);
+                       if (m.IsFinal)
+                               sb.AppendFormat ("{0} ", QualifierFinal);
+                       if (m.IsAbstract)
+                               sb.AppendFormat ("{0} ", QualifierAbstract);
+                       else if (m.IsVirtual)
+                               sb.AppendFormat ("{0} ", QualifierVirtual);
+               }
+
+               protected abstract string GetConstructorName (ConstructorInfo ctor);
+
+               protected void AddMethodArgs (StringBuilder sb, MethodBase m)
+               {
+                       sb.Append ("(");
+                       ParameterInfo[] parms = m.GetParameters ();
+                       if (parms.Length != 0) {
+                               int cur = 0;
+                               foreach (ParameterInfo pi in parms) {
+                                       sb.Append (GetParameterDescription (pi, pi));
+                                       if (cur++ != (parms.Length-1))
+                                               sb.Append (", ");
+                               }
+                       }
+                       sb.Append (")");
                }
 
                protected override string GetEventDescription (EventInfo e, object instance)
                {
-                       return e.Name;
+                       StringBuilder sb = new StringBuilder ();
+                       AddMethodQualifiers (sb, e.GetAddMethod(true));
+                       return string.Format ("{0}{1}{2} {3}",
+                                       sb.ToString (),
+                                       e.IsMulticast ? KeywordMulticast + " " : "",
+                                       e.EventHandlerType,
+                                       e.Name);
                }
 
                protected override string GetFieldDescription (FieldInfo field, object instance)
                {
+                       StringBuilder sb = new StringBuilder ();
+                       AddAttributes (sb, field);
+
+                       if (!field.DeclaringType.IsEnum || field.IsSpecialName) {
+                               AddFieldQualifiers (sb, field);
+                               sb.AppendFormat ("{0} ", field.FieldType);
+                       }
+
+                       sb.Append (field.Name);
+
                        try {
-                               return string.Format ("{0}={1}", field.Name, 
-                                               // GetValue (field, instance));
-                                               GetValue (instance));
-                       } catch {
-                               return field.Name;
+                               sb.AppendFormat (" = {0}", GetValue (field.GetValue (instance)));
+                       }
+                       catch {
                        }
+
+                       if (!field.DeclaringType.IsEnum || field.IsSpecialName)
+                               sb.Append (KeywordStatementTerminator);
+                       else
+                               sb.Append (KeywordStatementSeparator);
+
+                       return sb.ToString();
                }
 
-               protected override string GetMethodDescription (MethodInfo mb, object instance)
+               protected void AddFieldQualifiers (StringBuilder sb, FieldInfo field)
                {
-                       if (mb.GetParameters().Length == 0) {
+                       if (field.IsPublic)
+                               sb.AppendFormat ("{0} ", QualifierPublic);
+                       if (field.IsPrivate)
+                               sb.AppendFormat ("{0} ", QualifierPrivate);
+                       if (field.IsAssembly)
+                               sb.AppendFormat ("{0} ", QualifierAssembly);
+                       if (field.IsFamily)
+                               sb.AppendFormat ("{0} ", QualifierFamily);
+                       if (field.IsLiteral)
+                               sb.AppendFormat ("{0} ", QualifierLiteral);
+                       else if (field.IsStatic)
+                               sb.AppendFormat ("{0} ", QualifierStatic);
+               }
+
+               protected override string GetMethodDescription (MethodInfo method, object instance)
+               {
+                       StringBuilder sb = new StringBuilder ();
+
+                       if (method.IsSpecialName)
+                               sb.AppendFormat ("{0} Method is a specially named method:\n", LineComment);
+
+                       AddAttributes (sb, method);
+                       if (method.ReturnTypeCustomAttributes != null)
+                               AddCustomAttributes (sb, method.ReturnTypeCustomAttributes, "return: ", true);
+
+                       AddMethodQualifiers (sb, method);
+
+      AddMethodDeclaration (sb, method);
+
+                       if (method.GetParameters().Length == 0) {
                                try {
-                                       object r = mb.Invoke (instance, null);
+                                       object r = method.Invoke (instance, null);
                                        string s = GetValue (r);
-                                       return string.Format ("{0}()={1}", mb.Name, s);
+                                       sb.AppendFormat (" {0} = {1}", LineComment, s);
                                }
                                catch {
                                }
                        }
-                       return string.Format ("{0} ({1})", mb.Name, mb.GetParameters().Length);
+
+                       string r = sb.ToString();
+
+                       if (method.IsSpecialName)
+                               return r.Replace ("\n", "\n" + LineComment + "\t");
+                       return r;
+               }
+
+               protected virtual void AddMethodDeclaration (StringBuilder sb, MethodInfo method)
+               {
+                       sb.AppendFormat ("{0} {1} ", method.ReturnType, method.Name);
+
+                       AddMethodArgs (sb, method);
                }
 
                protected override string GetParameterDescription (ParameterInfo param, object instance)
                {
-                       return param.Name;
+                       StringBuilder sb = new StringBuilder ();
+
+                       AddCustomAttributes (sb, param, "", false);
+                       AddParameterAttributes (sb, param.Attributes);
+
+                       sb.AppendFormat ("{0} {1}", param.ParameterType, param.Name);
+
+                       return sb.ToString();
                }
 
-               protected override string GetPropertyDescription (PropertyInfo property, object instance)
+               protected void AddParameterAttributes (StringBuilder sb, ParameterAttributes attrs)
                {
-                       string v = "";
-                       try {
-                               // object o = property.GetGetMethod(true).Invoke(instance, null);
-                               object o = property.GetValue (instance, null);
-                               v = string.Format ("={0}", GetValue (o));
-                       } catch {
-                               v = "";
-                       }
-                       return string.Format ("{0}{1}", property.Name, v);
-                       // return property.Name;
-                       // return string.Format ("{0}={1}", property.Name, property.GetValue(null));
+                       if ((attrs & ParameterAttributes.In) != 0)
+                               sb.Append ("in");
+                       if ((attrs & ParameterAttributes.Out) != 0)
+                               sb.Append ("out");
+                       if ((attrs & ParameterAttributes.Lcid) != 0)
+                               sb.Append ("lcid");
+                       if ((attrs & ParameterAttributes.Retval) != 0)
+                               sb.Append ("retval");
+                       if ((attrs & ParameterAttributes.Optional) != 0)
+                               sb.Append ("optional");
+                       if ((attrs & ParameterAttributes.HasDefault) != 0)
+                               sb.Append ("hasdefault");
+                       if ((attrs & ParameterAttributes.HasFieldMarshal) != 0)
+                               sb.Append ("hasfieldmarshal");
+                       if ((attrs & ParameterAttributes.ReservedMask) != 0)
+                               sb.Append ("reservedmask");
+                       if ((attrs & ParameterAttributes.Reserved3) != 0)
+                               sb.Append ("reserved3");
+                       if ((attrs & ParameterAttributes.Reserved4) != 0)
+                               sb.Append ("reserved4");
                }
 
-               protected override string GetCustomAttributeProviderDescription (ICustomAttributeProvider m, object instance)
+               protected override string GetPropertyDescription (PropertyInfo property, object instance)
                {
                        StringBuilder sb = new StringBuilder ();
-                       foreach (object a in m.GetCustomAttributes(true)) {
-                               sb.Append (string.Format ("\n\t{0}", GetCustomAttribute(a)));
+                       AddAttributes (sb, property);
+                       AddMethodQualifiers (sb, property.GetAccessors(true)[0]);
+
+                       sb.AppendFormat ("{0} {1} {{", property.PropertyType, property.Name);
+                       if (property.CanRead) {
+                               sb.Append ("get");
+                               try {
+                                       sb.AppendFormat (" /* = {0} */", GetValue (property.GetValue (instance, null)));
+                               }
+                               catch {
+                               }
+                               sb.Append (";");
                        }
-                       return string.Format ("GetCustomAttributes()={0}{1}", 
-                                       sb.Length == 0 ? "<none/>" : "",
-                                       sb.ToString());
+                       if (property.CanWrite)
+                               sb.Append ("set;");
+                       sb.Append ("}}");
+
+                       return sb.ToString();
                }
 
-               protected override string GetCustomAttributes (ICustomAttributeProvider m, string attributeType, bool newLine)
+               protected override string GetReturnValueDescription (NodeInfo n)
                {
-                       StringBuilder sb = new StringBuilder ();
+                       return string.Format ("{0} ReturnValue={1}", 
+                                       LineComment, GetOtherDescription (n));
+               }
+
+               protected override string GetOtherDescription (NodeInfo node)
+               {
+                       if (node.Description != null)
+                               return node.Description.ToString();
+                       return "<null other description/>";
+               }
 
+               protected void AddCustomAttributes (StringBuilder sb, ICustomAttributeProvider m, string attributeType, bool newLine)
+               {
                        object[] attrs = m.GetCustomAttributes (true);
 
                        foreach (object a in attrs) {
 
-                               GetCustomAttribute (sb, a, attributeType);
+                               AddCustomAttribute (sb, a, attributeType);
 
                                if (newLine)
                                        sb.Append ("\n");
                        }
-
-                       return sb.ToString ();
                }
 
-               protected override string GetCustomAttribute (object attribute)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetCustomAttribute (sb, attribute, "");
-                       return sb.ToString();
-               }
-
-               protected override void GetCustomAttribute (StringBuilder sb, object attribute, string attributeType)
+               protected virtual void AddCustomAttribute (StringBuilder sb, object attribute, string attributeType)
                {
                        Type type = attribute.GetType();
-                       char[] delims = GetAttributeDelimeters ();
-                       sb.AppendFormat ("{0}{1}{2}", delims[0], attributeType, type.FullName);
+                       sb.AppendFormat ("{0}{1}{2}", AttributeDelimeters[0], attributeType, type.FullName);
 
-                       string p = GetPropertyValues (type.GetProperties(), attribute);
-                       string f = GetFieldValues (type.GetFields(), attribute);
+                       PropertyInfo[] props = type.GetProperties();
+                       FieldInfo[] fields = type.GetFields();
 
-                       if ((p.Length > 0) || (f.Length > 0)) {
+                       if (props.Length > 0 || fields.Length > 0) {
                                sb.Append ("(");
-                               if (p.Length > 0) {
-                                       sb.Append (p);
-                                       if (f.Length > 0)
+                               if (props.Length > 0) {
+                                       AddPropertyValues (sb, props, attribute);
+                                       if (fields.Length > 0)
                                                sb.Append (", ");
                                }
-                               if (f.Length > 0)
-                                       sb.Append (f);
+                               if (fields.Length > 0)
+                                       AddFieldValues (sb, fields, attribute);
                                sb.Append (")");
                        }
-
-                       sb.Append (delims[1]);
+                       sb.Append (AttributeDelimeters[1]);
                }
 
-               protected override char[] GetAttributeDelimeters ()
-               {
-                       return new char[]{'[', ']'};
-               }
-
-               private string GetPropertyValues (PropertyInfo[] props, object instance)
+               private void AddPropertyValues (StringBuilder sb, PropertyInfo[] props, object instance)
                {
                        int len = props.Length;
-                       StringBuilder sb = new StringBuilder ();
                        for (int i = 0; i != len; ++i) {
                                sb.Append (props[i].Name);
                                sb.Append ("=");
@@ -169,13 +397,11 @@ namespace Mono.TypeReflector
                                if (i != (len-1))
                                        sb.Append (", ");
                        }
-                       return sb.ToString();
                }
 
-               private string GetFieldValues (FieldInfo[] fields, object instance)
+               private void AddFieldValues (StringBuilder sb, FieldInfo[] fields, object instance)
                {
                        int len = fields.Length;
-                       StringBuilder sb = new StringBuilder ();
                        for (int i = 0; i != len; ++i) {
                                sb.Append (fields[i].Name);
                                sb.Append ("=");
@@ -183,10 +409,9 @@ namespace Mono.TypeReflector
                                if (i != (len-1))
                                        sb.Append (", ");
                        }
-                       return sb.ToString();
                }
 
-               protected override string GetEncodedValue (object value)
+               protected virtual string GetEncodedValue (object value)
                {
                        if (value == null)
                                return "null";
@@ -215,57 +440,50 @@ namespace Mono.TypeReflector
                        return value.ToString();
                }
 
-               protected override string GetEncodedCharValue (object value)
+               protected virtual string GetEncodedCharValue (object value)
                {
                        return String.Format ("'{0}'", value.ToString());
                }
 
-               protected override string GetEncodedDecimalValue (object value)
+               protected virtual string GetEncodedDecimalValue (object value)
                {
                        return String.Format ("{0}m", value.ToString());
                }
 
-               protected override string GetEncodedDoubleValue (object value)
+               protected virtual string GetEncodedDoubleValue (object value)
                {
                        return String.Format ("{0}d", value.ToString());
                }
 
-               protected override string GetEncodedInt64Value (object value)
+               protected virtual string GetEncodedInt64Value (object value)
                {
                        return String.Format ("{0}L", value.ToString());
                }
 
-               protected override string GetEncodedSingleValue (object value)
+               protected virtual string GetEncodedSingleValue (object value)
                {
                        return String.Format ("{0}f", value.ToString());
                }
 
-               protected override string GetEncodedStringValue (object value)
+               protected virtual string GetEncodedStringValue (object value)
                {
                        return String.Format ("\"{0}\"", value.ToString());
                }
 
-               protected override string GetEncodedUInt32Value (object value)
+               protected virtual string GetEncodedUInt32Value (object value)
                {
                        return String.Format ("{0}U", value.ToString());
                }
 
-               protected override string GetEncodedUInt64Value (object value)
+               protected virtual string GetEncodedUInt64Value (object value)
                {
                        return String.Format ("{0}UL", value.ToString());
                }
 
-               protected override string GetEncodedObjectValue (object value)
+               protected virtual string GetEncodedObjectValue (object value)
                {
                        return String.Format ("typeof({0})", value.ToString());
                }
-
-               protected override string GetOtherDescription (NodeInfo node)
-               {
-                       if (node.Description != null)
-                               return node.Description.ToString();
-                       return "<null other description/>";
-               }
        }
 }
 
index 911a778034bc0440700ddb8109a872aacaee73bd..459d7dedd3d2ed20a2322f0575fd3fa633b64a50 100644 (file)
@@ -49,9 +49,11 @@ namespace Mono.TypeReflector
                        case NodeTypes.Event:
                                r = GetEventDescription ((EventInfo) node.ReflectionObject, node.ReflectionInstance);
                                break;
+        /*
                        case NodeTypes.CustomAttributeProvider:
                                r = GetCustomAttributeProviderDescription ((ICustomAttributeProvider) node.ReflectionObject, node.ReflectionInstance);
                                break;
+         */
                        case NodeTypes.Other:
                        case NodeTypes.Alias:
                                r = GetOtherDescription (node);
@@ -106,12 +108,15 @@ namespace Mono.TypeReflector
 
                protected virtual string GetTypeDescription (Type type, object instance)
                {
-                       return string.Format ("{0} {1}", GetTypeKeyword(type), type.FullName);
+                       return string.Format ("{0} {1}", 
+                                       GetTypeKeyword(type), type.FullName);
                }
 
                protected virtual string GetBaseTypeDescription (Type type, object instance)
                {
-                       return type.Name;
+      if (type != null)
+        return type.Name;
+      return "No Base Type";
                }
 
                protected virtual string GetInterfaceDescription (Type type, object instance)
@@ -149,176 +154,6 @@ namespace Mono.TypeReflector
                        return property.Name;
                }
 
-               protected virtual string GetCustomAttributeProviderDescription (ICustomAttributeProvider m, object instance)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       foreach (object a in m.GetCustomAttributes(true)) {
-                               sb.Append (string.Format ("\n\t{0}", GetCustomAttribute(a)));
-                       }
-                       return string.Format ("GetCustomAttributes()={0}{1}", 
-                                       sb.Length == 0 ? "<none/>" : "",
-                                       sb.ToString());
-               }
-
-               protected virtual string GetCustomAttributes (ICustomAttributeProvider m, string attributeType, bool newLine)
-               {
-                       StringBuilder sb = new StringBuilder ();
-
-                       object[] attrs = m.GetCustomAttributes (true);
-
-                       foreach (object a in attrs) {
-
-                               GetCustomAttribute (sb, a, attributeType);
-
-                               if (newLine)
-                                       sb.Append ("\n");
-                       }
-
-                       return sb.ToString ();
-               }
-
-               protected virtual string GetCustomAttribute (object attribute)
-               {
-                       StringBuilder sb = new StringBuilder ();
-                       GetCustomAttribute (sb, attribute, "");
-                       return sb.ToString();
-               }
-
-               protected virtual void GetCustomAttribute (StringBuilder sb, object attribute, string attributeType)
-               {
-                       Type type = attribute.GetType();
-                       char[] delims = GetAttributeDelimeters ();
-                       sb.AppendFormat ("{0}{1}{2}", delims[0], attributeType, type.FullName);
-
-                       string p = GetPropertyValues (type.GetProperties(), attribute);
-                       string f = GetFieldValues (type.GetFields(), attribute);
-
-                       if ((p.Length > 0) || (f.Length > 0)) {
-                               sb.Append ("(");
-                               if (p.Length > 0) {
-                                       sb.Append (p);
-                                       if (f.Length > 0)
-                                               sb.Append (", ");
-                               }
-                               if (f.Length > 0)
-                                       sb.Append (f);
-                               sb.Append (")");
-                       }
-
-                       sb.Append (delims[1]);
-               }
-
-               protected virtual char[] GetAttributeDelimeters ()
-               {
-                       return new char[]{'[', ']'};
-               }
-
-               private string GetPropertyValues (PropertyInfo[] props, object instance)
-               {
-                       int len = props.Length;
-                       StringBuilder sb = new StringBuilder ();
-                       for (int i = 0; i != len; ++i) {
-                               sb.Append (props[i].Name);
-                               sb.Append ("=");
-                               try {
-                                       sb.Append (GetEncodedValue (props[i].GetValue (instance, null)));
-                               } catch {
-                                       sb.Append ("<exception/>");
-                               }
-                               if (i != (len-1))
-                                       sb.Append (", ");
-                       }
-                       return sb.ToString();
-               }
-
-               private string GetFieldValues (FieldInfo[] fields, object instance)
-               {
-                       int len = fields.Length;
-                       StringBuilder sb = new StringBuilder ();
-                       for (int i = 0; i != len; ++i) {
-                               sb.Append (fields[i].Name);
-                               sb.Append ("=");
-                               sb.Append (GetEncodedValue (fields[i].GetValue (instance)));
-                               if (i != (len-1))
-                                       sb.Append (", ");
-                       }
-                       return sb.ToString();
-               }
-
-               protected virtual string GetEncodedValue (object value)
-               {
-                       if (value == null)
-                               return "null";
-
-                       switch (Type.GetTypeCode(value.GetType())) {
-                               case TypeCode.Char:
-                                       return GetEncodedCharValue (value);
-                               case TypeCode.Decimal:
-                                       return GetEncodedDecimalValue (value);
-                               case TypeCode.Double:
-                                       return GetEncodedDoubleValue (value);
-                               case TypeCode.Int64:
-                                       return GetEncodedInt64Value (value);
-                               case TypeCode.Single:
-                                       return GetEncodedSingleValue (value);
-                               case TypeCode.String:
-                                       return GetEncodedStringValue (value);
-                               case TypeCode.UInt32:
-                                       return GetEncodedUInt32Value (value);
-                               case TypeCode.UInt64:
-                                       return GetEncodedUInt64Value (value);
-                               case TypeCode.Object:
-                                       return GetEncodedObjectValue (value);
-                       }
-                       // not special-cased; just return it's value
-                       return value.ToString();
-               }
-
-               protected virtual string GetEncodedCharValue (object value)
-               {
-                       return String.Format ("'{0}'", value.ToString());
-               }
-
-               protected virtual string GetEncodedDecimalValue (object value)
-               {
-                       return String.Format ("{0}m", value.ToString());
-               }
-
-               protected virtual string GetEncodedDoubleValue (object value)
-               {
-                       return String.Format ("{0}d", value.ToString());
-               }
-
-               protected virtual string GetEncodedInt64Value (object value)
-               {
-                       return String.Format ("{0}L", value.ToString());
-               }
-
-               protected virtual string GetEncodedSingleValue (object value)
-               {
-                       return String.Format ("{0}f", value.ToString());
-               }
-
-               protected virtual string GetEncodedStringValue (object value)
-               {
-                       return String.Format ("\"{0}\"", value.ToString());
-               }
-
-               protected virtual string GetEncodedUInt32Value (object value)
-               {
-                       return String.Format ("{0}U", value.ToString());
-               }
-
-               protected virtual string GetEncodedUInt64Value (object value)
-               {
-                       return String.Format ("{0}UL", value.ToString());
-               }
-
-               protected virtual string GetEncodedObjectValue (object value)
-               {
-                       return String.Format ("typeof({0})", value.ToString());
-               }
-
                protected virtual string GetOtherDescription (NodeInfo node)
                {
                        if (node.Description != null)
diff --git a/mcs/tools/type-reflector/formatters/VBNodeFormatter.cs b/mcs/tools/type-reflector/formatters/VBNodeFormatter.cs
new file mode 100644 (file)
index 0000000..7155a23
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// VBNodeFormatter.cs: Formats nodes with VB.NET syntax
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Mono.TypeReflector
+{
+       public class VBNodeFormatter : LanguageNodeFormatter {
+
+               public VBNodeFormatter ()
+               {
+               }
+
+               protected override string LineComment       {get {return "'";}}
+
+               protected override string KeywordClass      {get {return "Class";}}
+               protected override string KeywordEnum       {get {return "Enum";}}
+               protected override string KeywordValueType  {get {return "Struct";}}
+               protected override string KeywordInterface  {get {return "Interface";}}
+               protected override string KeywordInherits   {get {return "Inherits";}}
+               protected override string KeywordImplements {get {return "Implements";}}
+               protected override string KeywordMulticast  {get {return "Event";}}
+               protected override string KeywordStatementTerminator {get {return "";}}
+               protected override string KeywordStatementSeparator  {get {return ",";}}
+
+               protected override string QualifierPublic   {get {return "Public";}}
+               protected override string QualifierFamily   {get {return "Family";}}
+               protected override string QualifierAssembly {get {return "Internal";}}
+               protected override string QualifierPrivate  {get {return "Private";}}
+               protected override string QualifierFinal    {get {return "Final";}}
+               protected override string QualifierStatic   {get {return "Shared";}}
+               protected override string QualifierLiteral  {get {return "Const";}}
+               protected override string QualifierAbstract {get {return "Abstract";}}
+               protected override string QualifierVirtual  {get {return "Overridable";}}
+
+               private static readonly string[] attributeDelimeters = new string[]{"<", ">"};
+
+               protected override string[] AttributeDelimeters {
+                       get {return attributeDelimeters;}
+               }
+
+               protected override string GetConstructorName (ConstructorInfo ctor)
+               {
+      return "Sub New";
+               }
+
+               protected override void AddMethodDeclaration (StringBuilder sb, MethodInfo method)
+               {
+                       string type = "Function";
+
+                       bool sub = method.ReturnType == typeof(System.Void);
+
+                       if (sub) {
+                               type = "Sub";
+                       }
+
+                       sb.AppendFormat ("{0} {1}", type, method.Name);
+                       AddMethodArgs (sb, method);
+
+                       if (!sub)
+                               sb.AppendFormat (" As {0}", method.ReturnType);
+               }
+       }
+}
+
diff --git a/mcs/tools/type-reflector/gtk/ChangeLog b/mcs/tools/type-reflector/gtk/ChangeLog
new file mode 100644 (file)
index 0000000..8e91335
--- /dev/null
@@ -0,0 +1,6 @@
+2002-12-31  Jonathan Pryor <jonpryor@vt.edu>
+       * ChangeLog: Added
+       * GtkTypeDisplayer.cs: Gtk# front-end for reflection information
+       * type-reflector.glade: Glade description for Gtk# front-end
+       * type-reflector.gladep: Glade Project file
+
diff --git a/mcs/tools/type-reflector/gtk/GtkTypeDisplayer.cs b/mcs/tools/type-reflector/gtk/GtkTypeDisplayer.cs
new file mode 100644 (file)
index 0000000..cd499b8
--- /dev/null
@@ -0,0 +1,307 @@
+//
+// GtkTypeDisplayer.cs: 
+//   Display types using Gtk#.
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+// #define TRACE
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+// for GUI support
+using GLib;
+using Glade;
+using Gtk;
+using GtkSharp;
+using System.Drawing;
+
+namespace Mono.TypeReflector
+{
+       delegate void OpenFileSuccess (string filename);
+
+       class OpenFileDialog
+       {
+               private FileSelection file = new FileSelection ("Open an Assembly");
+               private OpenFileSuccess onSuccess;
+
+               public OpenFileDialog (OpenFileSuccess success)
+               {
+                       onSuccess = success;
+                       file.DeleteEvent += new DeleteEventHandler (delete_event);
+                       file.CancelButton.Clicked += new EventHandler (cancel_event);
+                       file.OkButton.Clicked += new EventHandler (ok_event);
+                       file.Show ();
+               }
+
+               private void delete_event (object o, DeleteEventArgs args)
+               {
+                       cancel_event (o, args);
+               }
+
+               private void cancel_event (object o, EventArgs args)
+               {
+                       file.Hide ();
+               }
+
+               private void ok_event (object o, EventArgs args)
+               {
+                       file.Hide ();
+                       onSuccess (file.Filename);
+               }
+       }
+
+       public class GtkTypeDisplayer : TypeDisplayer
+       {
+               private TreeStore store;
+               private Window mainWindow;
+               private Statusbar statusbar;
+               private Window aboutWindow;
+               private static int windows = 0;
+
+               public override int MaxDepth {
+                       set {/* ignore */}
+               }
+
+               public override bool RequireTypes {
+                       get {return false;}
+               }
+
+               public GtkTypeDisplayer ()
+               {
+      Console.WriteLine ("GtkTypeDisplayer created");
+                       if (++windows == 1)
+                               Application.Init ();
+
+                       InitMainWindow ();
+               }
+
+               private void InitMainWindow ()
+               {
+                       Glade.XML gxml = new Glade.XML (null, "gtk/type-reflector.glade", "main_window", null);
+                       try {
+                               gxml.Autoconnect (this);
+                       } catch (Exception e) {
+                               Console.WriteLine ("** Error with glade: " + e.ToString());
+                               throw;
+                       }
+
+                       store = new TreeStore ((int) TypeFundamentals.TypeString);
+
+                       TreeView tv = (TreeView) gxml ["treeview"];
+                       tv.Model = store;
+                       // tv.HeadersVisible = true;
+                       tv.HeadersVisible = false;
+                       tv.RowExpanded += new RowExpandedHandler (RowExpanded);
+
+                       TreeViewColumn nameCol = new TreeViewColumn ();
+                       CellRenderer nameRenderer = new CellRendererText ();
+                       nameCol.Title = "Stuff";
+                       nameCol.PackStart (nameRenderer, true);
+                       nameCol.AddAttribute (nameRenderer, "text", 0);
+                       tv.AppendColumn (nameCol);
+
+                       mainWindow = (Window) gxml ["main_window"];
+                       statusbar = (Statusbar) gxml ["status_bar"];
+               }
+
+               private void RowExpanded (object o, RowExpandedArgs args)
+               {
+                       Console.WriteLine ("** row expanded!");
+                       Console.WriteLine ("  ** Iter={0}, Path={1}", args.Iter, args.Path);
+                       /*
+                       NodeValue v = new NodeValue ();
+                       store.GetValue (args.Iter, 0, v);
+                       string s = (string) v;
+                       Console.WriteLine ("  ** v.Node={0}; v={1}", v.Node, s);
+                       GLib.Value gv = new GLib.Value ();
+                       store.GetValue (args.Iter, 1, gv);
+                       GLib.Object go = (GLib.Object) gv;
+                       NodeInfo ni = (NodeInfo) go.GetData ("mykey");
+                       Console.WriteLine ("  ** ni={0}", ni);
+                        */
+               }
+
+               private Node CreateNode (Type type)
+               {
+                       Node root = new Node (Formatter, Finder);
+                       root.NodeInfo = new NodeInfo (null, type);
+                       return root;
+               }
+
+               public override void AddType (Type type)
+               {
+                       Console.WriteLine ("Adding Type: " + type.FullName);
+                       base.AddType (type);
+               }
+
+               public override void Run ()
+               {
+                       ShowTypes();
+                       Application.Run ();
+               }
+
+               private void ShowTypes ()
+               {
+                       Console.WriteLine ("Showing Types...");
+                       foreach (Assembly a in Assemblies) {
+                               Console.WriteLine ("Assembly: " + a.FullName);
+                               TreeIter ai;
+                               store.Append (out ai);
+                               store.SetValue (ai, 0, new GLib.Value (string.Format ("Assembly: {0}", a.FullName)));
+
+                               foreach (string ns in Namespaces (a)) {
+                                       Console.WriteLine ("Namespace: " + ns);
+                                       TreeIter ni;
+                                       store.Append (out ni, ai);
+                                       store.SetValue (ni, 0, new GLib.Value (string.Format ("Namespace: {0}", ns)));
+                                       foreach (Type type in Types (a, ns))
+                                               AddType (type, ni);
+                               }
+                       }
+                       Console.WriteLine ("----");
+
+                       mainWindow.ShowAll ();
+               }
+               
+               private void AddType (Type type, TreeIter parent)
+               {
+                       Console.WriteLine ("Type: " + type.FullName);
+                       TreeIter p;
+                       store.Append (out p, parent);
+                       // store.SetValue (p, 0, new NodeValue (CreateNode(type)));
+                       NodeInfo r = new NodeInfo (null, type);
+                       store.SetValue (p, 0, new GLib.Value (Formatter.GetDescription (r)));
+
+                       foreach (NodeInfo ni in Finder.GetChildren (r)) {
+                               TreeIter i;
+                               store.Append (out i, p);
+                               store.SetValue (i, 0, 
+                                       new GLib.Value (Formatter.GetDescription (ni)));
+                               TreeIter j;
+                               store.Append (out j, i);
+                               store.SetValue (j, 0, new GLib.Value ("Dummy"));
+                       }
+               }
+
+               // Gtk#/Glade# Required Functions...
+               public void on_main_window_delete_event (object o, DeleteEventArgs args) 
+               {
+                       on_file_quit_activate (o, args);
+               }
+
+               public void on_file_new_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_file_open_activate (object o, EventArgs args)
+               {
+                       OpenFileDialog ofd = new OpenFileDialog (new OpenFileSuccess (OpenAssembly));
+               }
+
+               private void OpenAssembly (string assembly)
+               {
+                       GtkTypeDisplayer d = new GtkTypeDisplayer ();
+                       d.Finder = Finder;
+                       d.Formatter = Formatter;
+                       d.Options = Options;
+                       TypeLoader tl = TypeReflectorApp.CreateLoader (Options);
+      tl.Assemblies = new string[]{assembly};
+                       try {
+                               TypeReflectorApp.FindTypes (d, tl, new string[]{"."});
+                               d.ShowTypes ();
+                       }
+                       catch (Exception e) {
+                               // should be an Alert.
+                               Console.WriteLine ("Unable to load Assembly '{0}': {1}",
+                                               assembly, e.ToString());
+                       }
+               }
+
+    public void on_ok_button_clicked (object o, EventArgs args)
+    {
+      Console.WriteLine ("ok clicked; args=" + args);
+    }
+
+               public void on_file_save_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_file_save_as_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_file_quit_activate (object o, EventArgs args)
+               {
+                       if (--windows == 0)
+                               Application.Quit ();
+               }
+
+               public void on_edit_cut_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_edit_copy_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_edit_paste_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_edit_delete_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+               }
+
+               public void on_view_formatter_default_activate (object o, EventArgs args)
+               {
+               }
+
+               public void on_view_formatter_vb_activate (object o, EventArgs args)
+               {
+               }
+
+               public void on_view_formatter_csharp_activate (object o, EventArgs args)
+               {
+               }
+
+               public void on_view_finder_reflection_activate (object o, EventArgs args)
+               {
+               }
+
+               public void on_view_finder_explicit_activate (object o, EventArgs args)
+               {
+               }
+
+               public void on_help_about_activate (object o, EventArgs args)
+               {
+                       /* ignore */
+                       TypeReflectorApp.PrintVersion ();
+                       Glade.XML gxml = new Glade.XML (null, "gtk/type-reflector.glade", "about_window", null);
+                       try {
+                               gxml.Autoconnect (this);
+                       } catch (Exception e) {
+                               Console.WriteLine ("** Error with glade: " + e.ToString());
+                               throw;
+                       }
+
+                       aboutWindow = (Window) gxml ["about_window"];
+               }
+       }
+}
+
diff --git a/mcs/tools/type-reflector/gtk/type-reflector.glade b/mcs/tools/type-reflector/gtk/type-reflector.glade
new file mode 100644 (file)
index 0000000..f1295e4
--- /dev/null
@@ -0,0 +1,496 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+<requires lib="gnome"/>
+
+<widget class="GtkWindow" id="main_window">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">Type Reflector</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="default_width">640</property>
+  <property name="default_height">480</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <accessibility>
+    <atkproperty name="AtkObject::accessible_name" translatable="yes">Type Reflector</atkproperty>
+  </accessibility>
+  <signal name="delete_event" handler="on_main_window_delete_event" last_modification_time="Fri, 27 Dec 2002 01:50:35 GMT"/>
+
+  <child>
+    <widget class="GtkVBox" id="vbox1">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child>
+       <widget class="GtkMenuBar" id="menu_bar">
+         <property name="visible">True</property>
+         <accessibility>
+           <atkproperty name="AtkObject::accessible_name" translatable="yes">Menu</atkproperty>
+         </accessibility>
+
+         <child>
+           <widget class="GtkMenuItem" id="file_menu">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_File</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="file_menu_menu">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="file_new">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-new</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_file_new_activate" last_modification_time="Fri, 27 Dec 2002 02:00:50 GMT"/>
+                     <accelerator key="N" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="file_open">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-open</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_file_open_activate" last_modification_time="Fri, 27 Dec 2002 02:01:00 GMT"/>
+                     <accelerator key="O" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="file_save">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-save</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_file_save_activate" last_modification_time="Fri, 27 Dec 2002 02:01:07 GMT"/>
+                     <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="file_save_as">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-save-as</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_file_save_as_activate" last_modification_time="Fri, 27 Dec 2002 02:01:14 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkMenuItem" id="file_separatormenuitem1">
+                     <property name="visible">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="file_quit">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-quit</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_file_quit_activate" last_modification_time="Fri, 27 Dec 2002 01:56:45 GMT"/>
+                     <accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="edit_menu">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Edit</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="edit_menu_menu">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="edit_cut">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-cut</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_edit_cut_activate" last_modification_time="Fri, 27 Dec 2002 02:30:09 GMT"/>
+                     <accelerator key="X" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="edit_copy">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-copy</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_edit_copy_activate" last_modification_time="Fri, 27 Dec 2002 02:30:35 GMT"/>
+                     <accelerator key="C" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="edit_paste">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-paste</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_edit_paste_activate" last_modification_time="Fri, 27 Dec 2002 02:30:46 GMT"/>
+                     <accelerator key="V" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="edit_delete">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-delete</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_edit_delete_activate" last_modification_time="Fri, 27 Dec 2002 02:31:06 GMT"/>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="view_menu">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_View</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="view_menu_menu">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="view_formatter">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">F_ormatter</property>
+                     <property name="use_underline">True</property>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image10">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-select-color</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+
+                     <child>
+                       <widget class="GtkMenu" id="view_formatter_menu">
+
+                         <child>
+                           <widget class="GtkRadioMenuItem" id="view_formatter_default">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Default</property>
+                             <property name="use_underline">True</property>
+                             <property name="active">True</property>
+                             <signal name="activate" handler="on_view_formatter_default_activate" last_modification_time="Fri, 27 Dec 2002 03:00:29 GMT"/>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkRadioMenuItem" id="view_formatter_vb">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Visual Basic .NET</property>
+                             <property name="use_underline">True</property>
+                             <property name="active">False</property>
+                             <property name="group">view_formatter_default</property>
+                             <signal name="activate" handler="on_view_formatter_vb_activate" last_modification_time="Fri, 27 Dec 2002 03:00:29 GMT"/>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkRadioMenuItem" id="view_formatter_csharp">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">C#</property>
+                             <property name="use_underline">True</property>
+                             <property name="active">False</property>
+                             <property name="group">view_formatter_default</property>
+                             <signal name="activate" handler="on_view_formatter_csharp_activate" last_modification_time="Fri, 27 Dec 2002 03:00:29 GMT"/>
+                           </widget>
+                         </child>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="view_finder">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">F_inder</property>
+                     <property name="use_underline">True</property>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image11">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-convert</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+
+                     <child>
+                       <widget class="GtkMenu" id="view_finder_menu">
+
+                         <child>
+                           <widget class="GtkRadioMenuItem" id="view_finder_explicit">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Explicit</property>
+                             <property name="use_underline">True</property>
+                             <property name="active">True</property>
+                             <signal name="activate" handler="on_view_finder_explicit_activate" last_modification_time="Fri, 27 Dec 2002 03:00:29 GMT"/>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkRadioMenuItem" id="view_finder_reflection">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Reflection</property>
+                             <property name="use_underline">True</property>
+                             <property name="active">False</property>
+                             <property name="group">view_finder_explicit</property>
+                             <signal name="activate" handler="on_view_finder_reflection_activate" last_modification_time="Fri, 27 Dec 2002 03:00:29 GMT"/>
+                           </widget>
+                         </child>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="help_menu">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Help</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="help_menu_menu">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="help_about">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">About</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_help_about_activate" last_modification_time="Fri, 27 Dec 2002 01:56:33 GMT"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image12">
+                         <property name="visible">True</property>
+                         <property name="stock">gnome-stock-about</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkHandleBox" id="handlebox1">
+         <property name="visible">True</property>
+         <property name="shadow_type">GTK_SHADOW_OUT</property>
+         <property name="handle_position">GTK_POS_LEFT</property>
+         <property name="snap_edge">GTK_POS_TOP</property>
+
+         <child>
+           <widget class="GtkToolbar" id="toolbar2">
+             <property name="visible">True</property>
+             <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
+             <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
+             <property name="tooltips">True</property>
+
+             <child>
+               <widget class="GtkButton" id="open_button">
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="relief">GTK_RELIEF_NORMAL</property>
+                 <signal name="clicked" handler="on_file_open_activate" last_modification_time="Fri, 27 Dec 2002 18:57:38 GMT"/>
+
+                 <child>
+                   <widget class="GtkHBox" id="hbox1">
+                     <property name="visible">True</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">0</property>
+
+                     <child>
+                       <widget class="GtkImage" id="image13">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-open</property>
+                         <property name="icon_size">4</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">True</property>
+                         <property name="fill">True</property>
+                       </packing>
+                     </child>
+
+                     <child>
+                       <widget class="GtkLabel" id="label1">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">Open</property>
+                         <property name="use_underline">False</property>
+                         <property name="use_markup">False</property>
+                         <property name="justify">GTK_JUSTIFY_LEFT</property>
+                         <property name="wrap">False</property>
+                         <property name="selectable">False</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+
+             <child>
+               <widget class="GtkButton" id="preferences_button">
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="relief">GTK_RELIEF_NORMAL</property>
+
+                 <child>
+                   <widget class="GtkHBox" id="hbox2">
+                     <property name="visible">True</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">0</property>
+
+                     <child>
+                       <widget class="GtkImage" id="image14">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-preferences</property>
+                         <property name="icon_size">4</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">True</property>
+                         <property name="fill">True</property>
+                       </packing>
+                     </child>
+
+                     <child>
+                       <widget class="GtkLabel" id="label2">
+                         <property name="visible">True</property>
+                         <property name="label" translatable="yes">Preferences</property>
+                         <property name="use_underline">False</property>
+                         <property name="use_markup">False</property>
+                         <property name="justify">GTK_JUSTIFY_LEFT</property>
+                         <property name="wrap">False</property>
+                         <property name="selectable">False</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                       <packing>
+                         <property name="padding">0</property>
+                         <property name="expand">False</property>
+                         <property name="fill">False</property>
+                       </packing>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkScrolledWindow" id="scrolledwindow1">
+         <property name="visible">True</property>
+         <property name="can_focus">True</property>
+         <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
+         <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+         <property name="shadow_type">GTK_SHADOW_NONE</property>
+         <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+         <child>
+           <widget class="GtkTreeView" id="treeview">
+             <property name="visible">True</property>
+             <property name="can_focus">True</property>
+             <property name="headers_visible">False</property>
+             <property name="rules_hint">True</property>
+             <property name="reorderable">False</property>
+             <property name="enable_search">True</property>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkStatusbar" id="status_bar">
+         <property name="visible">True</property>
+         <property name="has_resize_grip">True</property>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
+<widget class="GnomeAbout" id="about_window">
+  <property name="visible">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="copyright" translatable="yes">(C) 2002 Jonathan Pryor</property>
+  <property name="comments" translatable="yes">Displays System.Reflection information about .NET types.</property>
+  <property name="authors">Jonathan Pryor</property>
+  <property name="documenters">Jonathan Pryor</property>
+  <property name="translator_credits" translatable="yes">translator_credits</property>
+</widget>
+
+</glade-interface>
diff --git a/mcs/tools/type-reflector/gtk/type-reflector.gladep b/mcs/tools/type-reflector/gtk/type-reflector.gladep
new file mode 100644 (file)
index 0000000..c6bcf45
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
+
+<glade-project>
+  <name>Type Reflector</name>
+  <program_name>type-reflector</program_name>
+  <gnome_support>FALSE</gnome_support>
+</glade-project>
diff --git a/mcs/tools/type-reflector/makefile.core b/mcs/tools/type-reflector/makefile.core
new file mode 100644 (file)
index 0000000..df0ec15
--- /dev/null
@@ -0,0 +1,96 @@
+PROGRAM = type-reflector.exe
+
+PROGRAM_LIBS = 
+
+PROGRAM_FLAGS = /out:$(PROGRAM) /d:TRACE /d:DEBUG $(PROGRAM_LIBS)
+
+# For debugging
+# CSCFLAGS = /debug+ /debug:full
+CSCFLAGS = 
+
+MONO = mono
+
+PROGRAM_FILES =  \
+       ConsoleTypeDisplayer.cs \
+       CSharpNodeFormatter.cs \
+       DefaultNodeFormatter.cs \
+       ExplicitNodeFinder.cs \
+       Factories.cs \
+  GroupingNodeFinder.cs \
+       IndentingTextWriter.cs \
+       INodeFinder.cs \
+       INodeFormatter.cs \
+       ITypeDisplayer.cs \
+       LanguageNodeFormatter.cs \
+       Node.cs \
+       NodeFinder.cs \
+       NodeFormatter.cs \
+  NodeGrouper.cs \
+       NodeInfo.cs \
+       NodeTypes.cs \
+       ProgramOptions.cs \
+  ReflectionNodeFinder.cs \
+       TestTypes.cs \
+       TextFormatter.cs \
+       TypeDisplayer.cs \
+       TypeFactory.cs \
+       TypeLoader.cs \
+       TypeReflectorApp.cs \
+       TypeReflectorOptions.cs \
+       VBNodeFormatter.cs \
+
+GUI_GTK_FILES = \
+       gtk/GtkTypeDisplayer.cs \
+
+GUI_GTK_GLADE_FILE = gtk/type-reflector.glade
+
+GUI_GTK_FLAGS = /d:HAVE_GUI_GTK /resource:$(GUI_GTK_GLADE_FILE)
+
+GUI_GTK_LIBS = -r glib-sharp.dll -r pango-sharp.dll -r atk-sharp.dll -r gdk-sharp.dll -r gtk-sharp.dll -r System.Drawing -r glade-sharp.dll
+
+all: $(PROGRAM)
+
+$(PROGRAM) : $(PROGRAM_FILES)
+       $(CSC) $(CSCFLAGS) $(PROGRAM_FLAGS) $(PROGRAM_FILES) $(PROGRAM_LIBS)
+       chmod +x $(PROGRAM)
+
+gui: $(PROGRAM_FILES) $(GUI_GTK_FILES) $(GUI_GTK_GLADE_FILE)
+       $(CSC) $(CSCFLAGS) $(PROGRAM_FLAGS) $(GUI_GTK_FLAGS) $(PROGRAM_FILES) $(GUI_GTK_FILES) $(GUI_GTK_LIBS)
+       chmod +x $(PROGRAM)
+
+test-run : $(PROGRAM)
+       $(MONO) $(PROGRAM) -A $(PROGRAM) $(ARGS)
+
+test-type : $(PROGRAM)
+       $(MONO) $(PROGRAM) -A $(PROGRAM) --max-depth=10000 $(ARGS) TestClass$$
+
+run : $(PROGRAM)
+       $(MONO) $(PROGRAM) $(ARGS)
+
+windows:
+       NAnt -buildfile:type-reflector.build
+
+linux: 
+       mcs @unix.args
+
+clean:
+       rm -f *.exe *.pdb *.dll *.dbg *~
+
+INSTALL_FILES = \
+       $(PROGRAM) \
+       $(PROGRAM).config \
+
+
+install: $(PROGRAM) $(PROGRAM).config
+       if test x$$prefix = x; then \
+               echo Usage is: make -f makefile.gnu install prefix=YOURPREFIX; \
+               exit 1; \
+       fi
+       mkdir -p $(prefix)/bin/
+       for i in $(INSTALL_FILES) ; do \
+               ($(INSTALL) -m 755 $$i $(prefix)/bin/) || exit 1; \
+       done
+
+linecount:
+       wc -l $(PROGRAM_FILES) $(GUI_GTK_FILES)
+
diff --git a/mcs/tools/type-reflector/makefile.gnu b/mcs/tools/type-reflector/makefile.gnu
new file mode 100644 (file)
index 0000000..da425a1
--- /dev/null
@@ -0,0 +1,5 @@
+INSTALL = /usr/bin/install
+CSC = mcs
+
+include makefile.core
+
index 8e843c1d72a7f77d24ce0f223f3838ade2b31992..87e683eb104cecd45202aaebea672a2c0ef528cc 100644 (file)
@@ -9,7 +9,16 @@
       <add name="indenter" value="0"/>
       <add name="node-finder" value="0"/>
       <add name="type-loader" value="0"/>
+      <add name="type-factory" value="0"/>
     </switches>
+    <trace>
+      <listeners>
+        <add
+          name="foo"
+          type="System.Diagnostics.TextWriterTraceListener, System"
+          initializeData="debug.txt"/>
+      </listeners>
+    </trace>
   </system.diagnostics>
 </configuration>