-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 JsonContent.Create overloads which accept JsonTypeInfo #89614
Add JsonContent.Create overloads which accept JsonTypeInfo #89614
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, 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. |
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsThis adds namespace System.Net.Http.Json
{
public partial class JsonContent
{
public static JsonContent Create<TValue>(TValue? inputValue, JsonTypeInfo<TValue> jsonTypeInfo, MediaTypeHeaderValue? mediaType = null);
public static JsonContent Create(object? inputValue, JsonTypeInfo jsonTypeInfo, MediaTypeHeaderValue? mediaType = null);
}
} I did consider changing the internal Fixes #51544
|
src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.JsonTypeInfoOfT.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.Object.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.Object.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.Object.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContentOfT.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/tests/FunctionalTests/JsonContentTests.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.cs
Show resolved
Hide resolved
…onContent.cs Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution, and for simplifying the implementation :-)
Thanks for teaching me the new |
This adds
JsonContent.Create
overloads that acceptJsonTypeInfo
parameters as approved in #51544.I did consider changing the internal
JsonContent<T>
overload to inherit fromJsonContent
. However, this requires unsealingJsonContent
which was not approved. More importantly, to work wellObjectType
and especiallyValue
would need to be madevirtual
, which is not an allowed change to the API surface due to binary compatibility requirements. This approach seemed cleaner at the cost of a very lightweight additional abstraction layer.Fixes #51544