2002-02-22 Nick Drochak <ndrochak@gol.com>
authorNick Drochak <nickd@mono-cvs.ximian.com>
Thu, 21 Feb 2002 11:28:02 +0000 (11:28 -0000)
committerNick Drochak <nickd@mono-cvs.ximian.com>
Thu, 21 Feb 2002 11:28:02 +0000 (11:28 -0000)
* New corcompare directory. Split program into separate class
files and a driver. Creates XML file with missing and todo
classes.  Not quite done with all member types, and also
there's a bug where it adds a todo class more than once.
This is a disaster recovery checkin.

svn path=/trunk/mcs/; revision=2562

mcs/tools/corcompare/CorCompare.cs [new file with mode: 0644]
mcs/tools/corcompare/Makefile [new file with mode: 0644]
mcs/tools/corcompare/MissingMethod.cs [new file with mode: 0644]
mcs/tools/corcompare/MissingProperty.cs [new file with mode: 0644]
mcs/tools/corcompare/MissingType.cs [new file with mode: 0644]
mcs/tools/corcompare/ToDoAssembly.cs [new file with mode: 0644]
mcs/tools/corcompare/ToDoMethod.cs [new file with mode: 0644]
mcs/tools/corcompare/ToDoNameSpace.cs [new file with mode: 0644]
mcs/tools/corcompare/ToDoProperty.cs [new file with mode: 0644]
mcs/tools/corcompare/ToDoType.cs [new file with mode: 0644]

diff --git a/mcs/tools/corcompare/CorCompare.cs b/mcs/tools/corcompare/CorCompare.cs
new file mode 100644 (file)
index 0000000..c1012ae
--- /dev/null
@@ -0,0 +1,43 @@
+// Mono.Util.CorCompare.CorCompareDriver\r
+//\r
+// Author(s):\r
+//   Nick Drochak (ndrochak@gol.com)\r
+//\r
+// (C) 2001-2002 Nick Drochak\r
+\r
+using System;\r
+\r
+namespace Mono.Util.CorCompare {\r
+\r
+       /// <summary>\r
+       ///     Handles command line arguments, and generates appropriate report(s) \r
+       ///     based on those arguments\r
+       /// </summary>\r
+       /// <remarks>\r
+       ///     created by - Nick\r
+       ///     created on - 2/20/2002 10:43:57 PM\r
+       /// </remarks>\r
+       class CorCompareDriver\r
+       {\r
+               public static void Main(string[] args) {\r
+                       // make sure we were called with the proper usage\r
+                       if (args.Length < 1) {\r
+                               Console.WriteLine("Usage: CorCompare [-t][-n][-x outfile] assembly_to_compare");\r
+                               return;\r
+                       }\r
+\r
+                       ToDoAssembly td = new ToDoAssembly(args[args.Length-1], "corlib");\r
+\r
+                       for (int i = 0; i < args.Length-1; i++) {\r
+                               if (args [i] == "-t") {\r
+                                       Console.WriteLine(td.CreateClassListReport());\r
+                               }\r
+                               if (args [i] == "-n") {\r
+                               }\r
+                               if (args [i] == "-x") {\r
+                    td.CreateXMLReport(args[++i]);\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/tools/corcompare/Makefile b/mcs/tools/corcompare/Makefile
new file mode 100644 (file)
index 0000000..89adbeb
--- /dev/null
@@ -0,0 +1,20 @@
+CSC=csc.exe
+CSCFLAGS=/nologo /debug+ /debug:full 
+CORCOMPARE_SRC=CorCompare.cs \
+       ToDoProperty.cs \
+       ToDoNameSpace.cs \
+       MissingProperty.cs \
+       ToDoMethod.cs \
+       MissingMethod.cs \
+       ToDoType.cs \
+       MissingType.cs \
+       ToDoAssembly.cs
+
+all: CorCompare.exe
+
+CorCompare.exe: $(CORCOMPARE_SRC)
+       $(CSC) $(CSCFLAGS) $(CORCOMPARE_SRC) ..\\XMLUtil.cs
+       ./CorCompare.exe -x cormissing.xml ../../class/lib/corlib_cmp.dll
+clean:
+       rm -f *.exe *.pdb *.dll
+       rm -f cormissing.xml
diff --git a/mcs/tools/corcompare/MissingMethod.cs b/mcs/tools/corcompare/MissingMethod.cs
new file mode 100644 (file)
index 0000000..5dc80ca
--- /dev/null
@@ -0,0 +1,40 @@
+// Mono.Util.CorCompare.MissingMethod\r
+//\r
+// Author(s):\r
+//   Nick Drochak (ndrochak@gol.com)\r
+//\r
+// (C) 2001-2002 Nick Drochak\r
+\r
+using System;\r
+using System.Reflection;\r
+\r
+namespace Mono.Util.CorCompare {\r
+\r
+       /// <summary>\r
+       ///     Represents a class method that is completely missing\r
+       /// </summary>\r
+       /// <remarks>\r
+       ///     created by - Nick\r
+       ///     created on - 2/20/2002 10:43:57 PM\r
+       /// </remarks>\r
+       class MissingMethod \r
+       {\r
+               // e.g. <method name="Equals" status="missing"/>\r
+               MethodInfo mInfo;\r
+\r
+               public MissingMethod(MethodInfo info) {\r
+                       mInfo = info;\r
+               }\r
+\r
+               public string Name {\r
+                       get {\r
+                               return mInfo.Name;\r
+                       }\r
+               }\r
+               public virtual string Status {\r
+                       get {\r
+                               return "missing";\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/tools/corcompare/MissingProperty.cs b/mcs/tools/corcompare/MissingProperty.cs
new file mode 100644 (file)
index 0000000..0cfa029
--- /dev/null
@@ -0,0 +1,40 @@
+// Mono.Util.CorCompare.MissingProperty\r
+//\r
+// Author(s):\r
+//   Nick Drochak (ndrochak@gol.com)\r
+//\r
+// (C) 2001-2002 Nick Drochak\r
+\r
+using System;\r
+using System.Reflection;\r
+\r
+namespace Mono.Util.CorCompare {\r
+\r
+       /// <summary>\r
+       ///     Represents a missing property from a class\r
+       /// </summary>\r
+       /// <remarks>\r
+       ///     created by - Nick\r
+       ///     created on - 2/20/2002 10:43:57 PM\r
+       /// </remarks>\r
+       class MissingProperty \r
+       {\r
+               // e.g. <property name="Length" status="missing"/>\r
+               PropertyInfo info;\r
+\r
+               public MissingProperty(PropertyInfo pInfo) {\r
+                       info = pInfo;\r
+               }\r
+\r
+               public string Name {\r
+                       get {\r
+                               return info.Name;\r
+                       }\r
+               }\r
+               public virtual string Status {\r
+                       get {\r
+                               return "missing";\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/tools/corcompare/MissingType.cs b/mcs/tools/corcompare/MissingType.cs
new file mode 100644 (file)
index 0000000..7f21072
--- /dev/null
@@ -0,0 +1,56 @@
+// Mono.Util.CorCompare.MissingType\r
+//\r
+// Author(s):\r
+//   Nick Drochak (ndrochak@gol.com)\r
+//\r
+// (C) 2001-2002 Nick Drochak\r
+\r
+using System;\r
+\r
+namespace Mono.Util.CorCompare {\r
+\r
+       /// <summary>\r
+       ///     Represents a class method that missing.\r
+       /// </summary>\r
+       /// <remarks>\r
+       ///     created by - Nick\r
+       ///     created on - 2/20/2002 10:43:57 PM\r
+       /// </remarks>\r
+       class MissingType \r
+       {\r
+               // e.g. <class name="System.Byte" status="missing"/>\r
+               protected Type theType;\r
+               public MissingType(Type t) {\r
+                       theType = t;\r
+               }\r
+\r
+               public override bool Equals(object o) {\r
+                       if (o is MissingType) {\r
+                               return o.GetHashCode() == this.GetHashCode();\r
+                       }\r
+                       return false;\r
+               }\r
+\r
+               public override int GetHashCode() {\r
+                       return theType.GetHashCode();\r
+               }\r
+\r
+               public string Name {\r
+                       get {\r
+                               return theType.Name;\r
+                       }\r
+               }\r
+\r
+               public string NameSpace {\r
+                       get {\r
+                               return theType.Namespace;\r
+                       }\r
+               }\r
+\r
+               public virtual string Status {\r
+                       get {\r
+                               return "missing";\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/tools/corcompare/ToDoAssembly.cs b/mcs/tools/corcompare/ToDoAssembly.cs
new file mode 100644 (file)
index 0000000..6862ca7
--- /dev/null
@@ -0,0 +1,328 @@
+// Mono.Util.CorCompare.ToDoAssembly\r
+//\r
+// Author(s):\r
+//   Nick Drochak (ndrochak@gol.com)\r
+//\r
+// (C) 2001-2002 Nick Drochak\r
+\r
+using System;\r
+using System.Reflection;\r
+using System.Collections;\r
+using System.IO;\r
+using System.Text;\r
+using System.Xml;\r
+\r
+namespace Mono.Util.CorCompare {\r
+\r
+       /// <summary>\r
+       ///     Represents an assembly that has missing or MonoTODO classes\r
+       /// </summary>\r
+       /// <remarks>\r
+       ///     created by - Nick\r
+       ///     created on - 2/20/2002 10:43:57 PM\r
+       /// </remarks>\r
+       class ToDoAssembly\r
+       {\r
+               // these types are in mono corlib, but not in the dll we are going to examine.\r
+               static string[] ghostTypes = {"System.Object", "System.ValueType", "System.Delegate", "System.Enum"};\r
+               ArrayList MissingTypes = new ArrayList();\r
+               string assemblyToCompare;\r
+               bool analyzed = false;\r
+               ArrayList todoNameSpaces = new ArrayList();\r
+               string name;\r
+\r
+               public ToDoAssembly(string fileName, string friendlyName)\r
+               {\r
+                       assemblyToCompare = fileName;\r
+                       name = friendlyName;\r
+               }\r
+\r
+               public string Name {\r
+                       get {\r
+                               return name;\r
+                       }\r
+               }\r
+\r
+               public int MissingCount {\r
+                       get {\r
+                               int sum = 0;\r
+                               foreach(ToDoNameSpace ns in todoNameSpaces) {\r
+                                       sum += ns.MissingCount;\r
+                               }\r
+                               return sum;\r
+                       }\r
+               }\r
+\r
+               public int ReferenceTypeCount {\r
+                       get {\r
+                               int sum = 0;\r
+                               foreach(ToDoNameSpace ns in todoNameSpaces) {\r
+                                       sum += ns.ReferenceTypeCount;\r
+                               }\r
+                               return sum;\r
+                       }\r
+               }\r
+\r
+               bool Analyze()\r
+               {\r
+                       if (analyzed) return true;\r
+\r
+                       Type[] mscorlibTypes = GetReferenceTypes();\r
+                       if (mscorlibTypes == null)\r
+                       {\r
+                               Console.WriteLine("Could not find corlib file: {0}", assemblyToCompare);\r
+                               return false;\r
+                       }\r
+\r
+                       Type[] monocorlibTypes = GetMonoTypes();\r
+\r
+                       foreach(string ns in ToDoNameSpace.GetNamespaces(monocorlibTypes)) {\r
+                               todoNameSpaces.Add(new ToDoNameSpace(ns, monocorlibTypes, mscorlibTypes));\r
+                       }\r
+\r
+                       analyzed = true;\r
+                       return true;\r
+/* ///////////////////////////////////////////////////////////////////////////////// stuff below here needs to be moved into classes above.\r
+\r
+                       ArrayList TypesList = new ArrayList();\r
+\r
+                       // load the classes we know should exist, but aren't in the dll\r
+                       foreach (string name in ghostTypes){\r
+                               TypesList.Add(name);\r
+                       }\r
+\r
+                       Hashtable monoMethodMap = new Hashtable();\r
+                       MethodInfo[] methods;\r
+                       ArrayList nameList = new ArrayList();\r
+                       // whether GetTypes() worked or not, we will have _some_ types here\r
+                       foreach(Type subt in monocorlibTypes)\r
+                       {\r
+                               if (null != subt && !TypesList.Contains(subt.FullName)) {\r
+                                       TypesList.Add(subt.FullName);\r
+\r
+                                       methods = subt.GetMethods();\r
+\r
+                                       nameList = GetMungedNames(methods);\r
+\r
+                                       monoMethodMap.Add(subt.FullName, nameList);\r
+                               }\r
+                       }\r
+\r
+                       // going to use BinarySearch, so sort first\r
+                       TypesList.Sort();\r
+                       \r
+                       ArrayList PartialClasses = new ArrayList();\r
+                       ArrayList MissingMethods = new ArrayList();\r
+                       bool foundit = false;\r
+\r
+                       // make list of ms types not in mono\r
+                       foreach(Type t in mscorlibTypes) {\r
+                               if (t.IsPublic) {\r
+                                       foundit = (TypesList.BinarySearch(t.FullName) >= 0);\r
+                                       if (foundit) \r
+                                       {\r
+                                               // look for missing members\r
+                                               nameList = GetMungedNames(t.GetMethods());\r
+                                               foreach (string name in nameList)\r
+                                               {\r
+                                                       ArrayList monoNames = (ArrayList)monoMethodMap[t.FullName];\r
+                                                       if (monoNames != null)\r
+                                                       {\r
+                                                               monoNames.Sort();\r
+                                                               if (monoNames.BinarySearch(name) < 0)\r
+                                                               {\r
+                                                                       MissingMethods.Add(t.FullName + "::" + name);\r
+\r
+                                                                       if (!PartialClasses.Contains(t.FullName))\r
+                                                                       {\r
+                                                                               PartialClasses.Add(t.FullName);\r
+                                                                       }\r
+                                                                       \r
+                                                               }\r
+\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               MissingTypes.Add(t.FullName);\r
+                                       }\r
+                               }\r
+                       }\r
+                       foreach (string pc in PartialClasses)\r
+                       {\r
+                               int missingInClass = GetMethodCount(MissingMethods, pc);\r
+                       }\r
+*/\r
+               }\r
+\r
+               public Type[] GetReferenceTypes()\r
+               {\r
+                       // get the types in the corlib we are running with\r
+                       Assembly msAsmbl = Assembly.GetAssembly(typeof (System.Object));\r
+                       Type[] mscorlibTypes = msAsmbl.GetTypes();\r
+                       return mscorlibTypes;\r
+               }\r
+\r
+               public Type[] GetMonoTypes()\r
+               {\r
+                       Type[] monocorlibTypes;\r
+                       Assembly monoAsmbl = null;\r
+                       try\r
+                       {\r
+                               monoAsmbl = Assembly.LoadFrom(assemblyToCompare);\r
+                       }\r
+                       catch(FileNotFoundException)\r
+                       {\r
+                               return null;\r
+                       }\r
+\r
+                       monocorlibTypes = monoAsmbl.GetTypes();\r
+\r
+                       return monocorlibTypes;\r
+               }\r
+\r
+               public string CreateClassListReport() {\r
+                       if (!Analyze() || todoNameSpaces.Count == 0) return "";\r
+\r
+                       StringBuilder output = new StringBuilder();\r
+                       foreach (ToDoNameSpace ns in todoNameSpaces)\r
+                       {\r
+                               string[] missingTypes = ns.MissingTypeNames(true);\r
+                               if (missingTypes.Length > 0) {\r
+                                       string joinedNames = String.Join("\n", missingTypes);\r
+                                       output.Append(joinedNames + "\n");\r
+                               }\r
+                       }\r
+                       return output.ToString();\r
+               }\r
+\r
+               public void CreateXMLReport(string filename) {\r
+                       bool analyzedOK = Analyze();\r
+\r
+                       XmlDocument outDoc;\r
+                       outDoc = new XmlDocument();\r
+                       outDoc.AppendChild(outDoc.CreateXmlDeclaration("1.0", null, null));\r
+                       XmlElement assembliesElem = outDoc.CreateElement("assemblies");\r
+                       outDoc.AppendChild(assembliesElem);\r
+                       XmlElement assemblyElem = outDoc.CreateElement("assembly");\r
+                       assemblyElem.SetAttribute("name", this.Name);\r
+                       assemblyElem.SetAttribute("missing", this.MissingCount.ToString());\r
+                       assemblyElem.SetAttribute("complete", (100 - 100 * this.MissingCount / this.ReferenceTypeCount).ToString());\r
+                       assembliesElem.AppendChild(assemblyElem);\r
+                       XmlElement namespacesElem = outDoc.CreateElement("namespaces");\r
+                       assemblyElem.AppendChild(namespacesElem);\r
+\r
+                       if (analyzedOK && todoNameSpaces.Count > 0) {\r
+                               XmlElement namespaceElem;\r
+                               XmlElement classesElem;\r
+                               XmlElement classElem;\r
+                               foreach (ToDoNameSpace ns in todoNameSpaces) {\r
+                                       namespaceElem = outDoc.CreateElement("namespace");\r
+                                       namespaceElem.SetAttribute("name", ns.name);\r
+                                       MissingType[] missingTypes = ns.MissingTypes;\r
+                                       classesElem = null;\r
+                                       if (missingTypes.Length > 0) {\r
+                                               classesElem = outDoc.CreateElement("classes");\r
+                                               namespaceElem.AppendChild(classesElem);\r
+\r
+                                               foreach (MissingType type in missingTypes) {\r
+                                                       classElem = outDoc.CreateElement("class");\r
+                                                       classElem.SetAttribute("name", type.Name);\r
+                                                       classElem.SetAttribute("status", type.Status);\r
+                                                       classesElem.AppendChild(classElem);\r
+                                               }\r
+\r
+                                               namespaceElem.SetAttribute("missing", ns.MissingCount.ToString());\r
+                                       }\r
+\r
+                                       ToDoType[] todoTypes = ns.ToDoTypes;\r
+                                       if (todoTypes.Length > 0) {\r
+                                               if (classesElem == null) {\r
+                                                       classesElem = outDoc.CreateElement("classes");\r
+                                                       namespaceElem.AppendChild(classesElem);\r
+                                               }\r
+                                               foreach (ToDoType type in todoTypes) {\r
+                                                       classElem = outDoc.CreateElement("class");\r
+                                                       classElem.SetAttribute("name", type.Name);\r
+                                                       classElem.SetAttribute("status", type.Status);\r
+                                                       classesElem.AppendChild(classElem);\r
+                                               }\r
+                                               namespaceElem.SetAttribute("todo", ns.ToDoCount.ToString());\r
+                                       }\r
+                                       if (ns.ReferenceTypeCount > 0) {\r
+                                               namespaceElem.SetAttribute("complete", (100 - 100 * (ns.MissingCount + ns.ToDoCount) / ns.ReferenceTypeCount).ToString());\r
+                                       }\r
+                                       else {\r
+                                               namespaceElem.SetAttribute("complete", "100");\r
+                                       }\r
+                                       namespacesElem.AppendChild(namespaceElem);\r
+                               }\r
+                       }\r
+                       \r
+                       outDoc.Save(filename);\r
+               }\r
+\r
+               static int GetMethodCount(ArrayList methods, string className) {\r
+                       int count = 0;\r
+                       foreach (string method in methods) {\r
+                               // starts with is not enough. for instance, they all start with "System"\r
+                               if (method.StartsWith(className)) {\r
+                                       count++;\r
+                               }\r
+                       }\r
+                       return count;\r
+               }\r
+                       \r
+               static int GetClassCount(ArrayList types, string ns) {\r
+                       int count = 0;\r
+                       foreach (string type in types) {\r
+                               // starts with is not enough. for instance, they all start with "System"\r
+                               if (type.StartsWith(ns+".") && type.IndexOf(".", ns.Length+1) < 0) {\r
+                                       count++;\r
+                               }\r
+                       }\r
+                       return count;\r
+               }\r
+\r
+               static int GetMSClassCount(Type[] types, string ns)\r
+               {\r
+                       int count = 0;\r
+                       for (int i=0; i < types.Length; i++)\r
+                       {\r
+                               if (types[i].Namespace == ns)\r
+                               {\r
+                                       count++;\r
+                               }\r
+                       }\r
+                       return count;\r
+               }\r
+\r
+               static ArrayList GetMungedNames(MethodInfo[] methods)\r
+               {\r
+                       ArrayList nameList = new ArrayList();\r
+                       foreach(MethodInfo method in methods)\r
+                       {\r
+                               StringBuilder methodMungedName = new StringBuilder(method.Name + "(");\r
+                               ParameterInfo[] parameters = method.GetParameters();\r
+                               ArrayList parameterTypes = new ArrayList();\r
+                               foreach(ParameterInfo parameter in parameters)\r
+                               {\r
+                                       parameterTypes.Insert(parameter.Position, parameter.ParameterType.Name);\r
+                               }\r
+                                               \r
+                               foreach(string parameterTypeName in parameterTypes)\r
+                               {\r
+                                       if (!methodMungedName.ToString().EndsWith("("))\r
+                                               methodMungedName.Append(",");\r
+                                       methodMungedName.Append(parameterTypeName);\r
+                               }\r
+\r
+                               methodMungedName.Append(")");\r
+                               nameList.Add(methodMungedName.ToString());\r
+                       }\r
+\r
+                       return nameList;\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/tools/corcompare/ToDoMethod.cs b/mcs/tools/corcompare/ToDoMethod.cs
new file mode 100644 (file)
index 0000000..1aa9544
--- /dev/null
@@ -0,0 +1,41 @@
+// Mono.Util.CorCompare.ToDoMethod\r
+//\r
+// Author(s):\r
+//   Nick Drochak (ndrochak@gol.com)\r
+//\r
+// (C) 2001-2002 Nick Drochak\r
+\r
+using System;\r
+using System.Reflection;\r
+\r
+namespace Mono.Util.CorCompare {\r
+\r
+       /// <summary>\r
+       ///     Represents a class method that is marked with MonoTODO\r
+       /// </summary>\r
+       /// <remarks>\r
+       ///     created by - Nick\r
+       ///     created on - 2/20/2002 10:43:57 PM\r
+       /// </remarks>\r
+       class ToDoMethod : MissingMethod \r
+       {\r
+               // e.g. <method name="ToString" status="todo" note="this is the note from MonoTODO"/>\r
+               string todoNote = "";\r
+\r
+               public ToDoMethod(MethodInfo info) : base(info) {\r
+               }\r
+               public ToDoMethod(MethodInfo info, string note) :base(info) {\r
+                       todoNote = note;\r
+               }\r
+               public string Note {\r
+                       get {\r
+                               return todoNote;\r
+                       }\r
+               }\r
+               public override string Status {\r
+                       get {\r
+                               return "todo";\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/tools/corcompare/ToDoNameSpace.cs b/mcs/tools/corcompare/ToDoNameSpace.cs
new file mode 100644 (file)
index 0000000..168e359
--- /dev/null
@@ -0,0 +1,269 @@
+// Mono.Util.CorCompare.ToDoNameSpace\r
+//\r
+// Author(s):\r
+//   Nick Drochak (ndrochak@gol.com)\r
+//\r
+// (C) 2001-2002 Nick Drochak\r
+\r
+using System;\r
+using System.Collections;\r
+using System.Reflection;\r
+\r
+namespace Mono.Util.CorCompare {\r
+\r
+       /// <summary>\r
+       ///     Represents a namespace that has missing and/or MonoTODO classes.\r
+       /// </summary>\r
+       /// <remarks>\r
+       ///     created by - Nick\r
+       ///     created on - 2/20/2002 10:43:57 PM\r
+       /// </remarks>\r
+       class ToDoNameSpace \r
+       {\r
+               // e.g. <namespace name="System" missing="267" todo="453" complete="21">\r
+               MissingType[] missingTypes;\r
+               ToDoType[] todoTypes;\r
+               public string name;\r
+               int complete = 0;\r
+               Type[] existingTypes;\r
+               int referenceTypeCount;\r
+\r
+               public static ArrayList GetNamespaces(Type[] types) {\r
+                       ArrayList nsList = new ArrayList();\r
+                       foreach (Type t in types) {\r
+                               if (!nsList.Contains(t.Namespace)) {\r
+                                       nsList.Add(t.Namespace);\r
+                               }\r
+                       }\r
+                       return nsList;\r
+               }\r
+\r
+               public ToDoNameSpace(string nameSpace, Type[] types) {\r
+                       name = nameSpace;\r
+                       existingTypes = Filter(types, name);\r
+               }\r
+\r
+               public ToDoNameSpace(string nameSpace, Type[] types, \r
+                                    Type[] referenceTypes) {\r
+                       name = nameSpace;\r
+                       existingTypes = Filter(types, name);\r
+                       CompareWith(referenceTypes);\r
+               }\r
+\r
+               public int MissingCount {\r
+                       get {\r
+                               return missingTypes.Length;\r
+                       }\r
+               }\r
+\r
+               public int ToDoCount {\r
+                       get {\r
+                               return todoTypes.Length;\r
+                       }\r
+               }\r
+\r
+               public int ReferenceTypeCount {\r
+                       get {\r
+                               return referenceTypeCount;\r
+                       }\r
+               }\r
+\r
+               Type[] Filter(Type[] types, string ns) {\r
+                       ArrayList filteredTypes = new ArrayList();\r
+                       foreach(Type t in types) {\r
+                               if (t.Namespace == ns) {\r
+                                       filteredTypes.Add(t);\r
+                               }\r
+                       }\r
+                       return (Type[])filteredTypes.ToArray(typeof(Type));\r
+               }\r
+\r
+               public int Complete {\r
+                       get {\r
+                               return complete;\r
+                       }\r
+               }\r
+\r
+               public void CompareWith(Type[] referenceTypes) {\r
+                       Type[] filteredReferenceTypes = Filter(referenceTypes, name);\r
+                       referenceTypeCount = 0;\r
+                       if (null != existingTypes) {\r
+                               referenceTypeCount = filteredReferenceTypes.Length;\r
+                               missingTypes = GetMissingTypes(filteredReferenceTypes);\r
+                               todoTypes = GetToDoTypes(filteredReferenceTypes);\r
+                               if (null != filteredReferenceTypes && \r
+                                       filteredReferenceTypes.Length > 0) {\r
+                                       int needLoveCount = 0;\r
+                                       if (null != missingTypes) {\r
+                                               needLoveCount += missingTypes.Length;\r
+                                       }\r
+                                       if (null != todoTypes) {\r
+                                               needLoveCount += todoTypes.Length;\r
+                                       }\r
+                                       complete = 100 * needLoveCount / \r
+                                                               filteredReferenceTypes.Length;\r
+                               }\r
+                       }\r
+               }\r
+\r
+               MissingType[] GetMissingTypes(Type[] referenceTypes) {\r
+                       ArrayList TypesList = new ArrayList();\r
+                       ArrayList MissingTypes = new ArrayList();\r
+                       bool foundIt;\r
+                       foreach(Type subt in existingTypes) {\r
+                               if (null != subt && !TypesList.Contains(subt.Name)) {\r
+                                       TypesList.Add(subt.Name);\r
+                               }\r
+                       } \r
+                       TypesList.Sort();\r
+                       foreach(Type t in referenceTypes) {\r
+                               foundIt = (TypesList.BinarySearch(t.Name) >= 0);\r
+                               if (t.IsPublic && !foundIt) {\r
+                                       MissingTypes.Add(new MissingType(t));\r
+                               }\r
+                       }\r
+                       return (MissingType[])MissingTypes.ToArray(typeof(MissingType));\r
+               }\r
+\r
+               ToDoType[] GetToDoTypes(Type[] referenceTypes) {\r
+                       // todo types are those marked with [MonoTODO] or having missing or\r
+                       // todo members\r
+                       ArrayList TypesList = new ArrayList();\r
+                       ArrayList ToDoTypes = new ArrayList();\r
+\r
+                       bool foundIt = false;\r
+                       Object[] myAttributes;\r
+\r
+                       // look at all the existing types in this namespace for MonoTODO attrib\r
+                       foreach(Type t in existingTypes) {\r
+                               // assume we won't find it\r
+                               foundIt = false;\r
+\r
+                               // get all the custom attributes on the type\r
+                               myAttributes = t.GetCustomAttributes(false);\r
+                               foreach (object o in myAttributes) {\r
+                                       // check to see if any of them are the MonoTODO attrib\r
+                                       if (o.ToString() == "System.MonoTODOAttribute"){\r
+                                               // if so, this is a todo type \r
+                                               ToDoTypes.Add(new ToDoType(t));\r
+                                               // and we can stop look at the custom attribs\r
+                                               break;\r
+                                       }\r
+                               }\r
+\r
+                               // look at all the members of the type\r
+                               foreach (MemberInfo mi in t.GetMembers()) {\r
+                                       // see if any of them have the MonoTODO attrib\r
+                                       myAttributes = mi.GetCustomAttributes(false);\r
+                                       foreach (object o in myAttributes) {\r
+                                               if (o.ToString() == "System.MonoTODOAttribute") {\r
+                                                       // the first time we find one for this type add the type to the list\r
+                                                       if (!foundIt) {\r
+                                                               ToDoTypes.Add(new ToDoType(t));\r
+                                                               foundIt = true;\r
+                                                       }\r
+                                                       // add any todo member infos to the todo type\r
+                                                       ((ToDoType)(ToDoTypes[ToDoTypes.Count-1])).AddToDoMember(mi);\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+                       // find types with missing members\r
+                       foreach (Type t in referenceTypes) {\r
+                               bool addedIt = false;\r
+                               int index = -1;\r
+\r
+                               foreach (MemberInfo mi in t.GetMembers()) {\r
+                                       if (IsMissingMember(mi, t.Name, existingTypes)) {\r
+                                               if (!addedIt) {\r
+                                                       index = ToDoType.IndexOf(t, ToDoTypes);\r
+                                                       if (index >= 0) {\r
+                                                               addedIt = true;\r
+                                                       }\r
+                                                       else {\r
+                                                               index = ToDoTypes.Add(new ToDoType(t));\r
+                                                               addedIt = true;\r
+                                                       }\r
+                                               }\r
+                                               ((ToDoType)(ToDoTypes[index])).AddMissingMember(mi);\r
+                                       }\r
+                               }                                       \r
+                       }\r
+\r
+                       return (ToDoType[])ToDoTypes.ToArray(typeof(ToDoType));\r
+               }\r
+\r
+               static bool IsMissingMember(MemberInfo mi, string typeName, Type[] typesToSearch) {\r
+                       foreach (Type t in typesToSearch) {\r
+                               if (t.Name == typeName) {\r
+                                       foreach (MemberInfo trialMI in t.GetMembers()) {\r
+                                               if (mi.Name == trialMI.Name && mi.MemberType == trialMI.MemberType) {\r
+                                                       if (mi.MemberType == MemberTypes.Method) {\r
+                                                               if (IsParameterListEqual(((MethodInfo)mi).GetParameters(), ((MethodInfo)trialMI).GetParameters())) {\r
+                                                                       return false;\r
+                                                               }\r
+                                                               else {\r
+                                                                       return true;\r
+                                                               }\r
+                                                       }\r
+                                                       else {\r
+                                                               return false;\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+                       return false;\r
+               }\r
+\r
+               static bool IsParameterListEqual(ParameterInfo[] piArray1, ParameterInfo[] piArray2) {\r
+                       if (piArray1.Length != piArray2.Length) {\r
+                               return false;\r
+                       }\r
+\r
+                       foreach (ParameterInfo pi1 in piArray1) {\r
+                               if (pi1.ParameterType.Name != GetTypeAt(pi1.Position, piArray2).Name) {\r
+                                       return false;\r
+                               }\r
+                       }\r
+\r
+                       return true;\r
+               }\r
+\r
+               static Type GetTypeAt(int position, ParameterInfo[] piArray){\r
+                       foreach (ParameterInfo pi in piArray) {\r
+                               if (pi.Position == position) {\r
+                                               return pi.ParameterType;\r
+                               }\r
+                       }\r
+                       throw new Exception("contract violation: need to call with existing position");\r
+               }\r
+\r
+               public MissingType[] MissingTypes {\r
+                       get {\r
+                               return missingTypes;\r
+                       }\r
+               }\r
+\r
+               public ToDoType[] ToDoTypes {\r
+                       get {\r
+                               return todoTypes;\r
+                       }\r
+               }\r
+\r
+               public string[] MissingTypeNames(bool qualify){\r
+                       ArrayList names = new ArrayList();\r
+                       if (qualify) {\r
+                               foreach (MissingType t in missingTypes) {\r
+                                       names.Add(t.NameSpace + "." + t.Name);\r
+                               }\r
+                       }\r
+                       else {\r
+                               foreach (MissingType t in missingTypes) {\r
+                                       names.Add(t.Name);\r
+                               }\r
+                       }\r
+                       return (string[])names.ToArray(typeof(string));\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/tools/corcompare/ToDoProperty.cs b/mcs/tools/corcompare/ToDoProperty.cs
new file mode 100644 (file)
index 0000000..5929bb6
--- /dev/null
@@ -0,0 +1,41 @@
+// Mono.Util.CorCompare.ToDoProperty\r
+//\r
+// Author(s):\r
+//   Nick Drochak (ndrochak@gol.com)\r
+//\r
+// (C) 2001-2002 Nick Drochak\r
+\r
+using System;\r
+using System.Reflection;\r
+\r
+namespace Mono.Util.CorCompare {\r
+\r
+       /// <summary>\r
+       ///     Represents a class's property that is marked with a MonoTODO\r
+       /// </summary>\r
+       /// <remarks>\r
+       ///     created by - Nick\r
+       ///     created on - 2/20/2002 10:43:57 PM\r
+       /// </remarks>\r
+       class ToDoProperty : MissingProperty \r
+       {\r
+               // e.g. <property name="Count" status="todo" note="another note"/>\r
+               string todoNote = "";\r
+\r
+               public ToDoProperty(PropertyInfo pInfo) : base(pInfo) {\r
+               }\r
+               public ToDoProperty(PropertyInfo pInfo, string note) :base(pInfo) {\r
+                       todoNote = note;\r
+               }\r
+               public string Note {\r
+                       get {\r
+                               return todoNote;\r
+                       }\r
+               }\r
+               public override string Status {\r
+                       get {\r
+                               return "todo";\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/tools/corcompare/ToDoType.cs b/mcs/tools/corcompare/ToDoType.cs
new file mode 100644 (file)
index 0000000..a9ea0cf
--- /dev/null
@@ -0,0 +1,133 @@
+// Mono.Util.CorCompare.ToDoType\r
+//\r
+// Author(s):\r
+//   Nick Drochak (ndrochak@gol.com)\r
+//\r
+// (C) 2001-2002 Nick Drochak\r
+\r
+using System;\r
+using System.Reflection;\r
+using System.Collections;\r
+\r
+namespace Mono.Util.CorCompare {\r
+\r
+       /// <summary>\r
+       ///     Represents a class that is marked with MonoTODO\r
+       /// </summary>\r
+       /// <remarks>\r
+       ///     created by - Nick\r
+       ///     created on - 2/20/2002 10:43:57 PM\r
+       /// </remarks>\r
+       class ToDoType : MissingType \r
+       {\r
+               // e.g. <class name="System.Array" status="todo" missing="5" todo="6" complete="45">\r
+               \r
+               ArrayList missingMethodList = new ArrayList();\r
+               public MissingMethod[] MissingMethods {\r
+                       get {\r
+                               return (MissingMethod[])missingMethodList.ToArray(typeof(MissingMethod));\r
+                       }\r
+               }\r
+\r
+               ArrayList todoMethodList = new ArrayList();\r
+               public ToDoMethod[] ToDoMethods {\r
+                       get {\r
+                               return (ToDoMethod[])todoMethodList.ToArray(typeof(ToDoMethod));\r
+                       }\r
+               }\r
+\r
+               ArrayList missingPropertyList = new ArrayList();\r
+               public MissingProperty[] MissingProperties {\r
+                       get {\r
+                               return (MissingProperty[])missingPropertyList.ToArray(typeof(MissingProperty));\r
+                       }\r
+               }\r
+               ArrayList todoPropertyList = new ArrayList();\r
+               public ToDoProperty[] ToDoProperties {\r
+                       get {\r
+                               return (ToDoProperty[])todoPropertyList.ToArray(typeof(ToDoProperty));\r
+                       }\r
+               }\r
+\r
+               int complete;\r
+\r
+               public ToDoType(Type t) : base(t) {\r
+               }\r
+\r
+               public int MissingCount {\r
+                       get {\r
+                               return MissingMethods.Length + MissingProperties.Length;\r
+                       }\r
+               }\r
+\r
+               public int ToDoCount {\r
+                       get {\r
+                               return ToDoMethods.Length + ToDoProperties.Length;\r
+                       }\r
+               }\r
+               \r
+               public int Complete {\r
+                       get {\r
+                               return complete;\r
+                       }\r
+               }\r
+               \r
+               public static int IndexOf(Type t, ArrayList todoTypes) {\r
+                       for(int index = 0; index < todoTypes.Count; index++) {\r
+                               if (((ToDoType)todoTypes[index]).Name == t.Name) {\r
+                                       return index;\r
+                               }\r
+                       }\r
+                       return -1;\r
+               }\r
+\r
+               public void CompareWith(Type referenceType) {\r
+                       //TODO: Next discover the missing methods, properties, etc.\r
+                       GetMissingMethods(referenceType.GetMethods());\r
+                       complete = 0;\r
+               }\r
+\r
+               void GetMissingMethods(MethodInfo[] referenceMethods) {\r
+                       ArrayList referenceMethodList = new ArrayList(referenceMethods);\r
+                       ArrayList MethodList = new ArrayList(theType.GetMethods());\r
+                       foreach (MethodInfo method in referenceMethods) {\r
+                               if (!MethodList.Contains(method)) {\r
+                                       missingMethodList.Add(method);\r
+                               }\r
+                       }\r
+               }\r
+\r
+               public override string Status {\r
+                       get {\r
+                               return "todo";\r
+                       }\r
+               }\r
+\r
+               public void AddToDoMember(MemberInfo info){\r
+                       switch (info.MemberType){\r
+                               case MemberTypes.Method:\r
+                                       todoMethodList.Add(info);\r
+                                       break;\r
+                               case MemberTypes.Property:\r
+                                       todoPropertyList.Add(info);\r
+                                       break;\r
+                               default:\r
+                                       break;\r
+                                       //throw new Exception("Didn't code that member type yet");\r
+                       }\r
+               }\r
+\r
+               public void AddMissingMember(MemberInfo info){\r
+                       switch (info.MemberType){\r
+                               case MemberTypes.Method:\r
+                                       missingMethodList.Add(info);\r
+                                       break;\r
+                               case MemberTypes.Property:\r
+                                       missingPropertyList.Add(info);\r
+                                       break;\r
+                               default:\r
+                                       throw new Exception("Didn't code that member type yet");\r
+                       }\r
+               }\r
+       }\r
+}\r