diff --git a/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Delete.cs b/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Delete.cs index 6423144eacb4cb..645003c015a5f6 100644 --- a/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Delete.cs +++ b/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Delete.cs @@ -84,7 +84,7 @@ public static partial class HttpClientJsonExtensions /// The client used to send the request. /// The Uri the request is sent to. /// The type of the object to deserialize to and return. - /// Source generated JsonSerializerContext used to control the deserialization behavior. + /// The JsonSerializerContext used to control the deserialization behavior. /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The task object representing the asynchronous operation. /// The is . @@ -97,7 +97,7 @@ public static partial class HttpClientJsonExtensions /// The client used to send the request. /// The Uri the request is sent to. /// The type of the object to deserialize to and return. - /// Source generated JsonSerializerContext used to control the deserialization behavior. + /// The JsonSerializerContext used to control the deserialization behavior. /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The task object representing the asynchronous operation. /// The is . @@ -110,7 +110,7 @@ public static partial class HttpClientJsonExtensions /// The target type to deserialize to. /// The client used to send the request. /// The Uri the request is sent to. - /// Source generated JsonTypeInfo to control the behavior during deserialization. + /// The JsonTypeInfo used to control the deserialization behavior. /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The task object representing the asynchronous operation. /// The is . @@ -123,7 +123,7 @@ public static partial class HttpClientJsonExtensions /// The target type to deserialize to. /// The client used to send the request. /// The Uri the request is sent to. - /// Source generated JsonTypeInfo to control the behavior during deserialization. + /// The JsonTypeInfo used to control the deserialization behavior. /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The task object representing the asynchronous operation. /// The is . diff --git a/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs b/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs index 057bf872692c3c..3fc12aeb935455 100644 --- a/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs +++ b/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs @@ -62,7 +62,7 @@ public static partial class HttpClientJsonExtensions /// The target type to deserialize to. /// The client used to send the request. /// The Uri the request is sent to. - /// Source generated JsonTypeInfo to control the behavior during deserialization. + /// The JsonTypeInfo used to control the behavior during deserialization. /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// An that represents the deserialized response body. /// The is . @@ -80,7 +80,7 @@ public static partial class HttpClientJsonExtensions /// The target type to deserialize to. /// The client used to send the request. /// The Uri the request is sent to. - /// Source generated JsonTypeInfo to control the behavior during deserialization. + /// The JsonTypeInfo used to control the behavior during deserialization. /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// An that represents the deserialized response body. /// The is . diff --git a/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Patch.cs b/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Patch.cs index b887011c92facc..4ed1ed590f3b46 100644 --- a/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Patch.cs +++ b/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Patch.cs @@ -96,7 +96,7 @@ public static Task PatchAsJsonAsync(this HttpClient /// The client used to send the request. /// The Uri the request is sent to. /// The value to serialize. - /// Metadata about the type to convert. + /// The JsonTypeInfo used to control the behavior during serialization. /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The task object representing the asynchronous operation. /// The is null. @@ -118,7 +118,7 @@ public static Task PatchAsJsonAsync(this HttpClient /// The client used to send the request. /// The Uri the request is sent to. /// The value to serialize. - /// Metadata about the type to convert. + /// The JsonTypeInfo used to control the behavior during serialization. /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// The task object representing the asynchronous operation. /// The is null. diff --git a/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpContentJsonExtensions.AsyncEnumerable.cs b/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpContentJsonExtensions.AsyncEnumerable.cs index 9ea80231aafc23..ffe778352b9cb5 100644 --- a/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpContentJsonExtensions.AsyncEnumerable.cs +++ b/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpContentJsonExtensions.AsyncEnumerable.cs @@ -60,17 +60,18 @@ public static partial class HttpContentJsonExtensions return ReadFromJsonAsAsyncEnumerableCore(content, options, cancellationToken); } - [RequiresUnreferencedCode(SerializationUnreferencedCodeMessage)] - [RequiresDynamicCode(SerializationDynamicCodeMessage)] - private static IAsyncEnumerable ReadFromJsonAsAsyncEnumerableCore( - HttpContent content, - JsonSerializerOptions? options, - CancellationToken cancellationToken) - { - var jsonTypeInfo = (JsonTypeInfo)JsonHelpers.GetJsonTypeInfo(typeof(TValue), options); - return ReadFromJsonAsAsyncEnumerableCore(content, jsonTypeInfo, cancellationToken); - } - + /// + /// Reads the HTTP content and returns the value that results from deserializing the content as + /// JSON in an async enumerable operation. + /// + /// The target type to deserialize to. + /// The content to read from. + /// The JsonTypeInfo used to control the deserialization behavior. + /// + /// An that represents the deserialized response body. + /// + /// The is . + /// public static IAsyncEnumerable ReadFromJsonAsAsyncEnumerable( this HttpContent content, JsonTypeInfo jsonTypeInfo, @@ -84,6 +85,17 @@ public static partial class HttpContentJsonExtensions return ReadFromJsonAsAsyncEnumerableCore(content, jsonTypeInfo, cancellationToken); } + [RequiresUnreferencedCode(SerializationUnreferencedCodeMessage)] + [RequiresDynamicCode(SerializationDynamicCodeMessage)] + private static IAsyncEnumerable ReadFromJsonAsAsyncEnumerableCore( + HttpContent content, + JsonSerializerOptions? options, + CancellationToken cancellationToken) + { + var jsonTypeInfo = (JsonTypeInfo)JsonHelpers.GetJsonTypeInfo(typeof(TValue), options); + return ReadFromJsonAsAsyncEnumerableCore(content, jsonTypeInfo, cancellationToken); + } + private static async IAsyncEnumerable ReadFromJsonAsAsyncEnumerableCore( HttpContent content, JsonTypeInfo jsonTypeInfo, diff --git a/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.cs b/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.cs index 6cb464db10fd06..07a4b4c1c35cb2 100644 --- a/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.cs +++ b/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/JsonContent.cs @@ -32,11 +32,27 @@ private JsonContent( Headers.ContentType = mediaType ?? JsonHelpers.GetDefaultMediaType(); } + /// + /// Creates a new instance of the class that will contain the serialized as JSON. + /// + /// The type of the value to serialize. + /// The value to serialize. + /// The media type to use for the content. + /// Options to control the behavior during serialization, the default options are . + /// A instance. [RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)] [RequiresDynamicCode(HttpContentJsonExtensions.SerializationDynamicCodeMessage)] public static JsonContent Create(T inputValue, MediaTypeHeaderValue? mediaType = null, JsonSerializerOptions? options = null) => Create(inputValue, JsonHelpers.GetJsonTypeInfo(typeof(T), options), mediaType); + /// + /// Creates a new instance of the class that will contain the serialized as JSON. + /// + /// The value to serialize. + /// The type of the value to serialize. + /// The media type to use for the content. + /// Options to control the behavior during serialization, the default options are . + /// A instance. [RequiresUnreferencedCode(HttpContentJsonExtensions.SerializationUnreferencedCodeMessage)] [RequiresDynamicCode(HttpContentJsonExtensions.SerializationDynamicCodeMessage)] public static JsonContent Create(object? inputValue, Type inputType, MediaTypeHeaderValue? mediaType = null, JsonSerializerOptions? options = null) @@ -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? inputValue, JsonTypeInfo jsonTypeInfo, - MediaTypeHeaderValue? mediaType = null) + /// + /// Creates a new instance of the class that will contain the serialized as JSON. + /// + /// The type of the value to serialize. + /// The value to serialize. + /// The JsonTypeInfo used to control the serialization behavior. + /// The media type to use for the content. + /// A instance. + public static JsonContent Create(T? inputValue, JsonTypeInfo jsonTypeInfo, MediaTypeHeaderValue? mediaType = null) { ThrowHelper.ThrowIfNull(jsonTypeInfo); return new JsonContent(inputValue, jsonTypeInfo, mediaType); } - public static JsonContent Create(object? inputValue, JsonTypeInfo jsonTypeInfo, - MediaTypeHeaderValue? mediaType = null) + /// + /// Creates a new instance of the class that will contain the serialized as JSON. + /// + /// The value to serialize. + /// The JsonTypeInfo used to control the serialization behavior. + /// The media type to use for the content. + /// A instance. + public static JsonContent Create(object? inputValue, JsonTypeInfo jsonTypeInfo, MediaTypeHeaderValue? mediaType = null) { ThrowHelper.ThrowIfNull(jsonTypeInfo); EnsureTypeCompatibility(inputValue, jsonTypeInfo.Type);