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

Add spec: deserializing objects with parameterized ctors #33095

Merged
merged 5 commits into from
Mar 20, 2020

Conversation

layomia
Copy link
Contributor

@layomia layomia commented Mar 3, 2020

Contributes to #29895.

@layomia layomia added this to the 5.0 milestone Mar 3, 2020
@layomia layomia self-assigned this Mar 3, 2020
@layomia layomia force-pushed the parameterized_ctors_spec branch from 3006d2b to 68f22e2 Compare March 3, 2020 07:04
@layomia layomia force-pushed the parameterized_ctors_spec branch from 68f22e2 to fa1ed91 Compare March 3, 2020 07:10
@layomia layomia force-pushed the parameterized_ctors_spec branch from a913b80 to 9063bf8 Compare March 6, 2020 04:28
Copy link
Member

@jozkee jozkee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise; looks great.

@jozkee jozkee added the documentation Documentation bug or enhancement, does not impact product or test code label Mar 6, 2020
with a message stating that objects without public parameterless constructors, including `interface`s and `abstract`
types, are not supported for deserialization. There is no way to deserialize an instance of an object using a parameterized constructor.

A common pattern is to make data objects immutable for various reasons. For example, given `Point`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that this change alone won't support all immutable types. For example, our own immutable collections don't use constructors but factory methods.

@layomia layomia merged commit a43d6c4 into dotnet:master Mar 20, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
@layomia layomia deleted the parameterized_ctors_spec branch May 18, 2021 07:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json documentation Documentation bug or enhancement, does not impact product or test code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants