Author: spouliot
Date: 2006-09-18 09:05:37 -0400 (Mon, 18 Sep 2006)
New Revision: 65574
Modified:
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/ChangeLog
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/Gendarme.Rules.Performance.xml.in
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UseStringEmptyRule.cs
Log:
2006-09-18 Sebastien Pouliot <[EMAIL PROTECTED]>
* Gendarme.Rules.Performance.xml.in: Update name and description for
UseStringEmptyRule.
* UseStringEmptyRule.cs: Update rule to provide location (which
results in better reports).
Modified: trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/ChangeLog
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/ChangeLog
2006-09-18 12:47:41 UTC (rev 65573)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/ChangeLog
2006-09-18 13:05:37 UTC (rev 65574)
@@ -1,3 +1,10 @@
+2006-09-18 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * Gendarme.Rules.Performance.xml.in: Update name and description for
+ UseStringEmptyRule.
+ * UseStringEmptyRule.cs: Update rule to provide location (which
+ results in better reports).
+
2006-08-21 Sebastien Pouliot <[EMAIL PROTECTED]>
* Gendarme.Rules.Performance.xml.in: Add description for new rule.
Modified:
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/Gendarme.Rules.Performance.xml.in
===================================================================
---
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/Gendarme.Rules.Performance.xml.in
2006-09-18 12:47:41 UTC (rev 65573)
+++
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/Gendarme.Rules.Performance.xml.in
2006-09-18 13:05:37 UTC (rev 65574)
@@ -11,10 +11,10 @@
<problem>The type '{0}' has a destructor and implements
IDisposable. However it doesn't call System.GC.SuppressFinalize inside it's
Dispose method.</problem>
<solution>Add a call to GC.SuppressFinalize inside your Dispose
method.</solution>
</rule>
- <rule Name="UseStringEmpty"
- Type="Gendarme.Rules.Performance.UseStringEmpty,
Gendarme.Rules.Performance, [EMAIL PROTECTED]@, Culture=neutral,
PublicKeyToken=null"
+ <rule Name="UseStringEmptyRule"
+ Type="Gendarme.Rules.Performance.UseStringEmptyRule,
Gendarme.Rules.Performance, [EMAIL PROTECTED]@, Culture=neutral,
PublicKeyToken=null"
Uri="http://www.mono-project.com/Gendarme" >
- <problem>The method '{0}' use literal \"\" instead of
String.Empty.</problem>
+ <problem>The method '{0}' use literal "" instead of
String.Empty.</problem>
<solution>Change the empty string for String.Empty.</solution>
</rule>
</rules>
Modified:
trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UseStringEmptyRule.cs
===================================================================
--- trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UseStringEmptyRule.cs
2006-09-18 12:47:41 UTC (rev 65573)
+++ trunk/cecil/gendarme/rules/Gendarme.Rules.Performance/UseStringEmptyRule.cs
2006-09-18 13:05:37 UTC (rev 65574)
@@ -46,24 +46,26 @@
// *** ok, the rule applies! ***
- int empty = 0;
-
+ ArrayList results = new ArrayList ();
+ string fullname = method.DeclaringType.FullName;
+
// #2 - look for string references
foreach (Instruction ins in method.Body.Instructions) {
switch (ins.OpCode.OperandType) {
case OperandType.InlineString:
string s = (ins.Operand as string);
- if (s.Length == 0)
- empty++;
+ if (s.Length == 0) {
+ Location loc = new Location
(fullname, method.Name, ins.Offset);
+ Message msg = new Message
("instance of an empty string has been found.",
+ loc,
MessageType.Warning);
+ results.Add (msg);
+ }
break;
}
}
- if (empty == 0)
+ if (results.Count == 0)
return null;
-
- ArrayList results = new ArrayList (1);
- results.Add (String.Format ("{0} instance of an empty
string has been found.", empty));
return results;
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches