Create and add instance reference inside ResolveMetadata*#39330
Merged
jozkee merged 2 commits intodotnet:masterfrom Jul 20, 2020
Merged
Create and add instance reference inside ResolveMetadata*#39330jozkee merged 2 commits intodotnet:masterfrom
jozkee merged 2 commits intodotnet:masterfrom
Conversation
Member
Author
|
Perf. results for the stream scenarios affected by this change: |
layomia
reviewed
Jul 16, 2020
...es/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.HandleMetadata.cs
Outdated
Show resolved
Hide resolved
jozkee
commented
Jul 17, 2020
| ref ReadStack state, | ||
| JsonSerializerOptions options) | ||
| { | ||
| JsonConverter converter = state.Current.JsonClassInfo.PropertyInfoForClassInfo.ConverterBase; |
Member
Author
There was a problem hiding this comment.
Removed JsonConverter from the params to use this one instead.
layomia
approved these changes
Jul 17, 2020
| } | ||
|
|
||
| public sealed override void CreateInstance(ref Utf8JsonReader reader, ref ReadStack state, JsonSerializerOptions options) | ||
| internal sealed override void CreateInstanceForReferenceResolver(ref Utf8JsonReader reader, ref ReadStack state, JsonSerializerOptions options) |
Contributor
There was a problem hiding this comment.
The type is already internal, so this should be left as public - here and elsewhere.
Member
Author
There was a problem hiding this comment.
This method is inherited from JsonConverter which is public, if I make it public here and in the base, then we would be adding new API to the base type.
jozkee
added a commit
to jozkee/runtime
that referenced
this pull request
Jul 20, 2020
* Create and add instance reference on ResolveMetadata * Address suggestions
jozkee
added a commit
that referenced
this pull request
Jul 21, 2020
Jacksondr5
pushed a commit
to Jacksondr5/runtime
that referenced
this pull request
Aug 10, 2020
* Create and add instance reference on ResolveMetadata * Address suggestions
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
...in order to remove workaround described in #37168 used to correctly build the JSON path in case of error.
This PR adds a new method
CreateInstancetoJsonResumableConverter<T>that is used to instantiate the object at the time thatReferenceResolver.AddReferenceis called.It also splits
ResolveMetadatainto two methods:ResolveMetadataForJsonObject(Used on POCOs and dictionaries) andResolveMetadataForJsonArray(Used for collections such asList<T>).This makes the code more mantainable, reduces the amount of if checks and allow us to remove the string field
ReadStackFrame.MetadataIdfrom the state.Fixes #37168.