Skip to content
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

Ensure reflection property metadata is instantiated lazily #76828

Merged
merged 2 commits into from
Oct 11, 2022

Conversation

eiriktsarpalis
Copy link
Member

Updates the reflection-based JsonTypeInfo implementation so that the property metadata resolution logic is done lazily via the pre-existing LateAddProperties method used by the source-gen metadata implementation instead of the constructor. This ensures that any pre-existing errors related to property misconfiguration/unsupported properties occurs at configuration time rather than at construction time.

Fixes #76807.

@ghost
Copy link

ghost commented Oct 10, 2022

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

Updates the reflection-based JsonTypeInfo implementation so that the property metadata resolution logic is done lazily via the pre-existing LateAddProperties method used by the source-gen metadata implementation instead of the constructor. This ensures that any pre-existing errors related to property misconfiguration/unsupported properties occurs at configuration time rather than at construction time.

Fixes #76807.

Author: eiriktsarpalis
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

@eiriktsarpalis eiriktsarpalis marked this pull request as ready for review October 10, 2022 17:28
Copy link
Contributor

@layomia layomia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@eiriktsarpalis eiriktsarpalis merged commit d6c8ba1 into dotnet:main Oct 11, 2022
@eiriktsarpalis
Copy link
Member Author

/backport to release/7.0

@github-actions
Copy link
Contributor

Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/3226217916

@github-actions
Copy link
Contributor

@eiriktsarpalis backporting to release/7.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Ensure reflection property metadata is instantiated lazily.
Using index info to reconstruct a base tree...
M	src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionJsonTypeInfoOfT.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionJsonTypeInfoOfT.cs
CONFLICT (content): Merge conflict in src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/ReflectionJsonTypeInfoOfT.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Ensure reflection property metadata is instantiated lazily.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

eiriktsarpalis added a commit to eiriktsarpalis/runtime that referenced this pull request Oct 11, 2022
)

* Ensure reflection property metadata is instantiated lazily.

* Address feedback
jeffhandley pushed a commit that referenced this pull request Oct 11, 2022
…76869)

* Ensure reflection property metadata is instantiated lazily.

* Address feedback
@eiriktsarpalis eiriktsarpalis deleted the fix-jsonignore-regression branch October 12, 2022 13:08
@ghost ghost locked as resolved and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serialization of ReadOnlyMemory<byte> with [JsonIgnore] attribute in .NET 6 and .NET 7 RC1
2 participants