Skip to content

Deserialization constructors#21025

Merged
gewarren merged 2 commits intodotnet:masterfrom
gewarren:constructors
Oct 12, 2020
Merged

Deserialization constructors#21025
gewarren merged 2 commits intodotnet:masterfrom
gewarren:constructors

Conversation

@gewarren
Copy link
Contributor

@gewarren gewarren commented Oct 10, 2020

@gewarren gewarren requested a review from a team as a code owner October 10, 2020 00:09
@dotnet-bot dotnet-bot added this to the October 2020 milestone Oct 10, 2020
@gewarren gewarren requested review from layomia and tdykstra October 10, 2020 01:02
Copy link
Contributor

@tdykstra tdykstra left a comment

Choose a reason for hiding this comment

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

LGTM, one suggestion.

…ss-constructors-not-used-for-deserialization.md

Co-authored-by: Tom Dykstra <tdykstra@microsoft.com>
@gewarren gewarren merged commit 0da16ea into dotnet:master Oct 12, 2020
@gewarren gewarren deleted the constructors branch October 12, 2020 16:26

#### Change description

On .NET Core 3.0 and 3.1, internal and private constructors can be used for deserialization. On .NET Standard 2.0 and 2.1, internal and private constructors are not allowed, and a <xref:System.MissingMethodException> is thrown if no public, parameterless constructor is defined.
Copy link
Contributor

@ahsonkhan ahsonkhan Oct 12, 2020

Choose a reason for hiding this comment

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

Netstandard isn't really a TFM, so it would be better to rephrase this to say something like: the standalone NuGet packages versions 4.6.0-4.7.2 that support netstandard 2.0 (and higher) behaved inconsistently with the built-in behavior on .NET Core 3.1/3.1 ... (add the details). Starting with .NET 5.0/NuGet package 5.0.0 (and higher), the behavior is consistent (and then describe the details of the consistent behavior).

https://www.nuget.org/packages/System.Text.Json/

  • .NET Core 3.0 release has STJ built-in and we also shipped a 4.6.0 standalone STJ NuGet package that supports ns2.0 to support older platform.
  • .NET Core 3.1 release along with 4.7.0 STJ NuGet package (which continues to support ns2.0).
    • .NET core 3.0/3.1 built-in API behavior was inconsistent with the 4.6.0/4.7.0 standalone NuGet package.
  • .NET Core 5.0 release along with 5.0.0 STJ NuGet package (which continues to support ns2.0).
    • Now, both the built-in APIs and the standalone package for older platforms behave the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

cc @layomia please help @gewarren update the wording, if you agree :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Breaking change: non-public parameterless ctors will not be used for deserialization with JsonSerializer

5 participants