Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Pouliot <sebastien@ximian.com>2011-01-18 03:00:53 +0300
committerSebastien Pouliot <sebastien@ximian.com>2011-01-24 02:50:36 +0300
commitbca1cb2336448a01edaee8c67e12f42b80e422bc (patch)
treed6a8833caee78145c32aecd9a4ec40a3a5fcd73f
parent11661783ff151cb010ec7c434ffae17d70334cb6 (diff)
Handle array types correctly in ReviewLinqMethodRule. FIx bnc664556
* ReviewLinqMethodRule.cs: Handle array types correctly * Test/ReviewLinqMethodTest.cs: Test case for above. Provided by Antoine Vandecreme <ant.vand@gmail.com>
-rw-r--r--gendarme/AUTHORS2
-rw-r--r--gendarme/rules/Gendarme.Rules.Performance/ReviewLinqMethodRule.cs3
-rw-r--r--gendarme/rules/Gendarme.Rules.Performance/Test/ReviewLinqMethodTest.cs13
3 files changed, 16 insertions, 2 deletions
diff --git a/gendarme/AUTHORS b/gendarme/AUTHORS
index e7bdabb3..4acb9738 100644
--- a/gendarme/AUTHORS
+++ b/gendarme/AUTHORS
@@ -16,7 +16,7 @@ Andres G. Aragoneses <aaragoneses@novell.com>
Peter Johanson <peter@peterjohanson.com>
Jesse Jones <jesjones@mindspring.com>
Rolf Bjarne Kvinge <RKvinge@novell.com>
-Antoine Vandecreme <avandecreme@sopragroup.com>
+Antoine Vandecreme <ant.vand@gmail.com>
Julien Hoarau <madgnome@gmail.com>
N Lum <nol888@gmail.com>
Nicholas Rioux <nickr500@gmail.com>
diff --git a/gendarme/rules/Gendarme.Rules.Performance/ReviewLinqMethodRule.cs b/gendarme/rules/Gendarme.Rules.Performance/ReviewLinqMethodRule.cs
index 5933b4aa..0bef7c2e 100644
--- a/gendarme/rules/Gendarme.Rules.Performance/ReviewLinqMethodRule.cs
+++ b/gendarme/rules/Gendarme.Rules.Performance/ReviewLinqMethodRule.cs
@@ -124,7 +124,8 @@ namespace Gendarme.Rules.Performance {
Log.WriteLine (this, "{0:X4} {1}", ins.Offset, message);
Runner.Report (method, ins, Severity.Medium, Confidence.High, message);
- } else if (HasMethod (type, LengthProperty)) {
+ } else if (type.IsArray || HasMethod (type, LengthProperty)) {
+ // note: arrays [] always have a Length property but resolving arrays return the element type
string message = "Use the Length property instead of the Count () method.";
Log.WriteLine (this, "{0:X4} {1}", ins.Offset, message);
Runner.Report (method, ins, Severity.Medium, Confidence.High, message);
diff --git a/gendarme/rules/Gendarme.Rules.Performance/Test/ReviewLinqMethodTest.cs b/gendarme/rules/Gendarme.Rules.Performance/Test/ReviewLinqMethodTest.cs
index bea83703..20360f68 100644
--- a/gendarme/rules/Gendarme.Rules.Performance/Test/ReviewLinqMethodTest.cs
+++ b/gendarme/rules/Gendarme.Rules.Performance/Test/ReviewLinqMethodTest.cs
@@ -293,5 +293,18 @@ namespace Test.Rules.Performance {
AssertRuleSuccess<Bug656790> ("CanExecute");
}
+
+ class Bug664556 {
+ public int DoSomething (Bug664556 [] ic)
+ {
+ return ic.Count ();
+ }
+ }
+
+ [Test]
+ public void Array ()
+ {
+ AssertRuleFailure<Bug664556> ("DoSomething", 1);
+ }
}
}