-
Notifications
You must be signed in to change notification settings - Fork 5k
fix json source generator serialize when writing #116004
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
fix json source generator serialize when writing #116004
Conversation
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis |
remove required modifier
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 fixes serialization behavior in the source generator so that properties marked with JsonIgnoreCondition.WhenWriting
are correctly omitted, and adds corresponding tests.
- Added
SerializedValueCheckType.Ignore
enum value and mapping forWhenWriting
- Updated emitter to handle the new ignore case in fast-path code
- Introduced two tests (
SerializeIgnoreWhenWritingTest
andSerializeIgnoreWhenReadingTest
) and theIgnoreWhenReadingWritingPerson
type
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
JsonSerializerContextTests.cs | Added new tests and the IgnoreWhenReadingWritingPerson type |
JsonSourceGenerator.Emitter.cs | Introduced Ignore enum case, mapped WhenWriting , and stubbed fast-path logic for skipping properties |
...System.Text.Json/tests/System.Text.Json.SourceGeneration.Tests/JsonSerializerContextTests.cs
Outdated
Show resolved
Hide resolved
removing the serializer options
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.
Thanks
fixes #116003