Skip to content
Browse files

Move

svn path=/old-code/; revision=157322
  • Loading branch information...
1 parent 780148a commit 30e96e3731bd96425479da590303d78bb1a65818 @migueldeicaza migueldeicaza committed May 13, 2010
Showing with 9,128 additions and 0 deletions.
  1. +1 −0 type-reflector/.cvsignore
  2. +66 −0 type-reflector/AssemblyInfo.cs
  3. +24 −0 type-reflector/COPYRIGHT
  4. +422 −0 type-reflector/ChangeLog
  5. +121 −0 type-reflector/DESIGN
  6. +51 −0 type-reflector/Factories.cs
  7. +20 −0 type-reflector/IPolicy.cs
  8. +24 −0 type-reflector/LICENSE
  9. +240 −0 type-reflector/Makefile
  10. +83 −0 type-reflector/Node.cs
  11. +49 −0 type-reflector/NodeGrouper.cs
  12. +177 −0 type-reflector/NodeInfo.cs
  13. +37 −0 type-reflector/NodeTypes.cs
  14. +41 −0 type-reflector/Policy.cs
  15. +390 −0 type-reflector/ProgramOptions.cs
  16. +128 −0 type-reflector/README
  17. +16 −0 type-reflector/TODO
  18. +168 −0 type-reflector/TestTypes.cs
  19. +162 −0 type-reflector/TextFormatter.cs
  20. +166 −0 type-reflector/TypeFactory.cs
  21. +189 −0 type-reflector/TypeLoader.cs
  22. +316 −0 type-reflector/TypeReflectorApp.cs
  23. +473 −0 type-reflector/TypeReflectorOptions.cs
  24. +24 −0 type-reflector/displayers/ChangeLog
  25. +96 −0 type-reflector/displayers/ConsoleTypeDisplayer.cs
  26. +36 −0 type-reflector/displayers/ITypeDisplayer.cs
  27. +162 −0 type-reflector/displayers/IndentingTextWriter.cs
  28. +141 −0 type-reflector/displayers/TypeDisplayer.cs
  29. BIN type-reflector/displayers/art/abstract.png
  30. BIN type-reflector/displayers/art/class.png
  31. BIN type-reflector/displayers/art/constructor.png
  32. BIN type-reflector/displayers/art/enum.png
  33. BIN type-reflector/displayers/art/event.png
  34. BIN type-reflector/displayers/art/field.png
  35. BIN type-reflector/displayers/art/interface.png
  36. BIN type-reflector/displayers/art/method.png
  37. BIN type-reflector/displayers/art/prop-read-only.png
  38. BIN type-reflector/displayers/art/prop-read-write.png
  39. BIN type-reflector/displayers/art/prop-write-only.png
  40. BIN type-reflector/displayers/art/sealed.png
  41. BIN type-reflector/displayers/art/transparent.png
  42. +313 −0 type-reflector/displayers/gtk/AppWindowManager.cs
  43. +129 −0 type-reflector/displayers/gtk/ChangeLog
  44. +1,019 −0 type-reflector/displayers/gtk/GtkTypeDisplayer.cs
  45. +1,055 −0 type-reflector/displayers/gtk/type-reflector.glade
  46. +8 −0 type-reflector/displayers/gtk/type-reflector.gladep
  47. +20 −0 type-reflector/displayers/swf/ChangeLog
  48. +243 −0 type-reflector/displayers/swf/SwfTypeDisplayer.cs
  49. +349 −0 type-reflector/displayers/swf/SwfWindow.cs
  50. +8 −0 type-reflector/finders/ChangeLog
  51. +362 −0 type-reflector/finders/ExplicitNodeFinder.cs
  52. +184 −0 type-reflector/finders/GroupingNodeFinder.cs
  53. +43 −0 type-reflector/finders/INodeFinder.cs
  54. +333 −0 type-reflector/finders/NodeFinder.cs
  55. +168 −0 type-reflector/finders/ReflectionNodeFinder.cs
  56. +64 −0 type-reflector/formatters/CSharpNodeFormatter.cs
  57. +20 −0 type-reflector/formatters/ChangeLog
  58. +55 −0 type-reflector/formatters/DefaultNodeFormatter.cs
  59. +25 −0 type-reflector/formatters/INodeFormatter.cs
  60. +502 −0 type-reflector/formatters/LanguageNodeFormatter.cs
  61. +207 −0 type-reflector/formatters/NodeFormatter.cs
  62. +81 −0 type-reflector/formatters/VBNodeFormatter.cs
  63. +17 −0 type-reflector/type-reflector
  64. +12 −0 type-reflector/type-reflector.build
  65. +69 −0 type-reflector/type-reflector.exe.config
  66. +5 −0 type-reflector/type-reflector.in
  67. +14 −0 type-reflector/unix.args
View
1 type-reflector/.cvsignore
@@ -0,0 +1 @@
+*.pdb
View
66 type-reflector/AssemblyInfo.cs
@@ -0,0 +1,66 @@
+//
+// AssemblyInfo.cs: Assembly information
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2003 Jonathan Pryor
+//
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTitle("Type Reflector")]
+[assembly: AssemblyDescription("Displays System.Reflection Information for .NET Types")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Jon Pryor Research Labs")]
+[assembly: AssemblyProduct("Type Reflector")]
+[assembly: AssemblyCopyright("Copyright (C) 2002-2003")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly: AssemblyVersion("0.6.*")]
+
+//
+// In order to sign your assembly you must specify a key to use. Refer to the
+// Microsoft .NET Framework documentation for more information on assembly signing.
+//
+// Use the attributes below to control which key is used for signing.
+//
+// Notes:
+// (*) If no key is specified, the assembly is not signed.
+// (*) KeyName refers to a key that has been installed in the Crypto Service
+// Provider (CSP) on your machine. KeyFile refers to a file which contains
+// a key.
+// (*) If the KeyFile and the KeyName values are both specified, the
+// following processing occurs:
+// (1) If the KeyName can be found in the CSP, that key is used.
+// (2) If the KeyName does not exist and the KeyFile does exist, the key
+// in the KeyFile is installed into the CSP and used.
+// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
+// When specifying the KeyFile, the location of the KeyFile should be
+// relative to the project output directory which is
+// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
+// located in the project directory, you would specify the AssemblyKeyFile
+// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
+// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
+// documentation for more information on this.
+//
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyName("")]
View
24 type-reflector/COPYRIGHT
@@ -0,0 +1,24 @@
+Type Reflector (C) 2002 Jonathan Pryor
+
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to
+do so, subject to the following conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
View
422 type-reflector/ChangeLog
@@ -0,0 +1,422 @@
+2005-04-12 Jonathan Pryor <jonpryor@vt.edu>
+ * type-reflector.exe.config: Change fully-qualified name of the Gtk# type
+ displayer (namespace had to change).
+ * TypeFactory.cs: protect against a null entry (if no suck key exists).
+
+2005-02-09
+
+ * type-reflector.in: Added; used so the installed script knows which
+ type-reflector program to launch.
+ * Makefile: Rewrite install/uninstall to be a better Linux citizen.
+ We shouldn't install type-reflector.exe into $prefix/bin; that's evil.
+ Instead, install it into $prefix/share/type-reflector/, and install a
+ script $prefix/bin/type-reflector which invokes the .exe.
+
+2004-09-18 Jonathan Pryor <jonpryor@vt.edu>
+ + Summary: Add new command-line argument, -r, which takes assembly partial
+ names instead of assembly file names. This allows us to load assembly "by
+ name" from the GAC, such as mscorlib, Mono.Posix, and gtk-sharp, without
+ needing to load *everything* (via --load-default-assemblies), or knowing
+ the actual path to the GAC (to explicity load the assemblies).
+ * Makefile: Update TARGETS so that it references the correct temporary
+ files. This allows ``make clean'' to actually clean up the appropriate
+ files, permitting proper rebuilds.
+ * TypeLoader.cs: Add assembly references collection, and use
+ Assembly.LoadWithPartialName() to load referenced assemblies. Change
+ internal collection type from IList<string> to IList<Assembly>.
+ * TypeReflectorApp.cs: Add handling of referenced assemby information.
+ * TypeReflectorOptions.cs: Add referenceAssembies argument, and change
+ showInheritedMembers option so referenceAssemblies can use -r. This
+ provides a command-line parameter more similar to mcs, etc.
+ * displayers/gtk/GtkTypeDisplayer.cs: Don't store uints in the TreeStore,
+ just ints. This removes a number of Gtk-WARNING messages.
+ * type-reflector: Permit spaces to be in the script filename.
+
+2004-06-02 Jonathan Pryor <jonpryor@vt.edu>
+ * Makefile: Update GUI_GTK_LIBS variable for new mcs syntax (-pkg:...).
+
+2004-03-07 Jonathan Pryor <jonpryor@vt.edu>
+ * Makefile: The "gui" target needs to use the "gtkui" and "swfui" sub-target
+ names; the gtk and swf targets no longer exist.
+
+2003-11-30 Jonathan Pryor <jonpryor@vt.edu>
+ * Makefile: change names of gtk & swf targets. Prior versions of
+ type-reflector didn't have a `dispayers' directory, but had
+ `displayers/gtk', etc., as top-level dirs.
+ Since these files are touched during the build process, this creates a CVS
+ update conflict (CVS expects a `gtk' directory, but a `gtk' file may
+ exist).
+ Change the names of the files generated (hence, the target names) to avoid
+ this conflict.
+
+2003-11-23 Jonathan Pryor <jonpryor@vt.edu>
+ * Makefile: Add rule to create TestTypes.dll, used in testing.
+
+2003-10-25 Jonathan Pryor <jonpryor@vt.edu>
+ * Makefile: Add displayers/gtk/AppWindowManager.cs to build.
+
+2003-??-?? Jonathan Pryor <jonpryor@vt.edu>
+ * Makefile: Merged contents of Makefile & makefile.gnu & makefile.core.
+ This simplifies building (only 1 Makefile), and makes it easier to be a
+ part of mono-tools. Also added new targets, such as "dist", "distdir".
+ * makefile.core: removed
+ * makefile.gnu: removed
+
+2003-09-28 Jonathan Pryor <jonpryor@vt.edu>
+ * TypeReflectorApp.cs: Update Version, Cope with ITypeDisplayer changes.
+ * makefile.core: add artwork resources
+ * type-reflector.exe.config: add Gtk# Displayer trace switch
+
+2003-08-10 Jonathan Pryor <jonpryor@vt.edu>
+ * TypeReflectorApp.cs: Update Version, more debugging information.
+
+2003-07-05 Jonathan Pryor <jonpryor@vt.edu>
+ * TypeReflectorApp.cs: Ensure that TraceListeners are flushed before program
+ exit. This ensures that any TraceListeners added in the .config file will
+ get everything they should.
+ * TypeReflectorOptions.cs: Remove "Experimental" wording, and make sure that
+ the right information is displayed.
+ * type-reflector.exe.config: Add additional examples (use of <assert/>).
+
+2003-07-03 Jonathan Pryor <jonpryor@vt.edu>
+ * IPolicy.cs: New File. Root interface for all "policies" -- things that can
+ change, such as INodeFinder, and INodeFormatter.
+ * Policy.cs: Default implementation of IPolicy interface.
+ * README: updated documentation
+ * TODO: Updated TODO list
+ * TypeFactory.cs: I don't want the Gtk# GUI displaying "short names" for
+ finders, formatters, etc. For example, to get C# formatting, you'd
+ normally pass `--formatter=csharp'. I don't want Gtk# showing "csharp," I
+ want it to show "C#". Furthermore, I don't want to update the GUI
+ whenever I add a new language. The solution is to add extra information
+ to the type-reflector.exe.config file. Now, instead of having the "key"
+ contain the actual factory key, it includes both the key and the
+ description, in the format "key:description," so the C# formatter can be
+ described as "csharp:C#". This could have been done with the "value"
+ instead of the "key", but ':' could be special in assembly names.
+ - Introduce TypeFactoryEntry, which contains the factory Key (everything
+ before the ':'), the Description (everything after the ':'), and the Type
+ (the value of the .config-file entry).
+ - TypeFactory is now a map from string -> TypeFactoryEntry (instead of
+ string -> Type).
+ * TypeLoader.cs: Allow directories to be specified. This requires expanding
+ directories into a list of .dll's and .exe's to open. Alternatively, we
+ could just open *all* files in the directory, but this seems safer for
+ now. Also, it's *not* recursive. This could change in the future.
+ * TypeReflectorApp.cs: Update version number, update for TypeFactory
+ changes, make '.' the default Type search character (instead of requiring
+ it as a parameter), ITypeDisplayer changes
+ * TypeReflectorOptions.cs: More far-reaching changes. It didn't make sense
+ to default to opening all assemblies -- this took forever -- and not
+ provide a default type search, so now it's flipped -- there are no default
+ assemblies (one must be provided, through -a), but the default Type search
+ is '.', which is the only sensible default. Update documentation.
+ * makefile.core: Cope with new files, install type-reflector script.
+ * type-reflector: shell script for Unix-like systems so that typing
+ type-reflector.exe isn't necessary. Script idea initially proposed on
+ mono-list, IIRC.
+ * type-reflector.exe.config: Add descriptions for various policies
+ (displayers and formatters).
+
+2003-06-26 Jonathan Pryor <jonpryor@vt.edu>
+ * TypeFactory.cs: Make a Factory look like a Dictionary. Useful for
+ enumerating over factory contents (e.g. debugging)
+ * TypeLoader.cs: Print the regex out before constructing the Regex. Useful
+ when the Regex constructor throws an exception.
+ * TypeReflectorApp.cs: Misc. Changes:
+ - Added static Version propery, which is used in the Gtk# About dialog
+ - Add/Remove some diagnostics messages
+ - Provide overloads for CreateFinder & CreateFormatter. These are used in
+ the Gtk# front-end to permit dynamic language selection.
+ * makefile.core: simplify the resource name for the Gtk# .glade file, add
+ the gnome-sharp.dll library for Gtk#.
+
+2003-02-19 Jonathan Pryor <jonpryor@vt.edu>
+ * TestTypes.cs: Added test cases.
+ * makefile.core: Re-enabled debugging as default
+
+2003-01-16 Jonathan Pryor <jonpryor@vt.edu>
+ * makefile.core: Fix the multiple-build problem. Again. Hopefully it'll
+ stay fixed this time...
+
+2003-01-14 Jonathan Pryor <jonpryor@vt.edu>
+ - General: massive file movement. I felt it would be cleaner if related
+ files were in the same directory, instead of (nearly) everything
+ cluttering up the root directory. Since the current architecture seems
+ pretty final (I don't see any major changes; it works) I split things up
+ among namespace boundaries.
+ * ConsoleTypeDisplayer.cs: moved to displayers/
+ * ITypeDisplayer.cs: moved to displayers/
+ * TypeDisplayer.cs: moved to displayers/
+ * IndentingTextWriter.cs: moved to displayers/
+ * gtk/: moved to displayers/
+ * swf/: moved to displayers/
+ * ExplicitNodeFinder.cs: moved to finders/
+ * GroupingNodeFinder.cs: moved to finders/
+ * INodeFinder.cs: moved to finders/
+ * NodeFinder.cs: moved to finders/
+ * ReflectionNodeFinder.cs: moved to finders/
+ * INodeFormatter.cs: moved to formatters/
+ * NodeFormatter.cs: moved to formatters/
+ * DefaultNodeFormatter.cs: moved to formatters/
+ * CSharpNodeFormatter.cs: moved to formatters/
+ * VBNodeFormatter.cs: moved to formatters/
+ * makefile.core: update for new file locations.
+
+2003-01-12 Jonathan Pryor <jonpryor@vt.edu>
+ * makefile.core: Add dependencies to `gui' target so it doesn't rebuild when
+ it doesn't need to. Reported by gonzalo.
+
+2003-01-10 Jonathan Pryor <jonpryor@vt.edu>
+ * CSharpNodeFormatter.cs: New properties required by LanguageNodeFormatter
+ * LanguageNodeFormatter.cs: Allow more declarative control over generation
+ of Property members.
+ * ReflectionNodeFinder.cs: Make sure the instance is appropriate. This
+ allows us to view static property values when using the
+ ReflectionNodeFinder.
+ * VBNodeFormatter.cs: New properties required by LanguageNodeFormatter
+
+2003-01-10 Jonathan Pryor <jonpryor@vt.edu>
+ - General: Specify the order of displayers to use in the .config file. This
+ allows us to have "intelligent" defaults, so that (by default) GUI
+ front-ends are preferred to console output. If no GUI is supported, then
+ fallback to console output.
+ * README: Updates
+ * TypeReflectorApp.cs: Follow the "displayer-order" when finding the default
+ displayer.
+ * TypeReflectorOptions.cs: Change default Displayer to "" so that we know if
+ the user has specified a preferred displayer.
+ * type-reflector.exe.config: Specify the default displayer ordering.
+
+2003-01-10 Jonathan Pryor <jonpryor@vt.edu>
+ * TypeReflectorApp.cs: Don't always require that types be specified on the
+ command line. This isn't necessary for the GUI front-ends, as the user
+ can just open an assembly from within the app after it's running.
+ * IndentingTextWriter.cs: Move to Mono.TypeReflector.Displayers.
+
+2003-01-10 Jonathan Pryor <jonpryor@vt.edu>
+ - General: Namespace partitioning. It was getting annoying (when using
+ type-reflector to display itself) to have ~70 classes in a single
+ namespace. So I split up the classes into namespace according to
+ function. For example, Finders (ExplicitNodeFinder, ReflectionNodeFinder)
+ went into Mono.TypeReflector.Finders.
+ * CSharpNodeFormatter.cs: Moved into Mono.TypeReflector.Formatters.
+ * ConsoleTypeDisplayer.cs: Moved into Mono.TypeReflector.Displayers.
+ * DefaultNodeFormatter.cs: Moved into Mono.TypeReflector.Formatters.
+ * ExplicitNodeFormatter.cs: Moved into Mono.TypeReflector.Formatters.
+ * Factories.cs: Reference the appropriate namespaces.
+ * GroupingNodeFinder.cs: Moved into Mono.TypeReflector.Finders.
+ * INodeFinder.cs: Moved into Mono.TypeReflector.Finders.
+ * INodeFormatter.cs: Moved into Mono.TypeReflector.Formatters.
+ * ITypeDisplayer.cs: Moved into Mono.TypeReflector.Displayers.
+ * LanguageNodeFormatter.cs: Moved into Mono.TypeReflector.Formatters.
+ * Node.cs: Reference the appropriate namespaces.
+ * NodeFinder.cs: Moved into Mono.TypeReflector.Finders.
+ * NodeFormatter.cs: Moved into Mono.TypeReflector.Formatters.
+ * NodeGrouper.cs: Moved into Mono.TypeReflector.Finders.
+ * ReflectionNodeFinder.cs: Moved into Mono.TypeReflector.Finders.
+ * TypeDisplayer.cs: Moved into Mono.TypeReflector.Displayers.
+ * TypeReflectorApp.cs: Reference the appropriate namespaces.
+ * VBNodeFormatter.cs: Moved into Mono.TypeReflector.Formatters.
+ * type-refelctor.exe.config: Update type names.
+
+2003-01-09 Jonathan Pryor <jonpryor@vt.edu>
+ - General: Do the most hackish thing I've ever thought of. OK, perhaps not
+ the *most*, but it must be up there...
+ - Problem: type-reflector supports multiple GUI toolkits. However, I don't
+ want to require the existance of any one of them to compile. Because of
+ this, the default has been to support only console output. Nothing else
+ was supported by the default build.
+ - Solution: Try to build everything. Literally. Due to the wonders of the
+ shell's || operator, if one build fails we can provide another build as a
+ backup. This boils down to doing the following:
+
+ make gui-all || make gtk || make swf || make console
+
+ The "make console" is to ensure that, at the very least, console-support
+ is built-in. If no GUI toolkit is available, we'll at least have
+ something.
+ - Good news: this works, and will support as many toolkits as the build
+ platform supports.
+ - Bad news: It may invoke several compilations. For example, my Windows box
+ doesn't have Gtk# support, so "gui-all" and "gtk" both fail before "swf"
+ successfully compiles. That's two failed compilation efforts, resulting
+ in additional overhead.
+ * Makefile: provide a MAKEFILE variable so that makefile.core can invoke the
+ correct top-level makefile for its sub-makes (see description above)
+ * makefile.core:
+ - "all" invokes the "gui" target, not "console". "gui", in turn,
+ carries out the process described above. It isn't pretty.
+ - removed support for "linux" target. This hasn't been used for awhile.
+ * makefile.gnu: provide a MAKEFILE variable so that makefile.core can invoke
+ the correct top-level makefile for its sub-makes (see description above)
+
+2003-01-09 Jonathan Pryor <jonpryor@vt.edu>
+ * TypeReflectorApp.cs: Remove hard-coded factory initialization and #ifdef
+ preprocessor use. Factory information is located in
+ type-reflector.exe.config now. This removes dependence on the
+ preprocessor, simplifies addition of new formatters/etc. (For example, if
+ you want to add a new formatter, you can just edit
+ type-reflector.exe.config with the appropriate type.)
+ * makefile.core:
+ - Remove -d:SYMBOL compiler arguments for GUI support
+ - Due to above, we can simplify GUI targets to use $(CSC_INVOKE). (I
+ would have done this before, but bug 36410 prevented this from working.)
+ * type-reflector.exe.config: Provide new sections to specify the displayers,
+ finders, and formatters that can be used.
+
+2003-01-08 Jonathan Pryor <jonpryor@vt.edu>
+ * AssemblyInfo.cs: New; Assembly Information (version, etc.)
+ * DefaultNodeFormatter.cs: Use AddMethodReturnValue to invoke methods
+ * ITypeDisplayer.cs: Provide a way to display error messages
+ * LanguageNodeFormatter.cs: Use AddMethodReturnValue to invoke methods
+ * Makefile: Since I need to use csc.exe to compile System.Windows.Forms
+ support, I need a way to use directory separators in a (reasonably)
+ portable fashion. Hennce the DS (Directory Separator) variable, which
+ holds the directory separator of the current platform. Set it to
+ backslash for Windows.
+ * NodeFormatter.cs:
+ - Provide an option to enable/disable invoking methods. See README for a
+ short discussion of why this is needed. (Search for [1].)
+ - Minor formatting changes.
+ - Add AddMethodReturnValue() function. This is used by derived classes,
+ instead of directly invoking a method, if invocation is permitted.
+ * README: Updates.
+ * TypeDisplayer.cs:
+ - Check for a null namespace. This apparently can happen under .NET.
+ I'm not sure why, but handle it.
+ - Provide default implementation of ITypeDisplayer.ShowError().
+ * TypeFactory.cs: Remove Console messages, clean formatting.
+ * TypeReflectorApp.cs:
+ - There's > 1 factory now. Change names so it makes more sense.
+ - Add "swf" displayer.
+ - Use ITypeDisplayer.ShowError() for errors
+ - Handle new program options for formatter objects
+ * TypeReflectorOptions.cs: Add option to enable method invocation. Clean up
+ formatting.
+ * makefile.core:
+ - Add "swf" target for System.Windows.Forms display:
+ - csc.exe wants ".dll" appended to referenced assemblies. Add this.
+ - csc.exe wants a colon, not a space, after -r. Fix.
+ - Add new files (AssemblyInfo.cs, swf/*.cs)
+ - Use $(DS) where appropriate.
+ * makefile.gnu: Add $(DS) variable
+ * type-reflector.exe.config: Comment out default listeners, enable
+ type-factory messages by default.
+
+2003-01-02 Jonathan Pryor <jonpryor@vt.edu>
+ * NodeFormatter.cs: Change formatting of error message.
+ * NodeInfo.cs: Nested types are MemberTypes.NestedType; set as
+ NodeTypes.Type so we don't get error messages under .NET.
+
+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.
+ * GroupingNodeFinder.cs: Use a Switch for trace messages.
+ * IndentingTextWriter.cs: Use a Switch for trace messages; remove copyright
+ statement.
+ * NodeFinder.cs: Use a Switch for trace messages.
+ * TypeLoader.cs: Use a Switch for trace messages; remove copyright
+ statement.
+ * type-reflector.exe.config: default .config file (disable all trace
+ messages)
+
+2002-12-10 Jonathan Pryor <jonpryor@vt.edu>
+ * TestTypes.cs: Use a different attribute type for [return:] attribute on
+ TestClass.PublicMethod, as mcs doesn't support [return:] attributes yet
+ and it was generating an error for the two "MyAttribute" attributes.
+
+2002-12-08 Jonathan Pryor <jonpryor@vt.edu>
+ * DESIGN: Read this to understand the new design that was implemented.
+ * ConsoleOutput.cs: Deal with "new world order" of Node objects
+ * Makefile: minor cleanup
+ * TestTypes.cs: additional tests
+ * TypeReflectorOptions.cs: new options
+ * CSharpTypeDisplayer.cs: removed
+ * ExplicitTypeDisplayer.cs: removed
+ * IndentingTypeDisplayer.cs: removed
+ * ReflectionTypeDisplayer.cs: removed
+ * TypeDisplayer.cs: removed
+ * TypeDisplayerFactory.cs: removed
+ * CSharpNodeFormatter.cs: new file
+ * DefaultNodeFormatter.cs: new file
+ * ExplicitNodeFinder.cs: new file
+ * Factories.cs: new file
+ * GroupingNodeFinder.cs: new file
+ * INodeFinder.cs: new file
+ * INodeFormatter.cs: new file
+ * LICENSE: new file
+ * LanguageNodeFormatter.cs: new file
+ * Node.cs: new file
+ * NodeFinder.cs: new file
+ * NodeFormatter.cs: new file
+ * NodeGrouper.cs: new file
+ * NodeInfo.cs: new file
+ * NodeTypes.cs: new file
+ * ReflectionNodeFinder.cs: new file
+ * TypeFactory.cs: new file
+
+2002-09-04 Jonathan Pryor <jonpryor@vt.edu>
+ * CSharpTypeDisplayer.cs: Better attribute output
+ * TestTypes.cs: Improve test cases
+
+2002-09-03 Jonathan Pryor <jonpryor@vt.edu>
+ * ChangeLog: Added
+ * ConsoleOutput.cs: s/parse/display; makes more sense
+ * ExplicitTypeDisplayer.cs: Add additional output
+ * IndentingTextWriter.cs: Allow indenting to be specified
+ * ProgramOptions.cs: Allow more space for program options in output
+ * ReflectionTypeDisplayer.cs: Formatting changes
+ * TypeDisplayer.cs: Trivial formatting changes
+ * TypeReflectorOptions.cs: Re-enable program option, formatting changes
+
+# vim: noexpandtab
+
View
121 type-reflector/DESIGN
@@ -0,0 +1,121 @@
+Overview:
+--------
+The major design is that of a connected model & controller. No view (as in
+MVC) is needed because the data that is modelled will never change--it's
+information about types, which must be static (or the CLR gets mad).
+
+The main problem (at this point) is one of future directions: I'd like to have
+a GUI front-end. Ideally, the GUI and console front-ends would use the same
+internal representation, which we could format as desired (e.g. format for
+different languages such as C#, Visual Basic, CLOS, Eiffel, etc.).
+
+
+GUI Issues:
+----------
+Additionally, with the GUI we don't want the entire tree to be generated --
+that would take too long. We want sub-nodes to be expanded only when required
+(the user clicks on them), and not sooner.
+
+The GUI actually becomes the most complicated design consideration. If we
+have a tree, we need to show to the user that the tree can be expanded by
+having a `+' next to it. This is typically done by having sub-nodes under the
+node to click. But these are the nodes we want to avoid displaying!
+
+I can think of two solutions to this: show them anyway, but not *their*
+children (so we only need to generate two levels when starting -- the
+top-level elements and their immediate children). We thus always have the
+children -- permitting (somewhat) rapid expansion of tree nodes, but when the
+children are displayed we'll have to grab the grand-children.
+
+Alternatively, instead of having the children available, we have a single
+placeholder available, and the first time the `+' is clicked we remove the
+placeholder and generate the immediate children that should be displayed.
+
+The problem with either of these approaches is that it requires that type
+displaying be interruptable. The 0.2 version had it simpler -- it would
+stream the type information to the console, following all children as it found
+them. This was simple, but it didn't permit a GUI view.
+
+Hopefully, all of these issues can be handled in the design below.
+
+
+Categories:
+----------
+I would like to retain the current 0.2 behavior of categorizing the output,
+where a category would be Fields, Methods, Properties, Constructors, etc.
+
+The question becomes: how is this supported? We want (e.g.) all interfaces to
+be grouped together; who maintains the grouping?
+
+Answer: NodeGrouper.
+
+
+Nodes:
+-----
+
+A node is an element in a tree hierarchy. In a GUI, it would be the
+underyling dat for an item in a tree-view (hierarchical display widget).
+It has a display string. It has sub-nodes (children). It also has an
+associated `object' which could be used for
+additional output possibilities. (This isn't explored very far, but I can see
+it as being useful. The `object' would be a Type instance for class names, a
+`MemberInfo' for members, etc.)
+
+Nodes have three classes associated with them: a NodeFormatter, which formats
+the display string described above. It also has a NodeFinder object, which is
+used to determine which sub-nodes will be displayed. Finally, it has a
+NodeInfo instance, which collects various information about the node such as
+its type (NodeTypes) and related information.
+
+The NodeInfo type is used as the sole communication between NodeFinder and
+NodeFormatter. A NodeFinder returns a collection of NodeInfo objects, each of
+which is sent to the NodeFormatter object before being displayed.
+
+Categorization can be done through "decorators" (see GoF) on the NodeFinder.
+
+
+Design:
+------
+
+ Controller [View]
+ \ /
+ \ /
+ Node
+ / | \
+ / | \
+ INodeFormatter INode- NodeInfo
+ Finder
+
+
+Controller:
+ - GUI App, Console Main program
+ -- Controls output, display
+
+[View]:
+ - Display device for Nodes.
+ - Note quite MVC; there's no feedback mechanism so that Views change when
+ the Node changes
+ - Nodes can't change; the type system is static
+ - However, this could be added in the future if necessary.
+
+Node (Model)
+ - Members:
+ - string Description {get; set;}
+ -- The display string
+ - NodeInfo NodeInfo {get;}
+ -- Information about this node
+ - NodeCollection GetChildren ();
+ -- Returns the sub-nodes of this node
+
+INodeFormatter:
+ -- Formats a node for output (particular language, etc.)
+ - Methods:
+ - string GetDescription (NodeInfo)
+ - LanguageFormatter
+ - CSharpFormatter, ...
+
+INodeFinder:
+ -- Decides which children are present
+ - Members:
+ - NodeInfoCollection GetChildren(NodeInfo);
+
View
51 type-reflector/Factories.cs
@@ -0,0 +1,51 @@
+//
+// Factory.cs: Declares finder and formatter policy factories
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+using System;
+using System.Collections;
+using System.Diagnostics;
+using System.Text;
+
+using Mono.TypeReflector.Displayers;
+using Mono.TypeReflector.Finders;
+using Mono.TypeReflector.Formatters;
+
+namespace Mono.TypeReflector
+{
+ public sealed class Factories
+ {
+ public sealed class FinderTypeFactory : TypeFactory
+ {
+ public new INodeFinder Create (object key)
+ {
+ return (INodeFinder) base.Create (key);
+ }
+ }
+
+ public sealed class FormatterTypeFactory : TypeFactory
+ {
+ public new INodeFormatter Create (object key)
+ {
+ return (INodeFormatter) base.Create (key);
+ }
+ }
+
+ 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 ();
+ }
+}
+
View
20 type-reflector/IPolicy.cs
@@ -0,0 +1,20 @@
+//
+// INodePolicy.cs: Root Policy interface to describe other policies.
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2003 Jonathan Pryor
+//
+
+using System;
+
+namespace Mono.TypeReflector
+{
+ public interface IPolicy : ICloneable {
+
+ string Description {get; set;}
+ string FactoryKey {get; set;}
+
+ }
+}
+
View
24 type-reflector/LICENSE
@@ -0,0 +1,24 @@
+Copyright (C) 2002 Jonathan Pryor
+
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to
+do so, subject to the following conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
View
240 type-reflector/Makefile
@@ -0,0 +1,240 @@
+
+# this is used in the MCS build system, but it doesn't make sense to me.
+# Where's OS defined?
+ifndef PLATFORM
+ifeq ($(OS), Windows_NT)
+PLATFORM = win32
+else
+PLATFORM = linux
+endif
+endif
+
+ifeq ($(PLATFORM), win32)
+CSC = csc
+DS=\\
+else
+CSC = mcs
+DS=/
+endif
+
+PACKAGE = type-reflector
+VERSION = 0.8
+topdir = .
+mkinstalldirs = mkdir -p
+
+INSTALL = install
+
+PROGRAM = type-reflector.exe
+
+PROGRAM_LIBS = -r:System.dll
+
+PROGRAM_FLAGS = -out:$(PROGRAM) -d:TRACE -d:DEBUG $(PROGRAM_LIBS)
+
+# For debugging
+CSCFLAGS = /debug+ /debug:full
+# CSCFLAGS =
+
+MONO = mono
+
+DISPLAYERS_DIR=displayers$(DS)
+
+DISPLAYERS_FILES = \
+ $(DISPLAYERS_DIR)ConsoleTypeDisplayer.cs \
+ $(DISPLAYERS_DIR)IndentingTextWriter.cs \
+ $(DISPLAYERS_DIR)ITypeDisplayer.cs \
+ $(DISPLAYERS_DIR)TypeDisplayer.cs \
+
+FINDERS_DIR=finders$(DS)
+
+FINDERS_FILES = \
+ $(FINDERS_DIR)ExplicitNodeFinder.cs \
+ $(FINDERS_DIR)GroupingNodeFinder.cs \
+ $(FINDERS_DIR)INodeFinder.cs \
+ $(FINDERS_DIR)NodeFinder.cs \
+ $(FINDERS_DIR)ReflectionNodeFinder.cs \
+
+FORMATTERS_DIR=formatters$(DS)
+
+FORMATTERS_FILES = \
+ $(FORMATTERS_DIR)CSharpNodeFormatter.cs \
+ $(FORMATTERS_DIR)DefaultNodeFormatter.cs \
+ $(FORMATTERS_DIR)INodeFormatter.cs \
+ $(FORMATTERS_DIR)LanguageNodeFormatter.cs \
+ $(FORMATTERS_DIR)NodeFormatter.cs \
+ $(FORMATTERS_DIR)VBNodeFormatter.cs \
+
+PROGRAM_FILES = \
+ AssemblyInfo.cs \
+ Factories.cs \
+ IPolicy.cs \
+ Node.cs \
+ NodeGrouper.cs \
+ NodeInfo.cs \
+ Policy.cs \
+ NodeTypes.cs \
+ ProgramOptions.cs \
+ TestTypes.cs \
+ TextFormatter.cs \
+ TypeFactory.cs \
+ TypeLoader.cs \
+ TypeReflectorApp.cs \
+ TypeReflectorOptions.cs \
+ $(DISPLAYERS_FILES) \
+ $(FINDERS_FILES) \
+ $(FORMATTERS_FILES) \
+
+CSC_INVOKE = $(CSC) $(CSCFLAGS) $(PROGRAM_FLAGS) $(PROGRAM_FILES) $(PROGRAM_LIBS)
+
+GUI_LIBS = -r:System.Drawing.dll
+
+GUI_ART_DIR = $(DISPLAYERS_DIR)art$(DS)
+
+GUI_RESOURCES = \
+ -resource:$(GUI_ART_DIR)abstract.png,abstract.png \
+ -resource:$(GUI_ART_DIR)class.png,class.png \
+ -resource:$(GUI_ART_DIR)constructor.png,constructor.png \
+ -resource:$(GUI_ART_DIR)enum.png,enum.png \
+ -resource:$(GUI_ART_DIR)event.png,event.png \
+ -resource:$(GUI_ART_DIR)field.png,field.png \
+ -resource:$(GUI_ART_DIR)interface.png,interface.png \
+ -resource:$(GUI_ART_DIR)method.png,method.png \
+ -resource:$(GUI_ART_DIR)prop-read-only.png,prop-read-only.png \
+ -resource:$(GUI_ART_DIR)prop-read-write.png,prop-read-write.png \
+ -resource:$(GUI_ART_DIR)prop-write-only.png,prop-write-only.png \
+ -resource:$(GUI_ART_DIR)sealed.png,sealed.png \
+ -resource:$(GUI_ART_DIR)transparent.png,transparent.png
+
+GUI_GTK_DIR = $(DISPLAYERS_DIR)gtk$(DS)
+
+GUI_GTK_FILES = \
+ $(GUI_GTK_DIR)GtkTypeDisplayer.cs \
+ $(GUI_GTK_DIR)AppWindowManager.cs \
+
+GUI_GTK_GLADE_FILE = $(GUI_GTK_DIR)type-reflector.glade
+
+GUI_GTK_FLAGS = -resource:$(GUI_GTK_GLADE_FILE),type-reflector.glade
+
+GUI_GTK_LIBS = -pkg:gtk-sharp -pkg:glade-sharp -pkg:gnome-sharp
+
+GUI_SWF_DIR = $(DISPLAYERS_DIR)swf$(DS)
+
+GUI_SWF_FILES = \
+ $(GUI_SWF_DIR)SwfWindow.cs \
+ $(GUI_SWF_DIR)SwfTypeDisplayer.cs \
+
+GUI_SWF_LIBS = -r:System.Windows.Forms.dll
+
+GUI_SWF_FLAGS =
+
+# These are files that are `touch'ed during the build process to prevent
+# constant rebuilding.
+TARGETS = gui-all gtkui swfui
+
+all: gui test-assemblies
+
+test-assemblies : TestTypes.dll
+
+TestTypes.dll: TestTypes.cs
+ $(CSC) -out:$@ -t:library $<
+
+console : $(PROGRAM)
+
+$(PROGRAM) : $(PROGRAM_FILES)
+ $(CSC_INVOKE)
+ chmod +x $(PROGRAM)
+
+# Pick the appropriate GUI Toolkit...
+# Fall back on console-only if nothing else compiles.
+gui: $(PROGRAM_FILES) $(GUI_GTK_FILES) $(GUI_GTK_GLADE_FILE) $(PROGRAM_FILES) $(GUI_SWF_FILES)
+ $(MAKE) gui-all || $(MAKE) gtkui || $(MAKE) swfui || $(MAKE) console
+
+# Compile in support for all GUI front-ends (Gtk#, Swf, and anything else...)
+gui-all: $(PROGRAM_FILES) $(GUI_GTK_FILES) $(GUI_GTK_GLADE_FILE) $(PROGRAM_FILES) $(GUI_SWF_FILES)
+ $(CSC_INVOKE) $(GUI_GTK_FLAGS) $(GUI_SWF_FLAGS) $(GUI_GTK_FILES) $(GUI_SWF_FILES) $(GUI_GTK_LIBS) $(GUI_SWF_LIBS) $(GUI_RESOURCES) $(GUI_LIBS)
+ chmod +x $(PROGRAM)
+ touch $@
+
+# Gtk# front-end
+gtkui: $(PROGRAM_FILES) $(GUI_GTK_FILES) $(GUI_GTK_GLADE_FILE)
+ $(CSC_INVOKE) $(GUI_GTK_FLAGS) $(GUI_GTK_FILES) $(GUI_GTK_LIBS) $(GUI_RESOURCES) $(GUI_LIBS)
+ chmod +x $(PROGRAM)
+ touch $@
+
+# System.Windows.Forms front-end
+swfui: $(PROGRAM_FILES) $(GUI_SWF_FILES)
+ $(CSC_INVOKE) $(GUI_SWF_FLAGS) $(GUI_SWF_FILES) $(GUI_SWF_LIBS) $(GUI_RESOURCES) $(GUI_LIBS)
+ chmod +x $(PROGRAM)
+ touch $@
+
+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
+
+clean:
+ rm -f *.exe *.pdb *.dll *.dbg *~ $(TARGETS) $(DISPLAYERS_DIR)*~ $(GUI_GTK_DIR)*~ $(GUI_SWF_DIR)*~ $(FINDERS_DIR)*~ $(FORMATTERS_DIR)*~
+
+# We don't generate any files for building, so don't do anything
+distclean: clean
+
+
+TR_FILES = \
+ $(PROGRAM) \
+ $(PROGRAM).config \
+
+
+install: $(BIN_FILES) $(TR_FILES)
+ if test "x$$prefix" = x; then \
+ echo Usage is: make -f makefile.gnu install prefix=YOURPREFIX; \
+ exit 1; \
+ fi
+ mkdir -p "$(prefix)/bin/"
+ mkdir -p "$(prefix)/share/$(PACKAGE)/"
+ cat type-reflector.in | sed 's:@PREFIX@:$(prefix):g' > "$(prefix)/bin/$(PACKAGE)"
+ chmod +x "$(prefix)/bin/$(PACKAGE)"
+ for i in $(TR_FILES) ; do \
+ ($(INSTALL) -m 755 $$i $(prefix)/share/$(PACKAGE)/) || exit 1; \
+ done
+
+uninstall:
+ if test x$$prefix = x; then \
+ echo Usage is: make -f makefile.gnu uninstall prefix=YOURPREFIX; \
+ exit 1; \
+ fi
+ rm "$(prefix)/bin/$(PACKAGE)"
+ for i in $(TR_FILES) ; do \
+ (rm -f $(prefix)/share/$(PACKAGE)/$$i) || exit 1; \
+ done
+ -rmdir $(prefix)/share/$(PACKAGE)
+
+linecount:
+ wc -l $(PROGRAM_FILES) $(GUI_GTK_FILES)
+
+
+# For packaging into a tarball
+distdir = $(topdir)/$(PACKAGE)-$(VERSION)
+
+# Simple, probably inaccurate (it'll likely copy too many files), but effective
+distdir:
+ -mkdir $(distdir)
+ for f in `find . | grep -v CVS | grep -v ~$$ | grep -v $(distdir)` ; do \
+ if test -d $$f; then \
+ $(mkinstalldirs) "$(distdir)/$$f" ; \
+ else \
+ cp -p "$$f" "$(distdir)/$$f" ; \
+ fi; \
+ done
+
+dist dist-all: distdir
+ tar chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ rm -rf $(distdir)
+
+# vim: noexpandtab
+
View
83 type-reflector/Node.cs
@@ -0,0 +1,83 @@
+//
+// Node.cs: Used to contain the output tree before display.
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+using System;
+using System.Collections;
+using System.Diagnostics;
+using System.Text;
+
+using Mono.TypeReflector.Finders;
+using Mono.TypeReflector.Formatters;
+
+namespace Mono.TypeReflector
+{
+ public sealed class Node : ICloneable {
+
+ INodeFormatter formatter;
+ INodeFinder finder;
+
+ NodeInfo nodeInfo;
+
+ public Node (INodeFormatter formatter, INodeFinder finder)
+ {
+ this.formatter = formatter;
+ this.finder = finder;
+ }
+
+ public object Clone ()
+ {
+ return MemberwiseClone();
+ }
+
+ public string Description {
+ get {return formatter.GetDescription(nodeInfo);}
+ }
+
+ public NodeCollection GetChildren ()
+ {
+ NodeCollection children = new NodeCollection ();
+ NodeInfoCollection nic = finder.GetChildren (nodeInfo);
+ // foreach (NodeInfo o in finder.GetChildren (nodeInfo)) {
+ foreach (NodeInfo o in nic) {
+ Node n = (Node) this.Clone ();
+ n.NodeInfo = o;
+ children.Add (n);
+ }
+ return children;
+ }
+
+ public NodeInfo NodeInfo {
+ get {return nodeInfo;}
+ set {nodeInfo = value;}
+ }
+ }
+
+ public class NodeCollection : CollectionBase {
+
+ internal NodeCollection ()
+ {
+ }
+
+ public Node this [int index] {
+ get {return (Node) InnerList[index];}
+ set {InnerList[index] = value;}
+ }
+
+ public int Add (Node value)
+ {
+ return InnerList.Add (value);
+ }
+
+ public void AddRange (Node[] values)
+ {
+ foreach (Node node in values)
+ Add (node);
+ }
+ }
+}
+
View
49 type-reflector/NodeGrouper.cs
@@ -0,0 +1,49 @@
+//
+// NodeGrouper.cs: A general way to sub-group nodes.
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+namespace Mono.TypeReflector.Finders
+{
+ public delegate void NodeGrouper (NodeInfoCollection c, NodeInfo root, object extra);
+
+ public class NodeGroup {
+ private string groupName;
+ private NodeGrouper grouper;
+ private object extra;
+
+ public NodeGroup (string name, object extra, NodeGrouper grouper)
+ {
+ this.groupName = name;
+ this.grouper = grouper;
+ this.extra = extra;
+ }
+
+ public NodeGroup (string name, NodeGrouper grouper)
+ : this (name, grouper, null)
+ {
+ }
+
+ public string GroupName {
+ get {return groupName;}
+ }
+
+ public NodeGrouper Grouper {
+ get {return grouper;}
+ }
+
+ public void Invoke (NodeInfoCollection c, NodeInfo root)
+ {
+ grouper (c, root, extra);
+ }
+
+ public override string ToString ()
+ {
+ return groupName;
+ }
+ }
+}
+
View
177 type-reflector/NodeInfo.cs
@@ -0,0 +1,177 @@
+//
+// NodeInfo.cs:
+//
+// A NodeInfo object represents a node in Type tree, such as a Constructor,
+// Field, or pseudo-collections like GroupingNodeFinder's "Methods:" branch.
+//
+// Additionally, it's used to get additional information about the node, such
+// as invoke methods to get additional information.
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002-2003 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 NodeInfo {
+ private NodeInfo parent;
+ private NodeTypes type;
+ private object reflectionObject = null;
+ private object reflectionInstance = null;
+ private object description = null;
+
+ public NodeInfo (NodeInfo parent, NodeTypes type, object reflectionObject,
+ object reflectionInstance, object description)
+ {
+ this.parent = parent;
+ this.type = type;
+ this.reflectionObject = reflectionObject;
+ this.reflectionInstance = reflectionInstance;
+ this.description = description;
+ }
+
+ public NodeInfo (NodeInfo parent, NodeTypes type, object reflectionObject,
+ object reflectionInstance)
+ : this (parent, type, reflectionObject, reflectionInstance, null)
+ {
+ }
+
+ public NodeInfo (NodeInfo parent, NodeTypes type)
+ : this (parent, type, null, null, null)
+ {
+ }
+
+ public NodeInfo (NodeInfo parent, object description)
+ : this (parent, NodeTypes.Other, null, null, description)
+ {
+ }
+
+ public NodeInfo (NodeInfo parent, MemberInfo mi)
+ : this (parent, mi, null)
+ {
+ }
+
+ public NodeInfo (NodeInfo parent, MemberInfo mi, object instance)
+ : this (parent, NodeTypes.Other, mi, instance, null)
+ {
+ // set type
+ switch (mi.MemberType) {
+ case MemberTypes.NestedType:
+ case MemberTypes.TypeInfo:
+ this.type = NodeTypes.Type;
+ break;
+ case MemberTypes.Constructor:
+ this.type = NodeTypes.Constructor;
+ break;
+ case MemberTypes.Event:
+ this.type = NodeTypes.Event;
+ break;
+ case MemberTypes.Field:
+ this.type = NodeTypes.Field;
+ break;
+ case MemberTypes.Method:
+ this.type = NodeTypes.Method;
+ break;
+ case MemberTypes.Property:
+ this.type = NodeTypes.Property;
+ break;
+ default:
+ this.type = NodeTypes.Other;
+ break;
+ }
+ }
+
+ /// <summary>
+ /// This is the type of the NodeInfo object.
+ /// </summary>
+ public NodeTypes NodeType {
+ get {return type;}
+ set {type = value;}
+ }
+
+ /// <summary>
+ /// This is the parent NodeInfo object. This is used to help represent
+ /// the tree.
+ /// </summary>
+ public NodeInfo Parent {
+ get {return parent;}
+ }
+
+ /// <summary>
+ /// If non-null, this is the underlying System.Reflection object, such as
+ /// System.Reflection.MemberInfo or System.Reflection.ParameterInfo.
+ /// </summary>
+ public object ReflectionObject {
+ get {return reflectionObject;}
+ set {reflectionObject = value;}
+ }
+
+ /// <summary>
+ /// This is the object instance to pass to System.Reflection methods using
+ /// the ReflectionObject.
+ /// </summary>
+ public object ReflectionInstance {
+ get {return reflectionInstance;}
+ set {reflectionInstance = value;}
+ }
+
+ /// <summary>
+ /// This is an arbitrary description that can be attached to the node.
+ /// This is only useful if ReflectionObject is null or NodeType is a value
+ /// that doesn't match against a "real" System.Reflection type, such as
+ /// NodeTypes.Other.
+ /// </summary>
+ public object Description {
+ 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 {
+
+ internal NodeInfoCollection ()
+ {
+ }
+
+ public NodeInfo this [int index] {
+ get {return (NodeInfo) InnerList[index];}
+ set {InnerList[index] = value;}
+ }
+
+ public int Add (NodeInfo value)
+ {
+ return InnerList.Add (value);
+ }
+
+ public void AddRange (NodeInfo[] values)
+ {
+ foreach (NodeInfo n in values)
+ Add (n);
+ }
+
+ public void AddRange (NodeInfoCollection values)
+ {
+ foreach (NodeInfo n in values)
+ Add (n);
+ }
+ }
+}
+
View
37 type-reflector/NodeTypes.cs
@@ -0,0 +1,37 @@
+//
+// NodeTypes.cs: The types of nodes that can be displayed.
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+namespace Mono.TypeReflector
+{
+ /// <summary>
+ /// The types of Nodes that can be displayed.
+ /// </summary>
+ public enum NodeTypes {
+ // Meta-nodes
+ Assembly,
+ Library,
+ Namespace,
+ Module,
+ // Type information
+ CustomAttributeProvider,
+ Type,
+ BaseType,
+ Interface,
+ Field,
+ Constructor,
+ Method,
+ Parameter,
+ Property,
+ Event,
+ // Misc
+ ReturnValue, // needed? could be simulated
+ Alias, // Refer's to a previous node. Description is the prior object
+ Other
+ }
+}
+
View
41 type-reflector/Policy.cs
@@ -0,0 +1,41 @@
+//
+// NodePolicy.cs:
+//
+// Default implementation of the INodePolicy interface.
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2003 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 Policy : IPolicy {
+
+ private string description, key;
+
+ public string Description {
+ get {return description;}
+ set {description = value;}
+ }
+
+ public string FactoryKey {
+ get {return key;}
+ set {key = value;}
+ }
+
+ public virtual object Clone ()
+ {
+ return MemberwiseClone ();
+ }
+ }
+}
+
View
390 type-reflector/ProgramOptions.cs
@@ -0,0 +1,390 @@
+//
+// ProgramOptions.cs: Parser for Program Options
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+// Permission is hereby granted, free of charge, to any
+// person obtaining a copy of this software and associated
+// documentation files (the "Software"), to deal in the
+// Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software,
+// and to permit persons to whom the Software is furnished to
+// do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice
+// shall be included in all copies or substantial portions
+// of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+// KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+/*
+ * TODO:
+ *
+ * Use a Dictionary object to store options
+ * - Removes O(n) searches that are currently used for option lookup
+ * - OR -
+ * - sort the options and use BinarySearch
+ *
+ * Option Handling:
+ * - Specify two sets of option groups:
+ * - Those that are "combinable"
+ * - Those that aren't
+ *
+ * - "Combining" refers to the ability to specify multiple options "at once",
+ * e.g. `ls -ctr' is a combined form of `ls -c -t -r'.
+ *
+ * - Specify a way to state how many '-'s prefix an option
+ *
+ * - Specify the actual option prefix ('/' or '-' or...)
+ *
+ * - Specify a way to set the delimeter between the option and the argument.
+ *
+ * - Add a `count' field so that options can be specified multiple times
+ *
+ * - Allow options to be specified multiple times, and collect all of the
+ * arguments for the option.
+ *
+ * - These changes to option handling should permit:
+ * - GCC-style options
+ * - e.g. `-dumpspecs' is a valid option (note 1 '-', not 2A)
+ * - e.g. `-DMYSYMBOL' is the option `-D' with the value `MYSYMBOL'
+ * - e.g. `-DFOO -DBAR' makes arguments `FOO' and `BAR' available when
+ * searching for option `D'
+ * - CSC.EXE-style options
+ * - /out:file-name
+ * - /help
+ * - /t:exe or /target:exe (/t is a synonym for /target)
+ * - Multiple level options (forget which program I saw this in...)
+ * - -v is 1 level of verbosity
+ * - -vv is 2 levels of verbosity
+ * - ...
+ *
+ * Sanity Checking
+ * - Should make sure that there aren't any duplicate entries
+ *
+ * Pie-in-the-sky:
+ * - Provide a way to specify how many positions an argument takes up.
+ * - Currently, options with arguments can have 1 argv[] slot (for the
+ * argument) (for non-long-opt options).
+ * - It might be useful to allow arguments to have > 1
+ * - Not aware of any program that would actually make use of this.
+ */
+
+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 OptionException : Exception {
+
+ public char ShortForm;
+
+ public OptionException (string reason, char shortForm )
+ : base (reason)
+ {
+ this.ShortForm = shortForm;
+ }
+
+ public OptionException (string reason)
+ : base (reason)
+ {
+ }
+
+ public OptionException (string reason, Exception inner)
+ : base (reason, inner)
+ {
+ }
+ }
+
+ public class ProgramOptions {
+
+ private class Option {
+ public char ShortForm = '\0';
+ public string LongForm = null;
+ public string Description = null;
+ public bool Found = false;
+ public bool HasArgument = false;
+ public string ArgumentValue = null;
+ public bool AllowMultiple = false;
+ public string ArgumentDescription = null;
+
+ public Option (char shortForm, string longForm, string description, string argDesc, bool hasArgument)
+ {
+ ShortForm = shortForm;
+ LongForm = longForm;
+ Description = description;
+ HasArgument = hasArgument;
+ ArgumentDescription = argDesc;
+ }
+
+ public Option (char shortForm, string description)
+ {
+ ShortForm = shortForm;
+ Description = description;
+ }
+
+ public Option (string longForm, string description)
+ {
+ LongForm = longForm;
+ Description = description;
+ }
+ }
+
+ // Option array
+ private ArrayList options = new ArrayList ();
+
+ // string array
+ private ArrayList unmatched = new ArrayList ();
+
+ public IList UnmatchedOptions {
+ get {return unmatched;}
+ }
+
+ public ProgramOptions ()
+ {
+ }
+
+ private void AddOption (Option opt)
+ {
+ options.Add (opt);
+ }
+
+ public void AddHelpOption ()
+ {
+ AddOption (new Option ('h', "help", "Display this help and exit.", null, false));
+ }
+
+ public void AddOption (char shortForm, string description)
+ {
+ AddOption (new Option (shortForm, description));
+ }
+
+ public void AddArgumentOption (char shortForm, string description, string argument)
+ {
+ AddOption (new Option (shortForm, null, description, argument, true));
+ }
+
+ public void AddOption (string longForm, string description)
+ {
+ AddOption (new Option (longForm, description));
+ }
+
+ public void AddArgumentOption (string longForm, string description, string argument)
+ {
+ AddOption (new Option ('\0', longForm, description, argument, true));
+ }
+
+ public void AddOption (char shortForm, string longForm, string description)
+ {
+ AddOption (new Option (shortForm, longForm, description, null, false));
+ }
+
+ public void AddArgumentOption (char shortForm, string longForm, string description, string argument)
+ {
+ AddOption (new Option (shortForm, longForm, description, argument, true));
+ }
+
+ public virtual void ParseOptions (string[] options)
+ {
+ int len = options.Length;
+ bool handle = true;
+ for (int cur = 0; cur != len; ++cur) {
+ string option = options[cur];
+ // necessary?
+ if (option == null || option.Length == 0)
+ continue;
+ if (handle) {
+ if (option.StartsWith ("-")) {
+ // possible option
+ if (option == "--")
+ handle = false;
+ else if (option.StartsWith ("--"))
+ ParseLongOption (options, ref cur);
+ else
+ ParseShortOptions (options, ref cur);
+ }
+ else
+ unmatched.Add (option);
+ }
+ else
+ unmatched.Add (option);
+ }
+ }
+
+ private void ParseLongOption (string[] args, ref int currentIndex)
+ {
+ // get rid of "--"
+ string arg = args[currentIndex].Substring (2);
+ bool found = false;
+ foreach (Option o in options) {
+ if (o.LongForm == null)
+ continue;
+ if (!arg.StartsWith(o.LongForm))
+ continue;
+ found = true;
+ o.Found = true;
+ if (o.HasArgument) {
+ try {
+ o.ArgumentValue = arg.Substring (arg.IndexOf('=')+1);
+ } catch (Exception e) {
+ throw new OptionException (
+ "missing argument to option --" + o.LongForm,
+ e);
+ }
+ }
+ }
+
+ if (!found)
+ throw new OptionException (
+ String.Format ("Unrecognized option `{0}'", args[currentIndex]));
+ }
+
+ private void ParseShortOptions (string[] args, ref int currentIndex)
+ {
+ string arg = args[currentIndex].Substring (1);
+ int needsArg = 0;
+ Option forArg = null;
+ for (int i = 0; i != arg.Length; ++i) {
+ bool found = false;
+ foreach (Option o in options) {
+ if (o.ShortForm != arg[i])
+ continue;
+ found = true;
+ o.Found = true;
+ if (o.HasArgument) {
+ ++needsArg;
+ forArg = o;
+ }
+ }
+ if (!found)
+ throw new OptionException (
+ String.Format("Unrecognized option `-{0}'", arg[i]));
+ }
+
+ if (needsArg > 1)
+ throw new OptionException ("too many options requiring arguments specified");
+ else if (needsArg == 1) {
+ if (currentIndex == (args.Length - 1))
+ throw new OptionException ("missing argument to option -" + forArg.ShortForm);
+ ++currentIndex;
+ forArg.ArgumentValue = args[currentIndex];
+ }
+ }
+
+ public virtual void Clear ()
+ {
+ foreach (Option o in options) {
+ o.Found = false;
+ o.ArgumentValue = null;
+ }
+ }
+
+ private static readonly string[] OptionFormats =
+ {
+ // 0: no short, no long, no arg
+ "<invalid option format: 0: 0={0},1={1},2={2}>",
+ // 1: short only
+ " -{0}",
+ // 2: long only
+ " --{1}",
+ // 3: long & short
+ " -{0}, --{1}",
+ // 4: no short, no long, arg
+ "<invalid option format: 4: 0={0},1={1},2={2}>",
+ // 5: short w/ arg
+ " -{0} {2}",
+ // 6: long w/ arg
+ " --{1}={2}",
+ // 7: short & long w/ arg
+ " -{0}, --{1}={2}"
+ };
+
+ public virtual string OptionsHelp {
+ get {
+ StringBuilder sb = new StringBuilder ();
+ foreach (Option o in options) {
+ uint f_s = Convert.ToUInt32 (o.ShortForm != '\0');
+ uint f_l = Convert.ToUInt32 (o.LongForm != null);
+ uint f_h = Convert.ToUInt32 (o.HasArgument);
+ uint format = (f_s << 0) | (f_l << 1) | (f_h << 2);
+ string opt = String.Format (OptionFormats[format],
+ o.ShortForm,
+ o.LongForm,
+ o.ArgumentDescription);
+ string fmt = null;
+ if (opt.Length < 30)
+ fmt = "{0,-30}{1}";
+ else
+ fmt = "{0,-30}\n{2,-30}{1}";
+ string d = new TextFormatter (30, 80, 2).Group (o.Description);
+ sb.Append (String.Format (fmt, opt, d, ""));
+ sb.Append ("\n");
+ }
+ return sb.ToString ();
+ }
+ }
+
+ public static readonly string ProgramName = Environment.GetCommandLineArgs()[0];
+
+ public bool FoundOption (char shortForm)
+ {
+ foreach (Option o in options) {
+ if (o.ShortForm != shortForm)
+ continue;
+ return o.Found;
+ }
+ return false;
+ }
+
+ public bool FoundOption (string longForm)
+ {
+ foreach (Option o in options) {
+ if (o.LongForm != longForm)
+ continue;
+ return o.Found;
+ }
+ return false;
+ }
+
+ public string FoundOptionValue (char shortForm)
+ {
+ foreach (Option o in options) {
+ if (o.ShortForm != shortForm)
+ continue;
+ return o.ArgumentValue;
+ }
+ return null;
+ }
+
+ public string FoundOptionValue (string longForm)
+ {
+ foreach (Option o in options) {
+ if (o.LongForm != longForm)
+ continue;
+ return o.ArgumentValue;
+ }
+ return null;
+ }
+
+ public bool FoundHelp {
+ get {return FoundOption ('h');}
+ }
+ }
+}
+
View
128 type-reflector/README
@@ -0,0 +1,128 @@
+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.
+
+It allows a regular expression (as understood by
+System.Text.RegularExpressions) to be used for finding types.
+
+It allows a specific list of assemblies to be searched to be specified,
+narrowing down the list of assemblies searched for a matching type.
+
+It also allows the types to be viewed according to three different policies.
+The "finder" policy dictates how members are found. There are currently two
+such policies:
+
+ explicit - Searches for members by name
+ reflection - uses System.Reflection for member lookup
+
+The finder policies often display different results, as "explicit" has had
+more work done on it, and "reflection" is dependant upon System.Reflection,
+which may or may not be complete, depending on the platform.
+
+The second policy is the "formatter" policy, which dictates how a member is
+displayed. There are currently three 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.
+
+The third policy is the "displayer" policy, which is how the members are
+displayed to the user. This is described below.
+
+Type Reflector shows (virtually) everything about a type that is available
+through the System.Reflection facility. Everything from the actual Attributes
+specified for a member, to custom attributes, the reflected type, GUID, where
+it was declared... This constitutes a great deal of information that isn't
+normally present without writing test programs to view the available
+information.
+
+I prefer to think of it as the "Frankenstein" combination of ``TypeFinder''
+and a debugger. It doesn't just find types. It doesn't just display the
+members of those types. It will also (when able to) display the result of
+invoking methods on a type. The method must fulfill some limitations:
+
+ - There must be a valid object instance. For arbitrary types, this
+ effectively means you can only get the result of invoking static
+ methods/properties, but this can be useful when looking at Reflection
+ objects.
+
+ - The invoked methods must accept 0 arguments.
+
+Thus, for the C# class definition:
+
+ public class Test {
+ public static int Foo {get {return 42;}}
+ }
+
+we can use type-reflector to determine the value returned by Test.Foo.
+
+This is also useful for determining the values of class constants/readonly
+fields and properties, such as Enumeration values.
+
+There is also support to invoke (and display the return value) of class
+methods that accept no arguments. However, due to "problems" [1] this is not
+enabled by default; pass the -n argument to enable.
+
+[1] Some of the mono tools do actual work in their static methods that accept
+no arguments. For example, using Type Reflector on itself to display the
+member Mono.TypeReflector.TypeReflectorApp.PrintVersion would display the
+version information to the console. Other apps request user input when
+invoked, halting all display until the user presses a key. Displaying all
+libraries would cause core dumps as gtk_init could be called before gdk_init
+(as they were P/Invoked from the Gtk# assemblies) during this process.
+
+I thought this would be cool, but unless you're careful, things can get weird.
+
+
+Displayers
+==========
+Type Reflector has three displayers, the "console" displayer, which sends
+output to the console, and two GUI front-ends, the availability of which
+depends upon which platform you're on. The front-end is specified with the
+--displayer program argument.
+
+All front ends have their own makefile target. For now, the "gui" target
+attempts to compiles in support for all displayers (Gtk#,
+System.Windows.Forms, and Console output).
+
+The ``--displayer'' argument is no longer required in order to use GUI output.
+The displayer to be used is specified in the .config file. (In the
+<appSettings/> element, <add/> sub-element with attribute
+key="displayer-order". XPath:
+ /configuration/appSettings/add[@key='displayer-order'].)
+
+The current order is Gtk#, followed by System.Windows.Forms, followed by
+console output. If you don't like this order, change the entry so your
+preferred displayer is first.
+
+Gtk#
+----
+The Gtk# front-end uses (duh!) Gtk#. And Glade#. And any other Gnome
+technology I feel like throwing in at any given point in time. Ahem.
+To compile it, run:
+
+ make -f makefile.gnu gtk
+
+To run it, pass ``--displayer=gtk'' on the command line:
+
+ type-reflector.exe --displayer=gtk --use-default-assemblies .
+
+This will display all types in all assemblies; it takes ~25 seconds to finish
+loading (PIII 700 MHz notebook).
+
+
+System.Windows.Forms
+--------------------
+The Windows.Forms front-end is the "swf" displayer. To compile, run:
+
+ make swf
+
+This must be done on a Windows box, as (at present) the Mono
+System.Windows.Forms implementation will not permit compilation.
+
+To run it, pass ``--displayer=gtk'' on the command line:
+
+ type-reflector.exe --displayer=swf -S --use-default-assemblies .
+
View
16 type-reflector/TODO
@@ -0,0 +1,16 @@
+A better way of displaying Custom Attributes needs to be used, so that the
+actual properties/field values of the custom attribute is displayed.
+
+A better way of specifying Assemblies on the command line. It would be useful
+to say ``-a foo.dll -a bar.dll -a baz.dll'' instead of
+``-a foo.dll:bar.dll:baz.dll''. The framework for such parsing is described
+in ``ProgramOptions.cs''.
+
+Any of the TODO items listed in ``ProgramOptions.cs''.
+
+For Gtk#:
+ - Make View->Formatter be synchronized with the Formatter sidebar. Requires
+ some way of getting information about the selected item. (There doesn't
+ appear to be a simple way to find the Menu Item Label text from a
+ RadioMenuItem. :-(
+
View
168 type-reflector/TestTypes.cs
@@ -0,0 +1,168 @@
+//
+// TestTypes.cs: Sample types for testing type-reflector
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+using System;
+
+namespace Testing
+{
+ public interface IFoo {}
+ public interface IBar {}
+ public interface IBaz : IFoo, IBar {}
+
+ public delegate void FooEventHandler ();
+ public delegate void FooEventHandler2 (int n);
+ public delegate void FooEventHandler3 (int n, long l);
+
+ public class MyAttribute : Attribute {
+ private string _f;
+ public MyAttribute (string f) {
+ _f = f;
+ }
+ public string F {
+ get {return _f;}
+ }
+ }
+
+ public class AnotherAttribute : Attribute {
+ private int n;
+ private string s;
+
+ public AnotherAttribute (int _n) {
+ n = _n;
+ }
+
+ public AnotherAttribute (string _s) {
+ s = _s;
+ }
+
+ public int N {
+ get {return n;}
+ }
+
+ public string S {
+ get {return s;}
+ }
+ }
+
+ public class TypeAttributes : Attribute {
+ public TypeAttributes () {}
+
+ public char Char = 'a';
+ public decimal Decimal = 42m;
+ public double Double = 17.0;
+ public int Int = 24;
+ public long Long = 57L;
+ public string String = "hello, world!";
+ public float Float = 34.0f;
+ public uint UInt = 10;
+ public ulong ULong = 20;
+ }
+
+ // [CLSCompliant(false)]
+ [MyAttribute ("Hello, world!")]
+ [Serializable]
+ public class TestClass : IFoo, IBar, IBaz {
+
+ [TypeAttributes]
+ public sealed class NestedClass {
+ public static int Foo = 10;
+ public const int Bar = 20;
+ public int Baz {
+ get {return 30;}
+ }
+ }
+
+ private int PrivateField;
+ protected float ProtectedField;
+
+ [MyAttribute("foo!")]
+ public double PublicField;
+
+ internal long InternalField;
+
+ public TestClass (short s) {PublicField = 3.14;}
+ protected TestClass (long l) {ProtectedField = 2.71F;}
+ private TestClass (int i) {PrivateField = 13;}
+ internal TestClass (float f) {InternalField = 64;}
+
+ // indexer
+ public int this [int index] {
+ get {return 42;}
+ set {/* ignore */}
+ }
+
+ [MyAttribute ("Public Property")]
+ public int PublicGetSet {
+ get {return 0;}
+ set {PublicField = value;}
+ }
+
+ public static int StaticGetter {
+ get {return 42;}
+ }
+
+ public static int StaticSetter {
+ set {/* ignore */}
+ }
+
+ protected short ProtectedGetter {
+ get {return -1;}
+ }
+
+ private char PrivateSetter {
+ set {PrivateField = value;}
+ }
+
+ internal float InternalProperty {
+ get {return ProtectedField;}
+ set {ProtectedField = value;}
+ }
+
+ public event FooEventHandler PubFoo;
+ protected event FooEventHandler ProFoo;
+ private event FooEventHandler PrivFoo;
+ internal event FooEventHandler IntFoo;
+
+ public static int msFoo = 42;
+ public const int msBar = 64;
+
+ [MyAttribute ("Some Name")]
+ [return: AnotherAttribute ("Return Attribute")]
+ public short PublicMethod ([MyAttribute("The parameter")] [AnotherAttribute(42)] short s)
+ {
+ PubFoo (); return s;
+ }
+
+ public static TestEnum PublicMethod2 ()
+ {
+ return TestEnum.Foo;
+ }
+
+ public void ParamsMethod (params object[] objs)
+ {
+ }
+
+ protected internal void ProtectedInternalFunction ()
+ {
+ }
+
+ private int PrivateMethod (int i) {PrivFoo (); return i;}
+ protected long ProtectedMethod (long l) {ProFoo (); return l;}
+ internal float InternalMethod (float f) {IntFoo (); return f;}
+ }
+
+ [Flags]
+ public enum TestEnum {
+ Foo,
+ Bar,
+ Baz,
+ Qux,
+ Quux
+ }
+}
+
View
162 type-reflector/TextFormatter.cs
@@ -0,0 +1,162 @@
+//
+// TextFormatter.cs: Formats text for display output
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+// Permission is hereby granted, free of charge, to any
+// person obtaining a copy of this software and associated
+// documentation files (the "Software"), to deal in the
+// Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software,
+// and to permit persons to whom the Software is furnished to
+// do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice
+// shall be included in all copies or substantial portions
+// of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+// KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Mono.TypeReflector
+{
+ internal class TextFormatter {
+ private int leftMargin = 0;
+ private int rightMargin = 80;
+ private int subsequentIndent = 0;
+
+ public int LeftMargin {
+ get {return leftMargin;}
+ set {leftMargin = value;}
+ }
+
+ public int RightMargin {
+ get {return rightMargin;}
+ set {rightMargin = value;}
+ }
+
+ public int SubsequentIndent {
+ get {return subsequentIndent;}
+ set {subsequentIndent = value;}
+ }
+
+ public TextFormatter ()
+ : this (0)
+ {
+ }
+
+ public TextFormatter (int leftMargin)
+ : this (leftMargin, 80)
+ {
+ }
+
+ public TextFormatter (int leftMargin, int rightMargin)
+ : this (leftMargin, rightMargin, 0)
+ {
+ }
+
+ public TextFormatter (int leftMargin, int rightMargin, int subsequentIndent)
+ {
+ this.leftMargin = leftMargin;
+ this.rightMargin = rightMargin;
+ this.subsequentIndent = subsequentIndent;
+ }
+
+ private void WrapText (string text, int width, IList lines)
+ {
+ if (text.Length <= width) {
+ lines.Add (text);
+ return;
+ }
+
+ while (text.Length > width) {
+ int b = width;
+ if (!Char.IsWhiteSpace(text[b])) {
+ b = text.LastIndexOf (' ', b);
+ if (b == -1)
+ // couldn't find an earlier word break
+ b = width;
+ }
+ lines.Add (text.Substring (0, b));
+ text = text.Substring (b).Trim();
+ }
+ lines.Add (text);
+ }
+
+ private ICollection WrapText (string text, int width)
+ {
+ ArrayList lines = new ArrayList ();
+ string[] paragraphs = text.Split(new char[] {'\n'});
+ foreach (string p in paragraphs)
+ WrapText (p, width, lines);
+ return lines;
+ }
+
+ public string Group (string text)
+ {
+ // should be "- followingIndent", but need an extra space for the '\n'.
+ int width = (RightMargin - LeftMargin) - (SubsequentIndent+1);
+ StringBuilder sb = new StringBuilder ();
+ string format1 = "{1}";
+ string formatN = "{0,-" + (LeftMargin + SubsequentIndent) + "}{1}";
+ ICollection c = WrapText (text, width);
+ int last = c.Count;
+ string format = format1;
+ foreach (string s in c) {
+ string line = String.Format (format, "", s);
+ sb.Append (line);
+ if (--last != 0) {
+ format = formatN;
+ sb.Append ("\n");
+ }
+ }
+ return sb.ToString();
+ }
+
+ private static int MaxDepth (string[][] args)
+ {
+ int max = 0;
+ foreach (string[] arg in args) {
+ if (arg.Length > max)
+ max = arg.Length;
+ }
+ return max;
+ }
+
+ public static string Format (string format, params string[][] args)
+ {
+ int count = MaxDepth (args);
+ StringBuilder sb = new StringBuilder ();
+ for (int i = 0; i != count; ++i) {
+ ArrayList row = new ArrayList ();
+ foreach (string[] arg in args) {
+ if (arg.Length > i)
+ row.Add (arg[i]);
+ else
+ row.Add ("");
+ }
+ sb.Append (string.Format (format, row.ToArray()));
+ }
+ return sb.ToString();
+ }
+ }
+}
+
View
166 type-reflector/TypeFactory.cs
@@ -0,0 +1,166 @@
+//
+// TypeFactory.cs: Generic factory implementation
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+using System;
+using System.Collections;
+using System.Diagnostics;
+using System.Text;
+
+namespace Mono.TypeReflector
+{
+ public class TypeFactoryEntry
+ {
+ private string key, desc;
+ private Type type;
+
+ public TypeFactoryEntry (string key, string description, Type type)
+ {
+ this.key = key;
+ this.desc = description;
+ this.type = type;
+ }
+
+ public string Key {
+ get {return key;}
+ }
+
+ public string Description {
+ get {return desc;}
+ }
+
+ public Type Type {
+ get {return type;}
+ }
+ }
+
+ public class TypeFactory : IDictionary
+ {
+ private static BooleanSwitch info = new BooleanSwitch (
+ "type-factory",
+ "Information about creating types.");
+
+ // type: IDictionary<string, TypeFactoryEntry>
+ private IDictionary entries = new Hashtable ();
+
+ //
+ // ICollection interface
+ //
+ public int Count {
+ get {return entries.Count;}
+ }
+
+ public bool IsSynchronized {
+ get {return entries.IsSynchronized;}
+ }
+
+ public object SyncRoot {
+ get {return entries.SyncRoot;}
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ entries.CopyTo (array, index);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return entries.GetEnumerator ();
+ }
+
+ //
+ // IDictionary interface
+ //
+
+ public bool IsFixedSize {
+ get {return false;}
+ }
+
+ public bool IsReadOnly {
+ get {return false;}
+ }
+
+ public object this [object key] {
+ get {return entries[key];}
+ set {entries[key] = value;}
+ }
+
+ public ICollection Keys {
+ get {return entries.Keys;}
+ }
+
+ public ICollection Values {
+ get {return entries.Values;}
+ }
+
+ void IDictionary.Add (object key, object value)
+ {
+ Add (key, (TypeFactoryEntry) value);
+ }
+
+ void IDictionary.Clear ()
+ {
+ /* do nothing */
+ }
+
+ public bool Contains (object key)
+ {
+ return entries.Contains (key);
+ }
+
+ public IDictionaryEnumerator GetEnumerator ()
+ {
+ return entries.GetEnumerator ();
+ }
+
+ public void Remove (object key)
+ {
+ entries.Remove (key);
+ }
+
+ //
+ // New methods
+ //
+
+ public void Add (object key, TypeFactoryEntry value)
+ {
+ entries.Add (key, value);
+ }
+
+ public void Add (TypeFactoryEntry entry)
+ {
+ Add (entry.Key, entry);
+ }
+
+ private object CreateInstance (Type type)
+ {
+ return Activator.CreateInstance (type);
+ }
+
+ public object Create (object key)
+ {
+ TypeFactoryEntry entry = null;
+ try {
+ entry = (TypeFactoryEntry) entries[key];
+ object o = CreateInstance (entry.Type);
+ IPolicy policy = o as IPolicy;
+ if (policy != null) {
+ policy.FactoryKey = entry.Key;
+ policy.Description = entry.Description;
+ }
+ return o;
+ }
+ catch (Exception e) {
+ Trace.WriteLineIf (info.Enabled, string.Format (
+ "Exception creating ({0}, {1}): {2})",
+ key, entry == null ? null : entry.Type, e.ToString()));
+ return null;
+ }
+ }
+ }
+}
+
View
189 type-reflector/TypeLoader.cs
@@ -0,0 +1,189 @@
+//
+// TypeLoader.cs: Loads types from a list of Assemblies
+//
+// Author: Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2002 Jonathan Pryor
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Diagnostics;