protected static bool CompareEnums (AssemblyStuff asm1, AssemblyStuff asm2) { bool res = true; Verifier.Log.Write ("info", "Comparing enums."); foreach (DictionaryEntry e in asm1.enums) { string enumName = e.Key as string; Verifier.Log.Write ("enum", enumName); EnumStuff e1 = e.Value as EnumStuff; EnumStuff e2 = asm2.enums [enumName] as EnumStuff; if (e2 == null) { Verifier.Log.Write ("error", String.Format ("There is no such enum in {0}", asm2.name)); res = false; if (Verifier.stopOnError || !Verifier.ignoreMissingTypes) return res; continue; } res &= (e1 == e2); if (!res && Verifier.stopOnError) return res; } return res; }
protected static bool CompareInterfaces (AssemblyStuff asm1, AssemblyStuff asm2) { bool res = true; Verifier.Log.Write ("info", "Comparing interfaces."); foreach (DictionaryEntry ifc in asm1.interfaces) { string ifcName = ifc.Key as string; Verifier.Log.Write ("interface", ifcName); InterfaceStuff ifc1 = ifc.Value as InterfaceStuff; InterfaceStuff ifc2 = asm2.interfaces [ifcName] as InterfaceStuff; if (ifc2 == null) { Verifier.Log.Write ("error", String.Format ("There is no such interface in {0}", asm2.name)); res = false; if (Verifier.stopOnError || !Verifier.ignoreMissingTypes) return res; continue; } res &= (ifc1 == ifc2); if (!res && Verifier.stopOnError) return res; } return res; }
protected static bool CompareNumInterfaces (AssemblyStuff asm1, AssemblyStuff asm2) { bool res = (asm1.interfaces.Count == asm2.interfaces.Count); if (!res) Verifier.Log.Write ("error", "Number of interfaces mismatch.", ImportanceLevel.MEDIUM); return res; }
protected static bool CompareClasses (AssemblyStuff asm1, AssemblyStuff asm2) { bool res = true; Verifier.Log.Write ("info", "Comparing classes."); foreach (DictionaryEntry c in asm1.classes) { string className = c.Key as string; if (Verifier.Excluded.Contains (className)) { Verifier.Log.Write ("info", String.Format ("Ignoring class {0}.", className), ImportanceLevel.MEDIUM); continue; } Verifier.Log.Write ("class", className); ClassStuff class1 = c.Value as ClassStuff; ClassStuff class2 = asm2.classes [className] as ClassStuff; if (class2 == null) { Verifier.Log.Write ("error", String.Format ("There is no such class in {0}", asm2.name)); res = false; if (Verifier.stopOnError || !Verifier.ignoreMissingTypes) return res; continue; } res &= (class1 == class2); if (!res && Verifier.stopOnError) return res; } return res; }
public static void Main (String [] args) { if (args.Length < 2) { Console.WriteLine ("Usage: verifier assembly1 assembly2"); } else { string name1 = args [0]; string name2 = args [1]; bool ok = false; AssemblyStuff asm1 = new AssemblyStuff (name1); AssemblyStuff asm2 = new AssemblyStuff (name2); ok = asm1.Load (); if (!ok) { Console.WriteLine ("Unable to load assembly {0}.", name1); Environment.Exit (-1); } ok = asm2.Load (); if (!ok) { Console.WriteLine ("Unable to load assembly {0}.", name2); Environment.Exit (-1); } try { ok = (asm1 == asm2); } catch { ok = false; } finally { Log.Close (); } if (!ok) { Console.WriteLine ("--- not equal"); Environment.Exit (-1); } } }