forked from loafle/openapi-generator-original
[csharp] Address obsolete build warnings in ApiClient (#19847)
* Stop using obsolete MaxTimeout * Convert timeout to a timespan, rather than update the configuration object * Use async overload of RestClientExtensions.Deserialize * Update samples * Fix typo * Undo timeout change
This commit is contained in:
parent
8849156d29
commit
b5b760a8a2
@ -550,11 +550,11 @@ namespace {{packageName}}.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -587,7 +587,7 @@ namespace {{packageName}}.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -613,7 +613,7 @@ namespace {{packageName}}.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -533,11 +533,11 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -570,7 +570,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -594,7 +594,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -533,11 +533,11 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -570,7 +570,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -594,7 +594,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -549,11 +549,11 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -586,7 +586,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -610,7 +610,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -549,11 +549,11 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -586,7 +586,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -610,7 +610,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -549,11 +549,11 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -586,7 +586,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -610,7 +610,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -532,11 +532,11 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -569,7 +569,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -593,7 +593,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -548,11 +548,11 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -585,7 +585,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -609,7 +609,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -548,11 +548,11 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -585,7 +585,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -609,7 +609,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -532,11 +532,11 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -569,7 +569,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -593,7 +593,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -549,11 +549,11 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -586,7 +586,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -610,7 +610,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -549,11 +549,11 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
}
|
||||
|
||||
private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
|
||||
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (policyResult.Outcome == OutcomeType.Successful)
|
||||
{
|
||||
return client.Deserialize<T>(policyResult.Result);
|
||||
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -586,7 +586,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.RetryPolicy;
|
||||
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
|
||||
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
|
||||
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -610,7 +610,7 @@ namespace Org.OpenAPITools.Client
|
||||
{
|
||||
var policy = RetryConfiguration.AsyncRetryPolicy;
|
||||
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
|
||||
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
|
||||
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user