Questions about NullReferenceException in Linq queries
Hi,
Using 5.1 I know that there is a bug when dealing with null values in Linq expressions.
For example here I get an error in the "Select" that says value could be null - obviously it isn't:
var properties = new[] {"1", null, "3"};
foreach (var value in properties.Where(value => value != null).Select(value => value.Trim()))
{
Debug.Write(value);
}
So to my question: Will there be a near fix of this or will it have to wait until the next major release? We have thousands of Linq queries and this bug is producing thousands of errors. Of course, the "NullreferenceException" check is something we don't want to disable.
Or is there a solution - Linq-wise - in the above "Select" that would make ReSharper validate correct?
--
Werner
Please sign in to leave a comment.
Hello Werner,
I'm afraid this problem can not be fixed easily, so there's little chance
that it will be fixed in the nearest bugfix releases. You can "watch" the
following issue in our tracker: http://youtrack.jetbrains.net/issue/RSRP-188273
to get notified when it's fixed. Thank you!
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Understood, thanks Andrey. I will keep an eye out for the fix.
I have to ask :)
Isn't there a way to get R# to ignore these null reference errors in linq? We are having thousands of errors/warnings due to this, but we don't want to ignore *all* null reference errors/warnings. Any "hack" to get R# to ignore them in Linq?