Author: nestor
Date: 2007-10-19 07:23:01 -0400 (Fri, 19 Oct 2007)
New Revision: 87820

Modified:
   trunk/cecil/gendarme/rules/Gendarme.Rules.Correctness/ChangeLog
   
trunk/cecil/gendarme/rules/Gendarme.Rules.Correctness/UseValueInPropertySetterRule.cs
Log:
2007-10-19  Nestor Salceda  <[EMAIL PROTECTED]>
        
        * UseValueInPropertySetterRule.cs:  If a method is empty, then the rule
        will skip this method, because could be an stub or empty method.  This
        fixes the NullReferenceException if the method body is empty.



Modified: trunk/cecil/gendarme/rules/Gendarme.Rules.Correctness/ChangeLog
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Correctness/ChangeLog     
2007-10-19 11:14:45 UTC (rev 87819)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Correctness/ChangeLog     
2007-10-19 11:23:01 UTC (rev 87820)
@@ -1,5 +1,11 @@
 2007-10-19  Nestor Salceda  <[EMAIL PROTECTED]>
+       
+       * UseValueInPropertySetterRule.cs:  If a method is empty, then the rule
+       will skip this method, because could be an stub or empty method.  This
+       fixes the NullReferenceException if the method body is empty.
 
+2007-10-19  Nestor Salceda  <[EMAIL PROTECTED]>
+
        * FloatComparisonRule.cs: Before get the instructions from the method
        body, the existence of method body should be checked.  This fixes the
        NullReferenceException.

Modified: 
trunk/cecil/gendarme/rules/Gendarme.Rules.Correctness/UseValueInPropertySetterRule.cs
===================================================================
--- 
trunk/cecil/gendarme/rules/Gendarme.Rules.Correctness/UseValueInPropertySetterRule.cs
       2007-10-19 11:14:45 UTC (rev 87819)
+++ 
trunk/cecil/gendarme/rules/Gendarme.Rules.Correctness/UseValueInPropertySetterRule.cs
       2007-10-19 11:23:01 UTC (rev 87820)
@@ -49,6 +49,12 @@
                        if ((method.Attributes & MethodAttributes.SpecialName) 
== MethodAttributes.SpecialName && method.Name.StartsWith("set_"))
                        {
                                bool valueAccessed = false;
+
+                               //Skip the test, instead of flooding messages 
+                               //in stubs or empty setters empty setter.
+                               if (!method.HasBody) 
+                                       return null;
+
                                foreach (Instruction instruction in 
method.Body.Instructions)
                                {
                                        if (instruction.OpCode.Code == 
Code.Ldarg_1)

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

Reply via email to