Domanda

protected override void OnTextInput(TextCompositionEventArgs e)
{
    e.Handled = true;
    DoSomething(e.Text);
}

If I check for null, CA is happy, but ReSharper says that the null check will always be false. I'm not sure who is more trust-worthy here... it seems like a bug in ReSharper possibly since, in theory, someone could extend from my class and call this method directly passing in null. But I guess I'm just looking to double check which tool is correct and which one has the bug in it.

È stato utile?

Soluzione

it seems like a bug in ReSharper possibly since, in theory, someone could extend from my class and call this method directly passing in null.

As unlikely as it may seem, this is entirely possible. I would err on the side of caution and follow the Code Analysis recommendation of doing a null check.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top