Is there anyway to turn off "Check if 'variable' is null" in R# 6.1.0?

Having way to many false positives and it is a warning with no inspection setting I can change. :(

The most common false positive is with .First methods...  

 

var survey = _infoturnHelper.Surveys.First(x => x.ImportId == template.ImportId);


Which according to MSN, will either return something or throw an exception.

http://msdn.microsoft.com/en-us/library/bb291976.aspx

So why is R# forcing me to null check it?
4 comments

Hello Charles
     Have you tried turning off the 'Check if variable is null' action under ReSharper | Options | Languages | C# | Context Actions? Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0

That worked, though it then gave the same warning, but for an inspection option for which I could then set to an hint.

Which R# would recognise when return values truly can be null, cause I have yet to find a case when it complains about a null that can actually have a null value.  I'm sure there has to be one valid case, but hitting 1 out of a thousand really is depressing odds. :(

0

Is it acutally flagging "survey" as possibly null, or is it one of the other objects (_infoturnHelper, _infoturnHelper.Surveys, x, or template)?

0

It is flagging survey.  The actual warning is on a different statement that is trying to use survey.

0

Please sign in to leave a comment.