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
Support checking for required members in minimal APIs #45084
Support checking for required members in minimal APIs #45084
Conversation
NullabilityState.Nullable => true, | ||
// In an oblivious context, the required modifier makes | ||
// members non-optional | ||
NullabilityState.Unknown => !GetCustomAttributes(true).OfType<RequiredMemberAttribute>().Any(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How often does this get called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is NullabilityState.Unknown the same as having Disabled for nullable references?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is NullabilityState.Unknown the same as having Disabled for nullable references?
Yep, this represents an oblivious nullability context AKA <Nullable>disable</Nullable>
.
How often does this get called?
Under an oblivious nullability context, it'll be called for every property in the AsParameters
call. We can probably cache this value on PropertyAsParameterInfo
as needed.
Part of #40099.
required
on a reference type in an oblivious nullability context makes it non-optional.required
on a nullable type means it is non-optional.required
necessitates the initialization of values which we already do in RDF, nullability allows them to be initialized to null.