-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[API Proposal]: Expose JsonContentOfT publicly #60378
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json Issue DetailsBackground and motivationThe Therefor I propose to mark said partial class as API Proposalnamespace System.Net.Http.Json
{
- internal sealed partial class JsonContent<TValue> : HttpContent
+ public sealed partial class JsonContent<TValue> : HttpContent
{
...
public JsonContent(TValue inputValue, JsonTypeInfo<TValue> jsonTypeInfo)
{
_typeInfo = jsonTypeInfo ?? throw new ArgumentNullException(nameof(jsonTypeInfo));
_typedValue = inputValue;
Headers.ContentType = JsonHelpers.GetDefaultMediaType();
}
...
}
} API UsageWon't change the usage internally, just exposes the class for use by external consumers. var jsonContent = new JsonContent<TBody>(inputValue: body, jsonTypeInfo: jsonBodyTypeInfo); RisksI don't know why it was marked as internal in the first place. I assume it has a reason, but I can't really come up with one myself as I'm not familiar enough with the repository nor it's underlying architecture/internal workings. It's not a breaking change at the very least as it's simply an addition to the public API surface. Maybe it affects trimmability though?
|
Why would you need to have access to the |
|
Right, so would |
I honestly didn't think of that myself when I raised this API proposal, but yeah, that would be sufficient for me. |
Great, would it be possible to update the title and OP of the issue so that it reflects this? |
This issue has been marked with the When ready to submit an amended proposal, please ensure that the original post in this issue has been updated, following the API proposal template and examples as provided in the guidelines. |
Will do so later today. |
Seems to be a duplicate of #51544. |
Request body serialization improvements are blocked by dotnet/runtime#60378 and dotnet/runtime#51544
…urcegen Request body serialization improvements are blocked by dotnet/runtime#60378 and dotnet/runtime#51544
Background and motivation
The
JsonContent<T>
is currently marked as internal which makes it impossible to call (without the use of reflection). However, there are cases in which it could be useful to call the constructor on said class directly.Eg: when constructing a JsonContent body for an instance while leveraging the newly-introduced source-generated
JsonTypeInfo<T>
for a PATCH API call.Therefor I propose to mark said partial class as
public
instead ofinternal
API Proposal
API Usage
Won't change the usage internally, just exposes the class for use by external consumers.
Risks
I don't know why it was marked as internal in the first place. I assume it has a reason, but I can't really come up with one myself as I'm not familiar enough with the repository nor it's underlying architecture/internal workings.
It's not a breaking change at the very least as it's simply an addition to the public API surface. Maybe it affects trimmability though?
The text was updated successfully, but these errors were encountered: