{
// these types are in mono corlib, but not in the dll we are going to examine.
ArrayList MissingTypes = new ArrayList();
- string assemblyToCompare, assemblyToCompareWith;
- bool analyzed = false;
ArrayList rgNamespaces = new ArrayList();
- string name;
+ string strName;
+ Assembly assMono;
+ Assembly assMS;
+ Type [] rgTypesMono;
+ Type [] rgTypesMS;
- CompletionInfo ci;
+ protected static Hashtable htGhostTypes;
+ private static string[] rgstrGhostTypes = {"System.Object", "System.ValueType", "System.Delegate", "System.Enum"};
- public ToDoAssembly(string fileName, string friendlyName, string strMSName)
+
+ static ToDoAssembly ()
{
- assemblyToCompare = fileName;
- name = friendlyName;
- assemblyToCompareWith = strMSName;
- }
+ htGhostTypes = new Hashtable ();
- public override string Name {
- get {
- return name;
+ foreach (string strGhostType in rgstrGhostTypes)
+ {
+ htGhostTypes.Add (strGhostType, null);
}
}
- public override string Type
+ public static ToDoAssembly Load (string strFileMono, string strName, string strNameMS)
{
- get { return "assembly"; }
- }
+ Assembly assemblyMono = Assembly.LoadFrom (strFileMono);
+ Assembly assemblyMS = Assembly.LoadWithPartialName (strNameMS);
- public override CompletionTypes Completion
- {
- get { return CompletionTypes.Todo; }
+ return new ToDoAssembly (strName, assemblyMono, assemblyMS);
}
- public CompletionInfo Analyze ()
+ public ToDoAssembly (string _strName, Assembly _assMono, Assembly _assMS)
{
- if (analyzed)
- return ci;
-
- Type[] mscorlibTypes = GetReferenceTypes();
- if (mscorlibTypes == null)
- throw new Exception ("Could not find corlib file: " + name);
+ strName = _strName;
+ assMono = _assMono;
+ assMS = _assMS;
- Type[] monocorlibTypes = GetMonoTypes();
- if (monocorlibTypes == null)
- throw new Exception ("Failed to load Mono assembly: " + assemblyToCompare);
-
- ArrayList rgNamespacesMono = ToDoNameSpace.GetNamespaces(monocorlibTypes);
- if (rgNamespacesMono == null)
- throw new Exception ("Failed to get namespaces from Mono assembly: " + assemblyToCompare);
+ rgTypesMono = assMono.GetTypes ();
+ rgTypesMS = assMS.GetTypes ();
+ m_nodeStatus = new NodeStatus (_assMono, _assMS);
+ }
- foreach(string ns in rgNamespacesMono) {
- if (ns != null && ns.Length != 0)
- {
- ToDoNameSpace tdns = new ToDoNameSpace(ns, mscorlibTypes, monocorlibTypes);
- rgNamespaces.Add (tdns);
- CompletionInfo ciNS = tdns.Analyze ();
- ci.cComplete += ciNS.cComplete;
- ci.cMissing += ciNS.cMissing;
- ci.cTodo += ciNS.cTodo;
- }
+ public override string Name {
+ get {
+ return strName;
}
+ }
- ArrayList rgNamespacesMS = ToDoNameSpace.GetNamespaces(mscorlibTypes);
- if (rgNamespacesMS == null)
- throw new Exception ("Failed to get namespaces from Microsoft assembly: " + assemblyToCompareWith);
+ public override string Type
+ {
+ get { return "assembly"; }
+ }
- foreach (string nsMS in rgNamespacesMS)
+ private Hashtable GetNamespaceMap (Type [] rgTypes)
+ {
+ Hashtable mapTypes = new Hashtable ();
+ foreach (Type t in rgTypes)
{
- if (nsMS != null && nsMS.Length != 0)
+ if (t != null)
{
- bool fMissing = true;
- foreach (string nsMono in rgNamespacesMono)
+ string strName = t.FullName;
+ string strNamespace = t.Namespace;
+ if (strNamespace != null && strNamespace.Length > 0 &&
+ strName != null && strName.Length > 0 &&
+ !htGhostTypes.Contains (strName))
{
- if (nsMono == nsMS)
+ ArrayList rgContainedTypes = (ArrayList) mapTypes [strNamespace];
+ if (rgContainedTypes == null)
{
- fMissing = false;
- break;
+ rgContainedTypes = new ArrayList ();
+ mapTypes [strNamespace] = rgContainedTypes;
}
- }
- if (fMissing && !nsMS.StartsWith ("Microsoft."))
- {
- MissingNameSpace mns = new MissingNameSpace (nsMS, mscorlibTypes);
- rgNamespaces.Add (mns);
+ rgContainedTypes.Add (t);
}
}
}
-
- analyzed = true;
- return ci;
+ return mapTypes;
}
- public Type[] GetReferenceTypes()
+ public override NodeStatus Analyze ()
{
- // get the types in the corlib we are running with
- //Assembly msAsmbl = Assembly.GetAssembly(typeof (System.Object));
- Assembly assembly = Assembly.LoadWithPartialName (assemblyToCompareWith);
- Type[] mscorlibTypes = assembly.GetTypes();
- return mscorlibTypes;
- }
+ Hashtable mapTypesMono = GetNamespaceMap (rgTypesMono);
+ Hashtable mapTypesMS = GetNamespaceMap (rgTypesMS);
- public Type[] GetMonoTypes()
- {
- Type[] monocorlibTypes;
- Assembly monoAsmbl = null;
- try
+ foreach (string strNamespaceMS in mapTypesMS.Keys)
{
- monoAsmbl = Assembly.LoadFrom(assemblyToCompare);
+ if (strNamespaceMS != null)
+ {
+ ArrayList rgContainedTypesMS = (ArrayList) mapTypesMS [strNamespaceMS];
+ ArrayList rgContainedTypesMono = (ArrayList) mapTypesMono [strNamespaceMS];
+ MissingNameSpace mns = new MissingNameSpace (strNamespaceMS, rgContainedTypesMono, rgContainedTypesMS);
+ NodeStatus nsNamespace = mns.Analyze ();
+ m_nodeStatus.AddChildren (nsNamespace);
+ if (rgTypesMono != null)
+ mapTypesMono.Remove (strNamespaceMS);
+ rgNamespaces.Add (mns);
+ }
}
- catch(FileNotFoundException)
+ foreach (string strNamespaceMono in mapTypesMono.Keys)
{
- return null;
+ if (strNamespaceMono != null)
+ {
+ ArrayList rgContainedTypesMono = (ArrayList) mapTypesMono [strNamespaceMono];
+ MissingNameSpace mns = new MissingNameSpace (strNamespaceMono, rgContainedTypesMono, null);
+ NodeStatus nsNamespace = mns.Analyze ();
+ m_nodeStatus.AddChildren (nsNamespace);
+ rgNamespaces.Add (mns);
+ }
}
- monocorlibTypes = monoAsmbl.GetTypes();
+ rgAttributes = new ArrayList ();
+ NodeStatus nsAttributes = MissingAttribute.AnalyzeAttributes (
+ assMono.GetCustomAttributes (true),
+ assMS.GetCustomAttributes (true),
+ rgAttributes);
+ m_nodeStatus.Add (nsAttributes);
- return monocorlibTypes;
+ return m_nodeStatus;
}
+
public string CreateClassListReport() {
- Analyze (); // TODO: catch exception
+ Analyze ();
if (rgNamespaces.Count == 0) return "";
StringBuilder output = new StringBuilder();
public override XmlElement CreateXML (XmlDocument doc)
{
XmlElement assemblyElem = base.CreateXML (doc);
- ci.SetAttributes (assemblyElem);
if (rgNamespaces.Count > 0)
{
}
public void CreateXMLReport(string filename) {
- Analyze(); // TODO: catch exception
+ Analyze();
XmlDocument outDoc;
outDoc = new XmlDocument();