Author: spouliot
Date: 2008-02-06 22:08:38 -0500 (Wed, 06 Feb 2008)
New Revision: 95110

Modified:
   trunk/mono-tools/gendarme/framework/Gendarme.Framework.Rocks/ChangeLog
   trunk/mono-tools/gendarme/framework/Gendarme.Framework.Rocks/TypeRocks.cs
Log:
2008-02-06  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * TypeRocks.cs: IsAttribute now works on a TypeReference. Fix 
        IsVisible documentation (it needs a TypeDefinition). Rework 
        IsGeneratedCode to ensure it catch the <Module> type (which is not
        marked with an attribute).



Modified: trunk/mono-tools/gendarme/framework/Gendarme.Framework.Rocks/ChangeLog
===================================================================
--- trunk/mono-tools/gendarme/framework/Gendarme.Framework.Rocks/ChangeLog      
2008-02-07 03:07:04 UTC (rev 95109)
+++ trunk/mono-tools/gendarme/framework/Gendarme.Framework.Rocks/ChangeLog      
2008-02-07 03:08:38 UTC (rev 95110)
@@ -1,3 +1,10 @@
+2008-02-06  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * TypeRocks.cs: IsAttribute now works on a TypeReference. Fix 
+       IsVisible documentation (it needs a TypeDefinition). Rework 
+       IsGeneratedCode to ensure it catch the <Module> type (which is not
+       marked with an attribute).
+
 2008-01-30  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * CommonRocks.cs: New. Shared but not Gendarme/Cecil specific rocks.

Modified: 
trunk/mono-tools/gendarme/framework/Gendarme.Framework.Rocks/TypeRocks.cs
===================================================================
--- trunk/mono-tools/gendarme/framework/Gendarme.Framework.Rocks/TypeRocks.cs   
2008-02-07 03:07:04 UTC (rev 95109)
+++ trunk/mono-tools/gendarme/framework/Gendarme.Framework.Rocks/TypeRocks.cs   
2008-02-07 03:08:38 UTC (rev 95110)
@@ -278,10 +278,10 @@
                /// we might now be able to know all inheritance since the 
assembly where 
                /// the information resides could be unavailable.
                /// </summary>
-               /// <param name="self">The TypeDefinition on which the 
extension method can be called.</param>
+               /// <param name="self">The TypeReference on which the extension 
method can be called.</param>
                /// <returns>True if the type inherits from 
<c>System.Attribute</c>, 
                /// False otherwise.</returns>
-               public static bool IsAttribute (this TypeDefinition self)
+               public static bool IsAttribute (this TypeReference self)
                {
                        return self.Inherits ("System.Attribute");
                }
@@ -322,14 +322,15 @@
                        if (self.Module.Assembly.Runtime >= 
TargetRuntime.NET_2_0) {
                                if (self.CustomAttributes.ContainsAnyType 
(CustomAttributeRocks.GeneratedCodeAttributes))
                                        return true;
-                       } else {
-                               switch (self.Name [0]) {
-                               case '<': // e.g. <PrivateImplementationDetails>
-                               case '$': // e.g. $ArrayType$1 nested inside 
<PrivateImplementationDetails>
-                                       return true;
-                               }
                        }
 
+                       // sadly <Module> still shows up for 2.0, so the 1.x 
logic still applies
+                       switch (self.Name [0]) {
+                       case '<': // e.g. <Module>, 
<PrivateImplementationDetails>
+                       case '$': // e.g. $ArrayType$1 nested inside 
<PrivateImplementationDetails>
+                               return true;
+                       }
+
                        // the type could be nested (inside a generated one) 
and not marked itself
                        if (self.IsNested)
                                return self.DeclaringType.IsGeneratedCode ();
@@ -356,7 +357,7 @@
                /// <summary>
                /// Check if the type is visible outside of the assembly.
                /// </summary>
-               /// <param name="self">The TypeReference on which the extension 
method can be called.</param>
+               /// <param name="self">The TypeDefinition on which the 
extension method can be called.</param>
                /// <returns>True if the type can be used from outside of the 
assembly, false otherwise.</returns>
                public static bool IsVisible (this TypeDefinition self)
                {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to