Author: spouliot
Date: 2008-01-11 20:08:27 -0500 (Fri, 11 Jan 2008)
New Revision: 92708

Modified:
   
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/AvoidUncalledPrivateCodeRule.cs
   
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/AvoidUninstantiatedInternalClassesRule.cs
   trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/ChangeLog
   trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UseStringEmptyRule.cs
   
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UsingStringLengthInsteadOfCheckingEmptyStringRule.cs
Log:
2008-01-11  Sebastien Pouliot  <[EMAIL PROTECTED]> 

        * AvoidUncalledPrivateCodeRule.cs: Use new Location ctors.
        * AvoidUninstantiatedInternalClassesRule.cs: Use new Location ctors.
        * UseStringEmptyRule.cs: Use new Location ctors.
        * UsingStringLengthInsteadOfCheckingEmptyStringRule.cs: Don't 
        create MessageCollection until needed. Use new Location ctors.



Modified: 
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/AvoidUncalledPrivateCodeRule.cs
===================================================================
--- 
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/AvoidUncalledPrivateCodeRule.cs
       2008-01-12 01:07:58 UTC (rev 92707)
+++ 
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/AvoidUncalledPrivateCodeRule.cs
       2008-01-12 01:08:27 UTC (rev 92708)
@@ -101,7 +101,7 @@
 
                                // then we must check if this type use the 
private method
                                if (!CheckTypeForMethodUsage 
((method.DeclaringType as TypeDefinition), method)) {
-                                       Location location = new Location 
(method.DeclaringType.FullName, method.Name, 0);
+                                       Location location = new Location 
(method);
                                        Message message = new Message ("The 
private method code is not used in it's declaring type.", location, 
MessageType.Error);
                                        return new MessageCollection (message);
                                }
@@ -115,7 +115,7 @@
 
                                // then we must check if something in the 
assembly is using this method
                                if (!CheckAssemblyForMethodUsage 
(method.DeclaringType.Module.Assembly, method)) {
-                                       Location location = new Location 
(method.DeclaringType.FullName, method.Name, 0);
+                                       Location location = new Location 
(method);
                                        Message message = new Message ("The 
internal method code is not used in it's declaring assembly.", location, 
MessageType.Error);
                                        return new MessageCollection (message);
                                }

Modified: 
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/AvoidUninstantiatedInternalClassesRule.cs
===================================================================
--- 
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/AvoidUninstantiatedInternalClassesRule.cs
     2008-01-12 01:07:58 UTC (rev 92707)
+++ 
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/AvoidUninstantiatedInternalClassesRule.cs
     2008-01-12 01:08:27 UTC (rev 92708)
@@ -136,7 +136,7 @@
 
                        // if we can't find the non-public type being used in 
the assembly then the rule fails
                        if (list == null || !list.Contains (type)) {
-                               Location location = new Location 
(type.FullName, null);
+                               Location location = new Location (type);
                                Message message = new Message ("There is no 
call for any of the types constructor found", location, MessageType.Error);
                                return new MessageCollection (message);
                        }

Modified: trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/ChangeLog
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/ChangeLog     
2008-01-12 01:07:58 UTC (rev 92707)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/ChangeLog     
2008-01-12 01:08:27 UTC (rev 92708)
@@ -1,3 +1,11 @@
+2008-01-11  Sebastien Pouliot  <[EMAIL PROTECTED]> 
+
+       * AvoidUncalledPrivateCodeRule.cs: Use new Location ctors.
+       * AvoidUninstantiatedInternalClassesRule.cs: Use new Location ctors.
+       * UseStringEmptyRule.cs: Use new Location ctors.
+       * UsingStringLengthInsteadOfCheckingEmptyStringRule.cs: Don't 
+       create MessageCollection until needed. Use new Location ctors.
+
 2008-01-08  Sebastien Pouliot  <[EMAIL PROTECTED]> 
 
        * AvoidUncalledPrivateCodeRule.cs: Don't report any serialization

Modified: 
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UseStringEmptyRule.cs
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UseStringEmptyRule.cs 
2008-01-12 01:07:58 UTC (rev 92707)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UseStringEmptyRule.cs 
2008-01-12 01:08:27 UTC (rev 92708)
@@ -4,7 +4,7 @@
 // Authors:
 //     Sebastien Pouliot <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2006-2008 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -27,11 +27,10 @@
 //
 
 using System;
-using System.Collections;
-using System.Globalization;
 
 using Mono.Cecil;
 using Mono.Cecil.Cil;
+
 using Gendarme.Framework;
 
 namespace Gendarme.Rules.Performance {
@@ -47,7 +46,6 @@
                        // *** ok, the rule applies! ***
 
                        MessageCollection results = null;
-                       string fullname = method.DeclaringType.FullName;
 
                        // #2 - look for string references
                        foreach (Instruction ins in method.Body.Instructions) {
@@ -55,7 +53,7 @@
                                case OperandType.InlineString:
                                        string s = (ins.Operand as string);
                                        if (s.Length == 0) {
-                                               Location loc = new Location 
(fullname, method.Name, ins.Offset);
+                                               Location loc = new Location 
(method, ins.Offset);
                                                Message msg = new Message 
("instance of an empty string has been found.",
                                                        loc, 
MessageType.Warning);
                                                if (results == null)

Modified: 
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UsingStringLengthInsteadOfCheckingEmptyStringRule.cs
===================================================================
--- 
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UsingStringLengthInsteadOfCheckingEmptyStringRule.cs
  2008-01-12 01:07:58 UTC (rev 92707)
+++ 
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UsingStringLengthInsteadOfCheckingEmptyStringRule.cs
  2008-01-12 01:08:27 UTC (rev 92708)
@@ -40,23 +40,24 @@
                        if (!method.HasBody)
                                return runner.RuleSuccess;
 
-                       MessageCollection messageCollection = new 
MessageCollection ();
+                       MessageCollection messageCollection = null;
 
                        foreach (Instruction instruction in 
method.Body.Instructions) {
                                if (instruction.Operand != null) {
                                        if (instruction.Operand.ToString () == 
"System.Boolean System.String::Equals(System.String)") {
                                                Instruction prevInstr = 
instruction.Previous;
                                                if (prevInstr.OpCode.Name == 
"ldstr" && prevInstr.Operand.ToString().Length == 0) {
-                                                       Location location = new 
Location (method.DeclaringType.ToString(), method.Name, instruction.Offset);
+                                                       Location location = new 
Location (method, instruction.Offset);
                                                        Message message = new 
Message ("Method uses .Equals (\"\") method to check for empty string instead 
of using Length property ", location, MessageType.Error);
-                                                       messageCollection.Add 
(message);
+                                                       if (messageCollection 
== null)
+                                                               
messageCollection = new MessageCollection (message);
+                                                       else
+                                                               
messageCollection.Add (message);
                                                }
                                        }
                                }
                        }
 
-                       if (messageCollection.Count == 0)
-                               return null;
                        return messageCollection;
                }
        }

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

Reply via email to