1 // Mono.Util.CorCompare.MissingNameSpace
4 // Nick Drochak (ndrochak@gol.com)
6 // (C) 2001-2002 Nick Drochak
9 using System.Collections;
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 TypeDefinitionCollection 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, TypeDefinitionCollection _rgTypesMono, TypeDefinitionCollection _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 (TypeDefinition t in rgTypesMono)
83 htMono.Add (t.FullName, t);
86 if (rgTypesMS != null)
88 foreach (TypeDefinition t in rgTypesMS)
90 TypeDefinition tMono = (TypeDefinition) htMono [t.FullName];
91 MissingType mt = null;
92 bool tIsPublic = (t.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public;
95 if (tIsPublic && !htGhostTypes.Contains (t.FullName))
96 mt = new MissingType (null, t);
102 htMono.Remove (t.FullName);
103 mt = new MissingType (tMono, t);
108 NodeStatus nsType = mt.Analyze ();
109 m_nodeStatus.AddChildren (nsType);
114 // do any mono types that aren't in microsoft's namespace
115 foreach (TypeDefinition tMono in htMono.Values)
117 if ((tMono.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public)
119 MissingType tdt = new MissingType (tMono, null);
120 NodeStatus nsType = tdt.Analyze ();
121 m_nodeStatus.AddChildren (nsType);
128 public override XmlElement CreateXML (XmlDocument doc)
130 XmlElement eltNameSpace = base.CreateXML (doc);
132 // TODO: include complete namespaces?
133 // if (m_nodeStatus.statusCountsTotal.cMissing > 0 || m_nodeStatus.statusCountsTotal.cTodo > 0)
135 XmlElement eltClasses = doc.CreateElement("classes");
136 eltNameSpace.AppendChild (eltClasses);
138 foreach (MissingType type in rgTypes)
140 XmlElement eltClass = type.CreateXML (doc);
141 if (eltClass != null)
142 eltClasses.AppendChild (eltClass);
149 public static ArrayList GetNamespaces (TypeDefinitionCollection types)
151 ArrayList nsList = new ArrayList();
152 foreach (TypeDefinition t in types)
154 if (!nsList.Contains(t.Namespace))
156 nsList.Add(t.Namespace);