Author: spouliot
Date: 2008-01-19 12:26:28 -0500 (Sat, 19 Jan 2008)
New Revision: 93319

Modified:
   trunk/cecil/gendarme/framework/Gendarme.Framework.Rocks/ChangeLog
   trunk/cecil/gendarme/framework/Gendarme.Framework.Rocks/TypeRocks.cs
Log:
2008-01-19  Sebastien Pouliot  <[EMAIL PROTECTED]> 

        * TypeRocks.cs: Handle nested types in IsGeneratedCode for all
        framework versions.



Modified: trunk/cecil/gendarme/framework/Gendarme.Framework.Rocks/ChangeLog
===================================================================
--- trunk/cecil/gendarme/framework/Gendarme.Framework.Rocks/ChangeLog   
2008-01-19 16:18:15 UTC (rev 93318)
+++ trunk/cecil/gendarme/framework/Gendarme.Framework.Rocks/ChangeLog   
2008-01-19 17:26:28 UTC (rev 93319)
@@ -1,3 +1,8 @@
+2008-01-19  Sebastien Pouliot  <[EMAIL PROTECTED]> 
+
+       * TypeRocks.cs: Handle nested types in IsGeneratedCode for all
+       framework versions.
+
 2008-01-18  Sebastien Pouliot  <[EMAIL PROTECTED]> 
 
        * TypeRocks.cs: Add [Get|Has]Method rocks from Andreas Noever. Mark

Modified: trunk/cecil/gendarme/framework/Gendarme.Framework.Rocks/TypeRocks.cs
===================================================================
--- trunk/cecil/gendarme/framework/Gendarme.Framework.Rocks/TypeRocks.cs        
2008-01-19 16:18:15 UTC (rev 93318)
+++ trunk/cecil/gendarme/framework/Gendarme.Framework.Rocks/TypeRocks.cs        
2008-01-19 17:26:28 UTC (rev 93319)
@@ -318,26 +318,22 @@
                /// False otherwise (e.g. compiler or tool generated)</returns>
                public static bool IsGeneratedCode (this TypeReference self)
                {
+                       // both helpful attributes only exists in 2.0 and more 
recent frameworks
                        if (self.Module.Assembly.Runtime >= 
TargetRuntime.NET_2_0) {
                                if (self.CustomAttributes.ContainsAnyType 
(CustomAttributeRocks.GeneratedCodeAttributes))
                                        return true;
-
-                               TypeReference type = self;
-                               while (type.IsNested) {
-                                       if 
(type.CustomAttributes.ContainsAnyType 
(CustomAttributeRocks.GeneratedCodeAttributes))
-                                               return true;
-                                       type = type.DeclaringType;
-                               }
-                               return false;
                        } else {
                                switch (self.Name [0]) {
                                case '<': // e.g. <PrivateImplementationDetails>
                                case '$': // e.g. $ArrayType$1 nested inside 
<PrivateImplementationDetails>
                                        return true;
-                               default:
-                                       return false;
                                }
                        }
+
+                       // the type could be nested (inside a generated one) 
and not marked itself
+                       if (self.IsNested)
+                               return self.DeclaringType.IsGeneratedCode ();
+                       return false;
                }
 
                /// <summary>

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

Reply via email to