-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Document missing vs. null value behavior in RespectNullableAnnotations #49378
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
Conversation
…ations Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
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.
I verified the code works as advertised.
Removed example demonstrating exception on explicit null value during deserialization.
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 addresses a documentation gap by clarifying how RespectNullableAnnotations behaves differently when JSON properties are missing versus explicitly set to null. The documentation update explains that JavaScript's undefined (missing property) and null (explicit null value) both deserialize to .NET null, but only explicit null values trigger exceptions for non-nullable properties.
Key Changes:
- Added a new "Missing values versus null values" section explaining the behavioral distinction
- Created a code example demonstrating that missing properties don't throw exceptions
- Updated metadata (date and added ai-usage frontmatter)
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| nullable-annotations.md | Added new section documenting missing vs. null value behavior and enforcement guidance |
| Nullable.cs | Added Nullable4 class with MissingVsNull example demonstrating missing property behavior |
| Program.cs | Updated to run the new Nullable4 example |
docs/standard/serialization/system-text-json/nullable-annotations.md
Outdated
Show resolved
Hide resolved
…o null Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
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.
Looks good to me. I am not finding an issue. Well written, great code example. Approved. Policheck seems to be slow or held up?
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.
Looks good!
Original prompt
Fixes #49298
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Internal previews