public override void Modified(XElement source, XElement target) { // hack - there could be changes that we're not monitoring (e.g. attributes properties) var output = Output; State.Output = new StringWriter(); ccomparer.Compare(source, target); icomparer.Compare(source, target); fcomparer.Compare(source, target); pcomparer.Compare(source, target); ecomparer.Compare(source, target); mcomparer.Compare(source, target); var si = source.Element("classes"); if (si != null) { var ti = target.Element("classes"); kcomparer = new NestedClassComparer(); kcomparer.Compare(si.Elements("class"), ti == null ? null : ti.Elements("class")); } var s = (Output as StringWriter).ToString(); State.Output = output; if (s.Length > 0) { Output.WriteLine("<h3>Type Changed: {0}.{1}</h3>", State.Namespace, GetTypeName(target)); Output.WriteLine(s); } }
public override void Modified(XElement source, XElement target, ApiChanges diff) { // hack - there could be changes that we're not monitoring (e.g. attributes properties) var output = Output; State.Output = new StringWriter(); var sb = source.GetAttribute("base"); var tb = target.GetAttribute("base"); var rm = $"{State.Namespace}.{State.Type}: Modified base type: '{sb}' to '{tb}'"; State.LogDebugMessage($"Possible -r value: {rm}"); if (sb != tb && !State.IgnoreRemoved.Any(re => re.IsMatch(rm)) && !(State.IgnoreNonbreaking && IsBaseChangeCompatible(sb, tb))) { 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); icomparer.Compare(source, target); fcomparer.Compare(source, target); pcomparer.Compare(source, target); ecomparer.Compare(source, target); mcomparer.Compare(source, target); var si = source.Element("classes"); 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) { SetContext(target); Formatter.BeginTypeModification(Output); Output.WriteLine(s); Formatter.EndTypeModification(Output); } }
public override void Modified(XElement source, XElement target, ApiChanges diff) { // hack - there could be changes that we're not monitoring (e.g. attributes properties) var output = Output; State.Output = new StringWriter(); var sb = source.GetAttribute("base"); var tb = target.GetAttribute("base"); var rm = $"{State.Namespace}.{State.Type}: Modified base type: '{sb}' to '{tb}'"; State.LogDebugMessage($"Possible -r value: {rm}"); 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()); } ccomparer.Compare(source, target); icomparer.Compare(source, target); fcomparer.Compare(source, target); pcomparer.Compare(source, target); ecomparer.Compare(source, target); mcomparer.Compare(source, target); var si = source.Element("classes"); if (si != null) { var ti = target.Element("classes"); kcomparer = new NestedClassComparer(); kcomparer.Compare(si.Elements("class"), ti == null ? null : ti.Elements("class")); } 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)); Output.WriteLine(s); Output.WriteLine("</div> <!-- end type {0} -->", tn); } }
public override void Modified(XElement source, XElement target, ApiChanges diff) { // hack - there could be changes that we're not monitoring (e.g. attributes properties) var output = Output; State.Output = new StringWriter(); var sb = source.GetAttribute("base"); var tb = target.GetAttribute("base"); if (sb != tb) { Output.Write("Modified base type: "); Output.WriteLine(new ApiChange().AppendModified(sb, tb, true).Member.ToString()); } ccomparer.Compare(source, target); icomparer.Compare(source, target); fcomparer.Compare(source, target); pcomparer.Compare(source, target); ecomparer.Compare(source, target); mcomparer.Compare(source, target); var si = source.Element("classes"); if (si != null) { var ti = target.Element("classes"); kcomparer = new NestedClassComparer(); kcomparer.Compare(si.Elements("class"), ti == null ? null : ti.Elements("class")); } 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)); Output.WriteLine(s); Output.WriteLine("</div> <!-- end type {0} -->", tn); } }
public void AddedInner(XElement target) { SetContext(target); if (target.IsTrue("serializable")) { Indent().WriteLine("[Serializable]"); } var type = target.Attribute("type").Value; if (type == "enum") { // check if [Flags] is present var cattrs = target.Element("attributes"); if (cattrs != null) { foreach (var ca in cattrs.Elements("attribute")) { if (ca.GetAttribute("name") == "System.FlagsAttribute") { Indent().WriteLine("[Flags]"); break; } } } } Indent().Write("public"); if (type != "enum") { bool seal = target.IsTrue("sealed"); bool abst = target.IsTrue("abstract"); if (seal && abst) { Output.Write(" static"); } else if (seal && type != "struct") { Output.Write(" sealed"); } else if (abst && type != "interface") { Output.Write(" abstract"); } } Output.Write(' '); Output.Write(type); Output.Write(' '); Output.Write(target.GetAttribute("name")); var baseclass = target.GetAttribute("base"); if ((type != "enum") && (type != "struct")) { if (baseclass != null) { if (baseclass == "System.Object") { // while true we do not need to be reminded every time... baseclass = null; } else { Output.Write(" : "); Output.Write(baseclass); } } } // interfaces on enums are "standard" not user provided - so we do not want to show them if (type != "enum") { var i = target.Element("interfaces"); if (i != null) { var interfaces = new List <string> (); foreach (var iface in i.Elements("interface")) { interfaces.Add(icomparer.GetDescription(iface)); } Output.Write((baseclass == null) ? " : " : ", "); Output.Write(String.Join(", ", interfaces)); } } Output.WriteLine(" {"); State.Indent++; var t = target.Element("constructors"); if (t != null) { Indent().WriteLine("// constructors"); foreach (var ctor in t.Elements("constructor")) { ccomparer.Added(ctor, true); } } t = target.Element("fields"); if (t != null) { if (type != "enum") { Indent().WriteLine("// fields"); } else { SetContext(target); } foreach (var field in t.Elements("field")) { fcomparer.Added(field, true); } } t = target.Element("properties"); if (t != null) { Indent().WriteLine("// properties"); foreach (var property in t.Elements("property")) { pcomparer.Added(property, true); } } t = target.Element("events"); if (t != null) { Indent().WriteLine("// events"); foreach (var evnt in t.Elements("event")) { ecomparer.Added(evnt, true); } } t = target.Element("methods"); if (t != null) { Indent().WriteLine("// methods"); foreach (var method in t.Elements("method")) { mcomparer.Added(method, true); } } t = target.Element("classes"); if (t != null) { Output.WriteLine(); Indent().WriteLine("// inner types"); State.Parent = State.Type; kcomparer = new NestedClassComparer(); foreach (var inner in t.Elements("class")) { kcomparer.AddedInner(inner); } State.Type = State.Parent; } State.Indent--; Indent().WriteLine("}"); }
public NamespaceComparer() { comparer = new ClassComparer(); }
public void AddedInner (XElement target) { SetContext (target); if (target.IsTrue ("serializable")) Indent ().WriteLine ("[Serializable]"); var type = target.Attribute ("type").Value; if (type == "enum") { // check if [Flags] is present var cattrs = target.Element ("attributes"); if (cattrs != null) { foreach (var ca in cattrs.Elements ("attribute")) { if (ca.GetAttribute ("name") == "System.FlagsAttribute") { Indent ().WriteLine ("[Flags]"); break; } } } } Indent ().Write ("public"); if (type != "enum") { bool seal = target.IsTrue ("sealed"); bool abst = target.IsTrue ("abstract"); if (seal && abst) Output.Write (" static"); else if (seal && type != "struct") Output.Write (" sealed"); else if (abst && type != "interface") Output.Write (" abstract"); } Output.Write (' '); Output.Write (type); Output.Write (' '); Output.Write (target.GetAttribute ("name")); var baseclass = target.GetAttribute ("base"); if ((type != "enum") && (type != "struct")) { if (baseclass != null) { if (baseclass == "System.Object") { // while true we do not need to be reminded every time... baseclass = null; } else { Output.Write (" : "); Output.Write (baseclass); } } } // interfaces on enums are "standard" not user provided - so we do not want to show them if (type != "enum") { var i = target.Element ("interfaces"); if (i != null) { var interfaces = new List<string> (); foreach (var iface in i.Elements ("interface")) interfaces.Add (icomparer.GetDescription (iface)); Output.Write ((baseclass == null) ? " : " : ", "); Output.Write (String.Join (", ", interfaces)); } } Output.WriteLine (" {"); var t = target.Element ("constructors"); if (t != null) { Indent ().WriteLine ("\t// constructors"); foreach (var ctor in t.Elements ("constructor")) ccomparer.Added (ctor); } t = target.Element ("fields"); if (t != null) { if (type != "enum") Indent ().WriteLine ("\t// fields"); else SetContext (target); foreach (var field in t.Elements ("field")) fcomparer.Added (field); } t = target.Element ("properties"); if (t != null) { Indent ().WriteLine ("\t// properties"); foreach (var property in t.Elements ("property")) pcomparer.Added (property); } t = target.Element ("events"); if (t != null) { Indent ().WriteLine ("\t// events"); foreach (var evnt in t.Elements ("event")) ecomparer.Added (evnt); } t = target.Element ("methods"); if (t != null) { Indent ().WriteLine ("\t// methods"); foreach (var method in t.Elements ("method")) mcomparer.Added (method); } t = target.Element ("classes"); if (t != null) { Output.WriteLine (); Indent ().WriteLine ("\t// inner types"); kcomparer = new NestedClassComparer (); State.Indent++; foreach (var inner in t.Elements ("class")) kcomparer.AddedInner (inner); State.Indent--; } Indent ().WriteLine ("}"); }
public override void Modified (XElement source, XElement target, ApiChanges diff) { // hack - there could be changes that we're not monitoring (e.g. attributes properties) var output = Output; State.Output = new StringWriter (); var sb = source.GetAttribute ("base"); var tb = target.GetAttribute ("base"); if (sb != tb) { Output.Write ("Modified base type: "); Output.WriteLine (new ApiChange ().AppendModified (sb, tb, true).Member.ToString ()); } ccomparer.Compare (source, target); icomparer.Compare (source, target); fcomparer.Compare (source, target); pcomparer.Compare (source, target); ecomparer.Compare (source, target); mcomparer.Compare (source, target); var si = source.Element ("classes"); if (si != null) { var ti = target.Element ("classes"); kcomparer = new NestedClassComparer (); kcomparer.Compare (si.Elements ("class"), ti == null ? null : ti.Elements ("class")); } var s = (Output as StringWriter).ToString (); State.Output = output; if (s.Length > 0) { Output.WriteLine ("<h3>Type Changed: {0}.{1}</h3>", State.Namespace, GetTypeName (target)); Output.WriteLine (s); } }
public NamespaceComparer () { comparer = new ClassComparer (); }
public override void Modified (XElement source, XElement target) { // hack - there could be changes that we're not monitoring (e.g. attributes properties) var output = Output; State.Output = new StringWriter (); ccomparer.Compare (source, target); icomparer.Compare (source, target); fcomparer.Compare (source, target); pcomparer.Compare (source, target); ecomparer.Compare (source, target); mcomparer.Compare (source, target); var si = source.Element ("classes"); if (si != null) { var ti = target.Element ("classes"); kcomparer = new ClassComparer (); kcomparer.Compare (si.Elements ("class"), ti == null ? null : ti.Elements ("class")); } var s = (Output as StringWriter).ToString (); State.Output = output; if (s.Length > 0) { Output.WriteLine ("<h3>Type Changed: {0}.{1}</h3>", State.Namespace, target.Attribute ("name").Value); Output.WriteLine (s); } }