-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[release/6.0] Fix custom JsonConverterFactories not working with nested type/property declarations. #62643
Conversation
…operty declarations.
Tagging subscribers to this area: @dotnet/area-system-text-json Issue DetailsBackport of #62595 to release/6.0 /cc @eiriktsarpalis Customer ImpactTestingRisk
|
@ericstj could you please handle getting approval for this? by email or on Thurs. |
@@ -96,6 +96,9 @@ private sealed partial class Emitter | |||
|
|||
private readonly HashSet<string> _emittedPropertyFileNames = new(); | |||
|
|||
private bool _generateGetConverterMethodForTypes = false; |
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.
nit: at first it wasn't clear to me that these were tied to the _currentContext and that _currentContext would actually change as the emitter did its work. It might make sense to associate this mutable state to a single object or name it in a way that makes it clear how it applies and when it changes.
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.
For example as members of ContextGenerationSpec
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; allows custom converters for types not adorned with [JsonSerializable]
Approved over email. |
is this ready to merge? |
test failures will be fixed by #63526. this can merge if it's ready. |
Let's re-run CI to verify those are fixed, since it's Sunday.. |
Maybe it just needs rebasing? |
I've seen it in multiple PRs already, I think I need to service the fix to 6.0 on the SDK and update the package. I'll do that for 6.0.3 as we don't have time for 6.0.2 anymore. |
Backport of #62595 to release/6.0
/cc @eiriktsarpalis
Customer Impact
Customer reported issues in #62079 and #61860. Fixes a bug in which System.Text.Json will generate invalid code in cases where transitive dependencies in the type graph of a serializable type specify custom
JsonConverterFactories
via theJsonConverter
attribute.Testing
Added regression tests validating the impacted use cases.
Risk
Low to moderate. Makes a minor adjustment in the product code.