[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mono-patches
Subject:    [Mono-patches] r120295 -
From:       "Sebastien Pouliot (sebastien () ximian ! com)"
Date:       2008-11-30 5:08:17
Message-ID: 20081130050817.DA7A09472C () mono-cvs ! ximian ! com
[Download RAW message or body]

Author: spouliot
Date: 2008-11-30 00:08:16 -0500 (Sun, 30 Nov 2008)
New Revision: 120295

Modified:
   trunk/mono-tools/gendarme/framework/Gendarme.Framework/AssemblyResolver.cs
   trunk/mono-tools/gendarme/framework/Gendarme.Framework/ChangeLog
   trunk/mono-tools/gendarme/framework/Gendarme.Framework/EngineController.cs
Log:
2008-11-29  Sebastien Pouliot  <sebastien@ximian.com>

	* AssemblyResolver.cs: Use Has{x} to avoid creating fields and 
	parameters collections while resolving.
	* EngineController.cs: Use Has{x} whenever possible to avoid the
	creation of empty collections in Cecil.



Modified: trunk/mono-tools/gendarme/framework/Gendarme.Framework/AssemblyResolver.cs
===================================================================
--- trunk/mono-tools/gendarme/framework/Gendarme.Framework/AssemblyResolver.cs	2008-11-30 \
                02:48:56 UTC (rev 120294)
+++ trunk/mono-tools/gendarme/framework/Gendarme.Framework/AssemblyResolver.cs	2008-11-30 \
05:08:16 UTC (rev 120295) @@ -102,14 +102,16 @@
 			if (type == null)
 				return (field as FieldDefinition);		// could not resolve type
 
-			foreach (FieldDefinition fd in type.Fields) {
-				if (fd.Name != field.Name)
-					continue;
+			if (type.HasFields) {
+				foreach (FieldDefinition fd in type.Fields) {
+					if (fd.Name != field.Name)
+						continue;
 
-				if (!AreSame (fd.FieldType, field.FieldType))
-					continue;
+					if (!AreSame (fd.FieldType, field.FieldType))
+						continue;
 
-				return fd;
+					return fd;
+				}
 			}
 
 			return null;
@@ -158,8 +160,10 @@
 				if (!AreSame (meth.ReturnType.ReturnType, reference.ReturnType.ReturnType))
 					continue;
 
-				if (!AreSame (meth.Parameters, reference.Parameters))
-					continue;
+				if (meth.HasParameters) {
+					if (!AreSame (meth.Parameters, reference.Parameters))
+						continue;
+				}
 
 				return meth;
 			}

Modified: trunk/mono-tools/gendarme/framework/Gendarme.Framework/ChangeLog
===================================================================
--- trunk/mono-tools/gendarme/framework/Gendarme.Framework/ChangeLog	2008-11-30 \
                02:48:56 UTC (rev 120294)
+++ trunk/mono-tools/gendarme/framework/Gendarme.Framework/ChangeLog	2008-11-30 \
05:08:16 UTC (rev 120295) @@ -1,3 +1,10 @@
+2008-11-29  Sebastien Pouliot  <sebastien@ximian.com>
+
+	* AssemblyResolver.cs: Use Has{x} to avoid creating fields and 
+	parameters collections while resolving.
+	* EngineController.cs: Use Has{x} whenever possible to avoid the
+	creation of empty collections in Cecil.
+
 2008-11-19  Sebastien Pouliot  <sebastien@ximian.com>
 
 	* Rule.cs: Do not create a new Uri each time we ask for one (its 

Modified: trunk/mono-tools/gendarme/framework/Gendarme.Framework/EngineController.cs
===================================================================
--- trunk/mono-tools/gendarme/framework/Gendarme.Framework/EngineController.cs	2008-11-30 \
                02:48:56 UTC (rev 120294)
+++ trunk/mono-tools/gendarme/framework/Gendarme.Framework/EngineController.cs	2008-11-30 \
05:08:16 UTC (rev 120295) @@ -85,18 +85,21 @@
 
 						BuildCustomAttributes (type, e);
 
-						foreach (FieldDefinition field in type.Fields) {
-							BuildCustomAttributes (field, e);
+						if (type.HasFields) {
+							foreach (FieldDefinition field in type.Fields)
+								BuildCustomAttributes (field, e);
 						}
 
 						// TODO check custom attributes (events)
 						// TODO check custom attributes (properties)
 
-						foreach (MethodDefinition ctor in type.Constructors) {
-							Build (ctor, e);
+						if (type.HasConstructors) {
+							foreach (MethodDefinition ctor in type.Constructors)
+								Build (ctor, e);
 						}
-						foreach (MethodDefinition method in type.Methods) {
-							Build (method, e);
+						if (type.HasMethods) {
+							foreach (MethodDefinition method in type.Methods)
+								Build (method, e);
 						}
 					}
 				}
@@ -105,7 +108,7 @@
 
 		private void BuildCustomAttributes (ICustomAttributeProvider custom, \
EngineEventArgs e)  {
-			if (custom.CustomAttributes.Count > 0) {
+			if (custom.HasCustomAttributes) {
 				EventHandler<EngineEventArgs> handler = BuildingCustomAttributes;
 				if (handler != null)
 					handler (custom, e);

_______________________________________________
Mono-patches maillist  -  Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic