Author: nestor
Date: 2007-12-21 10:27:50 -0500 (Fri, 21 Dec 2007)
New Revision: 91765

Modified:
   trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ChangeLog
   trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ExpressionFillerVisitor.cs
Log:
2007-12-21  Nestor Salceda  <[EMAIL PROTECTED]>

        * ExpressionFillerVisitor.cs: Avoid creating empty expressions, because
        the equals method in the Expression class checks for the same size, and
        if the size is zero, then the equals returns true. Fixes one of the 
        bug in code compiled under csc without optimization flag.
        


Modified: trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ChangeLog
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ChangeLog  2007-12-21 
15:26:03 UTC (rev 91764)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ChangeLog  2007-12-21 
15:27:50 UTC (rev 91765)
@@ -1,3 +1,10 @@
+2007-12-21  Nestor Salceda  <[EMAIL PROTECTED]>
+
+       * ExpressionFillerVisitor.cs: Avoid creating empty expressions, because
+       the equals method in the Expression class checks for the same size, and
+       if the size is zero, then the equals returns true.  Fixes one of the 
+       bug in code compiled under csc without optimization flag.
+
 2007-11-30  Nestor Salceda  <[EMAIL PROTECTED]>
 
        * AvoidLargeClassesRule.cs: As the rule is only applied to types, then

Modified: 
trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ExpressionFillerVisitor.cs
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ExpressionFillerVisitor.cs 
2007-12-21 15:26:03 UTC (rev 91764)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Smells/ExpressionFillerVisitor.cs 
2007-12-21 15:27:50 UTC (rev 91765)
@@ -53,10 +53,18 @@
                                instruction.OpCode.Code == Code.Stfld;
                }
 
+               private bool CanCreateANewExpression () 
+               {
+                       return currentExpression == null || 
+                               (currentExpression != null && 
currentExpression.Count != 0);
+               }
+
                private void CreateExpressionAndAddToExpressionContainer ()
                {
-                       currentExpression = new Expression ();
-                       expressionContainer.Add (currentExpression);
+                       if (CanCreateANewExpression ()) {
+                               currentExpression = new Expression ();
+                               expressionContainer.Add (currentExpression);
+                       }
                }
 
                private bool IsDelimiter (Instruction instruction)

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

Reply via email to