33/// <summary>
44/// A retry policy that can be applied to asynchronous delegates.
55/// </summary>
6- #pragma warning disable CA1062 // Validate arguments of public methods
76public class AsyncRetryPolicy : AsyncPolicy , IRetryPolicy
87{
98 private readonly Func < Exception , TimeSpan , int , Context , Task > _onRetryAsync ;
@@ -34,6 +33,11 @@ protected override Task<TResult> ImplementationAsync<TResult>(
3433 CancellationToken cancellationToken ,
3534 bool continueOnCapturedContext )
3635 {
36+ if ( action is null )
37+ {
38+ throw new ArgumentNullException ( nameof ( action ) ) ;
39+ }
40+
3741 var sleepDurationProvider = _sleepDurationProvider != null
3842 ? ( retryCount , outcome , ctx ) => _sleepDurationProvider ( retryCount , outcome . Exception , ctx )
3943 : ( Func < int , DelegateResult < TResult > , Context , TimeSpan > ) null ;
@@ -79,9 +83,18 @@ internal AsyncRetryPolicy(
7983
8084 /// <inheritdoc/>
8185 [ 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 (
8598 action ,
8699 context ,
87100 ExceptionPredicates ,
@@ -92,5 +105,6 @@ protected override Task<TResult> ImplementationAsync(Func<Context, CancellationT
92105 _sleepDurationsEnumerable ,
93106 _sleepDurationProvider ,
94107 continueOnCapturedContext ) ;
108+ }
95109}
96110
0 commit comments