-
Notifications
You must be signed in to change notification settings - Fork 6k
Update patterns.md with empty property pattern details #49385
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
base: main
Are you sure you want to change the base?
Conversation
Clarify the behavior of the empty property pattern in C#.
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.
Pull Request Overview
This PR adds clarification about the behavior of the empty property pattern (is { }) in C#, which was previously undocumented in the patterns documentation.
Key Changes:
- Added a note explaining that the empty property pattern
is { }matches all non-null values and can be used as an alternative tois not nullfor creating variables.
|
|
||
| :::code language="csharp" source="snippets/patterns/PropertyPattern.cs" id="WithTypeCheck"::: | ||
|
|
||
| This specifially means that the *empty* property pattern `is { }` matches everything non-null, and can be used instead of the `is not null` to create a variable: `somethingPossiblyNull is { } somethingDefinitelyNotNull`. |
Copilot
AI
Oct 21, 2025
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.
Corrected spelling of 'specifially' to 'specifically'.
| This specifially means that the *empty* property pattern `is { }` matches everything non-null, and can be used instead of the `is not null` to create a variable: `somethingPossiblyNull is { } somethingDefinitelyNotNull`. | |
| This specifically means that the *empty* property pattern `is { }` matches everything non-null, and can be used instead of the `is not null` to create a variable: `somethingPossiblyNull is { } somethingDefinitelyNotNull`. |
Copilot uses AI. Check for mistakes.
|
I like this change. I think it would be more clear to readers if you added an example of |
|
hi @BillWagner i didn't know how the or do you mean just expanding the inline |
|
Adding a second file in the same PR isn't easy in the GitHub UI. If you add an inline example, I'll move it to the included snippets. |
Clarify the behavior of the empty property pattern in C#.
Summary
added note about the empty property pattern because it wasn't mentioned anywhere.
Internal previews
isandswitchexpressions, and operatorsand,or, andnotin patterns