-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should nullability attributes affect method bodies and OHI? #36039
Comments
Relates to #30953 ([MaybeNull]: Cannot implement a generic method with a "default" return value with nullable references) |
Tracking my answer for posterity: Yes, they should warn. |
@RikkiGibson suggested that I add my concern about the lack of equivalence of Let's say I write a nongeneric public API with What's driving the signature is no longer anything intrinsic to the method. Now it's constrained by how it might be used. Real-world examples and flaws with each alternative are shown in depth at #38191. |
Agreed, although it wouldn't be terrible if the warning was produced by an analyzer. |
Late response, but I think this needs to happen in the compiler's nullability analysis, as the analysis of the attributes may result in removing warnings as well as adding them. |
All three components of this issue are done (two were in 16.5 and one is in 16.6p1). |
Status:
Not/MaybeNullWhen
,DoesNotReturn/If
(PR Enforce conditional attributes within method bodies #41098, 16.5p3)Also, should they affect OHI (override/hiding/implementation)?
Relates to #35816
Relates to https://github.com/dotnet/csharplang/blob/master/meetings/2019/LDM-2019-05-15.md#discussion
Stephen pointed out a scenario they hit:
The text was updated successfully, but these errors were encountered: