3
3
/// <summary>
4
4
/// A retry policy that can be applied to asynchronous delegates.
5
5
/// </summary>
6
- #pragma warning disable CA1062 // Validate arguments of public methods
7
6
public class AsyncRetryPolicy : AsyncPolicy , IRetryPolicy
8
7
{
9
8
private readonly Func < Exception , TimeSpan , int , Context , Task > _onRetryAsync ;
@@ -34,6 +33,11 @@ protected override Task<TResult> ImplementationAsync<TResult>(
34
33
CancellationToken cancellationToken ,
35
34
bool continueOnCapturedContext )
36
35
{
36
+ if ( action is null )
37
+ {
38
+ throw new ArgumentNullException ( nameof ( action ) ) ;
39
+ }
40
+
37
41
var sleepDurationProvider = _sleepDurationProvider != null
38
42
? ( retryCount , outcome , ctx ) => _sleepDurationProvider ( retryCount , outcome . Exception , ctx )
39
43
: ( Func < int , DelegateResult < TResult > , Context , TimeSpan > ) null ;
@@ -79,9 +83,18 @@ internal AsyncRetryPolicy(
79
83
80
84
/// <inheritdoc/>
81
85
[ DebuggerStepThrough ]
82
- protected override Task < TResult > ImplementationAsync ( Func < Context , CancellationToken , Task < TResult > > action , Context context , CancellationToken cancellationToken ,
83
- bool continueOnCapturedContext ) =>
84
- AsyncRetryEngine . ImplementationAsync (
86
+ protected override Task < TResult > ImplementationAsync (
87
+ Func < Context , CancellationToken , Task < TResult > > action ,
88
+ Context context ,
89
+ CancellationToken cancellationToken ,
90
+ bool continueOnCapturedContext )
91
+ {
92
+ if ( action is null )
93
+ {
94
+ throw new ArgumentNullException ( nameof ( action ) ) ;
95
+ }
96
+
97
+ return AsyncRetryEngine . ImplementationAsync (
85
98
action ,
86
99
context ,
87
100
ExceptionPredicates ,
@@ -92,5 +105,6 @@ protected override Task<TResult> ImplementationAsync(Func<Context, CancellationT
92
105
_sleepDurationsEnumerable ,
93
106
_sleepDurationProvider ,
94
107
continueOnCapturedContext ) ;
108
+ }
95
109
}
96
110
0 commit comments