the given expression is always of the provided type - no, it is not
using System;
namespace ResharperTest
{
class Program
{
static void Main(string[] args)
{
String test = null;
Random rnd = new Random();
test = (rnd.NextDouble() > 0.5) ? "String" : null;
if (test is String)
Console.WriteLine(test);
else
Console.WriteLine("Not a String");
Console.ReadLine();
}
}
}
Resharper is telling me, that (test is String) is always of the provided type ("The given expression is always of the provided type"). But that is not true. Is it a bug?
I am using ReSharper 6.1 C# Edition Build 6.1.1000.82
Please sign in to leave a comment.
First I thougt you where wrong as I thought is does not check for null but I was wrong.
In the msdn help you will find that one
And as your string variable will hold a null reference sometimes it will fail here.
So yes seems like a bug.
Thanks Sven, I have created an issue: RSRP-312505