Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ partial void ProcessGatewayDeleteFileResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ partial void ProcessGatewayDownloadFileResponseContent(
try
{
__response.EnsureSuccessStatusCode();

var __content = await __response.Content.ReadAsByteArrayAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ partial void ProcessGatewayGetFileResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ partial void ProcessGatewayGetFilesResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ partial void ProcessGatewayRetryFailedFilesResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ partial void ProcessGatewayUploadFileResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ partial void ProcessChatResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ partial void ProcessCompletionsResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ partial void ProcessGenerateContentResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ partial void ProcessGetApplicationsResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ partial void ProcessGetApplicationsByApplicationIdResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ partial void ProcessModelsResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ partial void ProcessAddFileToGraphResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ partial void ProcessCreateGraphResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ partial void ProcessDeleteGraphResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ partial void ProcessFindGraphWithFileStatusResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ partial void ProcessFindGraphsWithFileStatusResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
1 change: 0 additions & 1 deletion src/libs/Writer/Generated/Writer.KgApiClient.Question.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ partial void ProcessQuestionResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ partial void ProcessRemoveFileFromGraphResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ partial void ProcessUpdateGraphResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
126 changes: 124 additions & 2 deletions src/libs/Writer/Generated/Writer.Polyfills.g.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

#if !NET6_0_OR_GREATER
#nullable enable

namespace Writer
Expand All @@ -9,6 +8,7 @@ namespace Writer
/// </summary>
public static partial class AutoSdkPolyfills
{
#if !NET6_0_OR_GREATER
/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -48,6 +48,128 @@ public static partial class AutoSdkPolyfills
content = content ?? throw new global::System.ArgumentNullException(nameof(content));
return content.ReadAsByteArrayAsync();
}
#endif

/// <summary>
/// Creates a JSON request content instance.
/// </summary>
public static global::System.Net.Http.HttpContent CreateJsonContent<T>(
T inputValue,
string mediaType,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions)
{
if (string.IsNullOrWhiteSpace(mediaType))
{
throw new global::System.ArgumentException("Media type is required.", nameof(mediaType));
}

#if NET5_0_OR_GREATER
return global::System.Net.Http.Json.JsonContent.Create(
inputValue: inputValue,
mediaType: new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType),
options: jsonSerializerOptions);
#else
var json = global::System.Text.Json.JsonSerializer.Serialize(inputValue, jsonSerializerOptions);
var stringContent = new global::System.Net.Http.StringContent(
content: json,
encoding: global::System.Text.Encoding.UTF8);
stringContent.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType)
{
CharSet = global::System.Text.Encoding.UTF8.WebName,
};
return stringContent;
#endif
}

/// <summary>
/// Creates a JSON request content instance using a source-generated serializer context.
/// </summary>
public static global::System.Net.Http.HttpContent CreateJsonContent(
object? inputValue,
global::System.Type inputType,
string mediaType,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
inputType = inputType ?? throw new global::System.ArgumentNullException(nameof(inputType));
jsonSerializerContext = jsonSerializerContext ?? throw new global::System.ArgumentNullException(nameof(jsonSerializerContext));

if (string.IsNullOrWhiteSpace(mediaType))
{
throw new global::System.ArgumentException("Media type is required.", nameof(mediaType));
}

#if NET5_0_OR_GREATER
var jsonTypeInfo = jsonSerializerContext.GetTypeInfo(inputType) ??
throw new global::System.InvalidOperationException($"No JsonTypeInfo registered for '{inputType}'.");
return global::System.Net.Http.Json.JsonContent.Create(
inputValue: inputValue,
jsonTypeInfo: jsonTypeInfo,
mediaType: new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType));
#else
var json = global::System.Text.Json.JsonSerializer.Serialize(
value: inputValue,
inputType: inputType,
jsonSerializerContext);
var stringContent = new global::System.Net.Http.StringContent(
content: json,
encoding: global::System.Text.Encoding.UTF8);
stringContent.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType)
{
CharSet = global::System.Text.Encoding.UTF8.WebName,
};
return stringContent;
#endif
}

/// <summary>
/// Reads JSON content into the specified type using serializer options.
/// </summary>
public static async global::System.Threading.Tasks.Task<T?> ReadFromJsonAsync<T>(
this global::System.Net.Http.HttpContent content,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions,
global::System.Threading.CancellationToken cancellationToken)
{
content = content ?? throw new global::System.ArgumentNullException(nameof(content));

#if NET5_0_OR_GREATER
return await global::System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(
content,
jsonSerializerOptions,
cancellationToken).ConfigureAwait(false);
#else
using var stream = await AutoSdkPolyfills.ReadAsStreamAsync(content, cancellationToken).ConfigureAwait(false);
return await global::System.Text.Json.JsonSerializer.DeserializeAsync<T>(
utf8Json: stream,
options: jsonSerializerOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
#endif
}

/// <summary>
/// Reads JSON content into the specified type using a source-generated serializer context.
/// </summary>
public static async global::System.Threading.Tasks.Task<T?> ReadFromJsonAsync<T>(
this global::System.Net.Http.HttpContent content,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext,
global::System.Threading.CancellationToken cancellationToken)
{
content = content ?? throw new global::System.ArgumentNullException(nameof(content));
jsonSerializerContext = jsonSerializerContext ?? throw new global::System.ArgumentNullException(nameof(jsonSerializerContext));

#if NET5_0_OR_GREATER
return (T?)await global::System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync(
content,
typeof(T),
jsonSerializerContext,
cancellationToken).ConfigureAwait(false);
#else
using var stream = await AutoSdkPolyfills.ReadAsStreamAsync(content, cancellationToken).ConfigureAwait(false);
return (T?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(
utf8Json: stream,
returnType: typeof(T),
jsonSerializerContext,
cancellationToken: cancellationToken).ConfigureAwait(false);
#endif
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ partial void ProcessCreateApplicationsByApplicationIdJobsResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ partial void ProcessCreateApplicationsJobsByJobIdRetryResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ partial void ProcessGetApplicationsByApplicationIdGraphsResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ partial void ProcessGetApplicationsByApplicationIdJobsResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ partial void ProcessGetApplicationsJobsByJobIdResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ partial void ProcessPutApplicationsByApplicationIdGraphsResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ partial void ProcessCreateToolsAiDetectResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ partial void ProcessCreateToolsComprehendMedicalResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ partial void ProcessCreateToolsContextAwareSplittingResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ partial void ProcessCreateToolsPdfParserByFileIdResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ partial void ProcessCreateToolsTextToGraphResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Loading