Skip to content

Instantly share code, notes, and snippets.

@jonpryor
Last active December 16, 2015 15:56
Show Gist options
  • Save jonpryor/85574ef8a63d0cf1f1c0 to your computer and use it in GitHub Desktop.
Save jonpryor/85574ef8a63d0cf1f1c0 to your computer and use it in GitHub Desktop.
$ mono mono-api-info.exe --help
--abi Generate ABI, not API; includes only classes with
instance fields which are not [NonSerialized].
-L, --lib=DIRECTORY Check for assembly references in DIRECTORY.
-r=ASSEMBLY Read and register the file ASSEMBLY, and add the
directory containing ASSEMBLY to the search path.
-h, -?, --help Show this message and exit.
diff --git a/mcs/tools/corcompare/Makefile b/mcs/tools/corcompare/Makefile
index 15fec47..9067701 100644
--- a/mcs/tools/corcompare/Makefile
+++ b/mcs/tools/corcompare/Makefile
@@ -39,5 +39,5 @@ clean-local:
dist-local: dist-default
-mono-api-info.exe: $(APIINFO_SOURCES)
+mono-api-info.exe: $(APIINFO_SOURCES) ../../class/Mono.Options/Mono.Options/Options.cs
$(CSCOMPILE) -r:Mono.Cecil.dll -out:$@ $^
diff --git a/mcs/tools/corcompare/mono-api-info.cs b/mcs/tools/corcompare/mono-api-info.cs
index d0faabe..8b43375 100644
--- a/mcs/tools/corcompare/mono-api-info.cs
+++ b/mcs/tools/corcompare/mono-api-info.cs
@@ -22,6 +22,8 @@ using Mono.Cecil;
using Mono.Cecil.Cil;
using System.IO;
+using Mono.Options;
+
namespace CorCompare
{
public class Driver
@@ -39,7 +41,29 @@ namespace CorCompare
string pf = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
TypeHelper.Resolver.AddSearchDirectory (Path.Combine (windir, @"assembly\GAC\MSDATASRC\7.0.3300.0__b03f5f7f11d50a3a"));
- foreach (string arg in args) {
+ bool help = false;
+ var options = new OptionSet () {
+ { "abi",
+ "Generate ABI, not API; contains only classes with instance fields which are not [NonSerialized].",
+ v => AbiMode = v != null
+ },
+ { "L|lib=",
+ "Check for assembly references in {DIRECTORY}.",
+ v => TypeHelper.Resolver.AddSearchDirectory (v) },
+ { "r=",
+ "Read and register the file {ASSEMBLY}, and add the directory containing ASSEMBLY to the search path.",
+ v => TypeHelper.Resolver.ResolveFile (v) },
+ { "h|?|help",
+ "Show this message and exit.",
+ v => help = v != null },
+ };
+ var files = options.Parse (args);
+ if (help) {
+ options.WriteOptionDescriptions (Console.Out);
+ return 0;
+ }
+
+ foreach (string arg in files) {
if (arg == "--abi") {
AbiMode = true;
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment