Author: toshok
Date: 2007-12-27 13:28:51 -0500 (Thu, 27 Dec 2007)
New Revision: 91958
Modified:
trunk/mono-tools/gui-compare/CecilMetadata.cs
trunk/mono-tools/gui-compare/ChangeLog
trunk/mono-tools/gui-compare/MasterMetadata.cs
Log:
* CecilMetadata.cs: rename Utils to CecilUtils. Also, fix the broken
logic that was resulting in private properties being included in
the list of properties (and therefore showing up as extras).
* MasterMetadata.cs: abstract out a lot of the list creation stuff into
a Utils class, like we do in CecilMetadata.cs Call it MasterUtils.
Modified: trunk/mono-tools/gui-compare/CecilMetadata.cs
===================================================================
--- trunk/mono-tools/gui-compare/CecilMetadata.cs 2007-12-27 17:37:54 UTC
(rev 91957)
+++ trunk/mono-tools/gui-compare/CecilMetadata.cs 2007-12-27 18:28:51 UTC
(rev 91958)
@@ -9,7 +9,7 @@
namespace GuiCompare {
- static class Utils {
+ static class CecilUtils {
public static void PopulateMemberLists (TypeDefinition fromDef,
List<CompNamed>
interface_list,
List<CompNamed>
constructor_list,
@@ -41,7 +41,13 @@
}
if (property_list != null) {
foreach (PropertyDefinition pd in
fromDef.Properties) {
- if (/*pd.IsPrivate ||
pd.IsAssembly*/true)
+ bool include_set = true;
+ bool include_get = true;
+ if (pd.SetMethod == null ||
(pd.SetMethod.IsPrivate || pd.SetMethod.IsAssembly))
+ include_set = false;
+ if (pd.GetMethod == null ||
(pd.GetMethod.IsPrivate || pd.GetMethod.IsAssembly))
+ include_get = false;
+ if (include_set || include_get)
property_list.Add (new
CecilProperty (pd));
}
}
@@ -141,7 +147,7 @@
if (t.IsSpecialName || t.IsRuntimeSpecialName)
continue;
- if (Utils.ShouldSkipAttribute (t.Name))
+ if (CecilUtils.ShouldSkipAttribute (t.Name))
continue;
if (!namespaces.ContainsKey (t.Namespace))
@@ -242,7 +248,7 @@
fields = new List<CompNamed>();
events = new List<CompNamed>();
- Utils.PopulateMemberLists (type_def,
+ CecilUtils.PopulateMemberLists (type_def,
interfaces,
constructors,
methods,
@@ -250,7 +256,7 @@
fields,
events);
- attributes = Utils.GetCustomAttributes (type_def);
+ attributes = CecilUtils.GetCustomAttributes (type_def);
}
public CecilInterface (TypeReference type_ref)
@@ -263,7 +269,7 @@
fields = new List<CompNamed>();
events = new List<CompNamed>();
- attributes = Utils.GetCustomAttributes (type_ref);
+ attributes = CecilUtils.GetCustomAttributes (type_ref);
}
public override List<CompNamed> GetInterfaces ()
@@ -328,7 +334,7 @@
fields = new List<CompNamed>();
- Utils.PopulateMemberLists (type_def,
+ CecilUtils.PopulateMemberLists (type_def,
null,
null,
null,
@@ -344,7 +350,7 @@
public override List<CompNamed> GetAttributes ()
{
- return Utils.GetCustomAttributes (type_def);
+ return CecilUtils.GetCustomAttributes (type_def);
}
TypeDefinition type_def;
@@ -363,7 +369,7 @@
nested_interfaces = new List<CompNamed>();
nested_structs = new List<CompNamed>();
- Utils.PopulateTypeLists (type_def,
+ CecilUtils.PopulateTypeLists (type_def,
nested_classes,
nested_enums,
nested_delegates,
@@ -377,7 +383,7 @@
fields = new List<CompNamed>();
events = new List<CompNamed>();
- Utils.PopulateMemberLists (type_def,
+ CecilUtils.PopulateMemberLists (type_def,
interfaces,
constructors,
methods,
@@ -419,7 +425,7 @@
public override List<CompNamed> GetAttributes ()
{
- return Utils.GetCustomAttributes (type_def);
+ return CecilUtils.GetCustomAttributes (type_def);
}
public override List<CompNamed> GetNestedClasses()
@@ -471,7 +477,7 @@
public override List<CompNamed> GetAttributes ()
{
- return Utils.GetCustomAttributes (field_def);
+ return CecilUtils.GetCustomAttributes (field_def);
}
FieldDefinition field_def;
@@ -486,7 +492,7 @@
public override List<CompNamed> GetAttributes ()
{
- return Utils.GetCustomAttributes (method_def);
+ return CecilUtils.GetCustomAttributes (method_def);
}
static string MasterinfoFormattedName (MethodDefinition
method_def)
@@ -519,16 +525,16 @@
public override List<CompNamed> GetAttributes ()
{
- return Utils.GetCustomAttributes (pd);
+ return CecilUtils.GetCustomAttributes (pd);
}
public override List<CompNamed> GetMethods()
{
List<CompNamed> rv = new List<CompNamed>();
- if (pd.GetMethod != null)
+ if (pd.GetMethod != null && !pd.GetMethod.IsPrivate &&
!pd.GetMethod.IsAssembly)
rv.Add (new CecilMethod (pd.GetMethod));
- if (pd.SetMethod != null)
+ if (pd.SetMethod != null && !pd.SetMethod.IsPrivate &&
!pd.SetMethod.IsAssembly)
rv.Add (new CecilMethod (pd.SetMethod));
return rv;
@@ -547,7 +553,7 @@
public override List<CompNamed> GetAttributes ()
{
- return Utils.GetCustomAttributes (ed);
+ return CecilUtils.GetCustomAttributes (ed);
}
EventDefinition ed;
Modified: trunk/mono-tools/gui-compare/ChangeLog
===================================================================
--- trunk/mono-tools/gui-compare/ChangeLog 2007-12-27 17:37:54 UTC (rev
91957)
+++ trunk/mono-tools/gui-compare/ChangeLog 2007-12-27 18:28:51 UTC (rev
91958)
@@ -1,5 +1,13 @@
2007-12-27 Chris Toshok <[EMAIL PROTECTED]>
+ * CecilMetadata.cs: rename Utils to CecilUtils. Also, fix the broken
logic
+ that was resulting in private properties being included in the list of
+ properties (and therefore showing up as extras).
+ * MasterMetadata.cs: abstract out a lot of the list creation stuff into
a
+ Utils class, like we do in CecilMetadata.cs Call it MasterUtils.
+
+2007-12-27 Chris Toshok <[EMAIL PROTECTED]>
+
* CecilMetadata.cs: add a ctor for CecilMetadata that takes a
TypeDefinition
(along with one that takes a TypeReference). in the type_def case, we
populate the member lists just as we would for a class, so we can
check
Modified: trunk/mono-tools/gui-compare/MasterMetadata.cs
===================================================================
--- trunk/mono-tools/gui-compare/MasterMetadata.cs 2007-12-27 17:37:54 UTC
(rev 91957)
+++ trunk/mono-tools/gui-compare/MasterMetadata.cs 2007-12-27 18:28:51 UTC
(rev 91958)
@@ -7,6 +7,73 @@
namespace GuiCompare {
+ static class MasterUtils {
+ public static void PopulateMethodList (XMLMethods methods,
List<CompNamed> method_list)
+ {
+ foreach (object key in methods.keys.Keys) {
+ XMLMethods.SignatureFlags signatureFlags =
(methods.signatureFlags != null &&
+
methods.signatureFlags.ContainsKey (key) ?
+
(XMLMethods.SignatureFlags) methods.signatureFlags [key] :
+
XMLMethods.SignatureFlags.None);
+
+ XMLParameters parameters = (methods.parameters
== null ? null
+ :
(XMLParameters)methods.parameters[key]);
+ XMLGenericMethodConstraints genericConstraints
= (methods.genericConstraints == null ? null
+
: (XMLGenericMethodConstraints)methods.genericConstraints[key]);
+ XMLAttributes attributes =
(methods.attributeMap == null ? null
+ :
(XMLAttributes)methods.attributeMap[key]);
+ method_list.Add (new MasterMethod
((string)methods.keys[key],
+
signatureFlags,
+ parameters,
+
genericConstraints,
+ attributes));
+ }
+ }
+
+ public static void PopulateMemberLists (XMLClass xml_cls,
+ List<CompNamed>
interface_list,
+ List<CompNamed>
constructor_list,
+ List<CompNamed>
method_list,
+ List<CompNamed>
property_list,
+ List<CompNamed>
field_list,
+ List<CompNamed>
event_list)
+ {
+ if (interface_list != null && xml_cls.interfaces !=
null) {
+ foreach (object i in
xml_cls.interfaces.keys.Keys) {
+ interface_list.Add (new MasterInterface
((string)xml_cls.interfaces.keys[i]));
+ }
+ }
+
+ if (constructor_list != null && xml_cls.constructors !=
null) {
+ PopulateMethodList (xml_cls.constructors,
constructor_list);
+ }
+
+ if (method_list != null && xml_cls.methods != null) {
+ PopulateMethodList (xml_cls.methods,
method_list);
+ }
+
+ if (property_list != null && xml_cls.properties !=
null) {
+ foreach (object key in
xml_cls.properties.keys.Keys) {
+ property_list.Add (new MasterProperty
((string)xml_cls.properties.keys[key],
+
(XMLMethods)xml_cls.properties.nameToMethod[key]));
+ }
+ }
+
+ if (field_list != null && xml_cls.fields != null) {
+ foreach (object key in
xml_cls.fields.keys.Keys) {
+ field_list.Add (new MasterField
((string)xml_cls.fields.keys[key]));
+ }
+ }
+
+ if (event_list != null && xml_cls.events != null) {
+ foreach (object key in
xml_cls.events.keys.Keys) {
+ event_list.Add (new MasterEvent
((string)xml_cls.events.keys[key],
+
(string)xml_cls.events.eventTypes[key]));
+ }
+ }
+ }
+ }
+
public class MasterAssembly : CompAssembly {
public MasterAssembly (string path)
: base (path)
@@ -46,7 +113,7 @@
else if (cls.type == "delegate")
delegate_list.Add (new MasterDelegate
(cls));
else if (cls.type == "interface")
- interface_list.Add (new MasterInterface
(cls.name));
+ interface_list.Add (new MasterInterface
(cls));
else if (cls.type == "struct")
struct_list.Add (new MasterClass (cls,
CompType.Struct));
}
@@ -87,45 +154,64 @@
}
public class MasterInterface : CompInterface {
+ public MasterInterface (XMLClass xml_cls)
+ : base (xml_cls.name)
+ {
+ interfaces = new List<CompNamed>();
+ constructors = new List<CompNamed>();
+ methods = new List<CompNamed>();
+ properties = new List<CompNamed>();
+ fields = new List<CompNamed>();
+ events = new List<CompNamed>();
+
+ MasterUtils.PopulateMemberLists (xml_cls,
+ interfaces,
+ constructors,
+ methods,
+ properties,
+ fields,
+ events);
+ }
+
public MasterInterface (string name)
: base (name)
{
+ interfaces = new List<CompNamed>();
+ constructors = new List<CompNamed>();
+ methods = new List<CompNamed>();
+ properties = new List<CompNamed>();
+ fields = new List<CompNamed>();
+ events = new List<CompNamed>();
}
public override List<CompNamed> GetInterfaces ()
{
- // XXX
- return new List<CompNamed>();
+ return interfaces;
}
public override List<CompNamed> GetMethods ()
{
- // XXX
- return new List<CompNamed>();
+ return methods;
}
public override List<CompNamed> GetConstructors ()
{
- // XXX
- return new List<CompNamed>();
+ return constructors;
}
public override List<CompNamed> GetProperties()
{
- // XXX
- return new List<CompNamed>();
+ return properties;
}
public override List<CompNamed> GetFields()
{
- // XXX
- return new List<CompNamed>();
+ return fields;
}
public override List<CompNamed> GetEvents()
{
- // XXX
- return new List<CompNamed>();
+ return events;
}
public override List<CompNamed> GetAttributes ()
@@ -133,6 +219,13 @@
// XXX
return new List<CompNamed>();
}
+
+ List<CompNamed> interfaces;
+ List<CompNamed> constructors;
+ List<CompNamed> methods;
+ List<CompNamed> properties;
+ List<CompNamed> fields;
+ List<CompNamed> events;
}
public class MasterDelegate : CompDelegate {
@@ -150,18 +243,22 @@
: base (cls.name)
{
xml_cls = cls;
+
+ fields = new List<CompNamed>();
+
+ MasterUtils.PopulateMemberLists (xml_cls,
+ null,
+ null,
+ null,
+ null,
+ fields,
+ null);
+
}
public override List<CompNamed> GetFields()
{
- List<CompNamed> rv = new List<CompNamed>();
- if (xml_cls.fields != null) {
- foreach (object key in
xml_cls.fields.keys.Keys) {
- rv.Add (new MasterField
((string)xml_cls.fields.keys[key]));
- }
- }
-
- return rv;
+ return fields;
}
public override List<CompNamed> GetAttributes ()
@@ -170,7 +267,7 @@
return new List<CompNamed>();
}
-
+ List<CompNamed> fields;
XMLClass xml_cls;
}
@@ -179,101 +276,51 @@
: base (cls.name, type)
{
xml_cls = cls;
+
+ interfaces = new List<CompNamed>();
+ constructors = new List<CompNamed>();
+ methods = new List<CompNamed>();
+ properties = new List<CompNamed>();
+ fields = new List<CompNamed>();
+ events = new List<CompNamed>();
+
+ MasterUtils.PopulateMemberLists (xml_cls,
+ interfaces,
+ constructors,
+ methods,
+ properties,
+ fields,
+ events);
}
public override List<CompNamed> GetInterfaces ()
{
- List<CompNamed> rv = new List<CompNamed>();
-
- if (xml_cls.interfaces != null) {
- foreach (object i in
xml_cls.interfaces.keys.Keys) {
- rv.Add (new MasterInterface
((string)xml_cls.interfaces.keys[i]));
- }
- }
-
-
- return rv;
+ return interfaces;
}
public override List<CompNamed> GetMethods()
{
- List<CompNamed> rv = new List<CompNamed>();
- if (xml_cls.methods != null) {
- foreach (object key in
xml_cls.methods.keys.Keys) {
- XMLMethods.SignatureFlags
signatureFlags = (xml_cls.methods.signatureFlags != null &&
-
xml_cls.methods.signatureFlags.ContainsKey (key) ?
-
(XMLMethods.SignatureFlags) xml_cls.methods.signatureFlags [key] :
-
XMLMethods.SignatureFlags.None);
-
- XMLParameters parameters =
(xml_cls.methods.parameters == null ? null
- :
(XMLParameters)xml_cls.methods.parameters[key]);
- XMLGenericMethodConstraints
genericConstraints = (xml_cls.methods.genericConstraints == null ? null
-
:
(XMLGenericMethodConstraints)xml_cls.methods.genericConstraints[key]);
- XMLAttributes attributes =
(xml_cls.methods.attributeMap == null ? null
- :
(XMLAttributes)xml_cls.methods.attributeMap[key]);
- rv.Add (new MasterMethod
((string)xml_cls.methods.keys[key],
-
signatureFlags,
- parameters,
-
genericConstraints,
- attributes));
- }
- }
-
- return rv;
+ return methods;
}
public override List<CompNamed> GetConstructors()
{
- List<CompNamed> rv = new List<CompNamed>();
- if (xml_cls.constructors != null) {
- foreach (object key in
xml_cls.constructors.keys.Keys) {
- rv.Add (new MasterMethod
((string)xml_cls.constructors.keys[key],
-
(XMLConstructors.SignatureFlags)xml_cls.constructors.signatureFlags[key],
-
(XMLParameters)xml_cls.constructors.parameters[key],
-
(XMLGenericMethodConstraints)xml_cls.constructors.genericConstraints[key],
-
(XMLAttributes)xml_cls.constructors.attributeMap[key]));
- }
- }
-
- return rv;
+ return constructors;
}
public override List<CompNamed> GetProperties()
{
- List<CompNamed> rv = new List<CompNamed>();
- if (xml_cls.properties != null) {
- foreach (object key in
xml_cls.properties.keys.Keys) {
- rv.Add (new MasterProperty
((string)xml_cls.properties.keys[key],
-
(XMLMethods)xml_cls.properties.nameToMethod[key]));
- }
- }
-
- return rv;
+ return properties;
}
public override List<CompNamed> GetFields()
{
- List<CompNamed> rv = new List<CompNamed>();
- if (xml_cls.fields != null) {
- foreach (object key in
xml_cls.fields.keys.Keys) {
- rv.Add (new MasterField
((string)xml_cls.fields.keys[key]));
- }
- }
-
- return rv;
+ return fields;
}
public override List<CompNamed> GetEvents()
{
- List<CompNamed> rv = new List<CompNamed>();
- if (xml_cls.events != null) {
- foreach (object key in
xml_cls.events.keys.Keys) {
- rv.Add (new MasterEvent
((string)xml_cls.events.keys[key],
-
(string)xml_cls.events.eventTypes[key]));
- }
- }
-
- return rv;
+ return events;
}
public override List<CompNamed> GetAttributes ()
@@ -316,8 +363,15 @@
}
XMLClass xml_cls;
- }
+ List<CompNamed> interfaces;
+ List<CompNamed> constructors;
+ List<CompNamed> methods;
+ List<CompNamed> properties;
+ List<CompNamed> fields;
+ List<CompNamed> events;
+}
+
public class MasterEvent : CompEvent {
public MasterEvent (string name,
string eventType)
@@ -347,10 +401,12 @@
}
public class MasterProperty : CompProperty {
- public MasterProperty (string name, XMLMethods methods)
+ public MasterProperty (string name, XMLMethods xml_methods)
: base (name)
- {
- this.methods = methods;
+ {
+ methods = new List<CompNamed>();
+
+ MasterUtils.PopulateMethodList (xml_methods, methods);
}
public override List<CompNamed> GetAttributes ()
@@ -361,36 +417,12 @@
public override List<CompNamed> GetMethods()
{
- List<CompNamed> method_list = new List<CompNamed>();
-
- if (methods != null) {
- foreach (object key in methods.keys.Keys) {
- XMLMethods.SignatureFlags
signatureFlags = (methods.signatureFlags != null &&
-
methods.signatureFlags.ContainsKey (key) ?
-
(XMLMethods.SignatureFlags) methods.signatureFlags [key] :
-
XMLMethods.SignatureFlags.None);
+ return methods;
+ }
- XMLParameters parameters =
(methods.parameters == null ? null
- :
(XMLParameters)methods.parameters[key]);
- XMLGenericMethodConstraints
genericConstraints = (methods.genericConstraints == null ? null
-
: (XMLGenericMethodConstraints)methods.genericConstraints[key]);
- XMLAttributes attributes =
(methods.attributeMap == null ? null
- :
(XMLAttributes)methods.attributeMap[key]);
- method_list.Add (new MasterMethod
((string)methods.keys[key],
-
signatureFlags,
-
parameters,
-
genericConstraints,
-
attributes));
- }
- }
-
- return method_list;
- }
-
- XMLMethods methods;
+ List<CompNamed> methods;
}
- // XXX more stuff is needed here besides the name
public class MasterMethod : CompMethod {
public MasterMethod (string name,
XMLMethods.SignatureFlags signatureFlags,
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches