@@ -4,7 +4,6 @@ namespace Polly.RateLimit;
4
4
/// <summary>
5
5
/// A rate-limit policy that can be applied to asynchronous delegates.
6
6
/// </summary>
7
- #pragma warning disable CA1062 // Validate arguments of public methods
8
7
public class AsyncRateLimitPolicy : AsyncPolicy , IRateLimitPolicy
9
8
{
10
9
private readonly IRateLimiter _rateLimiter ;
@@ -14,9 +13,25 @@ internal AsyncRateLimitPolicy(IRateLimiter rateLimiter) =>
14
13
15
14
/// <inheritdoc/>
16
15
[ DebuggerStepThrough ]
17
- protected override Task < TResult > ImplementationAsync < TResult > ( Func < Context , CancellationToken , Task < TResult > > action , Context context , CancellationToken cancellationToken ,
18
- bool continueOnCapturedContext ) =>
19
- AsyncRateLimitEngine . ImplementationAsync ( _rateLimiter , null , action , context , continueOnCapturedContext , cancellationToken ) ;
16
+ protected override Task < TResult > ImplementationAsync < TResult > (
17
+ Func < Context , CancellationToken , Task < TResult > > action ,
18
+ Context context ,
19
+ CancellationToken cancellationToken ,
20
+ bool continueOnCapturedContext )
21
+ {
22
+ if ( action is null )
23
+ {
24
+ throw new ArgumentNullException ( nameof ( action ) ) ;
25
+ }
26
+
27
+ return AsyncRateLimitEngine . ImplementationAsync (
28
+ _rateLimiter ,
29
+ null ,
30
+ action ,
31
+ context ,
32
+ continueOnCapturedContext ,
33
+ cancellationToken ) ;
34
+ }
20
35
}
21
36
22
37
/// <summary>
@@ -38,7 +53,23 @@ internal AsyncRateLimitPolicy(
38
53
39
54
/// <inheritdoc/>
40
55
[ DebuggerStepThrough ]
41
- protected override Task < TResult > ImplementationAsync ( Func < Context , CancellationToken , Task < TResult > > action , Context context , CancellationToken cancellationToken ,
42
- bool continueOnCapturedContext ) =>
43
- AsyncRateLimitEngine . ImplementationAsync ( _rateLimiter , _retryAfterFactory , action , context , continueOnCapturedContext , cancellationToken ) ;
56
+ protected override Task < TResult > ImplementationAsync (
57
+ Func < Context , CancellationToken , Task < TResult > > action ,
58
+ Context context ,
59
+ CancellationToken cancellationToken ,
60
+ bool continueOnCapturedContext )
61
+ {
62
+ if ( action is null )
63
+ {
64
+ throw new ArgumentNullException ( nameof ( action ) ) ;
65
+ }
66
+
67
+ return AsyncRateLimitEngine . ImplementationAsync (
68
+ _rateLimiter ,
69
+ _retryAfterFactory ,
70
+ action ,
71
+ context ,
72
+ continueOnCapturedContext ,
73
+ cancellationToken ) ;
74
+ }
44
75
}
0 commit comments