Вопрос

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.

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top