You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
private Foo? fooMember;
public void DoSomethingWithFoo()
{
this.VerifyFooNotNull();
this.fooMember.DoSomething(); // Warning CS8602: Dereference of a possibly null reference.
}
private void VerifyFooNotNull()
{
if (this.fooMember == null)
{
throw new InvalidOperationException("Foo must be initialized");
}
}
Is there an attribute or similar I could apply to VerifyFooNotNull so that the CS8602 warning goes away?
The text was updated successfully, but these errors were encountered:
Yep, that should be covered by MemberNotNull. I'm going to close this as a duplicate, let me know if that's not quite the same as what you're looking for and I can reopen. #3297
Consider the following code:
Is there an attribute or similar I could apply to
VerifyFooNotNull
so that the CS8602 warning goes away?The text was updated successfully, but these errors were encountered: