You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support open generics in polymorphic serialization in System.Text.Json #127317
Polymorphic serialization currently has no mechanism to have open generics in their derived type declarations. This is particularly useful when you have the same general shape across multiple different fields but define different T's.
It would be useful if something similar to the below would work.
To work around this today you either have to duplicate code or create a custom serializer. There is also no way to define different types for the same Type across different properties. One other way to hack around it is to define a custom serializer that takes different JsonSerializerOptions that has been customized per property using contracts.
would get rejected. We might also support more complex forms where similarly the open generic unambiguously points to a specific monomorphization lie this one:
Activity
dotnet-policy-service commentedon Apr 23, 2026
Tagging subscribers to this area: @dotnet/area-system-text-json
See info in area-owners.md if you want to be subscribed.
MihuBot commentedon Apr 23, 2026
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):
eiriktsarpalis commentedon Apr 23, 2026
Note this would only work if the generic of the derived type exactly matches that of the base type. In other words forms such as
or
would get rejected. We might also support more complex forms where similarly the open generic unambiguously points to a specific monomorphization lie this one:
We should add a source generator diagnostic specifically providing this feedback for invalid open generics.