Reporter | Alex Berezoutsky (fergard) |
---|---|
Created | Jan 11, 2012 3:25:22 PM |
Updated | Feb 2, 2012 9:15:07 PM |
Resolved | Feb 2, 2012 4:16:10 PM |
Priority | Major |
Type | Bug |
Fix versions | Next |
State | Fixed |
Assignee | Evgeny Pasynkov (pasynkov) |
Subsystem | No subsystem |
Affected versions | 6.1 |
Fixed in build | 6.5.1.3937 |
Please consider the example below. ReSharper 6.1 suggests to replace enumerable.Count() == 0 to !enumerable.Any(), but this method is not defined. This should only be suggested for IEnumerable<T>.
using System; using System.Collections; namespace Contracts { public static class IEnumerableExtensions { public static int Count(this IEnumerable enumerable) { int result = 0; foreach (var item in enumerable) { result++; } return result; } } public class Demo { public void Test() { Console.WriteLine(IsEmptyString("hello!")); } public bool IsEmptyString(string s) { var enumerable = s as IEnumerable; if (enumerable.Count() == 0) { return true; } return false; } } }