-
Reduced sample code:
So the gist of this code is really simple. The property starts off null, but after InitLogins() it won't be null, and nothing ever assigns null to it again. There's reasons why I'm not just exposing the member as a property but even if I did it doesn't seem to help. Rewriting this to So basically, the nullability warning is getting in the way here. Since it's a static class variable not a local variable I'm kind of expecting it to throw out what it can infer between statements and just use the class level declaration every time. In the alternate hypothesis, different code can still get a null into it without a ! or a warning anywhere due to thread race issues. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can do this by applying |
Beta Was this translation helpful? Give feedback.
-
I hope my title's clear enough so the next person who hits this finds this discussion. |
Beta Was this translation helpful? Give feedback.
You can do this by applying
[MemberNotNull(nameof(logins))]
to theInitLogins
method. Then the compiler will not warn in your sample, and it will check thatlogins
is indeed not null for each return point withinInitLogins
.