-// 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
+// Mono.Util.CorCompare.CorCompareDriver
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Handles command line arguments, and generates appropriate report(s)
+ /// based on those arguments
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class CorCompareDriver
+ {
+ public static void Main(string[] args) {
+ // make sure we were called with the proper usage
+ if (args.Length < 1) {
+ Console.WriteLine("Usage: CorCompare [-t][-n][-x outfile] assembly_to_compare");
+ return;
+ }
+
+ ToDoAssembly td = new ToDoAssembly(args[args.Length-1], "corlib");
+
+ for (int i = 0; i < args.Length-1; i++) {
+ if (args [i] == "-t") {
+ Console.WriteLine(td.CreateClassListReport());
+ }
+ if (args [i] == "-n") {
+ }
+ if (args [i] == "-x") {
+ td.CreateXMLReport(args[++i]);
+ }
+ }
+ }
+ }
+}
-// Mono.Util.CorCompare.IMissingMember\r
-//\r
-// Author(s):\r
-// Nick Drochak (ndrochak@gol.com)\r
-//\r
-// (C) 2001-2002 Nick Drochak\r
-\r
-namespace Mono.Util.CorCompare {\r
-\r
- interface IMissingMember \r
- {\r
- string Name { get ; }\r
-\r
- string Status { get; }\r
-\r
- string Type { get; }\r
- }\r
-}\r
+// Mono.Util.CorCompare.IMissingMember
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+using System.Xml;
+
+namespace Mono.Util.CorCompare {
+
+ interface IMissingMember
+ {
+ string Name { get ; }
+
+ string Status { get; }
+
+ string Type { get; }
+
+ XmlElement CreateXML (XmlDocument doc);
+ }
+}
/// created by - Nick
/// created on - 2/24/2002 10:43:57 PM
/// </remarks>
- class MissingConstructor : IMissingMember {
+ class MissingConstructor : MissingMember {
// e.g. <method name="Equals" status="missing"/>
- MemberInfo mInfo;
+ public MissingConstructor (MemberInfo info) : base (info) {}
- public MissingConstructor(MemberInfo info) {
- mInfo = info;
- }
-
- public string Name {
+ public override string Name {
get {
//return mInfo.Name;
string s = mInfo.ToString();
}
}
- public virtual string Status {
- get {
- return "missing";
- }
- }
-
- public string Type {
+ public override string Type {
get {
return "constructor";
}
-// Mono.Util.CorCompare.MissingEvent\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 event that is completely missing\r
- /// </summary>\r
- /// <remarks>\r
- /// created by - Nick\r
- /// created on - 2/24/2002 10:43:57 PM\r
- /// </remarks>\r
- class MissingEvent : IMissingMember {\r
- // e.g. <method name="Equals" status="missing"/>\r
- MemberInfo mInfo;\r
-\r
- public MissingEvent(MemberInfo info) {\r
- mInfo = info;\r
- }\r
-\r
- public string Name {\r
- get {\r
- return mInfo.Name;\r
- }\r
- }\r
-\r
- public virtual string Status {\r
- get {\r
- return "missing";\r
- }\r
- }\r
-\r
- public string Type {\r
- get {\r
- return "event";\r
- }\r
- }\r
- }\r
-}\r
+// Mono.Util.CorCompare.MissingEvent
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class event that is completely missing
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/24/2002 10:43:57 PM
+ /// </remarks>
+ class MissingEvent : MissingMember {
+ // e.g. <method name="Equals" status="missing"/>
+ public MissingEvent (MemberInfo info) : base (info) {}
+
+ public override string Type {
+ get {
+ return "event";
+ }
+ }
+ }
+}
-// Mono.Util.CorCompare.MissingField\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 event that is completely missing\r
- /// </summary>\r
- /// <remarks>\r
- /// created by - Nick\r
- /// created on - 2/24/2002 10:43:57 PM\r
- /// </remarks>\r
- class MissingField : IMissingMember {\r
- // e.g. <method name="Equals" status="missing"/>\r
- MemberInfo mInfo;\r
-\r
- public MissingField(MemberInfo info) {\r
- mInfo = info;\r
- }\r
-\r
- public string Name {\r
- get {\r
- return mInfo.Name;\r
- }\r
- }\r
-\r
- public virtual string Status {\r
- get {\r
- return "missing";\r
- }\r
- }\r
-\r
- public string Type {\r
- get {\r
- return "field";\r
- }\r
- }\r
- }\r
-}\r
+// Mono.Util.CorCompare.MissingField
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class event that is completely missing
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/24/2002 10:43:57 PM
+ /// </remarks>
+ class MissingField : MissingMember {
+ // e.g. <method name="Equals" status="missing"/>
+ public MissingField (MemberInfo info) : base (info) {}
+
+ public override string Type {
+ get {
+ return "field";
+ }
+ }
+ }
+}
-// 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
-using System.Text;\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 : IMissingMember \r
- {\r
- // e.g. <method name="Equals" status="missing"/>\r
- MemberInfo mInfo;\r
-\r
- public MissingMethod(MemberInfo info) {\r
- mInfo = info;\r
- }\r
-\r
- public string Name {\r
- get {\r
- string s = mInfo.ToString();\r
- int index = s.IndexOf(' ');\r
- return s.Substring(index + 1);\r
- }\r
- }\r
-\r
- public virtual string Status {\r
- get {\r
- return "missing";\r
- }\r
- }\r
-\r
- public string Type {\r
- get {\r
- return "method";\r
- }\r
- }\r
- }\r
-}\r
+// Mono.Util.CorCompare.MissingMethod
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+using System.Text;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class method that is completely missing
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class MissingMethod : MissingMember
+ {
+ // e.g. <method name="Equals" status="missing"/>
+ public MissingMethod (MemberInfo info) : base (info) {}
+
+ public override string Name {
+ get {
+ string s = mInfo.ToString();
+ int index = s.IndexOf(' ');
+ return s.Substring(index + 1);
+ }
+ }
+
+ public override string Type {
+ get {
+ return "method";
+ }
+ }
+ }
+}
-// Mono.Util.CorCompare.MissingNestedType\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 event that is completely missing\r
- /// </summary>\r
- /// <remarks>\r
- /// created by - Nick\r
- /// created on - 2/24/2002 10:43:57 PM\r
- /// </remarks>\r
- class MissingNestedType : IMissingMember {\r
- // e.g. <method name="Equals" status="missing"/>\r
- MemberInfo mInfo;\r
-\r
- public MissingNestedType(MemberInfo info) {\r
- mInfo = info;\r
- }\r
-\r
- public string Name {\r
- get {\r
- return mInfo.Name;\r
- }\r
- }\r
-\r
- public virtual string Status {\r
- get {\r
- return "missing";\r
- }\r
- }\r
-\r
- public string Type {\r
- get {\r
- return "nestedType";\r
- }\r
- }\r
- }\r
-}\r
+// Mono.Util.CorCompare.MissingNestedType
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class event that is completely missing
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/24/2002 10:43:57 PM
+ /// </remarks>
+ class MissingNestedType : MissingMember {
+ // e.g. <method name="Equals" status="missing"/>
+ public MissingNestedType (MemberInfo info) : base (info) {}
+
+ public override string Type {
+ get {
+ return "nestedType";
+ }
+ }
+ }
+}
-// 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
-using System.Text;\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 : IMissingMember \r
- {\r
- // e.g. <property name="Length" status="missing"/>\r
- MemberInfo info;\r
-\r
- public MissingProperty(MemberInfo pInfo) {\r
- info = pInfo;\r
- }\r
-\r
- public string Name {\r
- get {\r
- StringBuilder retVal = new StringBuilder(info.Name + "{");\r
- if (this.NeedsGet) {\r
- retVal.Append(" get;");\r
- }\r
- if (this.NeedsSet) {\r
- retVal.Append(" set;");\r
- }\r
-\r
- retVal.Append(" }");\r
- return retVal.ToString();\r
- }\r
- }\r
- public virtual string Status {\r
- get {\r
- return "missing";\r
- }\r
- }\r
-\r
- public string Type {\r
- get {\r
- return "property";\r
- }\r
- }\r
-\r
- public bool NeedsGet = false;\r
- public bool NeedsSet = false;\r
- }\r
-}\r
+// Mono.Util.CorCompare.MissingProperty
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+using System.Text;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a missing property from a class
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class MissingProperty : MissingMember
+ {
+ // e.g. <property name="Length" status="missing"/>
+ public MissingProperty (MemberInfo info) : base (info) {}
+
+ public override string Name {
+ get {
+ StringBuilder retVal = new StringBuilder(mInfo.Name + "{");
+ if (this.NeedsGet) {
+ retVal.Append(" get;");
+ }
+ if (this.NeedsSet) {
+ retVal.Append(" set;");
+ }
+
+ retVal.Append(" }");
+ return retVal.ToString();
+ }
+ }
+
+ public override string Type {
+ get {
+ return "property";
+ }
+ }
+
+ public bool NeedsGet = false;
+ public bool NeedsSet = false;
+ }
+}
-// 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
+// Mono.Util.CorCompare.MissingType
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Xml;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class method that missing.
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class MissingType
+ {
+ // e.g. <class name="System.Byte" status="missing"/>
+ protected Type theType;
+ public MissingType(Type t)
+ {
+ theType = t;
+ }
+
+ public override bool Equals(object o)
+ {
+ if (o is MissingType)
+ {
+ return o.GetHashCode() == this.GetHashCode();
+ }
+ return false;
+ }
+
+ public override int GetHashCode()
+ {
+ return theType.GetHashCode();
+ }
+
+ public string Name
+ {
+ get
+ {
+ return theType.Name;
+ }
+ }
+
+ public string NameSpace
+ {
+ get
+ {
+ return theType.Namespace;
+ }
+ }
+
+ public virtual string Status
+ {
+ get
+ {
+ return "missing";
+ }
+ }
+ public bool IsDelegate
+ {
+ get
+ {
+ if (theType.IsEnum || theType.IsInterface || theType.IsValueType)
+ return false;
+ Type type = theType.BaseType;
+ while (type != null)
+ {
+ if (type.FullName == "System.Delegate")
+ return true;
+ type = type.BaseType;
+ }
+ return false;
+ }
+ }
+ public virtual XmlElement CreateXML (XmlDocument doc)
+ {
+ XmlElement eltClass;
+ if (theType.IsEnum)
+ eltClass = doc.CreateElement ("enum");
+ else if (theType.IsInterface)
+ eltClass = doc.CreateElement ("interface");
+ else if (IsDelegate)
+ eltClass = doc.CreateElement ("delegate");
+ else if (theType.IsValueType)
+ eltClass = doc.CreateElement ("struct");
+ else
+ eltClass = doc.CreateElement ("class");
+
+ eltClass.SetAttribute ("name", Name);
+ eltClass.SetAttribute ("status", Status);
+
+ return eltClass;
+ }
+ }
+}
-// 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 ToDoCount {\r
- get {\r
- int sum = 0;\r
- foreach(ToDoNameSpace ns in todoNameSpaces) {\r
- sum += ns.ToDoCount;\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
- }\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("todo", this.ToDoCount.ToString());\r
- assemblyElem.SetAttribute("complete", (100 - 100 * (this.MissingCount + this.ToDoCount) / 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
- XmlElement memberElem = null;\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
- classElem.SetAttribute("missing", type.MissingCount.ToString());\r
- classElem.SetAttribute("todo", type.ToDoCount.ToString());\r
- classesElem.AppendChild(classElem);\r
- \r
- memberElem = CreateMemberCollectionElement("methods", type.MissingMethods, type.ToDoMethods, outDoc);\r
- if (memberElem != null) {\r
- classElem.AppendChild(memberElem);\r
- }\r
-\r
- memberElem = CreateMemberCollectionElement("properties", type.MissingProperties, type.ToDoProperties, outDoc);\r
- if (memberElem != null) {\r
- classElem.AppendChild(memberElem);\r
- }\r
-\r
- memberElem = CreateMemberCollectionElement("events", type.MissingEvents, type.ToDoEvents, outDoc);\r
- if (memberElem != null) {\r
- classElem.AppendChild(memberElem);\r
- }\r
-\r
- memberElem = CreateMemberCollectionElement("fields", type.MissingFields, type.ToDoFields, outDoc);\r
- if (memberElem != null) {\r
- classElem.AppendChild(memberElem);\r
- }\r
-\r
- memberElem = CreateMemberCollectionElement("constructors", type.MissingConstructors, type.ToDoConstructors, outDoc);\r
- if (memberElem != null) {\r
- classElem.AppendChild(memberElem);\r
- }\r
-\r
- memberElem = CreateMemberCollectionElement("nestedTypes", type.MissingNestedTypes, type.ToDoNestedTypes, outDoc);\r
- if (memberElem != null) {\r
- classElem.AppendChild(memberElem);\r
- }\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 XmlElement CreateMemberCollectionElement(string name, ArrayList missingList, ArrayList todoList, XmlDocument doc) {\r
- XmlElement element = null;\r
- if (missingList.Count > 0) {\r
- element = doc.CreateElement(name);\r
- foreach (IMissingMember missing in missingList) {\r
- element.AppendChild(CreateMissingElement(missing, doc));\r
- }\r
- }\r
- if (todoList.Count > 0) {\r
- if (element == null) {\r
- element = doc.CreateElement(name);\r
- }\r
- foreach (IMissingMember missing in todoList) {\r
- element.AppendChild(CreateMissingElement(missing, doc));\r
- }\r
- }\r
- if (element != null) {\r
- element.SetAttribute("missing", missingList.Count.ToString());\r
- element.SetAttribute("todo", todoList.Count.ToString());\r
- }\r
- return element;\r
- }\r
-\r
- static XmlElement CreateMissingElement(IMissingMember member, XmlDocument doc) {\r
- XmlElement missingElement = doc.CreateElement(member.Type);\r
- missingElement.SetAttribute("name", (member.Name));\r
- missingElement.SetAttribute("status", (member.Status));\r
- return missingElement;\r
- }\r
- }\r
-}\r
+// Mono.Util.CorCompare.ToDoAssembly
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+using System.Collections;
+using System.IO;
+using System.Text;
+using System.Xml;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents an assembly that has missing or MonoTODO classes
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class ToDoAssembly
+ {
+ // these types are in mono corlib, but not in the dll we are going to examine.
+ static string[] ghostTypes = {"System.Object", "System.ValueType", "System.Delegate", "System.Enum"};
+ ArrayList MissingTypes = new ArrayList();
+ string assemblyToCompare;
+ bool analyzed = false;
+ ArrayList todoNameSpaces = new ArrayList();
+ string name;
+
+ public ToDoAssembly(string fileName, string friendlyName)
+ {
+ assemblyToCompare = fileName;
+ name = friendlyName;
+ }
+
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
+ public int MissingCount {
+ get {
+ int sum = 0;
+ foreach(ToDoNameSpace ns in todoNameSpaces) {
+ sum += ns.MissingCount;
+ }
+ return sum;
+ }
+ }
+
+ public int ToDoCount {
+ get {
+ int sum = 0;
+ foreach(ToDoNameSpace ns in todoNameSpaces) {
+ sum += ns.ToDoCount;
+ }
+ return sum;
+ }
+ }
+
+ public int ReferenceTypeCount {
+ get {
+ int sum = 0;
+ foreach(ToDoNameSpace ns in todoNameSpaces) {
+ sum += ns.ReferenceTypeCount;
+ }
+ return sum;
+ }
+ }
+
+ bool Analyze()
+ {
+ if (analyzed) return true;
+
+ Type[] mscorlibTypes = GetReferenceTypes();
+ if (mscorlibTypes == null)
+ {
+ Console.WriteLine("Could not find corlib file: {0}", assemblyToCompare);
+ return false;
+ }
+
+ Type[] monocorlibTypes = GetMonoTypes();
+
+ foreach(string ns in ToDoNameSpace.GetNamespaces(monocorlibTypes)) {
+ todoNameSpaces.Add(new ToDoNameSpace(ns, monocorlibTypes, mscorlibTypes));
+ }
+
+ analyzed = true;
+ return true;
+ }
+
+ public Type[] GetReferenceTypes()
+ {
+ // get the types in the corlib we are running with
+ Assembly msAsmbl = Assembly.GetAssembly(typeof (System.Object));
+ Type[] mscorlibTypes = msAsmbl.GetTypes();
+ return mscorlibTypes;
+ }
+
+ public Type[] GetMonoTypes()
+ {
+ Type[] monocorlibTypes;
+ Assembly monoAsmbl = null;
+ try
+ {
+ monoAsmbl = Assembly.LoadFrom(assemblyToCompare);
+ }
+ catch(FileNotFoundException)
+ {
+ return null;
+ }
+
+ monocorlibTypes = monoAsmbl.GetTypes();
+
+ return monocorlibTypes;
+ }
+
+ public string CreateClassListReport() {
+ if (!Analyze() || todoNameSpaces.Count == 0) return "";
+
+ StringBuilder output = new StringBuilder();
+ foreach (ToDoNameSpace ns in todoNameSpaces)
+ {
+ string[] missingTypes = ns.MissingTypeNames(true);
+ if (missingTypes.Length > 0) {
+ string joinedNames = String.Join("\n", missingTypes);
+ output.Append(joinedNames + "\n");
+ }
+ }
+ return output.ToString();
+ }
+
+ public XmlElement CreateXML (XmlDocument doc)
+ {
+ XmlElement assemblyElem = doc.CreateElement("assembly");
+ assemblyElem.SetAttribute("name", this.Name);
+ assemblyElem.SetAttribute("missing", this.MissingCount.ToString());
+ assemblyElem.SetAttribute("todo", this.ToDoCount.ToString());
+ assemblyElem.SetAttribute("complete", (100 - 100 * (this.MissingCount + this.ToDoCount) / this.ReferenceTypeCount).ToString());
+
+ if (todoNameSpaces.Count > 0)
+ {
+ XmlElement eltNamespaces = doc.CreateElement ("namespaces");
+ assemblyElem.AppendChild (eltNamespaces);
+
+ foreach (ToDoNameSpace ns in todoNameSpaces)
+ {
+ XmlElement eltNameSpace = ns.CreateXML (doc);
+ if (eltNameSpace != null)
+ eltNamespaces.AppendChild (eltNameSpace);
+ }
+ }
+ return assemblyElem;
+ }
+
+ public void CreateXMLReport(string filename) {
+ bool analyzedOK = Analyze();
+
+ XmlDocument outDoc;
+ outDoc = new XmlDocument();
+ outDoc.AppendChild(outDoc.CreateXmlDeclaration("1.0", null, null));
+ XmlElement assembliesElem = outDoc.CreateElement("assemblies");
+ outDoc.AppendChild(assembliesElem);
+ XmlElement assemblyElem = CreateXML (outDoc);
+ assembliesElem.AppendChild(assemblyElem);
+ outDoc.Save(filename);
+ }
+ }
+}
-// Mono.Util.CorCompare.ToDoConstructor\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 ToDoConstructor : MissingConstructor \r
- {\r
- // e.g. <method name="ToString" status="todo" note="this is the note from MonoTODO"/>\r
- string todoNote = "";\r
-\r
- public ToDoConstructor(MemberInfo info) : base(info) {\r
- }\r
- public ToDoConstructor(MemberInfo 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
+// Mono.Util.CorCompare.ToDoConstructor
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class method that is marked with MonoTODO
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class ToDoConstructor : MissingConstructor
+ {
+ // e.g. <method name="ToString" status="todo" note="this is the note from MonoTODO"/>
+ string todoNote = "";
+
+ public ToDoConstructor(MemberInfo info) : base(info) {
+ }
+ public ToDoConstructor(MemberInfo info, string note) :base(info) {
+ todoNote = note;
+ }
+ public string Note {
+ get {
+ return todoNote;
+ }
+ }
+ public override string Status {
+ get {
+ return "todo";
+ }
+ }
+ }
+}
-// Mono.Util.CorCompare.ToDoEvent\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 ToDoEvent : MissingEvent \r
- {\r
- // e.g. <method name="ToString" status="todo" note="this is the note from MonoTODO"/>\r
- string todoNote = "";\r
-\r
- public ToDoEvent(MemberInfo info) : base(info) {\r
- }\r
- public ToDoEvent(MemberInfo 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
+// Mono.Util.CorCompare.ToDoEvent
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class method that is marked with MonoTODO
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class ToDoEvent : MissingEvent
+ {
+ // e.g. <method name="ToString" status="todo" note="this is the note from MonoTODO"/>
+ string todoNote = "";
+
+ public ToDoEvent(MemberInfo info) : base(info) {
+ }
+ public ToDoEvent(MemberInfo info, string note) :base(info) {
+ todoNote = note;
+ }
+ public string Note {
+ get {
+ return todoNote;
+ }
+ }
+ public override string Status {
+ get {
+ return "todo";
+ }
+ }
+ }
+}
-// Mono.Util.CorCompare.ToDoField\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 ToDoField : MissingField \r
- {\r
- // e.g. <method name="ToString" status="todo" note="this is the note from MonoTODO"/>\r
- string todoNote = "";\r
-\r
- public ToDoField(MemberInfo info) : base(info) {\r
- }\r
- public ToDoField(MemberInfo 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
+// Mono.Util.CorCompare.ToDoField
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class method that is marked with MonoTODO
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class ToDoField : MissingField
+ {
+ // e.g. <method name="ToString" status="todo" note="this is the note from MonoTODO"/>
+ string todoNote = "";
+
+ public ToDoField(MemberInfo info) : base(info) {
+ }
+ public ToDoField(MemberInfo info, string note) :base(info) {
+ todoNote = note;
+ }
+ public string Note {
+ get {
+ return todoNote;
+ }
+ }
+ public override string Status {
+ get {
+ return "todo";
+ }
+ }
+ }
+}
-// 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(MemberInfo info) : base(info) {\r
- }\r
- public ToDoMethod(MemberInfo 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
+// Mono.Util.CorCompare.ToDoMethod
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class method that is marked with MonoTODO
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class ToDoMethod : MissingMethod
+ {
+ // e.g. <method name="ToString" status="todo" note="this is the note from MonoTODO"/>
+ string todoNote = "";
+
+ public ToDoMethod(MemberInfo info) : base(info) {
+ }
+ public ToDoMethod(MemberInfo info, string note) :base(info) {
+ todoNote = note;
+ }
+ public string Note {
+ get {
+ return todoNote;
+ }
+ }
+ public override string Status {
+ get {
+ return "todo";
+ }
+ }
+ }
+}
-// 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
- int index;\r
-\r
- // look at all the existing types in this namespace for MonoTODO attrib\r
- foreach(Type t in existingTypes) {\r
- if (t.IsPublic) {\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(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public)) {\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
- index = ToDoType.IndexOf(t, ToDoTypes);\r
- if (index < 0) {\r
- ToDoTypes.Add(new ToDoType(t));\r
- }\r
- foundIt = true;\r
- }\r
- // add any todo member infos to the todo type\r
- ((ToDoType)(ToDoTypes[ToDoTypes.Count-1])).AddToDoMember(t, mi);\r
- }\r
- }\r
- }\r
- }\r
- }\r
- // find types with missing members\r
- foreach (Type t in referenceTypes) {\r
- if (t.IsPublic && !IsMissingType(t)) {\r
- bool addedIt = false;\r
- index = -1;\r
- \r
- foreach (MemberInfo mi in t.GetMembers(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public)) {\r
- if (t.Name == mi.DeclaringType.Name && IsMissingMember(mi, t.Name, existingTypes)) {\r
- if (!addedIt) {\r
- index = ToDoType.IndexOf(t, ToDoTypes);\r
- if (index >= 0) {\r
- }\r
- else {\r
- index = ToDoTypes.Add(new ToDoType(t));\r
- }\r
- addedIt = true;\r
- }\r
- if (index >= 0) {\r
- ((ToDoType)(ToDoTypes[index])).AddMissingMember(mi);\r
- }\r
- else {\r
- throw new Exception("Don't know which ToDoType to add this missing member");\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- return (ToDoType[])ToDoTypes.ToArray(typeof(ToDoType));\r
- }\r
-\r
- bool IsMissingType(Type t) {\r
- foreach (MissingType mt in missingTypes) {\r
- if (t.Name == mt.Name) {\r
- return true;\r
- }\r
- }\r
- return false;\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(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public)) {\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
- }\r
- else {\r
- return false;\r
- }\r
- }\r
- }\r
- }\r
- }\r
- return true;\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
+// Mono.Util.CorCompare.ToDoNameSpace
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Xml;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a namespace that has missing and/or MonoTODO classes.
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class ToDoNameSpace
+ {
+ // e.g. <namespace name="System" missing="267" todo="453" complete="21">
+ MissingType[] missingTypes;
+ ToDoType[] todoTypes;
+ public string name;
+ int complete = 0;
+ Type[] existingTypes;
+ int referenceTypeCount;
+
+ public static ArrayList GetNamespaces(Type[] types) {
+ ArrayList nsList = new ArrayList();
+ foreach (Type t in types) {
+ if (!nsList.Contains(t.Namespace)) {
+ nsList.Add(t.Namespace);
+ }
+ }
+ return nsList;
+ }
+
+ public ToDoNameSpace(string nameSpace, Type[] types) {
+ name = nameSpace;
+ existingTypes = Filter(types, name);
+ }
+
+ public ToDoNameSpace(string nameSpace, Type[] types,
+ Type[] referenceTypes) {
+ name = nameSpace;
+ existingTypes = Filter(types, name);
+ CompareWith(referenceTypes);
+ }
+
+ public int MissingCount {
+ get {
+ return missingTypes.Length;
+ }
+ }
+
+ public int ToDoCount {
+ get {
+ return todoTypes.Length;
+ }
+ }
+
+ public int ReferenceTypeCount {
+ get {
+ return referenceTypeCount;
+ }
+ }
+
+ Type[] Filter(Type[] types, string ns) {
+ ArrayList filteredTypes = new ArrayList();
+ foreach(Type t in types) {
+ if (t.Namespace == ns) {
+ filteredTypes.Add(t);
+ }
+ }
+ return (Type[])filteredTypes.ToArray(typeof(Type));
+ }
+
+ public int Complete {
+ get {
+ return complete;
+ }
+ }
+
+ public void CompareWith(Type[] referenceTypes) {
+ Type[] filteredReferenceTypes = Filter(referenceTypes, name);
+ referenceTypeCount = 0;
+ if (null != existingTypes) {
+ referenceTypeCount = filteredReferenceTypes.Length;
+ missingTypes = GetMissingTypes(filteredReferenceTypes);
+ todoTypes = GetToDoTypes(filteredReferenceTypes);
+ if (null != filteredReferenceTypes &&
+ filteredReferenceTypes.Length > 0) {
+ int needLoveCount = 0;
+ if (null != missingTypes) {
+ needLoveCount += missingTypes.Length;
+ }
+ if (null != todoTypes) {
+ needLoveCount += todoTypes.Length;
+ }
+ complete = 100 * needLoveCount /
+ filteredReferenceTypes.Length;
+ }
+ }
+ }
+
+ MissingType[] GetMissingTypes(Type[] referenceTypes) {
+ ArrayList TypesList = new ArrayList();
+ ArrayList MissingTypes = new ArrayList();
+ bool foundIt;
+ foreach(Type subt in existingTypes) {
+ if (null != subt && !TypesList.Contains(subt.Name)) {
+ TypesList.Add(subt.Name);
+ }
+ }
+ TypesList.Sort();
+ foreach(Type t in referenceTypes) {
+ foundIt = (TypesList.BinarySearch(t.Name) >= 0);
+ if (t.IsPublic && !foundIt) {
+ MissingTypes.Add(new MissingType(t));
+ }
+ }
+ return (MissingType[])MissingTypes.ToArray(typeof(MissingType));
+ }
+
+ ToDoType[] GetToDoTypes(Type[] referenceTypes) {
+ // todo types are those marked with [MonoTODO] or having missing or
+ // todo members
+ ArrayList TypesList = new ArrayList();
+ ArrayList ToDoTypes = new ArrayList();
+
+ bool foundIt = false;
+ Object[] myAttributes;
+
+ int index;
+
+ // look at all the existing types in this namespace for MonoTODO attrib
+ foreach(Type t in existingTypes) {
+ if (t.IsPublic) {
+ // assume we won't find it
+ foundIt = false;
+
+ // get all the custom attributes on the type
+ myAttributes = t.GetCustomAttributes(false);
+ foreach (object o in myAttributes) {
+ // check to see if any of them are the MonoTODO attrib
+ if (o.ToString() == "System.MonoTODOAttribute"){
+ // if so, this is a todo type
+ ToDoTypes.Add(new ToDoType(t));
+ // and we can stop look at the custom attribs
+ break;
+ }
+ }
+
+ // look at all the members of the type
+ foreach (MemberInfo mi in t.GetMembers(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public)) {
+ // see if any of them have the MonoTODO attrib
+ myAttributes = mi.GetCustomAttributes(false);
+ foreach (object o in myAttributes) {
+ if (o.ToString() == "System.MonoTODOAttribute") {
+ // the first time we find one for this type add the type to the list
+ if (!foundIt) {
+ index = ToDoType.IndexOf(t, ToDoTypes);
+ if (index < 0) {
+ ToDoTypes.Add(new ToDoType(t));
+ }
+ foundIt = true;
+ }
+ // add any todo member infos to the todo type
+ ((ToDoType)(ToDoTypes[ToDoTypes.Count-1])).AddToDoMember(t, mi);
+ }
+ }
+ }
+ }
+ }
+ // find types with missing members
+ foreach (Type t in referenceTypes) {
+ if (t.IsPublic && !IsMissingType(t)) {
+ bool addedIt = false;
+ index = -1;
+
+ foreach (MemberInfo mi in t.GetMembers(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public)) {
+ if (t.Name == mi.DeclaringType.Name && IsMissingMember(mi, t.Name, existingTypes)) {
+ if (!addedIt) {
+ index = ToDoType.IndexOf(t, ToDoTypes);
+ if (index >= 0) {
+ }
+ else {
+ index = ToDoTypes.Add(new ToDoType(t));
+ }
+ addedIt = true;
+ }
+ if (index >= 0) {
+ ((ToDoType)(ToDoTypes[index])).AddMissingMember(mi);
+ }
+ else {
+ throw new Exception("Don't know which ToDoType to add this missing member");
+ }
+ }
+ }
+ }
+ }
+
+ return (ToDoType[])ToDoTypes.ToArray(typeof(ToDoType));
+ }
+
+ bool IsMissingType(Type t) {
+ foreach (MissingType mt in missingTypes) {
+ if (t.Name == mt.Name) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ static bool IsMissingMember(MemberInfo mi, string typeName, Type[] typesToSearch) {
+ foreach (Type t in typesToSearch) {
+ if (t.Name == typeName) {
+ foreach (MemberInfo trialMI in t.GetMembers(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public)) {
+ if (mi.Name == trialMI.Name && mi.MemberType == trialMI.MemberType) {
+ if (mi.MemberType == MemberTypes.Method) {
+ if (IsParameterListEqual(((MethodInfo)mi).GetParameters(), ((MethodInfo)trialMI).GetParameters())) {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ static bool IsParameterListEqual(ParameterInfo[] piArray1, ParameterInfo[] piArray2) {
+ if (piArray1.Length != piArray2.Length) {
+ return false;
+ }
+
+ foreach (ParameterInfo pi1 in piArray1) {
+ if (pi1.ParameterType.Name != GetTypeAt(pi1.Position, piArray2).Name) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ static Type GetTypeAt(int position, ParameterInfo[] piArray){
+ foreach (ParameterInfo pi in piArray) {
+ if (pi.Position == position) {
+ return pi.ParameterType;
+ }
+ }
+ throw new Exception("contract violation: need to call with existing position");
+ }
+
+ public MissingType[] MissingTypes {
+ get {
+ return missingTypes;
+ }
+ }
+
+ public ToDoType[] ToDoTypes {
+ get {
+ return todoTypes;
+ }
+ }
+
+ public string[] MissingTypeNames(bool qualify){
+ ArrayList names = new ArrayList();
+ if (qualify) {
+ foreach (MissingType t in missingTypes) {
+ names.Add(t.NameSpace + "." + t.Name);
+ }
+ }
+ else {
+ foreach (MissingType t in missingTypes) {
+ names.Add(t.Name);
+ }
+ }
+ return (string[])names.ToArray(typeof(string));
+ }
+ public XmlElement CreateXML (XmlDocument doc)
+ {
+ XmlElement eltNameSpace = doc.CreateElement("namespace");
+ eltNameSpace.SetAttribute("name", name);
+
+ if (MissingTypes.Length > 0 || ToDoTypes.Length > 0)
+ {
+ XmlElement eltClasses = doc.CreateElement("classes");
+ eltNameSpace.AppendChild (eltClasses);
+
+ foreach (MissingType type in missingTypes)
+ {
+ XmlElement eltClass = type.CreateXML (doc);
+ if (eltClass != null)
+ eltClasses.AppendChild (eltClass);
+ }
+ foreach (ToDoType type in todoTypes)
+ {
+ XmlElement eltClass = type.CreateXML (doc);
+ if (eltClass != null)
+ eltClasses.AppendChild (eltClass);
+ }
+ eltNameSpace.SetAttribute ("missing", MissingCount.ToString());
+
+ int percentComplete = (ReferenceTypeCount == 0) ? 100 : (100 - 100 * (MissingCount + ToDoCount) / ReferenceTypeCount);
+ eltNameSpace.SetAttribute ("complete", percentComplete.ToString ());
+ }
+ return eltNameSpace;
+ }
+ }
+}
-// Mono.Util.CorCompare.ToDoNestedType\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 ToDoNestedType : MissingNestedType\r
- {\r
- // e.g. <property name="Count" status="todo" note="another note"/>\r
- string todoNote = "";\r
-\r
- public ToDoNestedType(MemberInfo pInfo) : base(pInfo) {\r
- }\r
- public ToDoNestedType(MemberInfo 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
+// Mono.Util.CorCompare.ToDoNestedType
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class's property that is marked with a MonoTODO
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class ToDoNestedType : MissingNestedType
+ {
+ // e.g. <property name="Count" status="todo" note="another note"/>
+ string todoNote = "";
+
+ public ToDoNestedType(MemberInfo pInfo) : base(pInfo) {
+ }
+ public ToDoNestedType(MemberInfo pInfo, string note) :base(pInfo) {
+ todoNote = note;
+ }
+ public string Note {
+ get {
+ return todoNote;
+ }
+ }
+ public override string Status {
+ get {
+ return "todo";
+ }
+ }
+ }
+}
-// 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(MemberInfo pInfo) : base(pInfo) {\r
- }\r
- public ToDoProperty(MemberInfo 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
+// Mono.Util.CorCompare.ToDoProperty
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class's property that is marked with a MonoTODO
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class ToDoProperty : MissingProperty
+ {
+ // e.g. <property name="Count" status="todo" note="another note"/>
+ string todoNote = "";
+
+ public ToDoProperty(MemberInfo pInfo) : base(pInfo) {
+ }
+ public ToDoProperty(MemberInfo pInfo, string note) :base(pInfo) {
+ todoNote = note;
+ }
+ public string Note {
+ get {
+ return todoNote;
+ }
+ }
+ public override string Status {
+ get {
+ return "todo";
+ }
+ }
+ }
+}
-// 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 ArrayList MissingMethods {\r
- get {\r
- return missingMethodList;\r
- }\r
- }\r
-\r
- ArrayList todoMethodList = new ArrayList();\r
- public ArrayList ToDoMethods {\r
- get {\r
- return todoMethodList;\r
- }\r
- }\r
-\r
- ArrayList missingPropertyList = new ArrayList();\r
- public ArrayList MissingProperties {\r
- get {\r
- return missingPropertyList;\r
- }\r
- }\r
-\r
- ArrayList todoPropertyList = new ArrayList();\r
- public ArrayList ToDoProperties {\r
- get {\r
- return todoPropertyList;\r
- }\r
- }\r
-\r
- ArrayList missingEventList = new ArrayList();\r
- public ArrayList MissingEvents {\r
- get {\r
- return missingEventList;\r
- }\r
- }\r
-\r
- ArrayList todoEventList = new ArrayList();\r
- public ArrayList ToDoEvents {\r
- get {\r
- return todoEventList;\r
- }\r
- }\r
-\r
- ArrayList missingFieldList = new ArrayList();\r
- public ArrayList MissingFields {\r
- get {\r
- return missingFieldList;\r
- }\r
- }\r
-\r
- ArrayList todoFieldList = new ArrayList();\r
- public ArrayList ToDoFields {\r
- get {\r
- return todoFieldList;\r
- }\r
- }\r
-\r
- ArrayList missingConstructorList = new ArrayList();\r
- public ArrayList MissingConstructors {\r
- get {\r
- return missingConstructorList;\r
- }\r
- }\r
-\r
- ArrayList todoConstructorList = new ArrayList();\r
- public ArrayList ToDoConstructors {\r
- get {\r
- return todoConstructorList;\r
- }\r
- }\r
-\r
- ArrayList missingNestedTypeList = new ArrayList();\r
- public ArrayList MissingNestedTypes {\r
- get {\r
- return missingNestedTypeList;\r
- }\r
- }\r
-\r
- ArrayList todoNestedTypeList = new ArrayList();\r
- public ArrayList ToDoNestedTypes {\r
- get {\r
- return todoNestedTypeList;\r
- }\r
- }\r
-\r
- public ToDoType(Type t) : base(t) {\r
- }\r
-\r
- public int MissingCount {\r
- get {\r
- return missingMethodList.Count + missingPropertyList.Count;\r
- }\r
- }\r
-\r
- public int ToDoCount {\r
- get {\r
- return todoMethodList.Count + todoPropertyList.Count;\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 override string Status {\r
- get {\r
- return "todo";\r
- }\r
- }\r
-\r
- public void AddToDoMember(Type t, MemberInfo info){\r
- switch (info.MemberType){\r
- case MemberTypes.Method:\r
- todoMethodList.Add(new ToDoMethod(info));\r
- break;\r
- case MemberTypes.Property:\r
- todoPropertyList.Add(new ToDoProperty(info));\r
- break;\r
- case MemberTypes.Event:\r
- todoEventList.Add(new ToDoEvent(info));\r
- break;\r
- case MemberTypes.Field:\r
- todoFieldList.Add(new ToDoField(info));\r
- break;\r
- case MemberTypes.Constructor:\r
- todoConstructorList.Add(new ToDoConstructor(info));\r
- break;\r
- case MemberTypes.NestedType:\r
- todoNestedTypeList.Add(new ToDoNestedType(info));\r
- break;\r
- default:\r
- throw new Exception("Didn't code todo member type: " + info.MemberType.ToString());\r
- }\r
- }\r
-\r
- public void AddMissingMember(MemberInfo info){\r
- switch (info.MemberType){\r
- case MemberTypes.Method:\r
- missingMethodList.Add(new MissingMethod(info));\r
- break;\r
- case MemberTypes.Property:\r
- missingPropertyList.Add(new MissingProperty(info));\r
- break;\r
- case MemberTypes.Event:\r
- missingEventList.Add(new MissingEvent(info));\r
- break;\r
- case MemberTypes.Field:\r
- missingFieldList.Add(new MissingField(info));\r
- break;\r
- case MemberTypes.Constructor:\r
- missingConstructorList.Add(new MissingConstructor(info));\r
- break;\r
- case MemberTypes.NestedType:\r
- missingNestedTypeList.Add(new MissingNestedType(info));\r
- break;\r
- default:\r
- throw new Exception("Didn't code missing member type: " + info.MemberType.ToString());\r
- }\r
- }\r
- }\r
-}\r
+// Mono.Util.CorCompare.ToDoType
+//
+// Author(s):
+// Nick Drochak (ndrochak@gol.com)
+//
+// (C) 2001-2002 Nick Drochak
+
+using System;
+using System.Reflection;
+using System.Collections;
+using System.Xml;
+
+namespace Mono.Util.CorCompare {
+
+ /// <summary>
+ /// Represents a class that is marked with MonoTODO
+ /// </summary>
+ /// <remarks>
+ /// created by - Nick
+ /// created on - 2/20/2002 10:43:57 PM
+ /// </remarks>
+ class ToDoType : MissingType
+ {
+ // e.g. <class name="System.Array" status="todo" missing="5" todo="6" complete="45">
+
+ ArrayList missingMethodList = new ArrayList();
+ public ArrayList MissingMethods {
+ get {
+ return missingMethodList;
+ }
+ }
+
+ ArrayList todoMethodList = new ArrayList();
+ public ArrayList ToDoMethods {
+ get {
+ return todoMethodList;
+ }
+ }
+
+ ArrayList missingPropertyList = new ArrayList();
+ public ArrayList MissingProperties {
+ get {
+ return missingPropertyList;
+ }
+ }
+
+ ArrayList todoPropertyList = new ArrayList();
+ public ArrayList ToDoProperties {
+ get {
+ return todoPropertyList;
+ }
+ }
+
+ ArrayList missingEventList = new ArrayList();
+ public ArrayList MissingEvents {
+ get {
+ return missingEventList;
+ }
+ }
+
+ ArrayList todoEventList = new ArrayList();
+ public ArrayList ToDoEvents {
+ get {
+ return todoEventList;
+ }
+ }
+
+ ArrayList missingFieldList = new ArrayList();
+ public ArrayList MissingFields {
+ get {
+ return missingFieldList;
+ }
+ }
+
+ ArrayList todoFieldList = new ArrayList();
+ public ArrayList ToDoFields {
+ get {
+ return todoFieldList;
+ }
+ }
+
+ ArrayList missingConstructorList = new ArrayList();
+ public ArrayList MissingConstructors {
+ get {
+ return missingConstructorList;
+ }
+ }
+
+ ArrayList todoConstructorList = new ArrayList();
+ public ArrayList ToDoConstructors {
+ get {
+ return todoConstructorList;
+ }
+ }
+
+ ArrayList missingNestedTypeList = new ArrayList();
+ public ArrayList MissingNestedTypes {
+ get {
+ return missingNestedTypeList;
+ }
+ }
+
+ ArrayList todoNestedTypeList = new ArrayList();
+ public ArrayList ToDoNestedTypes {
+ get {
+ return todoNestedTypeList;
+ }
+ }
+
+ public ToDoType(Type t) : base(t) {
+ }
+
+ public int MissingCount {
+ get {
+ return missingMethodList.Count + missingPropertyList.Count;
+ }
+ }
+
+ public int ToDoCount {
+ get {
+ return todoMethodList.Count + todoPropertyList.Count;
+ }
+ }
+
+ public static int IndexOf(Type t, ArrayList todoTypes) {
+ for(int index = 0; index < todoTypes.Count; index++) {
+ if (((ToDoType)todoTypes[index]).Name == t.Name) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ public override string Status {
+ get {
+ return "todo";
+ }
+ }
+
+ public void AddToDoMember(Type t, MemberInfo info){
+ switch (info.MemberType){
+ case MemberTypes.Method:
+ todoMethodList.Add(new ToDoMethod(info));
+ break;
+ case MemberTypes.Property:
+ todoPropertyList.Add(new ToDoProperty(info));
+ break;
+ case MemberTypes.Event:
+ todoEventList.Add(new ToDoEvent(info));
+ break;
+ case MemberTypes.Field:
+ todoFieldList.Add(new ToDoField(info));
+ break;
+ case MemberTypes.Constructor:
+ todoConstructorList.Add(new ToDoConstructor(info));
+ break;
+ case MemberTypes.NestedType:
+ todoNestedTypeList.Add(new ToDoNestedType(info));
+ break;
+ default:
+ throw new Exception("Didn't code todo member type: " + info.MemberType.ToString());
+ }
+ }
+
+ public void AddMissingMember(MemberInfo info){
+ switch (info.MemberType){
+ case MemberTypes.Method:
+ missingMethodList.Add(new MissingMethod(info));
+ break;
+ case MemberTypes.Property:
+ missingPropertyList.Add(new MissingProperty(info));
+ break;
+ case MemberTypes.Event:
+ missingEventList.Add(new MissingEvent(info));
+ break;
+ case MemberTypes.Field:
+ missingFieldList.Add(new MissingField(info));
+ break;
+ case MemberTypes.Constructor:
+ missingConstructorList.Add(new MissingConstructor(info));
+ break;
+ case MemberTypes.NestedType:
+ missingNestedTypeList.Add(new MissingNestedType(info));
+ break;
+ default:
+ throw new Exception("Didn't code missing member type: " + info.MemberType.ToString());
+ }
+ }
+ public override XmlElement CreateXML (XmlDocument doc)
+ {
+ XmlElement eltClass = base.CreateXML (doc);
+ eltClass.SetAttribute ("missing", MissingCount.ToString());
+ eltClass.SetAttribute ("todo", ToDoCount.ToString());
+
+ XmlElement eltMember;
+ eltMember = CreateMemberCollectionElement ("methods", MissingMethods, ToDoMethods, doc);
+ if (eltMember != null)
+ {
+ eltClass.AppendChild (eltMember);
+ }
+
+ eltMember = CreateMemberCollectionElement ("properties", MissingProperties, ToDoProperties, doc);
+ if (eltMember != null)
+ {
+ eltClass.AppendChild (eltMember);
+ }
+
+ eltMember = CreateMemberCollectionElement ("events", MissingEvents, ToDoEvents, doc);
+ if (eltMember != null)
+ {
+ eltClass.AppendChild (eltMember);
+ }
+
+ eltMember = CreateMemberCollectionElement ("fields", MissingFields, ToDoFields, doc);
+ if (eltMember != null)
+ {
+ eltClass.AppendChild (eltMember);
+ }
+
+ eltMember = CreateMemberCollectionElement ("constructors", MissingConstructors, ToDoConstructors, doc);
+ if (eltMember != null)
+ {
+ eltClass.AppendChild (eltMember);
+ }
+
+ eltMember = CreateMemberCollectionElement ("nestedTypes", MissingNestedTypes, ToDoNestedTypes, doc);
+ if (eltMember != null)
+ {
+ eltClass.AppendChild (eltMember);
+ }
+ return eltClass;
+ }
+
+ static XmlElement CreateMemberCollectionElement (string name, ArrayList missingList, ArrayList todoList, XmlDocument doc)
+ {
+ XmlElement element = null;
+ if (missingList.Count > 0 || todoList.Count > 0)
+ {
+ element = doc.CreateElement(name);
+ if (missingList.Count > 0)
+ {
+ foreach (IMissingMember missing in missingList)
+ element.AppendChild (missing.CreateXML (doc));
+ }
+ if (todoList.Count > 0)
+ {
+ foreach (IMissingMember missing in todoList)
+ element.AppendChild (missing.CreateXML (doc));
+ }
+ element.SetAttribute ("missing", missingList.Count.ToString());
+ element.SetAttribute ("todo", todoList.Count.ToString());
+ }
+ return element;
+ }
+
+ static XmlElement CreateMissingElement(IMissingMember member, XmlDocument doc)
+ {
+ XmlElement missingElement = doc.CreateElement(member.Type);
+ missingElement.SetAttribute("name", (member.Name));
+ missingElement.SetAttribute("status", (member.Status));
+ return missingElement;
+ }
+ }
+}