1 // Mono.Util.CorCompare.MissingNameSpace
4 // Nick Drochak (ndrochak@gol.com)
6 // (C) 2001-2002 Nick Drochak
9 using System.Collections;
10 using System.Reflection;
13 namespace Mono.Util.CorCompare {
16 /// Represents a namespace that has missing and/or MonoTODO classes.
20 /// created on - 2/20/2002 10:43:57 PM
22 class MissingNameSpace : MissingBase
24 // e.g. <namespace name="System" missing="267" todo="453" complete="21">
25 protected ArrayList rgTypesMono, rgTypesMS;
27 ArrayList rgTypes = new ArrayList ();
28 protected static Hashtable htGhostTypes;
29 static string[] rgstrGhostTypes = {"System.Object", "System.ValueType", "System.Delegate", "System.Enum"};
32 static MissingNameSpace ()
34 htGhostTypes = new Hashtable ();
36 foreach (string strGhostType in rgstrGhostTypes)
38 htGhostTypes.Add (strGhostType, null);
42 public MissingNameSpace(string nameSpace, ArrayList _rgTypesMono, ArrayList _rgTypesMS)
44 strNamespace = nameSpace;
45 rgTypesMono = _rgTypesMono;
46 rgTypesMS = _rgTypesMS;
47 m_nodeStatus = new NodeStatus (_rgTypesMono, _rgTypesMS);
50 public virtual string [] MissingTypeNames (bool f)
55 public virtual ArrayList ToDoTypeNames
60 public override string Name
62 get { return strNamespace; }
64 public override string Type
66 get { return "namespace"; }
71 /// first we go through all the microsoft types adding any mono types that match, or missing types otherwise
72 /// then we go through the unmatched mono types adding those
73 /// uses a hashtable to speed up lookups
75 /// <returns></returns>
76 public override NodeStatus Analyze ()
78 Hashtable htMono = new Hashtable ();
79 if (rgTypesMono != null)
81 foreach (Type t in rgTypesMono)
83 htMono.Add (t.FullName, t);
86 if (rgTypesMS != null)
88 foreach (Type t in rgTypesMS)
90 Type tMono = (Type) htMono [t.FullName];
91 MissingType mt = null;
94 if (t.IsPublic && !htGhostTypes.Contains (t.FullName))
95 mt = new MissingType (null, t);
101 htMono.Remove (t.FullName);
102 mt = new MissingType (tMono, t);
107 NodeStatus nsType = mt.Analyze ();
108 m_nodeStatus.AddChildren (nsType);
113 // do any mono types that aren't in microsoft's namespace
114 foreach (Type tMono in htMono.Values)
118 MissingType tdt = new MissingType (tMono, null);
119 NodeStatus nsType = tdt.Analyze ();
120 m_nodeStatus.AddChildren (nsType);
127 public override XmlElement CreateXML (XmlDocument doc)
129 XmlElement eltNameSpace = base.CreateXML (doc);
131 // TODO: include complete namespaces?
132 // if (m_nodeStatus.statusCountsTotal.cMissing > 0 || m_nodeStatus.statusCountsTotal.cTodo > 0)
134 XmlElement eltClasses = doc.CreateElement("classes");
135 eltNameSpace.AppendChild (eltClasses);
137 foreach (MissingType type in rgTypes)
139 XmlElement eltClass = type.CreateXML (doc);
140 if (eltClass != null)
141 eltClasses.AppendChild (eltClass);
148 public static ArrayList GetNamespaces(Type[] types)
150 ArrayList nsList = new ArrayList();
151 foreach (Type t in types)
153 if (!nsList.Contains(t.Namespace))
155 nsList.Add(t.Namespace);