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

Why are immutable classes so poorly supported in System.Text.Json? #35959

Closed
jdvor opened this issue May 7, 2020 · 3 comments
Closed

Why are immutable classes so poorly supported in System.Text.Json? #35959

jdvor opened this issue May 7, 2020 · 3 comments

Comments

@jdvor
Copy link

jdvor commented May 7, 2020

System.Text.Json

This is a sincerely meant question, not a bug report.

Why is de-serialization of immutable classes so poorly supported?
(or one might argue that "not at all" is more precise than "poorly" unless custom converters are deemed support for such case).

By support I mean mostly ability to use parameterized (maybe not public) constructors and private setters during deserialization.

a) Is it by design for performance reasons?
b) Is it just a result of not enough time and it will be supported sometime in near future?

If a) is the answer what are the implications for the rest of the code?

  1. throw immutability out of the window?
  2. have dedicated layer of classes just for de/serialization which are immediately translated to immutable DTOs used down the line. (I wonder what would that do for overall performance even if the serialization framework would do better on its own).
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Collections untriaged New issue has not been triaged by the area owner labels May 7, 2020
@ghost
Copy link

ghost commented May 7, 2020

Tagging subscribers to this area: @eiriktsarpalis
Notify danmosemsft if you want to be subscribed.

@jdvor jdvor changed the title Why is immutable classes so poorly supported? Why is immutable classes so poorly supported in System.Text.Json? May 7, 2020
@jdvor jdvor changed the title Why is immutable classes so poorly supported in System.Text.Json? Why are immutable classes so poorly supported in System.Text.Json? May 7, 2020
@ghost
Copy link

ghost commented May 7, 2020

Tagging subscribers to this area: @jozkee
Notify danmosemsft if you want to be subscribed.

@layomia layomia added this to the 5.0 milestone May 7, 2020
@layomia layomia removed the untriaged New issue has not been triaged by the area owner label May 7, 2020
@layomia
Copy link
Contributor

layomia commented May 7, 2020

We have addressed these issues for .NET 5:

You can try these features in preview 4 of .NET 5 or the System.Text.Json package on Nuget.

These have always been on the roadmap for System.Text.Json, but were scoped out of 3.x due to time constraints and feature scoping. Please see the System.Text.Json project board for 5.0 for an overview of what we are prioritizing in this release.

@layomia layomia closed this as completed May 7, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants