2004-12-06 Ben Maurer <bmaurer@ximian.com>
[mono-project.git] / status / compare-assembly.cs
blob87028889922f24969ea17362a79ceaa8637c981d
1 /*
2 Tool #1:
4 compare file1.dll file2.dll annotations.xml
6 file1.dll: This is an assembly created by Microsoft.
8 file2.dll: This is a Mono assembly (currently we have none
9 that build).
11 annotations.xml: contains comments about a class:
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>
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:
25 <class name="System.Object">
26 </class>
28 Tool #2:
30 Using a Perl script that can grok XML, generate HTML pages
31 that we can put on the web site:
33 Per assembly status.
34 Per maintainer status.
35 Per Percent status.
39 using System;
40 using System.Collections;
41 using System.Reflection;
42 using System.Xml;
44 namespace Mapper
46 public class Mapper
48 Assembly ms, mono;
49 XmlDocument annotations, output;
51 public Mapper(string ms_lib, string mono_lib, string annotation)
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 ();
60 void DumpMember (MemberInfo mi)
62 string kind;
63 string more="";
65 switch (mi.MemberType)
67 case MemberTypes.Field:
68 kind = "field";
69 break;
70 case MemberTypes.Method:
71 if (((MethodInfo)mi).IsSpecialName) {
72 return;
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;
89 void DumpType (Type t)
91 string kind, name, attrs = "";
93 name = t.Name;
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;
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'";
113 foreach (Type type in t.GetNestedTypes ()) {
114 DumpType (type);
117 foreach (FieldInfo field in t.GetFields ()) {
118 DumpMember (field);
121 foreach (MethodInfo method in t.GetMethods ()) {
122 DumpMember (method);
127 void LoadTypeList (Type [] types)
129 foreach (Type t in types) {
133 public void Map ()
135 Type [] types;
136 Module [] modules;
137 string name;
139 name = ms.GetName ().Name;
140 types = ms.GetExportedTypes ();
141 modules = ms.GetModules ();
143 DumpTypeList (types);
146 public static int Main(string[] args)
148 Mapper m;
149 string basedir = "c:\\WINDOWS\\Microsoft.NET\\Framework\\v1.0.2914\\";
151 if (args.Length != 3) {
152 Console.WriteLine ("usage: compare ms_lib.dll mono_lib.dll annotations.xml");
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 ());
160 return 0;