[mono-api-html] Allow ignoring parameter names, virtual.

I've been trying to review API diffs in Xamarin.Android between API
levels, but the diffs are "noisy" because Google will change parameter
names at-will, or will change a non-virtual method into a virtual
method, or a virtual method into an override, all of which are
acceptable changes but individually generate a Removed line in
mono-api-html output, and manually removing the *hundreds* of changes
is error-prone.

Add two new option flags to mono-api-html:

  --ignore-changes-parameter-names:
      Ignore changes in constructor and method parameter names.

      If parameter names change between <reference.xml> and
      <assembly.xml>, don't report a change for the constructor or
      method.

  --ignore-changes-virtual:
      Ignore changes in "virtual-ness".

      If a method or property changes from non-virtual to virtual,
      non-virtual to override, or virtual to override, don't report a
      change for the member.
This commit is contained in:
Jonathan Pryor committed 2014-11-12 17:34:21 -05:00
1 parent b486e8372e
commit 789517f878
3 files changed
+15 -3

No files matched your search

@@ -74,6 +74,9 @@ namespace Xamarin.ApiDiff {
get { return ignoreRemoved; }
}
public static bool IgnoreParameterNameChanges { get; set; }
public static bool IgnoreVirtualChanges { get; set; }
public static bool Lax;
}
@@ -105,6 +108,12 @@ namespace Xamarin.ApiDiff {
{ "n|ignore-new=", "Ignore new namespaces and types whose description matches a given C# regular expression (see below).",
v => State.IgnoreNew.Add (new Regex (v))
},
{ "ignore-changes-parameter-names", "Ignore changes to parameter names for identically prototyped methods.",
v => State.IgnoreParameterNameChanges = v != null
},
{ "ignore-changes-virtual", "Ignore changing non-`virtual` to `virtual` or adding `override`.",
v => State.IgnoreVirtualChanges = v != null
},
{ "x|lax", "Ignore duplicate XML entries", v => State.Lax = true }
};
@@ -62,7 +62,7 @@ namespace Xamarin.ApiDiff {
if ((attr & MethodAttributes.Static) != 0) {
sb.Append ("static ");
} else if ((attr & MethodAttributes.Virtual) != 0) {
} else if ((attr & MethodAttributes.Virtual) != 0 && !State.IgnoreVirtualChanges) {
if ((attr & MethodAttributes.VtableLayoutMask) == 0)
sb.Append ("override ");
else
@@ -99,7 +99,10 @@ namespace Xamarin.ApiDiff {
if (parameters != null) {
var list = new List<string> ();
foreach (var p in parameters.Elements ("parameter")) {
list.Add (p.GetTypeName ("type") + " " + p.GetAttribute ("name"));
var pTypeName = p.GetTypeName ("type");
list.Add (State.IgnoreParameterNameChanges
? pTypeName
: pTypeName + " " + p.GetAttribute ("name"));
}
sb.Append (String.Join (", ", list));
}
@@ -77,7 +77,7 @@ namespace Xamarin.ApiDiff {
var sb = new StringBuilder ();
sb.Append (family ? "protected " : "public ");
if (virt)
if (virt && !State.IgnoreVirtualChanges)
sb.Append (over ? "override " : "virtual ");
else if (stat)
sb.Append ("static ");