MemberMaybeNull
#6854
Replies: 2 comments
-
An interesting idea. Another similar example:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Adding a new nullability attribute is a language suggestion so moving to csharplang. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I propose adding a new attribute called
MemberMaybeNull
that can be applied to methods and gives the compiler information about the nullability of a member variable after the method is executed.This attribute can be applied to a method like this:
In this example, the
DoSomething
method has theMemberMaybeNull
attribute applied to it, with theValue
member specified as the argument. This tells the compiler that the Value member may be null after theDoSomething
method is executed.A use case would be in the following method:
Beta Was this translation helpful? Give feedback.
All reactions