Reputation: 421
Given the following code:
bool test = false;
bool test2 = true;
if (test = test2)
{
}
I want to get a warning when compiling this code as probably I wanted == instead. I don't get a warning from compiler and can't find a code analysis rule anywhere for it (fxcop or stylecop).
The closest compiler warning I found was CS0665: http://msdn.microsoft.com/en-us/library/c1sde1ax%28v=vs.90%29.aspx But this only triggers if I do:
if (test = true)
Upvotes: 3
Views: 353
Reputation: 6158
ReSharper will display a warning for this, saying:
Expression is always true
I would suggest using 'Configure inspection severity' and upgrading it to an Error
Upvotes: 3