0

If I write something like

var list = PopulateMyListWithSomething();
if(!list.Any(a=>a.this = that) {
    // do something
}

Resharper always suggests rewriting the test as

if(list.All(a.this != that)

There is obviously a reason for the suggestion. Can anyone tell me what the reason might be?

Stuart Hemming
  • 1,553
  • 2
  • 21
  • 44
  • 1
    Did you mean `a.this == that`? Assignment and comparison are not quite the same... – Camilo Terevinto Jun 05 '18 at 10:35
  • Maybe resharper doesn't like negations – Tim Schmelter Jun 05 '18 at 10:39
  • 1
    The duplicate asked if there is a performance difference. This asks why resharper suggests that, which is slightly subjective – Tim Schmelter Jun 05 '18 at 10:40
  • @TimSchmelter "slightly" as in "let's wait for the ReSharper team to come answer"? (I voted to close as opinionated, just in case) – Camilo Terevinto Jun 05 '18 at 10:43
  • 1
    In my opinion the consensus in the duplicate is "technically it doesn't matter", so it is just to Resharper why they thought it was a good idea. We can't answer that and will only lead to speculation. Hence, I think the duplicate is the best we can give OP. – Patrick Hofman Jun 05 '18 at 10:46
  • @TimSchmelter In duplicate question OP assumed that it could be a performance hit, that's why he wrote that. So technically if he asked about his assumption why resharper changing and this question is about why is resharper changing, they are pretty much same. – SᴇM Jun 05 '18 at 10:47
  • "Resharper always suggests " - Does it? [Or does it just *offer you the option to quickly change it*?](https://stackoverflow.com/a/10976704/71059) – AakashM Jun 07 '18 at 08:47

0 Answers0