Imported Upstream version 5.14.0.121

Former-commit-id: 86f238de2954f615a08dc4afc175bee032151a5a
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-06-02 08:53:49 +00:00
parent f4dfa680ce
commit 54c0c51795
48 changed files with 710 additions and 260 deletions

View File

@ -69,18 +69,15 @@ namespace Xamarin.ApiDiff {
public override void Added (XElement target, bool wasParentAdded)
{
string name = target.Attribute ("name").Value;
var addedDescription = $"{State.Namespace}.{name}: Added type";
var addedDescription = $"{State.Namespace}.{State.Type}: Added type";
State.LogDebugMessage ($"Possible -n value: {addedDescription}");
if (State.IgnoreNew.Any (re => re.IsMatch (addedDescription)))
return;
Output.WriteLine ("<div> <!-- start type {0} -->", name);
Output.WriteLine ("<h3>New Type {0}.{1}</h3>", State.Namespace, name);
Output.WriteLine ("<pre class='added' data-is-non-breaking>");
Formatter.BeginTypeAddition (Output);
State.Indent = 0;
AddedInner (target);
Output.WriteLine ("</pre>");
Output.WriteLine ("</div> <!-- end type {0} -->", name);
Formatter.EndTypeAddition (Output);
}
public void AddedInner (XElement target)
@ -149,9 +146,10 @@ namespace Xamarin.ApiDiff {
Output.WriteLine (" {");
State.Indent++;
var t = target.Element ("constructors");
if (t != null) {
Indent ().WriteLine ("\t// constructors");
Indent ().WriteLine ("// constructors");
foreach (var ctor in t.Elements ("constructor"))
ccomparer.Added (ctor, true);
}
@ -159,7 +157,7 @@ namespace Xamarin.ApiDiff {
t = target.Element ("fields");
if (t != null) {
if (type != "enum")
Indent ().WriteLine ("\t// fields");
Indent ().WriteLine ("// fields");
else
SetContext (target);
foreach (var field in t.Elements ("field"))
@ -168,21 +166,21 @@ namespace Xamarin.ApiDiff {
t = target.Element ("properties");
if (t != null) {
Indent ().WriteLine ("\t// properties");
Indent ().WriteLine ("// properties");
foreach (var property in t.Elements ("property"))
pcomparer.Added (property, true);
}
t = target.Element ("events");
if (t != null) {
Indent ().WriteLine ("\t// events");
Indent ().WriteLine ("// events");
foreach (var evnt in t.Elements ("event"))
ecomparer.Added (evnt, true);
}
t = target.Element ("methods");
if (t != null) {
Indent ().WriteLine ("\t// methods");
Indent ().WriteLine ("// methods");
foreach (var method in t.Elements ("method"))
mcomparer.Added (method, true);
}
@ -190,13 +188,14 @@ namespace Xamarin.ApiDiff {
t = target.Element ("classes");
if (t != null) {
Output.WriteLine ();
Indent ().WriteLine ("\t// inner types");
Indent ().WriteLine ("// inner types");
State.Parent = State.Type;
kcomparer = new NestedClassComparer ();
State.Indent++;
foreach (var inner in t.Elements ("class"))
kcomparer.AddedInner (inner);
State.Indent--;
State.Type = State.Parent;
}
State.Indent--;
Indent ().WriteLine ("}");
}
@ -227,8 +226,10 @@ namespace Xamarin.ApiDiff {
if (sb != tb &&
!State.IgnoreRemoved.Any (re => re.IsMatch (rm)) &&
!(State.IgnoreNonbreaking && IsBaseChangeCompatible (sb, tb))) {
Output.Write ("Modified base type: ");
Output.WriteLine (new ApiChange ($"{State.Namespace}.{State.Type}").AppendModified (sb, tb, true).Member.ToString ());
Formatter.BeginMemberModification (Output, "Modified base type");
var apichange = new ApiChange ($"{State.Namespace}.{State.Type}").AppendModified (sb, tb, true);
Formatter.Diff (Output, apichange);
Formatter.EndMemberModification (Output);
}
ccomparer.Compare (source, target);
@ -242,17 +243,18 @@ namespace Xamarin.ApiDiff {
if (si != null) {
var ti = target.Element ("classes");
kcomparer = new NestedClassComparer ();
State.Parent = State.Type;
kcomparer.Compare (si.Elements ("class"), ti == null ? null : ti.Elements ("class"));
State.Type = State.Parent;
}
var s = (Output as StringWriter).ToString ();
State.Output = output;
if (s.Length > 0) {
var tn = GetTypeName (target);
Output.WriteLine ("<!-- start type {0} --> <div>", tn);
Output.WriteLine ("<h3>Type Changed: {0}.{1}</h3>", State.Namespace, GetTypeName (target));
SetContext (target);
Formatter.BeginTypeModification (Output);
Output.WriteLine (s);
Output.WriteLine ("</div> <!-- end type {0} -->", tn);
Formatter.EndTypeModification (Output);
}
}
@ -261,14 +263,15 @@ namespace Xamarin.ApiDiff {
if (source.Elements ("attributes").SelectMany (a => a.Elements ("attribute")).Any (c => c.Attribute ("name")?.Value == "System.ObsoleteAttribute"))
return;
string name = State.Namespace + "." + GetTypeName (source);
string name = State.Namespace + "." + State.Type;
var memberDescription = $"{name}: Removed type";
State.LogDebugMessage ($"Possible -r value: {memberDescription}");
if (State.IgnoreRemoved.Any (re => re.IsMatch (name)))
return;
Output.Write ("<h3>Removed Type <span class='breaking' data-is-breaking>{0}</span></h3>", name);
Formatter.BeginTypeRemoval (Output);
Formatter.EndTypeRemoval (Output);
}
public virtual string GetTypeName (XElement type)
@ -281,11 +284,13 @@ namespace Xamarin.ApiDiff {
public override void SetContext (XElement current)
{
State.Type = State.Parent + "." + current.GetAttribute ("name");
State.BaseType = current.GetAttribute ("base");
}
public override string GetTypeName (XElement type)
{
return State.Type + "." + base.GetTypeName (type);
return State.Parent + "." + base.GetTypeName (type);
}
}
}
}