Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds null handling support for primitive protobuf field deserialization. When JSON properties are explicitly set to null, the deserializer now treats them as default values rather than throwing an error.
Key Changes:
- Added null token check in
FieldConverter.Read()to skip processing when null values are encountered - Added comprehensive test coverage for null value handling across all primitive protobuf types
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Protobuf.System.Text.Json/InternalConverters/FieldConverter.cs | Added null token check to return early and use default values when converters don't handle nulls |
| test/Protobuf.System.Text.Json.Tests/SimpleMessageTests.cs | Added test case verifying that null values deserialize to default values for all primitive types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Assert.Equal(0, deserialized.Sfixed32Property); | ||
| Assert.Equal(0L, deserialized.Sfixed64Property); | ||
| Assert.False(deserialized.BoolProperty); | ||
| } |
There was a problem hiding this comment.
Extra trailing space after closing brace should be removed.
Suggested change
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.