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.
get { return ignoreRemoved; }
}
+ public static bool IgnoreParameterNameChanges { get; set; }
+ public static bool IgnoreVirtualChanges { get; set; }
+
public static bool Lax;
}
{ "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 }
};
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
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));
}
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 ");