Skip to content

Commit

Permalink
fix: adds cancellation token parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Biret <[email protected]>
  • Loading branch information
baywet committed Aug 27, 2024
1 parent 1b2094d commit 275120e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/abstractions/NativeResponseWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.Kiota.Abstractions
Expand Down Expand Up @@ -58,15 +59,17 @@ public class NativeResponseWrapper
/// <param name="q">The query parameters of the request</param>
/// <param name="h">The request headers of the request</param>
/// <param name="o">Request options</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns></returns>
public static async Task<NativeResponseType?> CallAndGetNativeTypeAsync<ModelType, NativeResponseType, QueryParametersType>(
Func<Action<QueryParametersType>?, Action<IDictionary<string, string>>?, IEnumerable<IRequestOption>?, IResponseHandler, Task<ModelType>> originalCall,
Func<Action<QueryParametersType>?, Action<IDictionary<string, string>>?, IEnumerable<IRequestOption>?, IResponseHandler, CancellationToken, Task<ModelType>> originalCall,
Action<QueryParametersType>? q = default,
Action<IDictionary<string, string>>? h = default,
IEnumerable<IRequestOption>? o = default) where NativeResponseType : class
IEnumerable<IRequestOption>? o = default,
CancellationToken cancellationToken = default) where NativeResponseType : class
{
var responseHandler = new NativeResponseHandler();
await originalCall.Invoke(q, h, o, responseHandler);
await originalCall.Invoke(q, h, o, responseHandler, cancellationToken);
return responseHandler.Value as NativeResponseType;
}

Expand All @@ -79,15 +82,17 @@ public class NativeResponseWrapper
/// <param name="q">The query parameters of the request</param>
/// <param name="h">The request headers of the request</param>
/// <param name="o">Request options</param>
/// <param name="cancellationToken">The cancellation token</param>
public static async Task<NativeResponseType?> CallAndGetNativeTypeAsync<ModelType, NativeResponseType, QueryParametersType, RequestBodyType>(

Check warning on line 86 in src/abstractions/NativeResponseWrapper.cs

View workflow job for this annotation

GitHub Actions / Build

Reduce the number of generic parameters in the 'NativeResponseWrapper.CallAndGetNativeTypeAsync' method to no more than the 3 authorized. (https://rules.sonarsource.com/csharp/RSPEC-2436)

Check warning on line 86 in src/abstractions/NativeResponseWrapper.cs

View workflow job for this annotation

GitHub Actions / Build

Reduce the number of generic parameters in the 'NativeResponseWrapper.CallAndGetNativeTypeAsync' method to no more than the 3 authorized. (https://rules.sonarsource.com/csharp/RSPEC-2436)
Func<RequestBodyType, Action<QueryParametersType>?, Action<IDictionary<string, string>>?, IEnumerable<IRequestOption>?, IResponseHandler, Task<ModelType>> originalCall,
Func<RequestBodyType, Action<QueryParametersType>?, Action<IDictionary<string, string>>?, IEnumerable<IRequestOption>?, IResponseHandler, CancellationToken, Task<ModelType>> originalCall,
RequestBodyType requestBody,
Action<QueryParametersType>? q = default,
Action<IDictionary<string, string>>? h = default,
IEnumerable<IRequestOption>? o = default) where NativeResponseType : class
IEnumerable<IRequestOption>? o = default,
CancellationToken cancellationToken = default) where NativeResponseType : class
{
var responseHandler = new NativeResponseHandler();
await originalCall.Invoke(requestBody, q, h, o, responseHandler);
await originalCall.Invoke(requestBody, q, h, o, responseHandler, cancellationToken);
return responseHandler.Value as NativeResponseType;
}
}
Expand Down

0 comments on commit 275120e

Please sign in to comment.