- Notifications
You must be signed in to change notification settings - Fork5.2k
[JSON source gen 1/3] Implement APIs needed by JSON source generator#51149
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedApr 12, 2021
Tagging subscribers to this area:@eiriktsarpalis,@layomia Issue DetailsContributes to#45448. This PR primarily implements the The changes are being made in chunks to avoid having one huge PR that might be way more difficult to review. The target completion date for PRs in this series is the preview 4 snap. Note to reviewers PR review can start from the third commit "Add JsonMetadataServices and APIs needed by source generator". The first two commits simply perform some refactoring:
Upcoming PRs to complete the implementation
|
ghost commentedApr 12, 2021
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerContext.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerContext.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerContext.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerContext.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...em.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.Collections.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...tem.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.Converters.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
.../System.Text.Json/src/System/Text/Json/Serialization/Attributes/JsonSerializableAttribute.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
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.
It the idea we can cache common property names together on the caller site, instead of here on the callee side which wouldn't know about the duplicated names?
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.
Yes that's the idea. The source generator/caller will keep track of duplicate property names and resolve them within the callback to return the list ofJsonPropertyInfos. We still detect collisions when putting the infos in the dictionary for deserialization, and throwIOE for those cases.
However, it will be possible for the same property name to be written multiple times if the caller is only serializing (and not deserializing). The source generator will not create metadata that has this behavior, but the user can construct this themselves unless we decide to validate both sides (essentially populating the deserialization cache even though we don't need to)
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfo.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
...em.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.Collections.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...em.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.Collections.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...braries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
eiriktsarpalis left a comment
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.
Other than minor feedback LGTM.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
tdykstra left a comment
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.
LGTM, just noted a few typos.
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerContext.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerContext.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...em.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.Collections.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...em.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.Collections.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...braries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonMetadataServices.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributes to#45448.
Note to reviewers
This PR primarily implements the
JsonMetadataServicesAPIs needed by the JSON source generator when generating code in user assemblies. It is essentially a no-op to existing serializer functionality, hence, no test changes are added in this PR. Tests for the new APIs will be included in an upcoming PR that adds the source generator itself.The changes are being made in chunks to avoid having one huge PR that might be way more difficult to review. The target completion date for PRs in this series is the preview 4 snap.
PR review can start from the third commit "Add JsonMetadataServices and APIs needed by source generator". The first two commits simply perform some refactoring:
Upcoming PRs to complete the implementation
JsonSerializerandSystem.Net.Http.Jsonmethods that take the new metadata classes being added in this PR ([JSON source gen 3/3] Add new methods to JsonSerializer and System.Net.Http.Json APIs that take type metadata #51528)I expect all 3 PRs to be open and reviewed concurrently, with reviewers focusing on the goal of each PR in isolation (to the degree possible). Thanks!