mono-api-html: ignore members using regex, add detailed help
authorAaron Bockover <abock@xamarin.com>
Wed, 19 Feb 2014 19:22:01 +0000 (14:22 -0500)
committerAaron Bockover <abock@xamarin.com>
Wed, 19 Feb 2014 19:22:44 +0000 (14:22 -0500)
mcs/tools/corcompare/mono-api-html/ApiDiff.cs
mcs/tools/corcompare/mono-api-html/MemberComparer.cs

index cd66e9ecd9d5d4762a7492b001a1e76cb7af89ca..8065019935b645922fa5c9ca68fa9f5c0d46aac0 100644 (file)
@@ -34,6 +34,7 @@
 using System;
 using System.IO;
 using System.Collections.Generic;
+using System.Text.RegularExpressions;
 
 using Mono.Options;
 
@@ -58,8 +59,8 @@ namespace Xamarin.ApiDiff {
 
                public static int Indent { get; set; }
 
-               static List<string> ignoreAdded = new List<string> ();
-               public static List<string> IgnoreAdded {
+               static List<Regex> ignoreAdded = new List<Regex> ();
+               public static List<Regex> IgnoreAdded {
                        get { return ignoreAdded; }
                }
        }
@@ -75,7 +76,9 @@ namespace Xamarin.ApiDiff {
                        var options = new OptionSet {
                                { "h|help", "Show this help", v => showHelp = true },
                                { "d|diff=", "HTML diff file out output (omit for stdout)", v => diff = v },
-                               { "i|ignore-added=", "Ignore added members with a given name", v => State.IgnoreAdded.Add (v) }
+                               { "i|ignore-added=", "Ignore added members whose description matches a given C# regular expression (see below).",
+                                       v => State.IgnoreAdded.Add (new Regex (v))
+                               }
                        };
 
                        try {
@@ -91,6 +94,19 @@ namespace Xamarin.ApiDiff {
                                Console.WriteLine ("Available options:");
                                options.WriteOptionDescriptions (Console.Out);
                                Console.WriteLine ();
+                               Console.WriteLine ("Ignoring Members:");
+                               Console.WriteLine ();
+                               Console.WriteLine ("  Members that were added can be filtered out of the diff by using the");
+                               Console.WriteLine ("  -i, --ignore-added option. The option takes a C# regular expression");
+                               Console.WriteLine ("  to match against member descriptions. For example, to ignore the");
+                               Console.WriteLine ("  introduction of the interfaces 'INSCopying' and 'INSCoding' on types");
+                               Console.WriteLine ("  pass the following to mono-api-html:");
+                               Console.WriteLine ();
+                               Console.WriteLine ("    mono-api-html ... -i 'INSCopying$' -i 'INSCoding$'");
+                               Console.WriteLine ();
+                               Console.WriteLine ("  The regular expressions will match any member description ending with");
+                               Console.WriteLine ("  'INSCopying' or 'INSCoding'.");
+                               Console.WriteLine ();
                                return 1;
                        }
 
@@ -130,4 +146,4 @@ namespace Xamarin.ApiDiff {
                        return 0;
                }
        }
-}
\ No newline at end of file
+}
index 1c9ceef5e4c781521dc0d49b7a74f34e55fc19b4..1045206de9159690e627884827672fa3bb4bf6b2 100644 (file)
@@ -109,7 +109,7 @@ namespace Xamarin.ApiDiff {
                        bool a = false;
                        foreach (var item in target) {
                                SetContext (item);
-                               if (State.IgnoreAdded.Contains (GetDescription (item)))
+                               if (State.IgnoreAdded.Any (re => re.IsMatch (GetDescription (item))))
                                        continue;
                                if (!a) {
                                        BeforeAdding ();
@@ -177,4 +177,4 @@ namespace Xamarin.ApiDiff {
                        Output.WriteLine ("</pre>");
                }
        }
-}
\ No newline at end of file
+}