Open
Description
Warning for 'value might be null' because upstream path potentially contains a null. Caused by use of as
keyword but preceeding is
keyword should make it impossible.
if (value is string)
Validate(fi, dicomFile, dicomItem, value as string); //<- lgtm considers that 'value' could be null because of as
Admittedly the code itself could be better. It should probably use a direct cast instead of as
or use the declaration feature of C# 7.0 (i.e. if(value is string s)
)
Unit test:
[Test]
public void TestNull()
{
string a = null;
Assert.IsFalse(a is string);
a = "yayy";
Assert.IsTrue(a is string);
}