[release/6.0] Prevent runtime prop metadata retrieval when [JsonIgnore] is used #60299
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.
Backport of #60024 to release/6.0
/cc @layomia
Customer Impact
Fixes customer-reported regression from .NET 5.0.
In 5.0 and earlier,
[JsonIgnore]
could be used ignore members with unsupported types from serialization and also members with invalid configuration (such as incompatible converters). 6.0 PR #56354 (JSON source gen support for parameterized ctors) had a side-effect that changed the serializer's behavior such that this metadata is inspected and validated, rather than ignored (note that the members are still not included during actual (de)serialization). This behavior change has led to new reported failures in user apps due to the serializer throwing exceptions upon validation:Users are dependent on
[JsonIgnore]
to suppress errors that could be yielded from the serializer, and those customers can now be broken. This PR reverses the regression to avoid breaking previously working scenarios.Testing
Tests for the reported breaking scenarios have been added, along with new tests for parameterized ctor support.
Risk
This PR makes product changes and has some risk. Some of the changes relate to parameterized ctor support since that code is dependent on the same underlying infra as the ignore/property handling. We'll be looking out for customer feedback in both
[JsonIgnore]
and parameterized ctor scenarios.