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

Rewire polymorphism metadata to the contract model #71346

Merged
merged 3 commits into from
Jun 28, 2022

Conversation

eiriktsarpalis
Copy link
Member

Completes #63747 by rewiring its metadata APIs to the newly merged contract model (#70435).

Fixes #63747.

@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@eiriktsarpalis eiriktsarpalis requested a review from krwq June 27, 2022 20:02
@ghost
Copy link

ghost commented Jun 27, 2022

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

Completes #63747 by rewiring its metadata APIs to the newly merged contract model (#70435).

Fixes #63747.

Author: eiriktsarpalis
Assignees: eiriktsarpalis
Labels:

area-System.Text.Json, new-api-needs-documentation

Milestone: 7.0.0

}
public enum JsonUnknownTypeHandling
{
JsonElement = 0,
JsonNode = 1,
}
public partial class JsonPolymorphicTypeConfiguration : System.Collections.Generic.ICollection<(System.Type DerivedType, object? TypeDiscriminator)>, System.Collections.Generic.IEnumerable<(System.Type DerivedType, object? TypeDiscriminator)>, System.Collections.IEnumerable
Copy link
Member Author

@eiriktsarpalis eiriktsarpalis Jun 28, 2022

Choose a reason for hiding this comment

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

First change made in the implementation of this PR: Remove provisional JsonPolymorphicTypeConfiguration

public System.Action<System.Text.Json.Utf8JsonWriter, TCollection>? SerializeHandler { get { throw null; } init { } }
}
public readonly partial struct JsonDerivedType
Copy link
Member Author

Choose a reason for hiding this comment

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

Added JsonDerivedType struct

@@ -1161,15 +1135,24 @@ public sealed partial class JsonParameterInfoValues
public System.Type ParameterType { get { throw null; } init { } }
public int Position { get { throw null; } init { } }
}
public partial class JsonPolymorphismOptions
Copy link
Member Author

Choose a reason for hiding this comment

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

Add JsonPolymorphismOptions

[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use generic overload or System.Text.Json source generation for native AOT applications.")]
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use generic overload or System.Text.Json source generation for native AOT applications.")]
public System.Text.Json.JsonSerializerOptions Options { get { throw null; } }
public System.Text.Json.Serialization.Metadata.JsonPolymorphismOptions? PolymorphismOptions { get { throw null; } set { } }
Copy link
Member Author

Choose a reason for hiding this comment

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

Add JsonPolymorphismOptions property to JsonTypeInfo

@@ -356,19 +356,12 @@ public sealed partial class JsonSerializerOptions
public System.Text.Json.JsonNamingPolicy? PropertyNamingPolicy { get { throw null; } set { } }
public System.Text.Json.JsonCommentHandling ReadCommentHandling { get { throw null; } set { } }
public System.Text.Json.Serialization.ReferenceHandler? ReferenceHandler { get { throw null; } set { } }
public System.Collections.Generic.IList<System.Text.Json.Serialization.JsonPolymorphicTypeConfiguration> PolymorphicTypeConfigurations { get { throw null; } }
Copy link
Member Author

@eiriktsarpalis eiriktsarpalis Jun 28, 2022

Choose a reason for hiding this comment

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

Remove provisional PolymorphicTypeConfigurations property from JsonSerializerOptions.

Copy link
Member

@krwq krwq left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@eiriktsarpalis eiriktsarpalis merged commit b720a5d into dotnet:main Jun 28, 2022
@eiriktsarpalis eiriktsarpalis deleted the polymorphism-metadata branch June 28, 2022 10:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Developers can use System.Text.Json to serialize type hierarchies securely
2 participants