Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

358
mcs/tools/monop/ChangeLog Normal file
View File

@@ -0,0 +1,358 @@
2008-10-24 Miguel de Icaza <miguel@novell.com>
* outline.cs: Small changes to allow the outline code to be embedded.
2005-10-10 John Luke <john.luke@gmail.com>
* options.cs: add --help output for the two new
options
2005-10-10 John Luke <john.luke@gmail.com>
* monop.cs: add PrintRefs and use it if the
option is set
* options.cs: add PrintRefs option to see the
assemblies referenced by an assembly
2005-10-10 John Luke <john.luke@gmail.com>
* monop.cs: don't print obsolete types if the
--filter-obsolete option is passed
* options.cs: add FilterObsolete option
* outline.cs: don't print obsolete members if
the --filter-obsolete option is passed
2005-09-21 John Luke <john.luke@gmail.com>
* monop.cs: catch exception on Process.Start
when gacutil cannot be found to avoid annoying
windows message boxes
2005-09-05 Michal Moskal <malekith@nemerle.org>
* outline.cs: Use new names of the GenericParameterAttributes enum.
2005-08-19 Ben Maurer <bmaurer@novell.com>
* outline.cs:
- Support for `sealed'
- Handle iface impls with non-virtual methods
- ';' for delegates
2005-07-11 Raja R Harinath <rharinath@novell.com>
* Makefile (PROGRAM): Make profile specific.
* monop2.exe.sources: Remove.
2005-07-10 Ben Maurer <bmaurer@ximian.com>
* outline.cs: mark abstract methods with the "abstract" keyword.
2005-07-09 Ben Maurer <bmaurer@ximian.com>
* outline.cs: Actually get the namespacing conditions right so
things look nice
* outline.cs: Friendly display of ifaces on -d
* outline.cs: Always show explicit interface impls. Don't display
the wrong flags for them.
2005-07-07 Ben Maurer <bmaurer@ximian.com>
* outline.cs:
- Print out static for fields (how the hell did I let myself
not put this in earlier!!!!!)
- To print out const fields, we might need to quote
things. This logic is not complete yet (for example, a string
with \n will have a literal new line)
- Try some smarter logic to get less verbosity by printing out
fewer namespaces
- Do a nicer sorting for methods. It sorts things by param
type, then from fewest params to most. This makes overloads
get sorted out cleanly.
2005-07-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* outline.cs: prevent nullref for non-public events.
2005-07-04 Ben Maurer <bmaurer@ximian.com>
* outline.cs: filter out interfaces in generic constraint clauses
that come from the base class.
2005-07-04 Ben Maurer <bmaurer@ximian.com>
* outline.cs: use tabs, not spaces, for indentation.
* outline.cs: Add support for constraints. Inspired by brada's
blog.
2005-07-03 Ben Maurer <bmaurer@ximian.com>
* outline.cs: Support for methods with generic parameters.
* *: begin support for 2.0
* outline.cs: Add support for readonly fields.
2005-05-30 Ben Maurer <bmaurer@ximian.com>
* outline.cs: Don't show static constructors: they are cctors,
which are uninteresting.
2005-01-22 Ben Maurer <bmaurer@ximian.com>
* outline.cs (OutlineProperty) handle mixed accessability.
* options.cs: Make things public.
* outline.cs: Use the Options class, rather than being passed
binding flags.
(.ctor): Add Options param
(OutlineType): remove bindingFlags param
(DefaultFlags): Get the correct binding flags
(ShowMember): Return true if we should show this member given the
Options. Way too long due to MSFT stupidity.
(OutlineType): call the above.
* monop.cs (Main): Don't fiddle with binding flags ourselves.
2005-01-08 John Luke <john.luke@gmail.com>
* monop.cs: use Options class
add a little print-runtime option
(PrintTypes): respect --private option
* options.cs: split out option parsing and improve it
(simpler, order independent, less prone to crash)
2005-01-01 Duncan Mak <duncan@ximian.com>
* monop.cs (SearchType): Filter out non-public members and return
the number of matches found. Use for loops instead of foreach
loops.
(Main): Jump to `found' if we find only one matching type.
2004-12-30 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* outline.cs : Add support for enums having types different than int.
2004-12-30 Atsushi Enomoto <atsushi@ximian.com>
* monop.cs : csc build fix (see bug #70185).
2004-12-29 Duncan Mak <duncan@ximian.com>
* monop.cs (SearchType): New method, returns a list of type names
that matches the method argument, either completely or partially.
(GetKnownAssemblyNames): Renamed from GetAssemblyNamesFromGAC, as
it now includes mscorlib in the return value.
(Main): Added new flags: "--search", "-s", "-k". These flags will
invoke SearchType. Prints out a list of Types and the location of
the Assembly containing the Type.
This fixes bug #70068.
2004-12-24 John Luke <john.luke@gmail.com>
* monop.cs: sort the types when printing an assembly
handle -r:~/foo.dll by substituting for $HOME
* TypeSorter.cs: IComparer to sort types by name
2004-12-25 Ben Maurer <bmaurer@ximian.com>
* monop.cs, outline.cs, monop-completion.sh: Add MIT/X11 License.
2004-12-09 Dan Winship <danw@novell.com>
* outline.cs (OutlineType, OutlineOperator, OperatorFromName):
Show overloaded operators and type conversions.
(FormatType): fix the logic here so that, eg "System.Int32"
becomes "int" rather than "Int32" when looking at a type in the
System namespace.
2004-12-03 Atsushi Enomoto <atsushi@ximian.com>
* monop.cs : csc build fix. See bug #70185 for details.
2004-11-30 Duncan Mak <duncan@ximian.com>
* monop.cs (GetAssemblyNamesFromGAC): New method, calls out to
"gacutil -l" and returns an array of Assembly fullnames.
(Main): Instead of probing the common_assemblies, use
GetAssemblyNamesFromGAC. If we found the type via probing, print
out a message noting the full type name and assembly name. This
fixes bug #70043.
2004-11-11 Ben Maurer <bmaurer@ximian.com>
* outline.cs: Remove `public virtual' for interface methods.
2004-11-08 Ben Maurer <bmaurer@ximian.com>
* outline.cs: If a type is in the namespace that we
are looking at right now, dont print out the fullname
this cuts down on verbosity
* outline.cs: Cut the extra whitespace.
* outline.cs: Report sealed and abstract
2004-10-27 John Luke <john.luke@gmail.com>
* outline.cs: report [Obsolete] types
2004-09-22 John Luke <john.luke@gmail.com>
* outline.cs: use simpler IsDefined method
for checking params and [Flags]
2004-09-18 John Luke <john.luke@gmail.com>
* outline.cs: add const = value; for const fields (Ben's idea)
detect ParamArrayAttribute for parameters
2004-09-03 John Luke <john.luke@gmail.com>
* monop.cs: report CLSCompliant for assemblies
2004-08-15 John Luke <john.luke@gmail.com>
* monop.cs: add declared-only option
* outline.cs: add limited attribute support (only for
[Serializable] and [Flags])
2004-08-13 John Luke <john.luke@gmail.com>
* monop.cs: add MONO_PATH support
2004-08-13 John Luke <john.luke@gmail.com>
* outline.cs: remove unused isPointer
* monop.cs: show information about the assembly that is being used
- remove unused IndentedTextWriter
- rework how Assemblies are being loaded, so that it works by trying
in order fromfile, fullname, partialname which fixes loading
from relative paths and generally should be more correct
* TODO: update
2004-08-06 John Luke <john.luke@gmail.com>
* outline.cs: add field support
2004-08-04 John Luke <john.luke@gmail.com>
* monop.cs: add PrintUsage so that it is reused in the few
places it is needed, add PrintHelp to display --help information
2004-05-20 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* monop.cs: give the correct assembly that fails loading or the type.
2004-05-14 Carlos Alberto Cortez <carlos@unixmexico.org>
* outline.cs: Support for delegates and nested types
added.
2004-05-09 John Luke <jluke@cfl.rr.com>
* monop.cs: seperate assembly loading into .GetAssembly method,
fail gracefully, and support loading assemblies from absolute and
relative paths
support /r: as well as -r:
2004-05-08 Pawel Rozanski <tokugawa@afn.no-ip.org>
* monop-completion.sh: simple bash completion for monop
2004-05-07 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: Helpers for completion.
2004-05-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* monop.cs: use assembly.LoadWithPartialName.
2004-04-29 Lluis Sanchez Gual <lluis@ximian.com>
* outline.cs: Property.GetGetMethod() does not return the method if it
is private (it did until now because of a bug). Make sure it works as it
worked before the fix.
2004-04-27 Ben Maurer <bmaurer@users.sourceforge.net>
* outline.cs: Don't show the interfaces of an enum,
s/;/, for enum. Style cop.
2004-04-27 John Luke <jluke@cfl.rr.com>
* outline.cs: add GetTypeKind so we print
enums and interfaces, instead of always class or
struct
add a special case for enums so we just print the fields
and quit
2004-04-03 Duncan Mak <duncan@ximian.com>
* monop.cs (PrintTypes): show the number of types in the assembly
as well.
2004-03-30 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: Print out class list on just -r.
2004-03-15 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: Add buffering, makes output way, way faster.
2004-03-15 Ben Maurer <bmaurer@users.sourceforge.net>
* outline.cs: add support for events.
2004-03-15 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: remove printing logic.
* outline.cs: new file that just does printing stuff.
Makes the code *MUCH* cleaner.
2004-03-15 Miguel de Icaza <miguel@ximian.com>
* monop.cs: Add -r: command line.
2004-03-14 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: do structs better.
2004-03-14 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: add gtk#. Try catch if gtk# is not installed.
2004-03-14 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: You can type `monop string'
2004-03-14 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: show `static' when it applies. Static members
first. new sorting stuff.
2004-03-14 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: sort members
2004-03-14 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: show base type, interfaces.
2004-03-14 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: Make this work on MS (we have a bug).
2004-03-07 Ben Maurer <bmaurer@users.sourceforge.net>
* monop.cs: New tool, clone of javap. Allows you to get
an outline view of a class.

9
mcs/tools/monop/Makefile Normal file
View File

@@ -0,0 +1,9 @@
thisdir = tools/monop
SUBDIRS =
include ../../build/rules.make
PROGRAM = monop.exe
CLEAN_FILES = monop.exe monop2.exe *.mdb
include ../../build/executable.make

View File

@@ -0,0 +1,42 @@
//
// TypeSorter.cs: Sorts types alphabetically by System.Type.FullName
//
// Author:
// John Luke <john.luke@gmail.com>
//
// 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;
class TypeSorter : IComparer
{
public int Compare (object first, object second)
{
Type type1 = first as Type;
Type type2 = second as Type;
if (type1 == null || type2 == null)
throw new ArgumentException ("invalid comparison");
return String.Compare (type1.FullName, type2.FullName);
}
}

405
mcs/tools/monop/monop.cs Normal file
View File

@@ -0,0 +1,405 @@
//
// monop -- a semi-clone of javap
//
// Authors:
// Ben Maurer (bmaurer@users.sourceforge.net)
// John Luke (john.luke@gmail.com)
//
// (C) 2004 Ben Maurer
// (C) 2004 John Luke
//
//
// 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.CodeDom.Compiler;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using Mono.CSharp;
class MonoP {
static string assembly;
// very common namespaces, all in corlib
static readonly string [] v_common_ns = {
"System",
"System.Collections",
"System.Reflection",
"System.Text",
"System.IO"
};
static readonly string [] common_assemblies = {
"System.Xml.dll",
"System.Web.dll",
"gtk-sharp.dll",
"glib-sharp.dll"
};
static readonly string [] common_ns = {
"System.Xml",
"System.Web",
"Gtk",
"GLib"
};
static Type GetType (string tname, bool ignoreCase)
{
Type t;
if (assembly != null) {
Assembly a = GetAssembly (assembly, true);
t = a.GetType (tname, false, ignoreCase);
} else
t = Type.GetType (tname, false, ignoreCase);
return t;
}
static string SearchTypes (string name, ref Type retval, out int count)
{
StringBuilder sb = new StringBuilder ();
Type current = null;
count = 0;
string [] assemblies = GetKnownAssemblyNames ();
for (int i = 0; i < assemblies.Length; i++) {
Assembly a = GetAssembly (assemblies [i], false);
if (a == null)
continue;
Type [] types = a.GetTypes ();
for (int j = 0; j < types.Length; j++) {
Type t = types [j];
if (t.IsPublic == false)
continue;
if (t.Name == name || t.Name.ToLower ().IndexOf (name.ToLower ()) > 0) {
current = t;
count ++;
sb.Append (t.FullName + " from " + a.Location + "\n");
}
}
}
if (count == 0)
return null;
if (count == 1) {
retval = current;
return String.Empty;
}
return sb.ToString ();
}
static string [] GetKnownAssemblyNames ()
{
Process p = new Process ();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "gacutil";
p.StartInfo.Arguments = "-l";
try {
p.Start ();
}
catch {
Console.WriteLine ("WARNING: gacutil could not be found.");
return new string[0];
}
string s;
ArrayList names = new ArrayList ();
StreamReader output = p.StandardOutput;
while ((s = output.ReadLine ()) != null)
names.Add (s);
p.WaitForExit ();
int length = names.Count - 1;
string [] retval = new string [length];
retval [0] = typeof (Object).Assembly.FullName;
names.CopyTo (1, retval, 1, length - 1); // skip the first and last line
return retval;
}
static Assembly GetAssembly (string assembly, bool exit)
{
Assembly a = null;
// if -r:~/foo.dll syntax is used the shell misses it
if (assembly.StartsWith ("~/"))
assembly = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), assembly.Substring (2));
try {
// if it exists try to use LoadFrom
if (File.Exists (assembly))
a = Assembly.LoadFrom (assembly);
// if it looks like a fullname try that
else if (assembly.Split (',').Length == 4)
a = Assembly.Load (assembly);
// see if MONO_PATH has it
else
a = LoadFromMonoPath (assembly);
} catch {
// ignore exception it gets handled below
}
// last try partial name
// this (apparently) is exception safe
if (a == null)
a = Assembly.LoadWithPartialName (assembly);
if (a == null && exit) {
Console.WriteLine ("Could not load {0}", MonoP.assembly);
Environment.Exit (1);
}
return a;
}
static Assembly LoadFromMonoPath (string assembly)
{
// ; on win32, : everywhere else
char sep = (Path.DirectorySeparatorChar == '/' ? ':' : ';');
string[] paths = Environment.GetEnvironmentVariable ("MONO_PATH").Split (sep);
foreach (string path in paths) {
string apath = Path.Combine (path, assembly);
if (File.Exists (apath))
return Assembly.LoadFrom (apath);
}
return null;
}
static Type GetType (string tname)
{
return GetType (tname, false);
}
static void PrintRefs (string assembly)
{
Assembly a = GetAssembly (assembly, true);
foreach (AssemblyName an in a.GetReferencedAssemblies ())
Console.WriteLine (an);
}
static void PrintTypes (string assembly, bool show_private, bool filter_obsolete)
{
Assembly a = GetAssembly (assembly, true);
Console.WriteLine ();
Console.WriteLine ("Assembly Information:");
object[] cls = a.GetCustomAttributes (typeof (CLSCompliantAttribute), false);
if (cls.Length > 0) {
CLSCompliantAttribute cca = cls[0] as CLSCompliantAttribute;
if (cca.IsCompliant)
Console.WriteLine ("[CLSCompliant]");
}
foreach (string ai in a.ToString ().Split (','))
Console.WriteLine (ai.Trim ());
Console.WriteLine ();
Type [] types = show_private ? a.GetTypes () : a.GetExportedTypes ();
Array.Sort (types, new TypeSorter ());
int obsolete_count = 0;
foreach (Type t in types) {
if (filter_obsolete && t.IsDefined (typeof (ObsoleteAttribute), false))
obsolete_count ++;
else
Console.WriteLine (t.FullName);
}
Console.WriteLine ("\nTotal: {0} types.", types.Length - obsolete_count);
}
internal static void Completion (string prefix)
{
foreach (Type t in typeof (object).Assembly.GetExportedTypes ()) {
if (t.Name.StartsWith (prefix)) {
if (Array.IndexOf (v_common_ns, t.Namespace) != -1) {
Console.WriteLine (t.Name);
return;
}
}
if (t.FullName.StartsWith (prefix)) {
Console.WriteLine (t.FullName);
}
}
foreach (string assm in common_assemblies) {
try {
Assembly a = GetAssembly (assm, true);
foreach (Type t in a.GetExportedTypes ()) {
if (t.Name.StartsWith (prefix)) {
if (Array.IndexOf (common_ns, t.Namespace) != -1) {
Console.WriteLine (t.Name);
return;
}
}
if (t.FullName.StartsWith (prefix)) {
Console.WriteLine (t.FullName);
}
}
} catch {
}
}
}
static void ShowAll (string assembly, bool show_private, bool filter_obsolete)
{
Assembly a = GetAssembly (assembly, true);
object[] cls = a.GetCustomAttributes (typeof (CLSCompliantAttribute), false);
if (cls.Length > 0) {
CLSCompliantAttribute cca = cls[0] as CLSCompliantAttribute;
if (cca.IsCompliant)
Console.WriteLine ("[CLSCompliant]");
}
foreach (string ai in a.ToString ().Split (','))
Console.WriteLine (ai.Trim ());
Console.WriteLine ();
Type [] types = show_private ? a.GetTypes () : a.GetExportedTypes ();
Array.Sort (types, new TypeSorter ());
var sw = new StreamWriter (Console.OpenStandardOutput (), Console.Out.Encoding);
foreach (Type t in types) {
if (filter_obsolete && t.IsDefined (typeof (ObsoleteAttribute), false))
continue;
new Outline (t, sw, true, show_private, filter_obsolete).OutlineType ();
}
sw.Flush ();
}
static void Main (string [] args)
{
Options options = new Options ();
if (!options.ProcessArgs (args))
return;
if (options.AssemblyReference != null) {
assembly = options.AssemblyReference;
if (options.ShowAll){
ShowAll (assembly, options.ShowPrivate, options.FilterObsolete);
return;
} else {
if (options.Type == null) {
if (options.PrintRefs)
PrintRefs (assembly);
else
PrintTypes (assembly, options.ShowPrivate, options.FilterObsolete);
return;
}
}
}
string message = null;
string tname = options.Type;
Type t = null;
int count;
if (options.Search) {
string matches = SearchTypes (tname, ref t, out count);
if (count == 0)
goto notfound;
if (count == 1)
goto found;
if (count > 1){
Console.WriteLine ("Found " + count + " types that match:");
Console.WriteLine (matches);
return;
}
}
t = GetType (tname);
if (t == null) {
// Try some very common ones, dont load anything
foreach (string ns in v_common_ns) {
t = GetType (ns + "." + tname, true);
if (t != null)
goto found;
}
}
if (t == null) {
foreach (string assm in GetKnownAssemblyNames ()) {
try {
Assembly a = GetAssembly (assm, false);
t = a.GetType (tname, false, true);
if (t != null) {
message = String.Format ("{0} is included in the {1} assembly.",
t.FullName,
t.Assembly.GetName ().Name);
goto found;
}
foreach (string ns in common_ns) {
t = a.GetType (ns + "." + tname, false, true);
if (t != null) {
message = String.Format ("{0} is included in the {1} assembly.",
t.FullName,
t.Assembly.GetName ().Name);
goto found;
}
}
} catch {
}
}
}
notfound:
if (t == null) {
Console.WriteLine ("Could not find {0}", tname);
return;
}
found:
//
// This gets us nice buffering
//
StreamWriter sw = new StreamWriter (Console.OpenStandardOutput (), Console.Out.Encoding);
new Outline (t, sw, options.DeclaredOnly, options.ShowPrivate, options.FilterObsolete).OutlineType ();
sw.Flush ();
if (message != null)
Console.WriteLine (message);
}
}

View File

@@ -0,0 +1,4 @@
monop.cs
options.cs
outline.cs
TypeSorter.cs

141
mcs/tools/monop/options.cs Normal file
View File

@@ -0,0 +1,141 @@
//
// options.cs: Processes command line args
//
// Author:
// John Luke <john.luke@gmail.com>
//
// 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;
public class Options
{
public bool DeclaredOnly = false;
public bool FilterObsolete = false;
public bool PrintRefs = false;
public bool Search = false;
public bool ShowAll = false;
public bool ShowPrivate = false;
public string AssemblyReference = null;
public string Type = null;
public Options ()
{
}
// returning true means processed ok
// and execution should continue
internal bool ProcessArgs (string[] args)
{
if (args.Length < 1) {
PrintHelp ();
return false;
}
for (int i = 0; i < args.Length; i++) {
switch (args[i]) {
case "-h":
case "--help":
PrintHelp ();
return false;
case "--runtime-version":
PrintRuntimeVersion ();
return false;
case "-d":
case "--declared-only":
DeclaredOnly = true;
break;
case "--filter-obsolete":
case "-f":
FilterObsolete = true;
break;
case "-p":
case "--private":
ShowPrivate = true;
break;
case "--refs":
PrintRefs = true;
break;
case "-s":
case "-k":
case "--search":
Search = true;
break;
case "-c":
i++;
if (i < args.Length)
MonoP.Completion (args[i]);
return false;
case "-r":
i++;
if (i < args.Length)
AssemblyReference = args[i];
break;
case "-a":
ShowAll = true;
break;
default:
if (args[i].StartsWith ("-r:") || args[i].StartsWith ("/r:")) {
AssemblyReference = args [i].Substring (3);
break;
}
// The first unrecognizable option becomes
// the type to look up
if (Type == null) {
Type = args[i];
break;
}
// others are ignored
Console.WriteLine ("ignored: {0}", args[i]);
break;
}
}
// must specify at least one of these
if (Type == null && AssemblyReference == null)
return false;
return true;
}
void PrintRuntimeVersion ()
{
Console.WriteLine ("runtime version: {0}", Environment.Version);
}
void PrintHelp ()
{
Console.WriteLine ("Usage is: monop [option] [-c] [-r:Assembly] [class-name]");
Console.WriteLine ("");
Console.WriteLine ("options:");
Console.WriteLine ("\t--declared-only,-d\tOnly show members declared in the Type");
Console.WriteLine ("\t--help,-h\t\tShow this information");
Console.WriteLine ("\t--filter-obsolete,-f\tDo not show obsolete types and members");
Console.WriteLine ("\t--private,-p\t\tShow private members");
Console.WriteLine ("\t--refs\t\t\tPrint a list of the referenced assemblies for an assembly");
Console.WriteLine ("\t--runtime-version\tPrint runtime version");
Console.WriteLine ("\t--search,-s,-k\t\tSearch through all known namespaces");
Console.WriteLine ("\t--a\t\tShows all the types declare in the specified assembly");
}
}

1038
mcs/tools/monop/outline.cs Normal file

File diff suppressed because it is too large Load Diff