Skip to content

Commit

Permalink
Add missing System.Net.Http.Json comments (#92223)
Browse files Browse the repository at this point in the history
* Add missing System.Net.Http.Json comments

* Wording
  • Loading branch information
MihaZupan authored Sep 21, 2023
1 parent 49930c1 commit 5149896
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static partial class HttpClientJsonExtensions
/// <param name="client">The client used to send the request.</param>
/// <param name="requestUri">The Uri the request is sent to.</param>
/// <param name="type">The type of the object to deserialize to and return.</param>
/// <param name="context">Source generated JsonSerializerContext used to control the deserialization behavior.</param>
/// <param name="context">The JsonSerializerContext used to control the deserialization behavior.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>The task object representing the asynchronous operation.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="client"/> is <see langword="null"/>.</exception>
Expand All @@ -97,7 +97,7 @@ public static partial class HttpClientJsonExtensions
/// <param name="client">The client used to send the request.</param>
/// <param name="requestUri">The Uri the request is sent to.</param>
/// <param name="type">The type of the object to deserialize to and return.</param>
/// <param name="context">Source generated JsonSerializerContext used to control the deserialization behavior.</param>
/// <param name="context">The JsonSerializerContext used to control the deserialization behavior.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>The task object representing the asynchronous operation.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="client"/> is <see langword="null"/>.</exception>
Expand All @@ -110,7 +110,7 @@ public static partial class HttpClientJsonExtensions
/// <typeparam name="TValue">The target type to deserialize to.</typeparam>
/// <param name="client">The client used to send the request.</param>
/// <param name="requestUri">The Uri the request is sent to.</param>
/// <param name="jsonTypeInfo">Source generated JsonTypeInfo to control the behavior during deserialization.</param>
/// <param name="jsonTypeInfo">The JsonTypeInfo used to control the deserialization behavior.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>The task object representing the asynchronous operation.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="client"/> is <see langword="null"/>.</exception>
Expand All @@ -123,7 +123,7 @@ public static partial class HttpClientJsonExtensions
/// <typeparam name="TValue">The target type to deserialize to.</typeparam>
/// <param name="client">The client used to send the request.</param>
/// <param name="requestUri">The Uri the request is sent to.</param>
/// <param name="jsonTypeInfo">Source generated JsonTypeInfo to control the behavior during deserialization.</param>
/// <param name="jsonTypeInfo">The JsonTypeInfo used to control the deserialization behavior.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>The task object representing the asynchronous operation.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="client"/> is <see langword="null"/>.</exception>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static partial class HttpClientJsonExtensions
/// <typeparam name="TValue">The target type to deserialize to.</typeparam>
/// <param name="client">The client used to send the request.</param>
/// <param name="requestUri">The Uri the request is sent to.</param>
/// <param name="jsonTypeInfo">Source generated JsonTypeInfo to control the behavior during deserialization.</param>
/// <param name="jsonTypeInfo">The JsonTypeInfo used to control the behavior during deserialization.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>An <see cref="IAsyncEnumerable{TValue}"/> that represents the deserialized response body.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="client"/> is <see langword="null"/>.</exception>
Expand All @@ -80,7 +80,7 @@ public static partial class HttpClientJsonExtensions
/// <typeparam name="TValue">The target type to deserialize to.</typeparam>
/// <param name="client">The client used to send the request.</param>
/// <param name="requestUri">The Uri the request is sent to.</param>
/// <param name="jsonTypeInfo">Source generated JsonTypeInfo to control the behavior during deserialization.</param>
/// <param name="jsonTypeInfo">The JsonTypeInfo used to control the behavior during deserialization.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>An <see cref="IAsyncEnumerable{TValue}"/> that represents the deserialized response body.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="client"/> is <see langword="null"/>.</exception>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static Task<HttpResponseMessage> PatchAsJsonAsync<TValue>(this HttpClient
/// <param name="client">The client used to send the request.</param>
/// <param name="requestUri">The Uri the request is sent to.</param>
/// <param name="value">The value to serialize.</param>
/// <param name="jsonTypeInfo">Metadata about the type to convert.</param>
/// <param name="jsonTypeInfo">The JsonTypeInfo used to control the behavior during serialization.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>The task object representing the asynchronous operation.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="client"/> is null.</exception>
Expand All @@ -118,7 +118,7 @@ public static Task<HttpResponseMessage> PatchAsJsonAsync<TValue>(this HttpClient
/// <param name="client">The client used to send the request.</param>
/// <param name="requestUri">The Uri the request is sent to.</param>
/// <param name="value">The value to serialize.</param>
/// <param name="jsonTypeInfo">Metadata about the type to convert.</param>
/// <param name="jsonTypeInfo">The JsonTypeInfo used to control the behavior during serialization.</param>
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>The task object representing the asynchronous operation.</returns>
/// <exception cref="ArgumentNullException">The <paramref name="client"/> is null.</exception>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,18 @@ public static partial class HttpContentJsonExtensions
return ReadFromJsonAsAsyncEnumerableCore<TValue>(content, options, cancellationToken);
}

[RequiresUnreferencedCode(SerializationUnreferencedCodeMessage)]
[RequiresDynamicCode(SerializationDynamicCodeMessage)]
private static IAsyncEnumerable<TValue?> ReadFromJsonAsAsyncEnumerableCore<TValue>(
HttpContent content,
JsonSerializerOptions? options,
CancellationToken cancellationToken)
{
var jsonTypeInfo = (JsonTypeInfo<TValue>)JsonHelpers.GetJsonTypeInfo(typeof(TValue), options);
return ReadFromJsonAsAsyncEnumerableCore(content, jsonTypeInfo, cancellationToken);
}

/// <summary>
/// Reads the HTTP content and returns the value that results from deserializing the content as
/// JSON in an async enumerable operation.
/// </summary>
/// <typeparam name="TValue">The target type to deserialize to.</typeparam>
/// <param name="content">The content to read from.</param>
/// <param name="jsonTypeInfo">The JsonTypeInfo used to control the deserialization behavior.</param>
/// <param name="cancellationToken"></param>
/// <returns>An <see cref="IAsyncEnumerable{TValue}"/> that represents the deserialized response body.</returns>
/// <exception cref="ArgumentNullException">
/// The <paramref name="content"/> is <see langword="null"/>.
/// </exception>
public static IAsyncEnumerable<TValue?> ReadFromJsonAsAsyncEnumerable<TValue>(
this HttpContent content,
JsonTypeInfo<TValue> jsonTypeInfo,
Expand All @@ -84,6 +85,17 @@ public static partial class HttpContentJsonExtensions
return ReadFromJsonAsAsyncEnumerableCore(content, jsonTypeInfo, cancellationToken);
}

[RequiresUnreferencedCode(SerializationUnreferencedCodeMessage)]
[RequiresDynamicCode(SerializationDynamicCodeMessage)]
private static IAsyncEnumerable<TValue?> ReadFromJsonAsAsyncEnumerableCore<TValue>(
HttpContent content,
JsonSerializerOptions? options,
CancellationToken cancellationToken)
{
var jsonTypeInfo = (JsonTypeInfo<TValue>)JsonHelpers.GetJsonTypeInfo(typeof(TValue), options);
return ReadFromJsonAsAsyncEnumerableCore(content, jsonTypeInfo, cancellationToken);
}

private static async IAsyncEnumerable<TValue?> ReadFromJsonAsAsyncEnumerableCore<TValue>(
HttpContent content,
JsonTypeInfo<TValue> jsonTypeInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,27 @@ private JsonContent(
Headers.ContentType = mediaType ?? JsonHelpers.GetDefaultMediaType();
}

/// <summary>
/// Creates a new instance of the <see cref="JsonContent"/> class that will contain the <paramref name="inputValue"/> serialized as JSON.
/// </summary>
/// <typeparam name="T">The type of the value to serialize.</typeparam>
/// <param name="inputValue">The value to serialize.</param>
/// <param name="mediaType">The media type to use for the content.</param>
/// <param name="options">Options to control the behavior during serialization, the default options are <see cref="JsonSerializerDefaults.Web"/>.</param>
/// <returns>A <see cref="JsonContent"/> instance.</returns>
[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
[RequiresDynamicCode(HttpContentJsonExtensions.SerializationDynamicCodeMessage)]
public static JsonContent Create<T>(T inputValue, MediaTypeHeaderValue? mediaType = null, JsonSerializerOptions? options = null)
=> Create(inputValue, JsonHelpers.GetJsonTypeInfo(typeof(T), options), mediaType);

/// <summary>
/// Creates a new instance of the <see cref="JsonContent"/> class that will contain the <paramref name="inputValue"/> serialized as JSON.
/// </summary>
/// <param name="inputValue">The value to serialize.</param>
/// <param name="inputType">The type of the value to serialize.</param>
/// <param name="mediaType">The media type to use for the content.</param>
/// <param name="options">Options to control the behavior during serialization, the default options are <see cref="JsonSerializerDefaults.Web"/>.</param>
/// <returns>A <see cref="JsonContent"/> instance.</returns>
[RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)]
[RequiresDynamicCode(HttpContentJsonExtensions.SerializationDynamicCodeMessage)]
public static JsonContent Create(object? inputValue, Type inputType, MediaTypeHeaderValue? mediaType = null, JsonSerializerOptions? options = null)
Expand All @@ -47,16 +63,29 @@ public static JsonContent Create(object? inputValue, Type inputType, MediaTypeHe
return new JsonContent(inputValue, JsonHelpers.GetJsonTypeInfo(inputType, options), mediaType);
}

public static JsonContent Create<T>(T? inputValue, JsonTypeInfo<T> jsonTypeInfo,
MediaTypeHeaderValue? mediaType = null)
/// <summary>
/// Creates a new instance of the <see cref="JsonContent"/> class that will contain the <paramref name="inputValue"/> serialized as JSON.
/// </summary>
/// <typeparam name="T">The type of the value to serialize.</typeparam>
/// <param name="inputValue">The value to serialize.</param>
/// <param name="jsonTypeInfo">The JsonTypeInfo used to control the serialization behavior.</param>
/// <param name="mediaType">The media type to use for the content.</param>
/// <returns>A <see cref="JsonContent"/> instance.</returns>
public static JsonContent Create<T>(T? inputValue, JsonTypeInfo<T> jsonTypeInfo, MediaTypeHeaderValue? mediaType = null)
{
ThrowHelper.ThrowIfNull(jsonTypeInfo);

return new JsonContent(inputValue, jsonTypeInfo, mediaType);
}

public static JsonContent Create(object? inputValue, JsonTypeInfo jsonTypeInfo,
MediaTypeHeaderValue? mediaType = null)
/// <summary>
/// Creates a new instance of the <see cref="JsonContent"/> class that will contain the <paramref name="inputValue"/> serialized as JSON.
/// </summary>
/// <param name="inputValue">The value to serialize.</param>
/// <param name="jsonTypeInfo">The JsonTypeInfo used to control the serialization behavior.</param>
/// <param name="mediaType">The media type to use for the content.</param>
/// <returns>A <see cref="JsonContent"/> instance.</returns>
public static JsonContent Create(object? inputValue, JsonTypeInfo jsonTypeInfo, MediaTypeHeaderValue? mediaType = null)
{
ThrowHelper.ThrowIfNull(jsonTypeInfo);
EnsureTypeCompatibility(inputValue, jsonTypeInfo.Type);
Expand Down

0 comments on commit 5149896

Please sign in to comment.