void CompareAttributes(ComparisonNode parent, ICompAttributeContainer reference_container, ICompAttributeContainer target_container) { int m = 0, a = 0; List <CompNamed> reference_attrs = reference_container.GetAttributes(); List <CompNamed> target_attrs = target_container.GetAttributes(); reference_attrs.Sort(CompNamed.Compare); target_attrs.Sort(CompNamed.Compare); while (m < reference_attrs.Count || a < target_attrs.Count) { if (m == reference_attrs.Count) { AddExtra(parent, target_attrs[a]); a++; continue; } else if (a == target_attrs.Count) { AddMissing(parent, reference_attrs[m]); m++; continue; } int c = String.Compare(reference_attrs[m].Name, target_attrs[a].Name); comparisons_performed++; if (c == 0) { /* the names match, further investigation is required */ // Console.WriteLine ("method {0} is in both, doing more comparisons", reference_list[m].Name); ComparisonNode comparison = target_attrs[a].GetComparisonNode(); parent.AddChild(comparison); //CompareParameters (comparison, reference_list[m], target_namespace [target_list[a]]); m++; a++; } else if (c < 0) { /* reference name is before target name, reference name is missing from target */ AddMissing(parent, reference_attrs[m]); m++; } else { /* reference name is after target name, target name is extra */ AddExtra(parent, target_attrs[a]); a++; } } }
void CompareAttributes (ComparisonNode parent, ICompAttributeContainer reference_container, ICompAttributeContainer target_container) { int m = 0, a = 0; List<CompNamed> reference_attrs = reference_container.GetAttributes (); List<CompNamed> target_attrs = target_container.GetAttributes (); reference_attrs.Sort (CompNamed.Compare); target_attrs.Sort (CompNamed.Compare); while (m < reference_attrs.Count || a < target_attrs.Count) { if (m == reference_attrs.Count) { AddExtra (parent, target_attrs[a]); a++; continue; } else if (a == target_attrs.Count) { AddMissing (parent, reference_attrs[m]); m++; continue; } int c = String.Compare (reference_attrs[m].Name, target_attrs[a].Name); comparisons_performed ++; if (c == 0) { /* the names match, further investigation is required */ // Console.WriteLine ("method {0} is in both, doing more comparisons", reference_list[m].Name); ComparisonNode comparison = target_attrs[a].GetComparisonNode(); parent.AddChild (comparison); //CompareParameters (comparison, reference_list[m], target_namespace [target_list[a]]); m++; a++; } else if (c < 0) { /* reference name is before target name, reference name is missing from target */ AddMissing (parent, reference_attrs[m]); m++; } else { /* reference name is after target name, target name is extra */ AddExtra (parent, target_attrs[a]); a++; } } }
void CompareAttributes (ComparisonNode parent, ICompAttributeContainer reference_container, ICompAttributeContainer target_container) { int m = 0, a = 0; List<CompNamed> reference_attrs = reference_container.GetAttributes (); List<CompNamed> target_attrs = target_container.GetAttributes (); Comparison<CompNamed> comp = (x, y) => { var r = CompNamed.Compare (x, y); if (r != 0) return r; var xa = ((CompAttribute)x).Properties.Values.ToList (); var ya = ((CompAttribute)y).Properties.Values.ToList (); for (int i = 0; i < Math.Min (xa.Count, ya.Count); ++i) { r = xa[i].CompareTo (ya[i]); if (r != 0) return r; } return 0; }; reference_attrs.Sort (comp); target_attrs.Sort (comp); while (m < reference_attrs.Count || a < target_attrs.Count) { if (m == reference_attrs.Count) { switch (target_attrs[a].Name) { case "System.Diagnostics.DebuggerDisplayAttribute": case "System.Runtime.CompilerServices.AsyncStateMachineAttribute": case "System.Runtime.CompilerServices.IteratorStateMachineAttribute": case "System.Diagnostics.DebuggerBrowsableAttribute": // Ignore extra attributes in Mono source code break; default: AddExtra (parent, target_attrs[a]); break; } a++; continue; } else if (a == target_attrs.Count) { AddMissing (parent, reference_attrs[m]); m++; continue; } int c = String.Compare (reference_attrs[m].Name, target_attrs[a].Name); comparisons_performed ++; if (c == 0) { /* the names match, further investigation is required */ ComparisonNode comparison = target_attrs[a].GetComparisonNode(); parent.AddChild (comparison); CompareAttributeArguments (comparison, (CompAttribute)reference_attrs[m], (CompAttribute)target_attrs[a]); m++; a++; } else if (c < 0) { /* reference name is before target name, reference name is missing from target */ AddMissing (parent, reference_attrs[m]); m++; } else { /* reference name is after target name, target name is extra */ AddExtra (parent, target_attrs[a]); a++; } } }
void CompareAttributes (ComparisonNode parent, ICompAttributeContainer reference_container, ICompAttributeContainer target_container) { int m = 0, a = 0; List<CompNamed> reference_attrs = reference_container.GetAttributes (); List<CompNamed> target_attrs = target_container.GetAttributes (); reference_attrs.Sort (CompNamed.Compare); target_attrs.Sort (CompNamed.Compare); while (m < reference_attrs.Count || a < target_attrs.Count) { if (m == reference_attrs.Count) { switch (target_attrs[a].Name) { case "System.Diagnostics.DebuggerDisplayAttribute": case "System.Runtime.CompilerServices.AsyncStateMachineAttribute": case "System.Runtime.CompilerServices.IteratorStateMachineAttribute": // Ignore extra attributes in Mono source code break; default: AddExtra (parent, target_attrs[a]); break; } a++; continue; } else if (a == target_attrs.Count) { AddMissing (parent, reference_attrs[m]); m++; continue; } int c = String.Compare (reference_attrs[m].Name, target_attrs[a].Name); comparisons_performed ++; if (c == 0) { /* the names match, further investigation is required */ // Console.WriteLine ("method {0} is in both, doing more comparisons", reference_list[m].Name); ComparisonNode comparison = target_attrs[a].GetComparisonNode(); parent.AddChild (comparison); //CompareParameters (comparison, reference_list[m], target_namespace [target_list[a]]); m++; a++; } else if (c < 0) { /* reference name is before target name, reference name is missing from target */ AddMissing (parent, reference_attrs[m]); m++; } else { /* reference name is after target name, target name is extra */ AddExtra (parent, target_attrs[a]); a++; } } }
void AddMissing(ComparisonNode parent, CompNamed item) { ComparisonNode node = item.GetComparisonNode(); parent.AddChild(node); node.Status = ComparisonStatus.Missing; comparisons_performed++; if (item is ICompHasBaseType) { string baseTypeName = ((ICompHasBaseType)item).GetBaseType(); if (!string.IsNullOrEmpty(baseTypeName)) { ComparisonNode baseTypeNode = new ComparisonNode(CompType.Class, string.Format("BaseType: {0}", baseTypeName), baseTypeName); baseTypeNode.Status = ComparisonStatus.Missing; node.AddChild(baseTypeNode); } } if (item is ICompTypeContainer) { ICompTypeContainer c = (ICompTypeContainer)item; foreach (CompNamed ifc in c.GetNestedInterfaces()) { AddMissing(node, ifc); } foreach (CompNamed cls in c.GetNestedClasses()) { AddMissing(node, cls); } foreach (CompNamed cls in c.GetNestedStructs()) { AddMissing(node, cls); } foreach (CompNamed en in c.GetNestedEnums()) { AddMissing(node, en); } } if (item is ICompMemberContainer) { ICompMemberContainer c = (ICompMemberContainer)item; foreach (CompNamed ifc in c.GetInterfaces()) { AddMissing(node, ifc); } foreach (CompNamed m in c.GetConstructors()) { AddMissing(node, m); } foreach (CompNamed m in c.GetMethods()) { AddMissing(node, m); } foreach (CompNamed p in c.GetProperties()) { AddMissing(node, p); } foreach (CompNamed f in c.GetFields()) { AddMissing(node, f); } foreach (CompNamed e in c.GetEvents()) { AddMissing(node, e); } } if (item is ICompAttributeContainer) { ICompAttributeContainer c = (ICompAttributeContainer)item; foreach (CompNamed attr in c.GetAttributes()) { AddMissing(node, attr); } } }
void CompareAttributes(ComparisonNode parent, ICompAttributeContainer reference_container, ICompAttributeContainer target_container) { int m = 0, a = 0; List <CompNamed> reference_attrs = reference_container.GetAttributes(); List <CompNamed> target_attrs = target_container.GetAttributes(); Comparison <CompNamed> comp = (x, y) => { var r = CompNamed.Compare(x, y); if (r != 0) { return(r); } var xa = ((CompAttribute)x).Properties.Values.ToList(); var ya = ((CompAttribute)y).Properties.Values.ToList(); for (int i = 0; i < Math.Min(xa.Count, ya.Count); ++i) { r = xa[i].CompareTo(ya[i]); if (r != 0) { return(r); } } return(0); }; reference_attrs.Sort(comp); target_attrs.Sort(comp); while (m < reference_attrs.Count || a < target_attrs.Count) { if (m == reference_attrs.Count) { switch (target_attrs[a].Name) { case "System.Diagnostics.DebuggerDisplayAttribute": case "System.Runtime.CompilerServices.AsyncStateMachineAttribute": case "System.Runtime.CompilerServices.IteratorStateMachineAttribute": case "System.Diagnostics.DebuggerBrowsableAttribute": // Ignore extra attributes in Mono source code break; default: AddExtra(parent, target_attrs[a]); break; } a++; continue; } else if (a == target_attrs.Count) { AddMissing(parent, reference_attrs[m]); m++; continue; } int c = String.Compare(reference_attrs[m].Name, target_attrs[a].Name); comparisons_performed++; if (c == 0) { /* the names match, further investigation is required */ ComparisonNode comparison = target_attrs[a].GetComparisonNode(); parent.AddChild(comparison); CompareAttributeArguments(comparison, (CompAttribute)reference_attrs[m], (CompAttribute)target_attrs[a]); m++; a++; } else if (c < 0) { /* reference name is before target name, reference name is missing from target */ AddMissing(parent, reference_attrs[m]); m++; } else { /* reference name is after target name, target name is extra */ AddExtra(parent, target_attrs[a]); a++; } } }
void CompareAttributes(ComparisonNode parent, ICompAttributeContainer reference_container, ICompAttributeContainer target_container) { int m = 0, a = 0; List <CompNamed> reference_attrs = reference_container.GetAttributes(); List <CompNamed> target_attrs = target_container.GetAttributes(); reference_attrs.Sort(CompNamed.Compare); target_attrs.Sort(CompNamed.Compare); while (m < reference_attrs.Count || a < target_attrs.Count) { if (m == reference_attrs.Count) { switch (target_attrs[a].Name) { case "System.Diagnostics.DebuggerDisplayAttribute": case "System.Runtime.CompilerServices.AsyncStateMachineAttribute": case "System.Runtime.CompilerServices.IteratorStateMachineAttribute": // Ignore extra attributes in Mono source code break; default: AddExtra(parent, target_attrs[a]); break; } a++; continue; } else if (a == target_attrs.Count) { AddMissing(parent, reference_attrs[m]); m++; continue; } int c = String.Compare(reference_attrs[m].Name, target_attrs[a].Name); comparisons_performed++; if (c == 0) { /* the names match, further investigation is required */ // Console.WriteLine ("method {0} is in both, doing more comparisons", reference_list[m].Name); ComparisonNode comparison = target_attrs[a].GetComparisonNode(); parent.AddChild(comparison); //CompareParameters (comparison, reference_list[m], target_namespace [target_list[a]]); m++; a++; } else if (c < 0) { /* reference name is before target name, reference name is missing from target */ AddMissing(parent, reference_attrs[m]); m++; } else { /* reference name is after target name, target name is extra */ AddExtra(parent, target_attrs[a]); a++; } } }