Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
eerhardt committed Apr 28, 2021
1 parent 086fd33 commit a0ae5f6
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 74 deletions.
40 changes: 20 additions & 20 deletions src/libraries/System.Net.Http.Json/ref/System.Net.Http.Json.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace System.Net.Http.Json
public static partial class HttpClientJsonExtensions
{
[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<object?> GetFromJsonAsync(this HttpClient client, string? requestUri, [DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] Type type, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
public static Task<object?> GetFromJsonAsync(this HttpClient client, string? requestUri, [DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] Type type, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
{
if (client == null)
{
Expand All @@ -45,7 +45,7 @@ public static partial class HttpClientJsonExtensions
}

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<object?> GetFromJsonAsync(this HttpClient client, Uri? requestUri, [DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] Type type, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
public static Task<object?> GetFromJsonAsync(this HttpClient client, Uri? requestUri, [DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] Type type, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
{
if (client == null)
{
Expand All @@ -57,7 +57,7 @@ public static partial class HttpClientJsonExtensions
}

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<TValue?> GetFromJsonAsync<[DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
public static Task<TValue?> GetFromJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
{
if (client == null)
{
Expand All @@ -69,7 +69,7 @@ public static partial class HttpClientJsonExtensions
}

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<TValue?> GetFromJsonAsync<[DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
public static Task<TValue?> GetFromJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
{
if (client == null)
{
Expand Down Expand Up @@ -125,23 +125,23 @@ public static partial class HttpClientJsonExtensions
}

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<object?> GetFromJsonAsync(this HttpClient client, string? requestUri, [DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] Type type, CancellationToken cancellationToken = default)
public static Task<object?> GetFromJsonAsync(this HttpClient client, string? requestUri, [DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] Type type, CancellationToken cancellationToken = default)
=> client.GetFromJsonAsync(requestUri, type, options: null, cancellationToken);

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<object?> GetFromJsonAsync(this HttpClient client, Uri? requestUri, [DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] Type type, CancellationToken cancellationToken = default)
public static Task<object?> GetFromJsonAsync(this HttpClient client, Uri? requestUri, [DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] Type type, CancellationToken cancellationToken = default)
=> client.GetFromJsonAsync(requestUri, type, options: null, cancellationToken);

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<TValue?> GetFromJsonAsync<[DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, CancellationToken cancellationToken = default)
public static Task<TValue?> GetFromJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, CancellationToken cancellationToken = default)
=> client.GetFromJsonAsync<TValue>(requestUri, options: null, cancellationToken);

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<TValue?> GetFromJsonAsync<[DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, CancellationToken cancellationToken = default)
public static Task<TValue?> GetFromJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, CancellationToken cancellationToken = default)
=> client.GetFromJsonAsync<TValue>(requestUri, options: null, cancellationToken);

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
private static async Task<object?> GetFromJsonAsyncCore(Task<HttpResponseMessage> taskResponse, [DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] Type type, JsonSerializerOptions? options, CancellationToken cancellationToken)
private static async Task<object?> GetFromJsonAsyncCore(Task<HttpResponseMessage> taskResponse, [DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] Type type, JsonSerializerOptions? options, CancellationToken cancellationToken)
{
using (HttpResponseMessage response = await taskResponse.ConfigureAwait(false))
{
Expand All @@ -154,7 +154,7 @@ public static partial class HttpClientJsonExtensions
}

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
private static async Task<T?> GetFromJsonAsyncCore<[DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] T>(Task<HttpResponseMessage> taskResponse, JsonSerializerOptions? options, CancellationToken cancellationToken)
private static async Task<T?> GetFromJsonAsyncCore<[DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] T>(Task<HttpResponseMessage> taskResponse, JsonSerializerOptions? options, CancellationToken cancellationToken)
{
using (HttpResponseMessage response = await taskResponse.ConfigureAwait(false))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace System.Net.Http.Json
public static partial class HttpClientJsonExtensions
{
[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<HttpResponseMessage> PostAsJsonAsync<[DynamicallyAccessedMembers(JsonContent.SerializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, TValue value, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
public static Task<HttpResponseMessage> PostAsJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.SerializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, TValue value, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
{
if (client == null)
{
Expand All @@ -24,7 +24,7 @@ public static partial class HttpClientJsonExtensions
}

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<HttpResponseMessage> PostAsJsonAsync<[DynamicallyAccessedMembers(JsonContent.SerializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, TValue value, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
public static Task<HttpResponseMessage> PostAsJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.SerializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, TValue value, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
{
if (client == null)
{
Expand All @@ -36,11 +36,11 @@ public static partial class HttpClientJsonExtensions
}

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<HttpResponseMessage> PostAsJsonAsync<[DynamicallyAccessedMembers(JsonContent.SerializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, TValue value, CancellationToken cancellationToken)
public static Task<HttpResponseMessage> PostAsJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.SerializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, TValue value, CancellationToken cancellationToken)
=> client.PostAsJsonAsync(requestUri, value, options: null, cancellationToken);

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<HttpResponseMessage> PostAsJsonAsync<[DynamicallyAccessedMembers(JsonContent.SerializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, TValue value, CancellationToken cancellationToken)
public static Task<HttpResponseMessage> PostAsJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.SerializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, TValue value, CancellationToken cancellationToken)
=> client.PostAsJsonAsync(requestUri, value, options: null, cancellationToken);

public static Task<HttpResponseMessage> PostAsJsonAsync<TValue>(this HttpClient client, string? requestUri, TValue value, JsonTypeInfo<TValue> jsonTypeInfo, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace System.Net.Http.Json
public static partial class HttpClientJsonExtensions
{
[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<HttpResponseMessage> PutAsJsonAsync<[DynamicallyAccessedMembers(JsonContent.SerializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, TValue value, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
public static Task<HttpResponseMessage> PutAsJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.SerializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, TValue value, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
{
if (client == null)
{
Expand All @@ -24,7 +24,7 @@ public static partial class HttpClientJsonExtensions
}

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<HttpResponseMessage> PutAsJsonAsync<[DynamicallyAccessedMembers(JsonContent.SerializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, TValue value, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
public static Task<HttpResponseMessage> PutAsJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.SerializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, TValue value, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
{
if (client == null)
{
Expand All @@ -36,11 +36,11 @@ public static partial class HttpClientJsonExtensions
}

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<HttpResponseMessage> PutAsJsonAsync<[DynamicallyAccessedMembers(JsonContent.SerializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, TValue value, CancellationToken cancellationToken)
public static Task<HttpResponseMessage> PutAsJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.SerializationMemberTypes)] TValue>(this HttpClient client, string? requestUri, TValue value, CancellationToken cancellationToken)
=> client.PutAsJsonAsync(requestUri, value, options: null, cancellationToken);

[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
public static Task<HttpResponseMessage> PutAsJsonAsync<[DynamicallyAccessedMembers(JsonContent.SerializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, TValue value, CancellationToken cancellationToken)
public static Task<HttpResponseMessage> PutAsJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.SerializationMemberTypes)] TValue>(this HttpClient client, Uri? requestUri, TValue value, CancellationToken cancellationToken)
=> client.PutAsJsonAsync(requestUri, value, options: null, cancellationToken);

public static Task<HttpResponseMessage> PutAsJsonAsync<TValue>(this HttpClient client, string? requestUri, TValue value, JsonTypeInfo<TValue> jsonTypeInfo, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ namespace System.Net.Http.Json
{
public static partial class HttpContentJsonExtensions
{
internal const string SerializationUnreferencedCodeMessage = "Json Serialization and Deserialization might require types that cannot be statically analyzed. Use the overloads that take a JsonTypeInfo, or make sure all of the required types are preserved.";
internal const string SerializationUnreferencedCodeMessage = "JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.";

[RequiresUnreferencedCode(SerializationUnreferencedCodeMessage)]
public static Task<object?> ReadFromJsonAsync(this HttpContent content, [DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] Type type, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
public static Task<object?> ReadFromJsonAsync(this HttpContent content, [DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] Type type, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
{
if (content == null)
{
Expand All @@ -47,7 +47,7 @@ public static partial class HttpContentJsonExtensions
}

[RequiresUnreferencedCode(SerializationUnreferencedCodeMessage)]
public static Task<T?> ReadFromJsonAsync<[DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] T>(this HttpContent content, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
public static Task<T?> ReadFromJsonAsync<[DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] T>(this HttpContent content, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
{
if (content == null)
{
Expand All @@ -60,7 +60,7 @@ public static partial class HttpContentJsonExtensions
}

[RequiresUnreferencedCode(SerializationUnreferencedCodeMessage)]
private static async Task<object?> ReadFromJsonAsyncCore(HttpContent content, [DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] Type type, Encoding? sourceEncoding, JsonSerializerOptions? options, CancellationToken cancellationToken)
private static async Task<object?> ReadFromJsonAsyncCore(HttpContent content, [DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] Type type, Encoding? sourceEncoding, JsonSerializerOptions? options, CancellationToken cancellationToken)
{
using (Stream contentStream = await GetContentStream(content, sourceEncoding, cancellationToken).ConfigureAwait(false))
{
Expand All @@ -69,7 +69,7 @@ public static partial class HttpContentJsonExtensions
}

[RequiresUnreferencedCode(SerializationUnreferencedCodeMessage)]
private static async Task<T?> ReadFromJsonAsyncCore<[DynamicallyAccessedMembers(JsonContent.DeserializationMemberTypes)] T>(HttpContent content, Encoding? sourceEncoding, JsonSerializerOptions? options, CancellationToken cancellationToken)
private static async Task<T?> ReadFromJsonAsyncCore<[DynamicallyAccessedMembers(JsonHelpers.DeserializationMemberTypes)] T>(HttpContent content, Encoding? sourceEncoding, JsonSerializerOptions? options, CancellationToken cancellationToken)
{
using (Stream contentStream = await GetContentStream(content, sourceEncoding, cancellationToken).ConfigureAwait(false))
{
Expand Down
Loading

0 comments on commit a0ae5f6

Please sign in to comment.