Reporter | 陆 超 (陆.超) |
---|---|
Created | Dec 28, 2011 12:58:47 PM |
Updated | Feb 17, 2012 6:27:07 PM |
Resolved | Feb 17, 2012 6:27:07 PM |
Priority | Normal |
Type | Bug |
Fix versions | No Fix versions |
State | Won't fix |
Assignee | Evgeny Pasynkov (pasynkov) |
Subsystem | No subsystem |
Affected versions | 6.1 |
Fixed in build | No Fixed in build |
I have code like this in my project:
if (!Model.Answers.Any(x => x.Creator == user))
{
}
Resharper prompts that the condition expression could be simplified into something like this:
if (Model.Answers.All(x => x.Creator != user))
{
}
The problem is that these codes isn't same in semantics.
Code to prove that:
var items = new string[] {}; //empty sources make all the difference
var any = items.Any(x => x.StartsWith("A")); //false
var all = items.All(x => !x.StartsWith("A")); //true
Assert.AreNotEqual(any, all);
if (!Model.Answers.Any(x => x.Creator == user))
{
}
Resharper prompts that the condition expression could be simplified into something like this:
if (Model.Answers.All(x => x.Creator != user))
{
}
The problem is that these codes isn't same in semantics.
Code to prove that:
var items = new string[] {}; //empty sources make all the difference
var any = items.Any(x => x.StartsWith("A")); //false
var all = items.All(x => !x.StartsWith("A")); //true
Assert.AreNotEqual(any, all);