Fixed bug number.
[mono.git] / status / compare-assembly.cs
1 /*
2 Tool #1:
3
4         compare file1.dll file2.dll annotations.xml
5
6         file1.dll: This is an assembly created by Microsoft.
7
8         file2.dll: This is a Mono assembly (currently we have none
9         that build).
10
11         annotations.xml: contains comments about a class:
12
13         <class name="System.Object">
14                 <maintainer>
15                         <email>miguel@ximian.com</email>
16                         <name>Miguel de Icaza</name>
17                 </maintainer>
18                 <status test-suite="no" percent="XX">
19         </class>
20
21         That would generate an XML file with all the classes that are
22         implemented in the second library.  If there is nothing for a
23         given class, it should generate an emtpy group:
24
25         <class name="System.Object">
26         </class>
27
28 Tool #2:
29
30         Using a Perl script that can grok XML, generate HTML pages
31         that we can put on the web site:
32
33                 Per assembly status.
34                 Per maintainer status.
35                 Per Percent status.
36
37 */
38
39 using System;
40 using System.Collections;
41 using System.Reflection;
42 using System.Xml;
43
44 namespace Mapper
45 {
46         public class Mapper
47         {
48                 Assembly ms, mono;
49                 XmlDocument annotations, output;
50
51                 public Mapper(string ms_lib, string mono_lib, string annotation)
52                 {
53                         Assembly ms = Assembly.LoadFrom (ms_lib);
54                         Assembly mono = Assembly.LoadFrom (mono_lib);
55                         annotations = new XmlDocument ();
56                         annotations.Load (annotation);
57                         output = new XmlDocument ();
58                 }
59
60                 void DumpMember (MemberInfo mi)
61                 {
62                         string kind;
63                         string more="";
64
65                         switch (mi.MemberType)
66                                 {
67                                 case MemberTypes.Field:
68                                         kind = "field";
69                                         break;
70                                 case MemberTypes.Method:
71                                         if (((MethodInfo)mi).IsSpecialName) {
72                                                 return;
73                                         }
74                                         kind = "method";
75                                         more = " signature='" + mi.ToString() +"'";
76                                         break;
77                                 case MemberTypes.Event:
78                                         kind = "event";
79                                         break;
80                                 case MemberTypes.Property:
81                                         kind = "property";
82                                         break;
83                                 default:
84                                         kind = "***UNKOWN***";
85                                         break;
86                                 }
87                 }
88
89                 void DumpType (Type t)
90                 {
91                         string kind, name, attrs = "";
92
93                         name = t.Name;
94
95                         if (t.IsClass) {
96                                 kind = "class";
97                         } else if (t.IsInterface) {
98                                 kind = "interface";
99                         } else if (t.IsValueType) {
100                                 kind = "valueType";
101                         } else if (t.IsEnum) {
102                                 kind = "enum";
103                         } else return;
104
105                         if (t.IsAbstract) {
106                                 attrs += "abstract='true'";
107                         } else if (t.IsSealed) {
108                                 attrs += "sealed='true'";
109                         } else if (t.IsCOMObject) {
110                                 attrs += "comobject='true'";
111                         }
112
113                         foreach (Type type in t.GetNestedTypes ()) {
114                                         DumpType (type);
115                         }
116
117                         foreach (FieldInfo field in t.GetFields ()) {
118                                         DumpMember (field);
119                         }
120
121                         foreach (MethodInfo method in t.GetMethods ()) {
122                                 DumpMember (method);
123                         }
124
125                 }
126         
127                 void LoadTypeList (Type [] types)
128                 {
129                         foreach (Type t in types) {
130                         }
131                 }
132         
133                 public void Map ()
134                 {
135                         Type [] types;
136                         Module [] modules;
137                         string name;
138
139                         name = ms.GetName ().Name;
140                         types = ms.GetExportedTypes ();
141                         modules = ms.GetModules ();
142
143                         DumpTypeList (types);
144                 }
145
146                 public static int Main(string[] args)
147                 {
148                         Mapper m;
149                         string basedir = "c:\\WINDOWS\\Microsoft.NET\\Framework\\v1.0.2914\\";
150
151                         if (args.Length != 3) {
152                                 Console.WriteLine ("usage: compare ms_lib.dll mono_lib.dll annotations.xml");
153                         }
154                         try {
155                                 m = new Mapper (args[0], args[1], args[2]);
156                                 m.Map ();
157                         } catch (Exception e) {
158                                 Console.WriteLine("Error: " + e.ToString ());
159                         }               
160                         return 0;
161                 }
162         }
163 }
164