[API Proposal]: System.Json reference handling allow per-type customization #110048
Labels
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
area-System.Text.Json
Milestone
Background and motivation
ReferenceHandler.Preserve
is very useful when references to the same object need to be sent. However, it easily breaks, for example withTuple<>
, since it does not have a constructor of the expected form.It would be useful, if the user could opt-in to reference preservation only for specific types. I read a little through the implementation, and it seems like
JsonConverter.CanHaveMetadata
could already do what I need, but it is marked as internal and thus cannot be influenced by the user.API Proposal
API Usage
Alternative Designs
No response
Risks
The property setter should probably only allow setting to
false
, as reference preserving on value types is not supported, and the converter must already support writing metadata, as implemented byObjectDefaultConverter
.The text was updated successfully, but these errors were encountered: