[csharp] Add missing ConfigureAwait(false) for csharp generator (#21244)

* [csharp] ApiClient.mustache: Apply ConfigureAwait(false) consistently

* [csharp] Update samples to include 59936f29f00
This commit is contained in:
Billy Booth 2025-05-08 23:02:38 -05:00 committed by GitHub
parent bb811db2a2
commit d6c4634269
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 42 additions and 42 deletions

View File

@ -493,7 +493,7 @@ namespace {{packageName}}.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -562,7 +562,7 @@ namespace {{packageName}}.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -621,7 +621,7 @@ namespace {{packageName}}.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -476,7 +476,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -545,7 +545,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -602,7 +602,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -476,7 +476,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -545,7 +545,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -602,7 +602,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -492,7 +492,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -561,7 +561,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -618,7 +618,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -492,7 +492,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -561,7 +561,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -618,7 +618,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -492,7 +492,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -561,7 +561,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -618,7 +618,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -491,7 +491,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -560,7 +560,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -617,7 +617,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -475,7 +475,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -544,7 +544,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -601,7 +601,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -491,7 +491,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -560,7 +560,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -617,7 +617,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -475,7 +475,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -544,7 +544,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -601,7 +601,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -491,7 +491,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -560,7 +560,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -617,7 +617,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -491,7 +491,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -560,7 +560,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -617,7 +617,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -492,7 +492,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -561,7 +561,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -618,7 +618,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{

View File

@ -492,7 +492,7 @@ namespace Org.OpenAPITools.Client
{
InterceptRequest(request);
RestResponse<T> response = await getResponse(client);
RestResponse<T> response = await getResponse(client).ConfigureAwait(false);
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
@ -561,7 +561,7 @@ namespace Org.OpenAPITools.Client
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
return await client.Deserialize<T>(policyResult.Result, cancellationToken).ConfigureAwait(false);
}
else
{
@ -618,7 +618,7 @@ namespace Org.OpenAPITools.Client
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken).ConfigureAwait(false);
}
else
{