Skip to content
Discussion options

You must be logged in to vote

It's correct to ask at csharplang.

The current practice is to use MemberNotNullWhen on the condition property:

[MemberNotNullWhen(true, nameof(Id))]
public bool IsDisposed;
public string? Id;

Conjunction of multiple properties is unlikely to be supported because of the logical complexity.
Moreover, it's not the recommended practice to mark the nullability for invalid state. Usage of disposed/uninitialized object should be undefined or always throwing.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@metaone01
Comment options

Answer selected by metaone01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants