ReSharper 2016.1 Nullability and unreachable code analysis seems to have issues.
Answered
When a method's return value has an unspecified nullability, it seems to treat it as always null.
Here's a simple console application to repro [Visual Studio 2015; no ReSharper Extensions].
using System; namespace ConsoleApplication2 { static class Program { static void Main() { var foo = MakeAString(); Console.WriteLine(foo?.Length); Console.WriteLine(foo.Length); } private static string MakeAString() { return new string(new[] { 'f', 'o', 'o' }); } } }
Please sign in to leave a comment.
Seems the same problem:
Is it same to Issue RSRP-458210 ?
I got the same issues. Here two good examples of the strange behavior:
1. In this example I'm debugging into the code from which R# says it cannot happen.
2. Perhaps the same cause but here it says I can get a NullRefException while casting my object to a custom enum. Also the code after that line would be unreachable... And getting back to line 421, this warning says that my object will always be null.
Any feedback would be appreciated.
I have used installation from Issue RSRP-458210 and it helps.
Thanks @Yevhen, that helped! I installed the fixed version and my issues were gone. :-)