Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MissingNameSpace.cs « corcompare « tools « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b63168e06729a51b50a1b0688e629f2c4704d09f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Mono.Util.CorCompare.MissingNameSpace
//
// 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 MissingNameSpace : MissingBase
	{
		// e.g. <namespace name="System" missing="267" todo="453" complete="21">
		protected ArrayList rgTypesMono, rgTypesMS;
		string strNamespace;
		ArrayList rgTypes = new ArrayList ();
		protected static Hashtable htGhostTypes;
		static string[] rgstrGhostTypes = {"System.Object", "System.ValueType", "System.Delegate", "System.Enum"};


		static MissingNameSpace ()
		{
			htGhostTypes = new Hashtable ();

			foreach (string strGhostType in rgstrGhostTypes)
			{
				htGhostTypes.Add (strGhostType, null);
			}
		}

		public MissingNameSpace(string nameSpace, ArrayList _rgTypesMono, ArrayList _rgTypesMS)
		{
			strNamespace = nameSpace;
			rgTypesMono = _rgTypesMono;
			rgTypesMS = _rgTypesMS;
			m_nodeStatus = new NodeStatus (_rgTypesMono, _rgTypesMS);
		}

		public virtual string [] MissingTypeNames (bool f)
		{
			return null;
		}

		public virtual ArrayList ToDoTypeNames
		{
			get { return null; }
		}

		public override string Name 
		{
			get { return strNamespace; }
		}
		public override string Type
		{
			get { return "namespace"; }
		}


		/// <summary>
		/// first we go through all the microsoft types adding any mono types that match, or missing types otherwise
		/// then we go through the unmatched mono types adding those
		/// uses a hashtable to speed up lookups
		/// </summary>
		/// <returns></returns>
		public override NodeStatus Analyze ()
		{
			Hashtable htMono = new Hashtable ();
			if (rgTypesMono != null)
			{
				foreach (Type t in rgTypesMono)
				{
					htMono.Add (t.FullName, t);
				}
			}
			if (rgTypesMS != null)
			{
				foreach (Type t in rgTypesMS)
				{
					Type tMono = (Type) htMono [t.FullName];
					MissingType mt = null;
					if (tMono == null)
					{
						if (t.IsPublic && !htGhostTypes.Contains (t.FullName))
							mt = new MissingType (null, t);
					}
					else
					{
						htMono.Remove (t.FullName);
						mt = new MissingType (tMono, t);
					}
					if (mt != null)
					{
						NodeStatus nsType = mt.Analyze ();
						m_nodeStatus.AddChildren (nsType);
						rgTypes.Add (mt);
					}
				}
			}
			// do any mono types that aren't in microsoft's namespace
			foreach (Type tMono in htMono.Values)
			{
				if (tMono.IsPublic)
				{
					MissingType tdt = new MissingType (tMono, null);
					NodeStatus nsType = tdt.Analyze ();
					m_nodeStatus.AddChildren (nsType);
					rgTypes.Add (tdt);
				}
			}
			return m_nodeStatus;
		}

		public override XmlElement CreateXML (XmlDocument doc)
		{
			XmlElement eltNameSpace = base.CreateXML (doc);

			// TODO: include complete namespaces?
//			if (m_nodeStatus.statusCountsTotal.cMissing > 0 || m_nodeStatus.statusCountsTotal.cTodo > 0)
			{
				XmlElement eltClasses = doc.CreateElement("classes");
				eltNameSpace.AppendChild (eltClasses);

				foreach (MissingType type in rgTypes) 
				{
					XmlElement eltClass = type.CreateXML (doc);
					if (eltClass != null)
						eltClasses.AppendChild (eltClass);
				}
			}
			return eltNameSpace;
		}


		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;
		}
	}
}