Author: nestor
Date: 2008-02-07 11:47:43 -0500 (Thu, 07 Feb 2008)
New Revision: 95154
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Smells/ChangeLog
Log:
2008-02-07 Nestor Salceda <[EMAIL PROTECTED]>
* AvoidLongMethodsRule.cs: As suggested by Sebastien, the new
comparisons are better than a string comparison.
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs
===================================================================
---
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs
2008-02-07 16:31:59 UTC (rev 95153)
+++
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Smells/AvoidLongMethodsRule.cs
2008-02-07 16:47:43 UTC (rev 95154)
@@ -74,16 +74,6 @@
return false;
}
- private static bool IsStaticConstructor (MethodDefinition
method)
- {
- return method.Name == MethodDefinition.Cctor;
- }
-
- private static bool IsConstructor (MethodDefinition method)
- {
- return method.Name == MethodDefinition.Ctor;
- }
-
private static int CountStaticFields (TypeDefinition type) {
int counter = 0;
foreach (FieldDefinition field in type.Fields) {
@@ -132,11 +122,11 @@
// rule applies!
// success if the instruction count is below the
defined threshold
- if (IsStaticConstructor (method)) {
+ if (method.IsConstructor && method.IsStatic) {
if (method.Body.Instructions.Count <=
MaxInstructions + (CountStaticFields (method.DeclaringType as TypeDefinition) *
AsignationRatio))
return runner.RuleSuccess;
}
- else if (IsConstructor (method)) {
+ else if (method.IsConstructor && method.IsStatic) {
if (method.Body.Instructions.Count <=
MaxInstructions + (CountInstanceFields (method.DeclaringType as TypeDefinition)
* AsignationRatio))
return runner.RuleSuccess;
}
Modified: trunk/mono-tools/gendarme/rules/Gendarme.Rules.Smells/ChangeLog
===================================================================
--- trunk/mono-tools/gendarme/rules/Gendarme.Rules.Smells/ChangeLog
2008-02-07 16:31:59 UTC (rev 95153)
+++ trunk/mono-tools/gendarme/rules/Gendarme.Rules.Smells/ChangeLog
2008-02-07 16:47:43 UTC (rev 95154)
@@ -1,4 +1,9 @@
2008-02-07 Nestor Salceda <[EMAIL PROTECTED]>
+
+ * AvoidLongMethodsRule.cs: As suggested by Sebastien, the new
+ comparisons are better than a string comparison.
+
+2008-02-07 Nestor Salceda <[EMAIL PROTECTED]>
* AvoidLongMethodsRule.cs: The rule should be applied to static
constructors. Now we add several extra instructions for each field for
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches