From 84518b81c6db70612dee12897b7e13d775f72216 Mon Sep 17 00:00:00 2001 From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com> Date: Thu, 25 Apr 2024 23:33:40 +0300 Subject: [PATCH 1/9] Fix SA1618 by documenting typeparams https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1618.md --- src/Polly/AsyncPolicy.ExecuteOverloads.cs | 3 + .../Bulkhead/AsyncBulkheadTResultSyntax.cs | 4 + src/Polly/Bulkhead/BulkheadPolicy.cs | 1 + src/Polly/Bulkhead/BulkheadTResultSyntax.cs | 4 + src/Polly/Bulkhead/IBulkheadPolicy.cs | 1 + src/Polly/Caching/AsyncCacheTResultSyntax.cs | 30 +++++++ src/Polly/Caching/CachePolicy.cs | 1 + src/Polly/Caching/CacheTResultSyntax.cs | 30 +++++++ src/Polly/Caching/IAsyncCacheProvider.cs | 1 + src/Polly/Caching/ICachePolicy.cs | 1 + src/Polly/Caching/ISyncCacheProvider.cs | 1 + src/Polly/Caching/ITtlStrategy.cs | 1 + .../AdvancedCircuitBreakerTResultSyntax.cs | 4 + ...syncAdvancedCircuitBreakerTResultSyntax.cs | 6 ++ .../AsyncCircuitBreakerTResultSyntax.cs | 6 ++ .../CircuitBreaker/CircuitBreakerPolicy.cs | 1 + .../CircuitBreakerTResultSyntax.cs | 6 ++ .../CircuitBreaker/ICircuitBreakerPolicy.cs | 1 + src/Polly/DelegateResult.cs | 1 + src/Polly/Fallback/AsyncFallbackSyntax.cs | 7 ++ src/Polly/Fallback/FallbackPolicy.cs | 1 + src/Polly/Fallback/FallbackSyntax.cs | 10 +++ src/Polly/Fallback/IFallbackPolicy.cs | 1 + src/Polly/IAsyncPolicy.Extensions.cs | 1 + src/Polly/IAsyncPolicy.cs | 3 + src/Polly/ISyncPolicy.Extensions.cs | 1 + src/Polly/ISyncPolicy.cs | 4 + src/Polly/NoOp/AsyncNoOpPolicy.cs | 1 + src/Polly/NoOp/INoOpPolicy.cs | 1 + src/Polly/Policy.ExecuteOverloads.cs | 4 + src/Polly/PolicyBase.cs | 1 + src/Polly/PolicyResult.cs | 1 + src/Polly/Polly.csproj | 2 +- src/Polly/RateLimit/AsyncRateLimitPolicy.cs | 1 + src/Polly/RateLimit/IRateLimitPolicy.cs | 1 + src/Polly/RateLimit/RateLimitPolicy.cs | 1 + .../Registry/IConcurrentPolicyRegistry.cs | 4 + src/Polly/Registry/PolicyRegistry.cs | 4 + .../ResiliencePipelineConversionExtensions.cs | 2 + src/Polly/ResultPredicates.cs | 1 + src/Polly/Retry/AsyncRetryPolicy.cs | 1 + src/Polly/Retry/AsyncRetrySyntax.cs | 28 +++---- src/Polly/Retry/AsyncRetryTResultSyntax.cs | 78 +++++++++++++++---- src/Polly/Retry/IRetryPolicy.cs | 1 + src/Polly/Retry/RetryPolicy.cs | 1 + src/Polly/Retry/RetrySyntax.cs | 20 ++--- src/Polly/Retry/RetryTResultSyntax.cs | 57 +++++++++++--- .../Timeout/AsyncTimeoutTResultSyntax.cs | 24 ++++++ src/Polly/Timeout/ITimeoutPolicy.cs | 1 + src/Polly/Timeout/TimeoutPolicy.cs | 1 + src/Polly/Timeout/TimeoutTResultSyntax.cs | 11 +++ src/Polly/Wrap/AsyncPolicyWrapSyntax.cs | 3 + src/Polly/Wrap/IPolicyWrap.cs | 1 + src/Polly/Wrap/PolicyWrapSyntax.cs | 3 + 54 files changed, 334 insertions(+), 51 deletions(-) diff --git a/src/Polly/AsyncPolicy.ExecuteOverloads.cs b/src/Polly/AsyncPolicy.ExecuteOverloads.cs index 744a3dfb86..661cfadf64 100644 --- a/src/Polly/AsyncPolicy.ExecuteOverloads.cs +++ b/src/Polly/AsyncPolicy.ExecuteOverloads.cs @@ -123,6 +123,7 @@ public Task ExecuteAsync(Func> action) => /// /// Executes the specified asynchronous action within the policy and returns the result. /// + /// The type of the result. /// The action to perform. /// Arbitrary data that is passed to the exception policy. /// The value returned by the action. @@ -155,6 +156,7 @@ public Task ExecuteAsync(Func /// /// Executes the specified asynchronous action within the policy and returns the result. /// + /// The type of the result. /// The action to perform. /// Arbitrary data that is passed to the exception policy. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. @@ -191,6 +193,7 @@ public Task ExecuteAsync(Func /// /// Executes the specified asynchronous action within the policy and returns the result. /// + /// The type of the result. /// The action to perform. /// Arbitrary data that is passed to the exception policy. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. diff --git a/src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs b/src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs index b31a35104f..ee3f43ccfb 100644 --- a/src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs +++ b/src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs @@ -7,6 +7,7 @@ public partial class Policy /// Builds a bulkhead isolation , which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system. /// When an execution would cause the number of actions executing concurrently through the policy to exceed , the action is not executed and a is thrown. /// + /// The type of the result. /// The maximum number of concurrent actions that may be executing through the policy. /// The policy instance. public static AsyncBulkheadPolicy BulkheadAsync(int maxParallelization) @@ -19,6 +20,7 @@ public static AsyncBulkheadPolicy BulkheadAsync(int maxParalle /// Builds a bulkhead isolation , which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system. /// When an execution would cause the number of actions executing concurrently through the policy to exceed , the action is not executed and a is thrown. /// + /// The type of the result. /// The maximum number of concurrent actions that may be executing through the policy. /// An action to call asynchronously, if the bulkhead rejects execution due to oversubscription. /// maxParallelization;Value must be greater than zero. @@ -31,6 +33,7 @@ public static AsyncBulkheadPolicy BulkheadAsync(int maxParalle /// Builds a bulkhead isolation , which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system. /// When an execution would cause the number of actions executing concurrently through the policy to exceed , the policy allows a further executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed , a is thrown. /// + /// The type of the result. /// The maximum number of concurrent actions that may be executing through the policy. /// The maximum number of actions that may be queuing, waiting for an execution slot. /// The policy instance. @@ -46,6 +49,7 @@ public static AsyncBulkheadPolicy BulkheadAsync(int maxParalle /// Builds a bulkhead isolation , which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system. /// When an execution would cause the number of actions executing concurrently through the policy to exceed , the policy allows a further executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed , a is thrown. /// + /// The type of the result. /// The maximum number of concurrent actions that may be executing through the policy. /// The maximum number of actions that may be queuing, waiting for an execution slot. /// An action to call asynchronously, if the bulkhead rejects execution due to oversubscription. diff --git a/src/Polly/Bulkhead/BulkheadPolicy.cs b/src/Polly/Bulkhead/BulkheadPolicy.cs index 35c3dd0963..9d76902526 100644 --- a/src/Polly/Bulkhead/BulkheadPolicy.cs +++ b/src/Polly/Bulkhead/BulkheadPolicy.cs @@ -51,6 +51,7 @@ public void Dispose() /// /// A bulkhead-isolation policy which can be applied to delegates returning a value of type . /// +/// The type of the result. public class BulkheadPolicy : Policy, IBulkheadPolicy { private readonly SemaphoreSlim _maxParallelizationSemaphore; diff --git a/src/Polly/Bulkhead/BulkheadTResultSyntax.cs b/src/Polly/Bulkhead/BulkheadTResultSyntax.cs index d5918091fa..19f7efe267 100644 --- a/src/Polly/Bulkhead/BulkheadTResultSyntax.cs +++ b/src/Polly/Bulkhead/BulkheadTResultSyntax.cs @@ -7,6 +7,7 @@ public partial class Policy /// Builds a bulkhead isolation , which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system. /// When an execution would cause the number of actions executing concurrently through the policy to exceed , the action is not executed and a is thrown. /// + /// The type of the result. /// The maximum number of concurrent actions that may be executing through the policy. /// maxParallelization;Value must be greater than zero. /// The policy instance. @@ -20,6 +21,7 @@ public static BulkheadPolicy Bulkhead(int maxParallelization) /// Builds a bulkhead isolation , which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system. /// When an execution would cause the number of actions executing concurrently through the policy to exceed , the action is not executed and a is thrown. /// + /// The type of the result. /// The maximum number of concurrent actions that may be executing through the policy. /// An action to call, if the bulkhead rejects execution due to oversubscription. /// maxParallelization;Value must be greater than zero. @@ -32,6 +34,7 @@ public static BulkheadPolicy Bulkhead(int maxParallelization, /// Builds a bulkhead isolation , which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system. /// When an execution would cause the number of actions executing concurrently through the policy to exceed , the policy allows a further executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed , a is thrown. /// + /// The type of the result. /// The maximum number of concurrent actions that may be executing through the policy. /// The maximum number of actions that may be queuing, waiting for an execution slot. /// The policy instance. @@ -47,6 +50,7 @@ public static BulkheadPolicy Bulkhead(int maxParallelization, /// Builds a bulkhead isolation , which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system. /// When an execution would cause the number of actions executing concurrently through the policy to exceed , the policy allows a further executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed , a is thrown. /// + /// The type of the result. /// The maximum number of concurrent actions that may be executing through the policy. /// The maximum number of actions that may be queuing, waiting for an execution slot. /// An action to call, if the bulkhead rejects execution due to oversubscription. diff --git a/src/Polly/Bulkhead/IBulkheadPolicy.cs b/src/Polly/Bulkhead/IBulkheadPolicy.cs index c2a8996c21..127896b2aa 100644 --- a/src/Polly/Bulkhead/IBulkheadPolicy.cs +++ b/src/Polly/Bulkhead/IBulkheadPolicy.cs @@ -20,6 +20,7 @@ public interface IBulkheadPolicy : IsPolicy, IDisposable /// /// Defines properties and methods common to all bulkhead policies generic-typed for executions returning results of type . /// +/// The type of the result. public interface IBulkheadPolicy : IBulkheadPolicy { } diff --git a/src/Polly/Caching/AsyncCacheTResultSyntax.cs b/src/Polly/Caching/AsyncCacheTResultSyntax.cs index 91d43c9bbc..3a4daa6d41 100644 --- a/src/Polly/Caching/AsyncCacheTResultSyntax.cs +++ b/src/Polly/Caching/AsyncCacheTResultSyntax.cs @@ -9,6 +9,7 @@ public partial class Policy /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception. @@ -28,6 +29,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception. @@ -48,6 +50,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -69,6 +72,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -91,6 +95,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -112,6 +117,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -134,6 +140,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// Delegate to call on a cache hit, when value is returned from cache. @@ -167,6 +174,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call on a cache hit, when value is returned from cache. @@ -201,6 +209,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -237,6 +246,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -274,6 +284,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -310,6 +321,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -347,6 +359,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception. @@ -361,6 +374,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider< /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception. @@ -376,6 +390,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider< /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception. @@ -391,6 +406,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider< /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -407,6 +423,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider< /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -428,6 +445,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider< /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -449,6 +467,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider< /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -465,6 +484,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider< /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -486,6 +506,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider< /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -507,6 +528,7 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider< /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// Delegate to call on a cache hit, when value is returned from cache. @@ -536,6 +558,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call on a cache hit, when value is returned from cache. @@ -565,6 +588,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call on a cache hit, when value is returned from cache. @@ -594,6 +618,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -626,6 +651,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -658,6 +684,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -690,6 +717,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -722,6 +750,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -754,6 +783,7 @@ public static AsyncCachePolicy CacheAsync( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. diff --git a/src/Polly/Caching/CachePolicy.cs b/src/Polly/Caching/CachePolicy.cs index da58c7bca2..efd576bc67 100644 --- a/src/Polly/Caching/CachePolicy.cs +++ b/src/Polly/Caching/CachePolicy.cs @@ -62,6 +62,7 @@ protected override TResult Implementation(Func /// A cache policy that can be applied to the results of delegate executions. /// +/// The type of the result. public class CachePolicy : Policy, ICachePolicy { private readonly Action _onCacheGet; diff --git a/src/Polly/Caching/CacheTResultSyntax.cs b/src/Polly/Caching/CacheTResultSyntax.cs index d96ec35833..4f7c671226 100644 --- a/src/Polly/Caching/CacheTResultSyntax.cs +++ b/src/Polly/Caching/CacheTResultSyntax.cs @@ -9,6 +9,7 @@ public partial class Policy /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception. @@ -28,6 +29,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvid /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception. @@ -48,6 +50,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvid /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -69,6 +72,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvid /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -91,6 +95,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvid /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -112,6 +117,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvid /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -134,6 +140,7 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvid /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// Delegate to call on a cache hit, when value is returned from cache. @@ -167,6 +174,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call on a cache hit, when value is returned from cache. @@ -201,6 +209,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -237,6 +246,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -274,6 +284,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -310,6 +321,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -347,6 +359,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception. @@ -361,6 +374,7 @@ public static CachePolicy Cache(ISyncCacheProvider ca /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception. @@ -376,6 +390,7 @@ public static CachePolicy Cache(ISyncCacheProvider ca /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception. @@ -391,6 +406,7 @@ public static CachePolicy Cache(ISyncCacheProvider ca /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -407,6 +423,7 @@ public static CachePolicy Cache(ISyncCacheProvider ca /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -429,6 +446,7 @@ public static CachePolicy Cache(ISyncCacheProvider ca /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -451,6 +469,7 @@ public static CachePolicy Cache(ISyncCacheProvider ca /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -467,6 +486,7 @@ public static CachePolicy Cache(ISyncCacheProvider ca /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -489,6 +509,7 @@ public static CachePolicy Cache(ISyncCacheProvider ca /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -511,6 +532,7 @@ public static CachePolicy Cache(ISyncCacheProvider ca /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// Delegate to call on a cache hit, when value is returned from cache. @@ -540,6 +562,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call on a cache hit, when value is returned from cache. @@ -569,6 +592,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// Delegate to call on a cache hit, when value is returned from cache. @@ -598,6 +622,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -630,6 +655,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -662,6 +688,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -694,6 +721,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// Duration (ttl) for which to cache values. /// The cache key strategy. @@ -726,6 +754,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. @@ -759,6 +788,7 @@ public static CachePolicy Cache( /// If the provides a value from cache, returns that value and does not execute the governed delegate. If the does not provide a value, executes the governed delegate, stores the value with the , then returns the value. /// /// + /// The type of the result. /// The cache provider. /// A strategy for specifying ttl for values to be cached. /// The cache key strategy. diff --git a/src/Polly/Caching/IAsyncCacheProvider.cs b/src/Polly/Caching/IAsyncCacheProvider.cs index 3d390a8ea1..d1fddb20a6 100644 --- a/src/Polly/Caching/IAsyncCacheProvider.cs +++ b/src/Polly/Caching/IAsyncCacheProvider.cs @@ -33,6 +33,7 @@ public interface IAsyncCacheProvider /// /// Defines methods for classes providing asynchronous cache functionality for Polly s. /// +/// The type of the result. public interface IAsyncCacheProvider { /// diff --git a/src/Polly/Caching/ICachePolicy.cs b/src/Polly/Caching/ICachePolicy.cs index ca01367942..0f73405cb5 100644 --- a/src/Polly/Caching/ICachePolicy.cs +++ b/src/Polly/Caching/ICachePolicy.cs @@ -11,6 +11,7 @@ public interface ICachePolicy : IsPolicy /// /// Defines properties and methods common to all Cache policies generic-typed for executions returning results of type . /// +/// The type of the result. public interface ICachePolicy : ICachePolicy { } diff --git a/src/Polly/Caching/ISyncCacheProvider.cs b/src/Polly/Caching/ISyncCacheProvider.cs index 6e2eefd6cf..7c4b87917f 100644 --- a/src/Polly/Caching/ISyncCacheProvider.cs +++ b/src/Polly/Caching/ISyncCacheProvider.cs @@ -28,6 +28,7 @@ public interface ISyncCacheProvider /// /// Defines methods for classes providing synchronous cache functionality for Polly s. /// +/// The type of the result. public interface ISyncCacheProvider { /// diff --git a/src/Polly/Caching/ITtlStrategy.cs b/src/Polly/Caching/ITtlStrategy.cs index fd911a07ec..6aeaa60ee9 100644 --- a/src/Polly/Caching/ITtlStrategy.cs +++ b/src/Polly/Caching/ITtlStrategy.cs @@ -11,6 +11,7 @@ public interface ITtlStrategy : ITtlStrategy /// /// Defines a strategy for providing time-to-live durations for cacheable results. /// +/// The type of the result. public interface ITtlStrategy { /// diff --git a/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs b/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs index 8dcc1b870c..16740fe647 100644 --- a/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs +++ b/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs @@ -16,6 +16,7 @@ public static class AdvancedCircuitBreakerTResultSyntax /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The type of the result. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure). /// The duration of the timeslice over which failure ratios are assessed. @@ -50,6 +51,7 @@ public static CircuitBreakerPolicy AdvancedCircuitBreaker(this /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure. /// The duration of the timeslice over which failure ratios are assessed. @@ -83,6 +85,7 @@ public static CircuitBreakerPolicy AdvancedCircuitBreaker(this /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure. /// The duration of the timeslice over which failure ratios are assessed. @@ -119,6 +122,7 @@ public static CircuitBreakerPolicy AdvancedCircuitBreaker(this /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure. /// The duration of the timeslice over which failure ratios are assessed. diff --git a/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs b/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs index a3efca75b3..930902fac6 100644 --- a/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs +++ b/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs @@ -16,6 +16,7 @@ public static class AsyncAdvancedCircuitBreakerTResultSyntax /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure). /// The duration of the timeslice over which failure ratios are assessed. @@ -51,6 +52,7 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure). /// The duration of the timeslice over which failure ratios are assessed. @@ -85,6 +87,7 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The type of the result. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure). /// The duration of the timeslice over which failure ratios are assessed. @@ -124,6 +127,7 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure). /// The duration of the timeslice over which failure ratios are assessed. @@ -160,6 +164,7 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure). /// The duration of the timeslice over which failure ratios are assessed. @@ -197,6 +202,7 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure). /// The duration of the timeslice over which failure ratios are assessed. diff --git a/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs b/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs index 71e965a3ad..18b424e0eb 100644 --- a/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs +++ b/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs @@ -17,6 +17,7 @@ public static class AsyncCircuitBreakerTResultSyntax /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. @@ -47,6 +48,7 @@ public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(th /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. @@ -76,6 +78,7 @@ public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(th /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. @@ -110,6 +113,7 @@ public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(th /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The type of the result. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. @@ -141,6 +145,7 @@ public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(th /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. @@ -173,6 +178,7 @@ public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(th /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. diff --git a/src/Polly/CircuitBreaker/CircuitBreakerPolicy.cs b/src/Polly/CircuitBreaker/CircuitBreakerPolicy.cs index 138185ae78..0e356ac181 100644 --- a/src/Polly/CircuitBreaker/CircuitBreakerPolicy.cs +++ b/src/Polly/CircuitBreaker/CircuitBreakerPolicy.cs @@ -55,6 +55,7 @@ protected override TResult Implementation(Func /// A circuit-breaker policy that can be applied to delegates returning a value of type . /// +/// The type of the result. public class CircuitBreakerPolicy : Policy, ICircuitBreakerPolicy { internal readonly ICircuitController _breakerController; diff --git a/src/Polly/CircuitBreaker/CircuitBreakerTResultSyntax.cs b/src/Polly/CircuitBreaker/CircuitBreakerTResultSyntax.cs index 1f85c40ae6..b001aa2db5 100644 --- a/src/Polly/CircuitBreaker/CircuitBreakerTResultSyntax.cs +++ b/src/Polly/CircuitBreaker/CircuitBreakerTResultSyntax.cs @@ -17,6 +17,7 @@ public static class CircuitBreakerTResultSyntax /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The type of the result. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. @@ -47,6 +48,7 @@ public static CircuitBreakerPolicy CircuitBreaker(this PolicyB /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The type of the result. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. @@ -76,6 +78,7 @@ public static CircuitBreakerPolicy CircuitBreaker(this PolicyB /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The type of the result. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. @@ -109,6 +112,7 @@ public static CircuitBreakerPolicy CircuitBreaker(this PolicyB /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The type of the result. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. @@ -140,6 +144,7 @@ public static CircuitBreakerPolicy CircuitBreaker(this PolicyB /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The type of the result. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. @@ -172,6 +177,7 @@ public static CircuitBreakerPolicy CircuitBreaker(this PolicyB /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// + /// The type of the result. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. diff --git a/src/Polly/CircuitBreaker/ICircuitBreakerPolicy.cs b/src/Polly/CircuitBreaker/ICircuitBreakerPolicy.cs index 2c0f882ac9..9cf4b8bd83 100644 --- a/src/Polly/CircuitBreaker/ICircuitBreakerPolicy.cs +++ b/src/Polly/CircuitBreaker/ICircuitBreakerPolicy.cs @@ -30,6 +30,7 @@ public interface ICircuitBreakerPolicy : IsPolicy /// /// Defines properties and methods common to all circuit-breaker policies generic-typed for executions returning results of type . /// +/// The type of the result. public interface ICircuitBreakerPolicy : ICircuitBreakerPolicy { /// diff --git a/src/Polly/DelegateResult.cs b/src/Polly/DelegateResult.cs index fc2bc3fc04..6012b5664d 100644 --- a/src/Polly/DelegateResult.cs +++ b/src/Polly/DelegateResult.cs @@ -3,6 +3,7 @@ /// /// The captured outcome of executing an individual Func<TResult>. /// +/// The type of the result. public class DelegateResult { /// diff --git a/src/Polly/Fallback/AsyncFallbackSyntax.cs b/src/Polly/Fallback/AsyncFallbackSyntax.cs index 31009c0b54..d0b4cc9de9 100644 --- a/src/Polly/Fallback/AsyncFallbackSyntax.cs +++ b/src/Polly/Fallback/AsyncFallbackSyntax.cs @@ -93,6 +93,7 @@ public static class AsyncFallbackTResultSyntax /// /// Builds an which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, returns . /// + /// The type of the result. /// The policy builder. /// The fallback value to provide. /// The policy instance. @@ -107,6 +108,7 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui /// /// Builds an which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, asynchronously calls and returns its result. /// + /// The type of the result. /// The policy builder. /// The fallback delegate. /// Thrown when is . @@ -125,6 +127,7 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui /// /// Builds an which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, first asynchronously calls with details of the handled exception or result; then returns . /// + /// The type of the result. /// The policy builder. /// The fallback value to provide. /// The action to call asynchronously before invoking the fallback delegate. @@ -143,6 +146,7 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui /// /// Builds an which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, first asynchronously calls with details of the handled exception or result; then asynchronously calls and returns its result. /// + /// The type of the result. /// The policy builder. /// The fallback delegate. /// The action to call asynchronously before invoking the fallback delegate. @@ -164,6 +168,7 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui /// /// Builds an which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, first asynchronously calls with details of the handled exception or result and the execution context; then returns . /// + /// The type of the result. /// The policy builder. /// The fallback value to provide. /// The action to call asynchronously before invoking the fallback delegate. @@ -182,6 +187,7 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui /// /// Builds an which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, first asynchronously calls with details of the handled exception or result and the execution context; then asynchronously calls and returns its result. /// + /// The type of the result. /// The policy builder. /// The fallback delegate. /// The action to call asynchronously before invoking the fallback delegate. @@ -201,6 +207,7 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui /// /// Builds an which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, first asynchronously calls with details of the handled exception or result and the execution context; then asynchronously calls and returns its result. /// + /// The type of the result. /// The policy builder. /// The fallback delegate. /// The action to call asynchronously before invoking the fallback delegate. diff --git a/src/Polly/Fallback/FallbackPolicy.cs b/src/Polly/Fallback/FallbackPolicy.cs index 56fe7c91e7..3deeaeea9f 100644 --- a/src/Polly/Fallback/FallbackPolicy.cs +++ b/src/Polly/Fallback/FallbackPolicy.cs @@ -48,6 +48,7 @@ protected override TResult Implementation(Func /// A fallback policy that can be applied to delegates returning a value of type . /// +/// The type of the result. public class FallbackPolicy : Policy, IFallbackPolicy { private readonly Action, Context> _onFallback; diff --git a/src/Polly/Fallback/FallbackSyntax.cs b/src/Polly/Fallback/FallbackSyntax.cs index d64ae98185..91143eaa60 100644 --- a/src/Polly/Fallback/FallbackSyntax.cs +++ b/src/Polly/Fallback/FallbackSyntax.cs @@ -146,6 +146,7 @@ public static class FallbackTResultSyntax /// /// Builds a which provides a fallback value if the main execution fails. Executes the main delegate, but if this throws a handled exception or raises a handled result, returns instead. /// + /// The type of the result. /// The policy builder. /// The fallback value to provide. /// The policy instance. @@ -158,6 +159,7 @@ public static FallbackPolicy Fallback(this PolicyBuilder /// Builds a which provides a fallback value if the main execution fails. Executes the main delegate, but if this throws a handled exception or raises a handled result, calls and returns its result. /// + /// The type of the result. /// The policy builder. /// The fallback action. /// Thrown when is . @@ -174,6 +176,7 @@ public static FallbackPolicy Fallback(this PolicyBuilder /// Builds a which provides a fallback value if the main execution fails. Executes the main delegate, but if this throws a handled exception or raises a handled result, calls and returns its result. /// + /// The type of the result. /// The policy builder. /// The fallback action. /// Thrown when is . @@ -190,6 +193,7 @@ public static FallbackPolicy Fallback(this PolicyBuilder /// Builds a which provides a fallback value if the main execution fails. Executes the main delegate, but if this throws a handled exception or raises a handled result, first calls with details of the handled exception or result; then returns . /// + /// The type of the result. /// The policy builder. /// The fallback value to provide. /// The action to call before invoking the fallback delegate. @@ -206,6 +210,7 @@ public static FallbackPolicy Fallback(this PolicyBuilder /// Builds a which provides a fallback value if the main execution fails. Executes the main delegate, but if this throws a handled exception or raises a handled result, first calls with details of the handled exception or result; then calls and returns its result. /// + /// The type of the result. /// The policy builder. /// The fallback action. /// The action to call before invoking the fallback delegate. @@ -225,6 +230,7 @@ public static FallbackPolicy Fallback(this PolicyBuilder /// Builds a which provides a fallback value if the main execution fails. Executes the main delegate, but if this throws a handled exception or raises a handled result, first calls with details of the handled exception or result; then calls and returns its result. /// + /// The type of the result. /// The policy builder. /// The fallback action. /// The action to call before invoking the fallback delegate. @@ -244,6 +250,7 @@ public static FallbackPolicy Fallback(this PolicyBuilder /// Builds a which provides a fallback value if the main execution fails. Executes the main delegate, but if this throws a handled exception or raises a handled result, first calls with details of the handled exception or result and the execution context; then returns . /// + /// The type of the result. /// The policy builder. /// The fallback value to provide. /// The action to call before invoking the fallback delegate. @@ -260,6 +267,7 @@ public static FallbackPolicy Fallback(this PolicyBuilder /// Builds a which provides a fallback value if the main execution fails. Executes the main delegate, but if this throws a handled exception or raises a handled result, first calls with details of the handled exception or result and the execution context; then calls and returns its result. /// + /// The type of the result. /// The policy builder. /// The fallback action. /// The action to call before invoking the fallback delegate. @@ -279,6 +287,7 @@ public static FallbackPolicy Fallback(this PolicyBuilder /// Builds a which provides a fallback value if the main execution fails. Executes the main delegate, but if this throws a handled exception or raises a handled result, first calls with details of the handled exception or result and the execution context; then calls and returns its result. /// + /// The type of the result. /// The policy builder. /// The fallback action. /// The action to call before invoking the fallback delegate. @@ -298,6 +307,7 @@ public static FallbackPolicy Fallback(this PolicyBuilder /// Builds a which provides a fallback value if the main execution fails. Executes the main delegate, but if this throws a handled exception or raises a handled result, first calls with details of the handled exception or result and the execution context; then calls and returns its result. /// + /// The type of the result. /// The policy builder. /// The fallback action. /// The action to call before invoking the fallback delegate. diff --git a/src/Polly/Fallback/IFallbackPolicy.cs b/src/Polly/Fallback/IFallbackPolicy.cs index 19ce110386..102fdd5862 100644 --- a/src/Polly/Fallback/IFallbackPolicy.cs +++ b/src/Polly/Fallback/IFallbackPolicy.cs @@ -12,6 +12,7 @@ public interface IFallbackPolicy : IsPolicy /// /// Defines properties and methods common to all Fallback policies generic-typed for executions returning results of type . /// +/// The type of the result. public interface IFallbackPolicy : IFallbackPolicy { } diff --git a/src/Polly/IAsyncPolicy.Extensions.cs b/src/Polly/IAsyncPolicy.Extensions.cs index c3b888bd49..2e6974d919 100644 --- a/src/Polly/IAsyncPolicy.Extensions.cs +++ b/src/Polly/IAsyncPolicy.Extensions.cs @@ -9,6 +9,7 @@ public static class IAsyncPolicyExtensions /// Converts a non-generic into a generic for handling only executions returning . /// /// This method allows you to convert a non-generic into a generic for contexts such as variables or parameters which may explicitly require a generic . + /// The type of the result. /// The non-generic to convert to a generic . /// A generic version of the supplied non-generic . public static IAsyncPolicy AsAsyncPolicy(this IAsyncPolicy policy) => diff --git a/src/Polly/IAsyncPolicy.cs b/src/Polly/IAsyncPolicy.cs index faa75d2f24..387650d741 100644 --- a/src/Polly/IAsyncPolicy.cs +++ b/src/Polly/IAsyncPolicy.cs @@ -104,6 +104,7 @@ public interface IAsyncPolicy : IsPolicy /// /// Executes the specified asynchronous action within the policy and returns the result. /// + /// The type of the result. /// The action to perform. /// Arbitrary data that is passed to the exception policy. /// The value returned by the action. @@ -121,6 +122,7 @@ public interface IAsyncPolicy : IsPolicy /// /// Executes the specified asynchronous action within the policy and returns the result. /// + /// The type of the result. /// The action to perform. /// Arbitrary data that is passed to the exception policy. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. @@ -151,6 +153,7 @@ public interface IAsyncPolicy : IsPolicy /// /// Executes the specified asynchronous action within the policy and returns the result. /// + /// The type of the result. /// The action to perform. /// Arbitrary data that is passed to the exception policy. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. diff --git a/src/Polly/ISyncPolicy.Extensions.cs b/src/Polly/ISyncPolicy.Extensions.cs index 31334800c4..a5053e55b9 100644 --- a/src/Polly/ISyncPolicy.Extensions.cs +++ b/src/Polly/ISyncPolicy.Extensions.cs @@ -9,6 +9,7 @@ public static class ISyncPolicyExtensions /// Converts a non-generic into a generic for handling only executions returning . /// /// This method allows you to convert a non-generic into a generic for contexts such as variables or parameters which may explicitly require a generic . + /// The type of the result. /// The non-generic to convert to a generic . /// A generic version of the supplied non-generic . public static ISyncPolicy AsPolicy(this ISyncPolicy policy) => diff --git a/src/Polly/ISyncPolicy.cs b/src/Polly/ISyncPolicy.cs index 3fddc2d790..e14f7f5f20 100644 --- a/src/Polly/ISyncPolicy.cs +++ b/src/Polly/ISyncPolicy.cs @@ -168,6 +168,7 @@ public interface ISyncPolicy : IsPolicy /// /// Executes the specified action within the policy and returns the captured result. /// + /// The type of the result. /// The action to perform. /// The captured result. PolicyResult ExecuteAndCapture(Func action); @@ -175,6 +176,7 @@ public interface ISyncPolicy : IsPolicy /// /// Executes the specified action within the policy and returns the captured result. /// + /// The type of the result. /// The action to perform. /// Arbitrary data that is passed to the exception policy. /// The captured result. @@ -184,6 +186,7 @@ public interface ISyncPolicy : IsPolicy /// /// Executes the specified action within the policy and returns the captured result. /// + /// The type of the result. /// The action to perform. /// Context data that is passed to the exception policy. /// The captured result. @@ -213,6 +216,7 @@ public interface ISyncPolicy : IsPolicy /// /// Executes the specified action within the policy and returns the captured result. /// + /// The type of the result. /// The action to perform. /// Context data that is passed to the exception policy. /// The cancellation token. diff --git a/src/Polly/NoOp/AsyncNoOpPolicy.cs b/src/Polly/NoOp/AsyncNoOpPolicy.cs index f75cddafd7..68fdcb7497 100644 --- a/src/Polly/NoOp/AsyncNoOpPolicy.cs +++ b/src/Polly/NoOp/AsyncNoOpPolicy.cs @@ -21,6 +21,7 @@ protected override Task ImplementationAsync(Func /// A noop policy that can be applied to asynchronous delegates returning a value of type . /// +/// The type of the result. public class AsyncNoOpPolicy : AsyncPolicy, INoOpPolicy { internal AsyncNoOpPolicy() diff --git a/src/Polly/NoOp/INoOpPolicy.cs b/src/Polly/NoOp/INoOpPolicy.cs index 8e04c7372d..e5b32d3005 100644 --- a/src/Polly/NoOp/INoOpPolicy.cs +++ b/src/Polly/NoOp/INoOpPolicy.cs @@ -12,6 +12,7 @@ public interface INoOpPolicy : IsPolicy /// /// Defines properties and methods common to all NoOp policies generic-typed for executions returning results of type . /// +/// The type of the result. public interface INoOpPolicy : INoOpPolicy { } diff --git a/src/Polly/Policy.ExecuteOverloads.cs b/src/Polly/Policy.ExecuteOverloads.cs index 5576b7399b..c4828d63f8 100644 --- a/src/Polly/Policy.ExecuteOverloads.cs +++ b/src/Polly/Policy.ExecuteOverloads.cs @@ -247,6 +247,7 @@ public PolicyResult ExecuteAndCapture(Action action, /// /// Executes the specified action within the policy and returns the captured result. /// + /// The type of the result. /// The action to perform. /// The captured result. [DebuggerStepThrough] @@ -256,6 +257,7 @@ public PolicyResult ExecuteAndCapture(Func action) => /// /// Executes the specified action within the policy and returns the captured result. /// + /// The type of the result. /// The action to perform. /// Arbitrary data that is passed to the exception policy. /// The captured result. @@ -267,6 +269,7 @@ public PolicyResult ExecuteAndCapture(Func a /// /// Executes the specified action within the policy and returns the captured result. /// + /// The type of the result. /// The action to perform. /// Context data that is passed to the exception policy. /// The captured result. @@ -301,6 +304,7 @@ public PolicyResult ExecuteAndCapture(Func /// Executes the specified action within the policy and returns the captured result. /// + /// The type of the result. /// The action to perform. /// Context data that is passed to the exception policy. /// The cancellation token. diff --git a/src/Polly/PolicyBase.cs b/src/Polly/PolicyBase.cs index 85f11886fd..a54a8f3db1 100644 --- a/src/Polly/PolicyBase.cs +++ b/src/Polly/PolicyBase.cs @@ -49,6 +49,7 @@ protected PolicyBase(PolicyBuilder policyBuilder) /// /// Implements elements common to sync and async generic policies. /// +/// The type of the result. public abstract class PolicyBase : PolicyBase { /// diff --git a/src/Polly/PolicyResult.cs b/src/Polly/PolicyResult.cs index 9aafa7e44b..7446035b31 100644 --- a/src/Polly/PolicyResult.cs +++ b/src/Polly/PolicyResult.cs @@ -59,6 +59,7 @@ public static PolicyResult Failure(Exception exception, ExceptionType exceptionT /// /// The captured result of executing a policy. /// +/// The type of the result. public class PolicyResult { internal PolicyResult(TResult result, OutcomeType outcome, Exception finalException, ExceptionType? exceptionType, Context context) diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj index e128b592ed..ef9bae12f9 100644 --- a/src/Polly/Polly.csproj +++ b/src/Polly/Polly.csproj @@ -9,7 +9,7 @@ true $(NoWarn);IDE0011;S103;S3872;SA1402;SA1414;S3215 $(NoWarn);IDE1006;CA1062;S107;CA1068;S4039;CA1000;CA1063;CA1031;CA1051 - $(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;SA1618;CA1033 + $(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;CA1033 $(NoWarn);S4023;CA1010;S3442;CA1064;SA1649;SA1625;SA1623;SA1118 $(NoWarn);S3253;S3971;S6605;CA1724;CA1716;SA1108;CA1710;S4049;S3246 $(NoWarn);CA1805 diff --git a/src/Polly/RateLimit/AsyncRateLimitPolicy.cs b/src/Polly/RateLimit/AsyncRateLimitPolicy.cs index 86e8b0c294..0acec910a5 100644 --- a/src/Polly/RateLimit/AsyncRateLimitPolicy.cs +++ b/src/Polly/RateLimit/AsyncRateLimitPolicy.cs @@ -22,6 +22,7 @@ protected override Task ImplementationAsync(Func /// A rate-limit policy that can be applied to asynchronous delegates returning a value of type . /// +/// The type of the result. public class AsyncRateLimitPolicy : AsyncPolicy, IRateLimitPolicy { private readonly IRateLimiter _rateLimiter; diff --git a/src/Polly/RateLimit/IRateLimitPolicy.cs b/src/Polly/RateLimit/IRateLimitPolicy.cs index 58e8b5041b..d30534ef53 100644 --- a/src/Polly/RateLimit/IRateLimitPolicy.cs +++ b/src/Polly/RateLimit/IRateLimitPolicy.cs @@ -12,6 +12,7 @@ public interface IRateLimitPolicy : IsPolicy /// /// Defines properties and methods common to all RateLimit policies generic-typed for executions returning results of type . /// +/// The type of the result. public interface IRateLimitPolicy : IRateLimitPolicy { } diff --git a/src/Polly/RateLimit/RateLimitPolicy.cs b/src/Polly/RateLimit/RateLimitPolicy.cs index d9cb2bc206..07de422bfb 100644 --- a/src/Polly/RateLimit/RateLimitPolicy.cs +++ b/src/Polly/RateLimit/RateLimitPolicy.cs @@ -21,6 +21,7 @@ protected override TResult Implementation(Func /// A rate-limit policy that can be applied to synchronous delegates returning a value of type . /// +/// The type of the result. public class RateLimitPolicy : Policy, IRateLimitPolicy { private readonly IRateLimiter _rateLimiter; diff --git a/src/Polly/Registry/IConcurrentPolicyRegistry.cs b/src/Polly/Registry/IConcurrentPolicyRegistry.cs index 7c2427ddfe..4f8c30c44f 100644 --- a/src/Polly/Registry/IConcurrentPolicyRegistry.cs +++ b/src/Polly/Registry/IConcurrentPolicyRegistry.cs @@ -45,6 +45,7 @@ bool TryUpdate(TKey key, TPolicy newPolicy, TPolicy comparisonPolicy) /// Adds a policy with the provided key and policy to the registry /// if the key does not already exist. /// + /// The type of Policy. /// The key of the policy to add. /// The function used to generate a policy for the key. /// The policy for the key. This will be either the existing policy for the key if the @@ -57,6 +58,7 @@ TPolicy GetOrAdd(TKey key, Func policyFactory) /// Adds a key/policy pair to the registry /// if the key does not already exist. /// + /// The type of Policy. /// The key of the policy to add. /// The value to be added, if the key does not already exist. /// The policy for the key. This will be either the existing policy for the key if the @@ -69,6 +71,7 @@ TPolicy GetOrAdd(TKey key, TPolicy policy) /// exist, or updates a key/policy pair in the registry if the key /// already exists. /// + /// The type of Policy. /// The key to be added or whose policy should be updated. /// The function used to generate a policy for an absent key. /// The function used to generate a new policy for an existing key @@ -83,6 +86,7 @@ TPolicy AddOrUpdate(TKey key, Func addPolicyFactory, Fun /// exist, or updates a key/policy pair in the registry if the key /// already exists. /// + /// The type of Policy. /// The key to be added or whose policy should be updated. /// The policy to be added for an absent key. /// The function used to generate a new policy for an existing key based on diff --git a/src/Polly/Registry/PolicyRegistry.cs b/src/Polly/Registry/PolicyRegistry.cs index 6e927b3336..34169e35d2 100644 --- a/src/Polly/Registry/PolicyRegistry.cs +++ b/src/Polly/Registry/PolicyRegistry.cs @@ -181,6 +181,7 @@ public bool TryUpdate(string key, TPolicy newPolicy, TPolicy comparison /// Adds a policy with the provided key and policy to the registry /// if the key does not already exist. /// + /// The type of Policy. /// The key of the policy to add. /// The function used to generate a policy for the key. /// The policy for the key. This will be either the existing policy for the key if the @@ -198,6 +199,7 @@ public TPolicy GetOrAdd(string key, Func policyFactory /// Adds a key/policy pair to the registry /// if the key does not already exist. /// + /// The type of Policy. /// The key of the policy to add. /// the policy to be added, if the key does not already exist. /// The policy for the key. This will be either the existing policy for the key if the @@ -215,6 +217,7 @@ public TPolicy GetOrAdd(string key, TPolicy policy) /// exist, or updates a key/policy pair in the registry if the key /// already exists. /// + /// The type of Policy. /// The key to be added or whose policy should be updated. /// The function used to generate a policy for an absent key. /// The function used to generate a new policy for an existing key @@ -234,6 +237,7 @@ public TPolicy AddOrUpdate(string key, Func addPolicyF /// exist, or updates a key/policy pair in the registry if the key /// already exists. /// + /// The type of Policy. /// The key to be added or whose policy should be updated. /// The policy to be added for an absent key. /// The function used to generate a new policy for an existing key based on diff --git a/src/Polly/ResiliencePipelineConversionExtensions.cs b/src/Polly/ResiliencePipelineConversionExtensions.cs index b943c65805..a02ef89c27 100644 --- a/src/Polly/ResiliencePipelineConversionExtensions.cs +++ b/src/Polly/ResiliencePipelineConversionExtensions.cs @@ -19,6 +19,7 @@ public static IAsyncPolicy AsAsyncPolicy(this ResiliencePipeline strategy) /// /// Converts a to an . /// + /// The type of the result. /// The strategy instance. /// An instance of . /// Thrown when is . @@ -38,6 +39,7 @@ public static ISyncPolicy AsSyncPolicy(this ResiliencePipeline strategy) /// Converts a to an . /// /// The strategy instance. + /// The type of the result. /// An instance of . /// Thrown when is . public static ISyncPolicy AsSyncPolicy(this ResiliencePipeline strategy) diff --git a/src/Polly/ResultPredicates.cs b/src/Polly/ResultPredicates.cs index ebe34ed854..63b02ddec3 100644 --- a/src/Polly/ResultPredicates.cs +++ b/src/Polly/ResultPredicates.cs @@ -3,6 +3,7 @@ /// /// A collection of predicates used to define whether a policy handles a given value. /// +/// The type of the result. public class ResultPredicates { private List> _predicates; diff --git a/src/Polly/Retry/AsyncRetryPolicy.cs b/src/Polly/Retry/AsyncRetryPolicy.cs index f7c2081f62..bd8b6b4b0f 100644 --- a/src/Polly/Retry/AsyncRetryPolicy.cs +++ b/src/Polly/Retry/AsyncRetryPolicy.cs @@ -54,6 +54,7 @@ protected override Task ImplementationAsync( /// /// A retry policy that can be applied to asynchronous delegates returning a value of type . /// +/// The type of the result. public class AsyncRetryPolicy : AsyncPolicy, IRetryPolicy { private readonly Func, TimeSpan, int, Context, Task> _onRetryAsync; diff --git a/src/Polly/Retry/AsyncRetrySyntax.cs b/src/Polly/Retry/AsyncRetrySyntax.cs index ef247265b9..7cbb1d0607 100644 --- a/src/Polly/Retry/AsyncRetrySyntax.cs +++ b/src/Polly/Retry/AsyncRetrySyntax.cs @@ -318,7 +318,7 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider) { @@ -335,7 +335,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -361,7 +361,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -387,7 +387,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -414,7 +414,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -439,7 +439,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -465,7 +465,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -498,7 +498,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -525,7 +525,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -550,7 +550,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -576,7 +576,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -600,7 +600,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -778,7 +778,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde /// the current retry number (1 for first retry, 2 for second etc). /// /// The policy builder. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. /// Thrown when is . public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider) @@ -797,7 +797,7 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// /// The policy builder. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. /// Thrown when is . public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider) diff --git a/src/Polly/Retry/AsyncRetryTResultSyntax.cs b/src/Polly/Retry/AsyncRetryTResultSyntax.cs index 8770a1420e..5d5a8ba922 100644 --- a/src/Polly/Retry/AsyncRetryTResultSyntax.cs +++ b/src/Polly/Retry/AsyncRetryTResultSyntax.cs @@ -8,6 +8,7 @@ public static class AsyncRetryTResultSyntax /// /// Builds an that will retry once. /// + /// The type of the result. /// The policy builder. /// The policy instance. public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder) => @@ -16,6 +17,7 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder /// Builds an that will retry times. /// + /// The type of the result. /// The policy builder. /// The retry count. /// The policy instance. @@ -30,6 +32,7 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder that will retry once /// calling on retry with the handled exception or result and retry count. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -43,6 +46,7 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder that will retry once /// calling on retry with the handled exception or result and retry count. /// + /// The type of the result. /// The policy builder. /// The action to call asynchronously on each retry. /// The policy instance. @@ -54,6 +58,7 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder that will retry times /// calling on each retry with the handled exception or result and retry count. /// + /// The type of the result. /// The policy builder. /// The retry count. /// The action to call on each retry. @@ -75,6 +80,7 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder that will retry times /// calling on each retry with the handled exception or result and retry count. /// + /// The type of the result. /// The policy builder. /// The retry count. /// The action to call asynchronously on each retry. @@ -93,6 +99,7 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder that will retry once /// calling on retry with the handled exception or result, retry count and context data. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -104,6 +111,7 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder that will retry once /// calling on retry with the handled exception or result, retry count and context data. /// + /// The type of the result. /// The policy builder. /// The action to call asynchronously on each retry. /// The policy instance. @@ -115,6 +123,7 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder that will retry times /// calling on each retry with the handled exception or result, retry count and context data. /// + /// The type of the result. /// The policy builder. /// The retry count. /// The action to call on each retry. @@ -136,6 +145,7 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder that will retry times /// calling on each retry with the handled exception or result, retry count and context data. /// + /// The type of the result. /// The policy builder. /// The retry count. /// The action to call asynchronously on each retry. @@ -158,6 +168,7 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder /// Builds an that will retry indefinitely until the action succeeds. /// + /// The type of the result. /// The policy builder. /// The policy instance. public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder) @@ -171,6 +182,7 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu /// Builds an that will retry indefinitely /// calling on each retry with the handled exception or result. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -190,6 +202,7 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu /// Builds an that will retry indefinitely /// calling on each retry with the handled exception or result and retry count. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -209,6 +222,7 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu /// Builds an that will retry indefinitely /// calling on each retry with the handled exception or result. /// + /// The type of the result. /// The policy builder. /// The action to call asynchronously on each retry. /// The policy instance. @@ -225,6 +239,7 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu /// Builds an that will retry indefinitely /// calling on each retry with the handled exception or result and retry count. /// + /// The type of the result. /// The policy builder. /// The action to call asynchronously on each retry. /// The policy instance. @@ -241,6 +256,7 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu /// Builds an that will retry indefinitely /// calling on each retry with the handled exception or result and context data. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -260,6 +276,7 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu /// Builds an that will retry indefinitely /// calling on each retry with the handled exception or result, retry count and context data. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -279,6 +296,7 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu /// Builds an that will retry indefinitely /// calling on each retry with the handled exception or result and context data. /// + /// The type of the result. /// The policy builder. /// The action to call asynchronously on each retry. /// The policy instance. @@ -297,6 +315,7 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu /// Builds an that will retry indefinitely /// calling on each retry with the handled exception or result, retry count and context data. /// + /// The type of the result. /// The policy builder. /// The action to call asynchronously on each retry. /// The policy instance. @@ -316,9 +335,10 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider) { @@ -333,9 +353,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -360,9 +381,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -386,9 +408,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -413,9 +436,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -437,9 +461,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -463,9 +488,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -496,9 +522,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -523,9 +550,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -547,9 +575,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -573,9 +602,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -598,9 +628,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc), result of previous execution, and execution context. /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call asynchronously on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -627,6 +658,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// /// On each retry, the duration to wait is the current item. /// + /// The type of the result. /// The policy builder. /// The sleep durations to wait for on each retry. /// The policy instance. @@ -643,6 +675,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// calling on each retry with the handled exception or result and the current sleep duration. /// On each retry, the duration to wait is the current item. /// + /// The type of the result. /// The policy builder. /// The sleep durations to wait for on each retry. /// The action to call on each retry. @@ -666,6 +699,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// calling on each retry with the handled exception or result and the current sleep duration. /// On each retry, the duration to wait is the current item. /// + /// The type of the result. /// The policy builder. /// The sleep durations to wait for on each retry. /// The action to call asynchronously on each retry. @@ -687,6 +721,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// calling on each retry with the handled exception or result, the current sleep duration and context data. /// On each retry, the duration to wait is the current item. /// + /// The type of the result. /// The policy builder. /// The sleep durations to wait for on each retry. /// The action to call on each retry. @@ -710,6 +745,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// calling on each retry with the handled exception or result, the current sleep duration and context data. /// On each retry, the duration to wait is the current item. /// + /// The type of the result. /// The policy builder. /// The sleep durations to wait for on each retry. /// The action to call asynchronously on each retry. @@ -731,6 +767,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// calling on each retry with the handled exception or result, the current sleep duration, retry count, and context data. /// On each retry, the duration to wait is the current item. /// + /// The type of the result. /// The policy builder. /// The sleep durations to wait for on each retry. /// The action to call on each retry. @@ -754,6 +791,7 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// calling on each retry with the handled exception or result, the current sleep duration, retry count, and context data. /// On each retry, the duration to wait is the current item. /// + /// The type of the result. /// The policy builder. /// The sleep durations to wait for on each retry. /// The action to call asynchronously on each retry. @@ -777,8 +815,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. /// Thrown when is . public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider) @@ -796,8 +835,9 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. /// Thrown when is . public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider) @@ -816,6 +856,7 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call on each retry. @@ -840,6 +881,7 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call on each retry. @@ -864,6 +906,7 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call asynchronously on each retry. @@ -888,6 +931,7 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call asynchronously on each retry. @@ -912,6 +956,7 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call on each retry. @@ -936,6 +981,7 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call on each retry. @@ -960,6 +1006,7 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call asynchronously on each retry. @@ -982,6 +1029,7 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call asynchronously on each retry. @@ -1004,6 +1052,7 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc), previous execution result and execution context. /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call asynchronously on each retry. @@ -1029,6 +1078,7 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc), previous execution result and execution context. /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call asynchronously on each retry. diff --git a/src/Polly/Retry/IRetryPolicy.cs b/src/Polly/Retry/IRetryPolicy.cs index 7dc3a45e52..0e938d039c 100644 --- a/src/Polly/Retry/IRetryPolicy.cs +++ b/src/Polly/Retry/IRetryPolicy.cs @@ -10,6 +10,7 @@ public interface IRetryPolicy : IsPolicy /// /// Defines properties and methods common to all Retry policies generic-typed for executions returning results of type . /// +/// The type of the result. public interface IRetryPolicy : IRetryPolicy { } diff --git a/src/Polly/Retry/RetryPolicy.cs b/src/Polly/Retry/RetryPolicy.cs index 0604267287..8662c5869b 100644 --- a/src/Polly/Retry/RetryPolicy.cs +++ b/src/Polly/Retry/RetryPolicy.cs @@ -47,6 +47,7 @@ protected override TResult Implementation(Func /// A retry policy that can be applied to synchronous delegates returning a value of type . /// +/// The type of the result. public class RetryPolicy : Policy, IRetryPolicy { private readonly Action, TimeSpan, int, Context> _onRetry; diff --git a/src/Polly/Retry/RetrySyntax.cs b/src/Polly/Retry/RetrySyntax.cs index c4dd558437..8a371b9aa4 100644 --- a/src/Polly/Retry/RetrySyntax.cs +++ b/src/Polly/Retry/RetrySyntax.cs @@ -178,7 +178,7 @@ public static RetryPolicy RetryForever(this PolicyBuilder policyBuilder, Action< /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider) { @@ -195,7 +195,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -219,7 +219,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -243,7 +243,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -274,7 +274,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider) { @@ -291,7 +291,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -315,7 +315,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -338,7 +338,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret /// /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -438,7 +438,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, IEnumer /// the current retry number (1 for first retry, 2 for second etc). /// /// The policy builder. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. /// Thrown when is . public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider) @@ -457,7 +457,7 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// /// The policy builder. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. /// Thrown when is . public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider) diff --git a/src/Polly/Retry/RetryTResultSyntax.cs b/src/Polly/Retry/RetryTResultSyntax.cs index c04d9dde0f..3c1fbc30be 100644 --- a/src/Polly/Retry/RetryTResultSyntax.cs +++ b/src/Polly/Retry/RetryTResultSyntax.cs @@ -8,6 +8,7 @@ public static class RetryTResultSyntax /// /// Builds a that will retry once. /// + /// The type of the result. /// The policy builder. /// The policy instance. public static RetryPolicy Retry(this PolicyBuilder policyBuilder) => @@ -16,6 +17,7 @@ public static RetryPolicy Retry(this PolicyBuilder po /// /// Builds a that will retry times. /// + /// The type of the result. /// The policy builder. /// The retry count. /// The policy instance. @@ -30,6 +32,7 @@ public static RetryPolicy Retry(this PolicyBuilder po /// Builds a that will retry once /// calling on retry with the handled exception or result and retry count. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -41,6 +44,7 @@ public static RetryPolicy Retry(this PolicyBuilder po /// Builds a that will retry times /// calling on each retry with the handled exception or result and retry count. /// + /// The type of the result. /// The policy builder. /// The retry count. /// The action to call on each retry. @@ -61,6 +65,7 @@ public static RetryPolicy Retry(this PolicyBuilder po /// Builds a that will retry once /// calling on retry with the handled exception or result, retry count and context data. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -72,6 +77,7 @@ public static RetryPolicy Retry(this PolicyBuilder po /// Builds a that will retry times /// calling on each retry with the handled exception or result, retry count and context data. /// + /// The type of the result. /// The policy builder. /// The retry count. /// The action to call on each retry. @@ -94,6 +100,7 @@ public static RetryPolicy Retry(this PolicyBuilder po /// /// Builds a that will retry indefinitely until the action succeeds. /// + /// The type of the result. /// The policy builder. /// The policy instance. public static RetryPolicy RetryForever(this PolicyBuilder policyBuilder) @@ -107,6 +114,7 @@ public static RetryPolicy RetryForever(this PolicyBuilder that will retry indefinitely /// calling on each retry with the handled exception or result. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -123,6 +131,7 @@ public static RetryPolicy RetryForever(this PolicyBuilder that will retry indefinitely /// calling on each retry with the handled exception or result and retry count. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -139,6 +148,7 @@ public static RetryPolicy RetryForever(this PolicyBuilder that will retry indefinitely /// calling on each retry with the handled exception or result and context data. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -157,6 +167,7 @@ public static RetryPolicy RetryForever(this PolicyBuilder that will retry indefinitely /// calling on each retry with the handled exception or result, retry count and context data. /// + /// The type of the result. /// The policy builder. /// The action to call on each retry. /// The policy instance. @@ -176,9 +187,10 @@ public static RetryPolicy RetryForever(this PolicyBuilder with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider) { @@ -193,9 +205,10 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -217,9 +230,10 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -241,9 +255,10 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -272,9 +287,10 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider) { @@ -289,9 +305,10 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -313,9 +330,10 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -331,9 +349,10 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder with /// the current retry number (1 for first retry, 2 for second etc), previous execution result and execution context. /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func, Context, TimeSpan> sleepDurationProvider) { @@ -348,9 +367,10 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder with /// the current retry number (1 for first retry, 2 for second etc), previous execution result and execution context. /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -372,9 +392,10 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder with /// the current retry number (1 for first retry, 2 for second etc), previous execution result and execution context. /// + /// The type of the result. /// The policy builder. /// The retry count. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The action to call on each retry. /// The policy instance. /// retryCount;Value must be greater than or equal to zero. @@ -399,6 +420,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder that will wait and retry as many times as there are provided /// On each retry, the duration to wait is the current item. /// + /// The type of the result. /// The policy builder. /// The sleep durations to wait for on each retry. /// The policy instance. @@ -414,6 +436,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder on each retry with the handled exception or result and the current sleep duration. /// On each retry, the duration to wait is the current item. /// + /// The type of the result. /// The policy builder. /// The sleep durations to wait for on each retry. /// The action to call on each retry. @@ -432,6 +455,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder on each retry with the handled exception or result, current sleep duration and context data. /// On each retry, the duration to wait is the current item. /// + /// The type of the result. /// The policy builder. /// The sleep durations to wait for on each retry. /// The action to call on each retry. @@ -450,6 +474,7 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder on each retry with the handled exception or result, current sleep duration, retry count and context data. /// On each retry, the duration to wait is the current item. /// + /// The type of the result. /// The policy builder. /// The sleep durations to wait for on each retry. /// The action to call on each retry. @@ -473,8 +498,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. /// Thrown when is . public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider) @@ -492,8 +518,9 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. - /// The function that provides the duration to wait for for a particular retry attempt. + /// The function that provides the duration to wait for a particular retry attempt. /// The policy instance. /// Thrown when is . public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider) @@ -512,6 +539,7 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call on each retry. @@ -536,6 +564,7 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc). /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call on each retry. @@ -560,6 +589,7 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call on each retry. @@ -582,6 +612,7 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc) and execution context. /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call on each retry. @@ -604,6 +635,7 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc), previous execution result and execution context. /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call on each retry. @@ -629,6 +661,7 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild /// On each retry, the duration to wait is calculated by calling with /// the current retry number (1 for first retry, 2 for second etc), previous execution result and execution context. /// + /// The type of the result. /// The policy builder. /// A function providing the duration to wait before retrying. /// The action to call on each retry. diff --git a/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs b/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs index 7e73cdfe09..ff1986a2ad 100644 --- a/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs +++ b/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs @@ -5,6 +5,7 @@ public partial class Policy /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The number of seconds after which to timeout. /// seconds;Value must be greater than zero. /// The policy instance. @@ -19,6 +20,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(int seconds) /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The number of seconds after which to timeout. /// The timeout strategy. /// seconds;Value must be greater than zero. @@ -34,6 +36,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(int seconds, Tim /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The number of seconds after which to timeout. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -50,6 +53,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(int seconds, Fun /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The number of seconds after which to timeout. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -67,6 +71,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(int seconds, Fun /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The number of seconds after which to timeout. /// The timeout strategy. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. @@ -84,6 +89,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(int seconds, Tim /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The number of seconds after which to timeout. /// The timeout strategy. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . @@ -102,6 +108,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(int seconds, Tim /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The timeout. /// The policy instance. /// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout). @@ -116,6 +123,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The timeout. /// The timeout strategy. /// The policy instance. @@ -131,6 +139,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The timeout. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -149,6 +158,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The timeout. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -168,6 +178,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The timeout. /// The timeout strategy. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. @@ -185,6 +196,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The timeout. /// The timeout strategy. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . @@ -202,6 +214,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// Thrown when is . /// The policy instance. @@ -217,6 +230,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func t /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// The timeout strategy. /// Thrown when is . @@ -233,6 +247,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func t /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -250,6 +265,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func t /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -267,6 +283,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func t /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// The timeout strategy. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. @@ -285,6 +302,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func t /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// The timeout strategy. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . @@ -303,6 +321,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func t /// /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// Thrown when is . /// The policy instance. @@ -315,6 +334,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// The timeout strategy. /// Thrown when is . @@ -328,6 +348,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -340,6 +361,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -352,6 +374,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// The timeout strategy. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. @@ -370,6 +393,7 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func /// Builds an that will wait asynchronously for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// A function to provide the timeout for this execution. /// The timeout strategy. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . diff --git a/src/Polly/Timeout/ITimeoutPolicy.cs b/src/Polly/Timeout/ITimeoutPolicy.cs index 8c4ab38028..df2b44a4fc 100644 --- a/src/Polly/Timeout/ITimeoutPolicy.cs +++ b/src/Polly/Timeout/ITimeoutPolicy.cs @@ -10,6 +10,7 @@ public interface ITimeoutPolicy : IsPolicy /// /// Defines properties and methods common to all Timeout policies generic-typed for executions returning results of type . /// +/// The type of the result. public interface ITimeoutPolicy : ITimeoutPolicy { } diff --git a/src/Polly/Timeout/TimeoutPolicy.cs b/src/Polly/Timeout/TimeoutPolicy.cs index 0f9390ed66..179b37301d 100644 --- a/src/Polly/Timeout/TimeoutPolicy.cs +++ b/src/Polly/Timeout/TimeoutPolicy.cs @@ -34,6 +34,7 @@ protected override TResult Implementation(Func /// A timeout policy which can be applied to delegates returning a value of type . /// +/// The type of the result. public class TimeoutPolicy : Policy, ITimeoutPolicy { private readonly TimeoutStrategy _timeoutStrategy; diff --git a/src/Polly/Timeout/TimeoutTResultSyntax.cs b/src/Polly/Timeout/TimeoutTResultSyntax.cs index 3ab38addce..cab88febc5 100644 --- a/src/Polly/Timeout/TimeoutTResultSyntax.cs +++ b/src/Polly/Timeout/TimeoutTResultSyntax.cs @@ -36,6 +36,7 @@ public static TimeoutPolicy Timeout(int seconds, TimeoutStrate /// /// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The return type of delegates which may be executed through the policy. /// The number of seconds after which to timeout. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -51,6 +52,7 @@ public static TimeoutPolicy Timeout(int seconds, Action /// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The return type of delegates which may be executed through the policy. /// The number of seconds after which to timeout. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -105,6 +107,7 @@ public static TimeoutPolicy Timeout(int seconds, TimeoutStrate /// /// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The type of the result. /// The timeout. /// The policy instance. /// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout). @@ -135,6 +138,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutS /// /// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The return type of delegates which may be executed through the policy. /// The timeout. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -150,6 +154,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, Action /// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The return type of delegates which may be executed through the policy. /// The timeout. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -199,6 +204,7 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutS /// /// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The return type of delegates which may be executed through the policy. /// A function to provide the timeout for this execution. /// Thrown when is . /// The policy instance. @@ -231,6 +237,7 @@ public static TimeoutPolicy Timeout(Func timeoutProv /// /// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The return type of delegates which may be executed through the policy. /// A function to provide the timeout for this execution. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -248,6 +255,7 @@ public static TimeoutPolicy Timeout(Func timeoutProv /// /// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The return type of delegates which may be executed through the policy. /// A function to provide the timeout for this execution. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -303,6 +311,7 @@ public static TimeoutPolicy Timeout(Func timeoutProv /// /// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The return type of delegates which may be executed through the policy. /// A function to provide the timeout for this execution. /// Thrown when is . /// The policy instance. @@ -329,6 +338,7 @@ public static TimeoutPolicy Timeout(Func ti /// /// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The return type of delegates which may be executed through the policy. /// A function to provide the timeout for this execution. /// An action to call on timeout, passing the execution context, the timeout applied, and a capturing the abandoned, timed-out action. /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. @@ -341,6 +351,7 @@ public static TimeoutPolicy Timeout(Func ti /// /// Builds a that will wait for a delegate to complete for a specified period of time. A will be thrown if the delegate does not complete within the configured timeout. /// + /// The return type of delegates which may be executed through the policy. /// A function to provide the timeout for this execution. /// An action to call on timeout, passing the execution context, the timeout applied, the capturing the abandoned, timed-out action, and the captured . /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. diff --git a/src/Polly/Wrap/AsyncPolicyWrapSyntax.cs b/src/Polly/Wrap/AsyncPolicyWrapSyntax.cs index 0bb2cc1936..cbc0cdd686 100644 --- a/src/Polly/Wrap/AsyncPolicyWrapSyntax.cs +++ b/src/Polly/Wrap/AsyncPolicyWrapSyntax.cs @@ -21,6 +21,7 @@ public static AsyncPolicyWrap WrapAsync(this IAsyncPolicy outerPolicy, IAsyncPol /// /// Wraps the specified outer policy round the inner policy. /// + /// The type of the result. /// The outer policy. /// The inner policy. /// A instance representing the combined wrap. @@ -34,6 +35,7 @@ public static AsyncPolicyWrap WrapAsync(this IAsyncPolicy oute /// /// Wraps the specified outer policy round the inner policy. /// + /// The type of the result. /// The outer policy. /// The inner policy. /// A instance representing the combined wrap. @@ -47,6 +49,7 @@ public static AsyncPolicyWrap WrapAsync(this IAsyncPolicy /// Wraps the specified outer policy round the inner policy. /// + /// The type of the result. /// The outer policy. /// The inner policy. /// A instance representing the combined wrap. diff --git a/src/Polly/Wrap/IPolicyWrap.cs b/src/Polly/Wrap/IPolicyWrap.cs index abea62a2ec..b8535ea78b 100644 --- a/src/Polly/Wrap/IPolicyWrap.cs +++ b/src/Polly/Wrap/IPolicyWrap.cs @@ -19,6 +19,7 @@ public interface IPolicyWrap : IsPolicy /// /// Defines properties and methods common to all PolicyWrap policies generic-typed for executions returning results of type . /// +/// The type of the result. public interface IPolicyWrap : IPolicyWrap { } diff --git a/src/Polly/Wrap/PolicyWrapSyntax.cs b/src/Polly/Wrap/PolicyWrapSyntax.cs index a55c9d6c6d..e44fea20e3 100644 --- a/src/Polly/Wrap/PolicyWrapSyntax.cs +++ b/src/Polly/Wrap/PolicyWrapSyntax.cs @@ -21,6 +21,7 @@ public static PolicyWrap Wrap(this ISyncPolicy outerPolicy, ISyncPolicy innerPol /// /// Wraps the specified outer policy round the inner policy. /// + /// The type of the result. /// The outer policy. /// The inner policy. /// A instance representing the combined wrap. @@ -34,6 +35,7 @@ public static PolicyWrap Wrap(this ISyncPolicy outerPolicy, IS /// /// Wraps the specified outer policy round the inner policy. /// + /// The type of the result. /// The outer policy. /// The inner policy. /// A instance representing the combined wrap. @@ -47,6 +49,7 @@ public static PolicyWrap Wrap(this ISyncPolicy outerP /// /// Wraps the specified outer policy round the inner policy. /// + /// The type of the result. /// The outer policy. /// The inner policy. /// A instance representing the combined wrap. From f32222b70dec918d3d05e5cba3f698c696fdcd71 Mon Sep 17 00:00:00 2001 From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com> Date: Thu, 25 Apr 2024 23:38:22 +0300 Subject: [PATCH 2/9] Consolidate typeparam text --- src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs | 2 +- .../CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs | 2 +- src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs b/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs index 16740fe647..bc19455523 100644 --- a/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs +++ b/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs @@ -16,7 +16,7 @@ public static class AdvancedCircuitBreakerTResultSyntax /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// - /// The type of the result. + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure). /// The duration of the timeslice over which failure ratios are assessed. diff --git a/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs b/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs index 930902fac6..67afe0c6ff 100644 --- a/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs +++ b/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs @@ -87,7 +87,7 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync; if no exception or handled result is encountered, the circuit will reset. /// /// - /// The type of the result. + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The failure threshold at which the circuit will break (a number between 0 and 1; eg 0.5 represents breaking if 50% or more of actions result in a handled failure). /// The duration of the timeslice over which failure ratios are assessed. diff --git a/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs b/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs index 18b424e0eb..885777e73d 100644 --- a/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs +++ b/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs @@ -113,7 +113,7 @@ public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(th /// again for another ; if no exception or handled result is encountered, the circuit will reset. /// /// - /// The type of the result. + /// The return type of delegates which may be executed through the policy. /// The policy builder. /// The number of exceptions or handled results that are allowed before opening the circuit. /// The duration the circuit will stay open before resetting. From e013fa4861c0be80d876316638290488b98f8d70 Mon Sep 17 00:00:00 2001 From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com> Date: Fri, 26 Apr 2024 00:05:24 +0300 Subject: [PATCH 3/9] Enable S6605 --- src/Polly/Polly.csproj | 2 +- src/Polly/ResultPredicates.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj index ef9bae12f9..6326a634f1 100644 --- a/src/Polly/Polly.csproj +++ b/src/Polly/Polly.csproj @@ -11,7 +11,7 @@ $(NoWarn);IDE1006;CA1062;S107;CA1068;S4039;CA1000;CA1063;CA1031;CA1051 $(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;CA1033 $(NoWarn);S4023;CA1010;S3442;CA1064;SA1649;SA1625;SA1623;SA1118 - $(NoWarn);S3253;S3971;S6605;CA1724;CA1716;SA1108;CA1710;S4049;S3246 + $(NoWarn);S3253;S3971;CA1724;CA1716;SA1108;CA1710;S4049;S3246 $(NoWarn);CA1805 diff --git a/src/Polly/ResultPredicates.cs b/src/Polly/ResultPredicates.cs index 63b02ddec3..093c139d65 100644 --- a/src/Polly/ResultPredicates.cs +++ b/src/Polly/ResultPredicates.cs @@ -24,7 +24,7 @@ public bool AnyMatch(TResult result) if (_predicates == null) return false; - return _predicates.Any(predicate => predicate(result)); + return _predicates.Exists(predicate => predicate(result)); } /// From f21b7836740ffaff08f4851f66f1579dfc78b24e Mon Sep 17 00:00:00 2001 From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com> Date: Fri, 26 Apr 2024 00:11:04 +0300 Subject: [PATCH 4/9] Disable S3253 --- src/Polly/Polly.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj index 6326a634f1..d79fe8d113 100644 --- a/src/Polly/Polly.csproj +++ b/src/Polly/Polly.csproj @@ -11,7 +11,7 @@ $(NoWarn);IDE1006;CA1062;S107;CA1068;S4039;CA1000;CA1063;CA1031;CA1051 $(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;CA1033 $(NoWarn);S4023;CA1010;S3442;CA1064;SA1649;SA1625;SA1623;SA1118 - $(NoWarn);S3253;S3971;CA1724;CA1716;SA1108;CA1710;S4049;S3246 + $(NoWarn);S3971;CA1724;CA1716;SA1108;CA1710;S4049;S3246 $(NoWarn);CA1805 From 33c09c472726e22ce8fdf02e4c1a68291ca1df92 Mon Sep 17 00:00:00 2001 From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com> Date: Sun, 28 Apr 2024 19:50:56 +0300 Subject: [PATCH 5/9] Fix IDE0011 --- src/Polly/AsyncPolicy.ContextAndKeys.cs | 8 ++ src/Polly/AsyncPolicy.ExecuteOverloads.cs | 8 ++ .../AsyncPolicy.TResult.ExecuteOverloads.cs | 4 + src/Polly/Bulkhead/AsyncBulkheadSyntax.cs | 8 ++ .../Bulkhead/AsyncBulkheadTResultSyntax.cs | 8 ++ src/Polly/Bulkhead/BulkheadSyntax.cs | 8 ++ src/Polly/Bulkhead/BulkheadTResultSyntax.cs | 8 ++ src/Polly/Caching/AsyncCacheSyntax.cs | 32 +++++ src/Polly/Caching/AsyncCacheTResultSyntax.cs | 40 ++++++ src/Polly/Caching/CacheSyntax.cs | 32 +++++ src/Polly/Caching/CacheTResultSyntax.cs | 40 ++++++ src/Polly/Caching/ContextualTtl.cs | 2 + src/Polly/Caching/RelativeTtl.cs | 2 + src/Polly/Caching/ResultTtl.cs | 3 + src/Polly/Caching/SlidingTtl.cs | 2 + .../AdvancedCircuitBreakerSyntax.cs | 22 +++ .../AdvancedCircuitBreakerTResultSyntax.cs | 22 +++ .../AsyncAdvancedCircuitBreakerSyntax.cs | 22 +++ ...syncAdvancedCircuitBreakerTResultSyntax.cs | 22 +++ .../AsyncCircuitBreakerSyntax.cs | 13 ++ .../AsyncCircuitBreakerTResultSyntax.cs | 13 ++ .../CircuitBreaker/CircuitBreakerSyntax.cs | 13 ++ .../CircuitBreakerTResultSyntax.cs | 13 ++ .../CircuitBreaker/RollingHealthMetrics.cs | 4 +- src/Polly/Context.Dictionary.cs | 3 + src/Polly/Fallback/AsyncFallbackSyntax.cs | 38 ++++++ src/Polly/Fallback/FallbackSyntax.cs | 62 +++++++++ src/Polly/Policy.ContextAndKeys.cs | 8 ++ src/Polly/Policy.ExecuteOverloads.cs | 8 ++ src/Polly/Policy.TResult.ExecuteOverloads.cs | 4 + src/Polly/PolicyBuilder.OrSyntax.cs | 7 + src/Polly/Polly.csproj | 2 +- src/Polly/Polly.sln | 25 ++++ src/Polly/RateLimit/AsyncRateLimitSyntax.cs | 8 ++ .../RateLimit/AsyncRateLimitTResultSyntax.cs | 8 ++ .../LockFreeTokenBucketRateLimiter.cs | 5 + .../RateLimit/RateLimitRejectedException.cs | 3 + src/Polly/RateLimit/RateLimitSyntax.cs | 8 ++ src/Polly/RateLimit/RateLimitTResultSyntax.cs | 8 ++ src/Polly/ResultPredicates.cs | 2 + src/Polly/Retry/AsyncRetrySyntax.cs | 125 ++++++++++++++++++ src/Polly/Retry/AsyncRetryTResultSyntax.cs | 118 +++++++++++++++++ src/Polly/Retry/RetrySyntax.cs | 80 +++++++++++ src/Polly/Retry/RetryTResultSyntax.cs | 79 +++++++++++ src/Polly/Timeout/AsyncTimeoutSyntax.cs | 28 ++++ .../Timeout/AsyncTimeoutTResultSyntax.cs | 32 +++++ src/Polly/Timeout/TimeoutSyntax.cs | 23 ++++ src/Polly/Timeout/TimeoutTResultSyntax.cs | 23 ++++ src/Polly/Timeout/TimeoutValidator.cs | 2 + src/Polly/Utilities/SystemClock.cs | 4 + .../Wrap/AsyncPolicyWrap.ContextAndKeys.cs | 4 + src/Polly/Wrap/AsyncPolicyWrapSyntax.cs | 20 +++ src/Polly/Wrap/IPolicyWrapExtension.cs | 4 + src/Polly/Wrap/PolicyWrap.ContextAndKeys.cs | 4 + src/Polly/Wrap/PolicyWrapSyntax.cs | 20 +++ 55 files changed, 1112 insertions(+), 2 deletions(-) create mode 100644 src/Polly/Polly.sln diff --git a/src/Polly/AsyncPolicy.ContextAndKeys.cs b/src/Polly/AsyncPolicy.ContextAndKeys.cs index ec0e813c14..7ba44c96a7 100644 --- a/src/Polly/AsyncPolicy.ContextAndKeys.cs +++ b/src/Polly/AsyncPolicy.ContextAndKeys.cs @@ -10,7 +10,9 @@ public abstract partial class AsyncPolicy public AsyncPolicy WithPolicyKey(string policyKey) { if (policyKeyInternal != null) + { throw PolicyKeyMustBeImmutableException(nameof(policyKey)); + } policyKeyInternal = policyKey; return this; @@ -24,7 +26,9 @@ public AsyncPolicy WithPolicyKey(string policyKey) IAsyncPolicy IAsyncPolicy.WithPolicyKey(string policyKey) { if (policyKeyInternal != null) + { throw PolicyKeyMustBeImmutableException(nameof(policyKey)); + } policyKeyInternal = policyKey; return this; @@ -41,7 +45,9 @@ public abstract partial class AsyncPolicy public AsyncPolicy WithPolicyKey(string policyKey) { if (policyKeyInternal != null) + { throw PolicyKeyMustBeImmutableException(nameof(policyKey)); + } policyKeyInternal = policyKey; return this; @@ -55,7 +61,9 @@ public AsyncPolicy WithPolicyKey(string policyKey) IAsyncPolicy IAsyncPolicy.WithPolicyKey(string policyKey) { if (policyKeyInternal != null) + { throw PolicyKeyMustBeImmutableException(nameof(policyKey)); + } policyKeyInternal = policyKey; return this; diff --git a/src/Polly/AsyncPolicy.ExecuteOverloads.cs b/src/Polly/AsyncPolicy.ExecuteOverloads.cs index 661cfadf64..af804d5d39 100644 --- a/src/Polly/AsyncPolicy.ExecuteOverloads.cs +++ b/src/Polly/AsyncPolicy.ExecuteOverloads.cs @@ -94,7 +94,9 @@ public Task ExecuteAsync(Func action, IDiction public async Task ExecuteAsync(Func action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } SetPolicyContext(context, out string priorPolicyWrapKey, out string priorPolicyKey); @@ -218,7 +220,9 @@ public Task ExecuteAsync(Func ExecuteAsync(Func> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } SetPolicyContext(context, out string priorPolicyWrapKey, out string priorPolicyKey); @@ -335,7 +339,9 @@ public Task ExecuteAndCaptureAsync(Func ExecuteAndCaptureAsync(Func action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } try { @@ -460,7 +466,9 @@ public Task> ExecuteAndCaptureAsync(Func> ExecuteAndCaptureAsync(Func> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } try { diff --git a/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs b/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs index 74a178f394..8e704d5b2e 100644 --- a/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs +++ b/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs @@ -103,7 +103,9 @@ public Task ExecuteAsync(Func public async Task ExecuteAsync(Func> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } SetPolicyContext(context, out string priorPolicyWrapKey, out string priorPolicyKey); @@ -222,7 +224,9 @@ public Task> ExecuteAndCaptureAsync(Func> ExecuteAndCaptureAsync(Func> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } try { diff --git a/src/Polly/Bulkhead/AsyncBulkheadSyntax.cs b/src/Polly/Bulkhead/AsyncBulkheadSyntax.cs index 80cfc1459a..f31052e169 100644 --- a/src/Polly/Bulkhead/AsyncBulkheadSyntax.cs +++ b/src/Polly/Bulkhead/AsyncBulkheadSyntax.cs @@ -60,11 +60,19 @@ public static AsyncBulkheadPolicy BulkheadAsync( Func onBulkheadRejectedAsync) { if (maxParallelization <= 0) + { throw new ArgumentOutOfRangeException(nameof(maxParallelization), "Value must be greater than zero."); + } + if (maxQueuingActions < 0) + { throw new ArgumentOutOfRangeException(nameof(maxQueuingActions), "Value must be greater than or equal to zero."); + } + if (onBulkheadRejectedAsync == null) + { throw new ArgumentNullException(nameof(onBulkheadRejectedAsync)); + } return new AsyncBulkheadPolicy( maxParallelization, diff --git a/src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs b/src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs index ee3f43ccfb..a174fda319 100644 --- a/src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs +++ b/src/Polly/Bulkhead/AsyncBulkheadTResultSyntax.cs @@ -60,11 +60,19 @@ public static AsyncBulkheadPolicy BulkheadAsync(int maxParalle public static AsyncBulkheadPolicy BulkheadAsync(int maxParallelization, int maxQueuingActions, Func onBulkheadRejectedAsync) { if (maxParallelization <= 0) + { throw new ArgumentOutOfRangeException(nameof(maxParallelization), "Value must be greater than zero."); + } + if (maxQueuingActions < 0) + { throw new ArgumentOutOfRangeException(nameof(maxQueuingActions), "Value must be greater than or equal to zero."); + } + if (onBulkheadRejectedAsync == null) + { throw new ArgumentNullException(nameof(onBulkheadRejectedAsync)); + } return new AsyncBulkheadPolicy( maxParallelization, diff --git a/src/Polly/Bulkhead/BulkheadSyntax.cs b/src/Polly/Bulkhead/BulkheadSyntax.cs index c841d9d8ba..7b1b751547 100644 --- a/src/Polly/Bulkhead/BulkheadSyntax.cs +++ b/src/Polly/Bulkhead/BulkheadSyntax.cs @@ -57,11 +57,19 @@ public static BulkheadPolicy Bulkhead(int maxParallelization, int maxQueuingActi public static BulkheadPolicy Bulkhead(int maxParallelization, int maxQueuingActions, Action onBulkheadRejected) { if (maxParallelization <= 0) + { throw new ArgumentOutOfRangeException(nameof(maxParallelization), "Value must be greater than zero."); + } + if (maxQueuingActions < 0) + { throw new ArgumentOutOfRangeException(nameof(maxQueuingActions), "Value must be greater than or equal to zero."); + } + if (onBulkheadRejected == null) + { throw new ArgumentNullException(nameof(onBulkheadRejected)); + } return new BulkheadPolicy( maxParallelization, diff --git a/src/Polly/Bulkhead/BulkheadTResultSyntax.cs b/src/Polly/Bulkhead/BulkheadTResultSyntax.cs index 19f7efe267..c3661c1562 100644 --- a/src/Polly/Bulkhead/BulkheadTResultSyntax.cs +++ b/src/Polly/Bulkhead/BulkheadTResultSyntax.cs @@ -61,11 +61,19 @@ public static BulkheadPolicy Bulkhead(int maxParallelization, public static BulkheadPolicy Bulkhead(int maxParallelization, int maxQueuingActions, Action onBulkheadRejected) { if (maxParallelization <= 0) + { throw new ArgumentOutOfRangeException(nameof(maxParallelization), "Value must be greater than zero."); + } + if (maxQueuingActions < 0) + { throw new ArgumentOutOfRangeException(nameof(maxQueuingActions), "Value must be greater than or equal to zero."); + } + if (onBulkheadRejected == null) + { throw new ArgumentNullException(nameof(onBulkheadRejected)); + } return new BulkheadPolicy( maxParallelization, diff --git a/src/Polly/Caching/AsyncCacheSyntax.cs b/src/Polly/Caching/AsyncCacheSyntax.cs index 9fa5db4510..9da9b5a27c 100644 --- a/src/Polly/Caching/AsyncCacheSyntax.cs +++ b/src/Polly/Caching/AsyncCacheSyntax.cs @@ -65,11 +65,19 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, Tim public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } + if (ttlStrategy == null) + { throw new ArgumentNullException(nameof(ttlStrategy)); + } + if (cacheKeyStrategy == null) + { throw new ArgumentNullException(nameof(cacheKeyStrategy)); + } Action emptyDelegate = (_, _) => { }; @@ -109,11 +117,19 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, Tim public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } + if (ttlStrategy == null) + { throw new ArgumentNullException(nameof(ttlStrategy)); + } + if (cacheKeyStrategy == null) + { throw new ArgumentNullException(nameof(cacheKeyStrategy)); + } Action emptyDelegate = (_, _) => { }; @@ -303,18 +319,34 @@ public static AsyncCachePolicy CacheAsync( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } + if (ttlStrategy == null) + { throw new ArgumentNullException(nameof(ttlStrategy)); + } + if (cacheKeyStrategy == null) + { throw new ArgumentNullException(nameof(cacheKeyStrategy)); + } if (onCacheGet == null) + { throw new ArgumentNullException(nameof(onCacheGet)); + } + if (onCacheMiss == null) + { throw new ArgumentNullException(nameof(onCacheMiss)); + } + if (onCachePut == null) + { throw new ArgumentNullException(nameof(onCachePut)); + } return new AsyncCachePolicy(cacheProvider, ttlStrategy, cacheKeyStrategy, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } diff --git a/src/Polly/Caching/AsyncCacheTResultSyntax.cs b/src/Polly/Caching/AsyncCacheTResultSyntax.cs index 3a4daa6d41..966e69b05a 100644 --- a/src/Polly/Caching/AsyncCacheTResultSyntax.cs +++ b/src/Polly/Caching/AsyncCacheTResultSyntax.cs @@ -18,7 +18,9 @@ public partial class Policy public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), new RelativeTtl(ttl), DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError); } @@ -39,7 +41,9 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), ttlStrategy, DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError); } @@ -61,7 +65,9 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, ICacheKeyStrategy cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheError); } @@ -84,7 +90,9 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), ttlStrategy, cacheKeyStrategy.GetCacheKey, onCacheError); } @@ -106,7 +114,9 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Func cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), new RelativeTtl(ttl), cacheKeyStrategy, onCacheError); } @@ -129,7 +139,9 @@ public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider public static AsyncCachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), ttlStrategy, cacheKeyStrategy, onCacheError); } @@ -163,7 +175,9 @@ public static AsyncCachePolicy CacheAsync( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), new RelativeTtl(ttl), DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -198,7 +212,9 @@ public static AsyncCachePolicy CacheAsync( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), ttlStrategy, DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -235,7 +251,9 @@ public static AsyncCachePolicy CacheAsync( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -273,7 +291,9 @@ public static AsyncCachePolicy CacheAsync( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), ttlStrategy, cacheKeyStrategy.GetCacheKey, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -310,7 +330,9 @@ public static AsyncCachePolicy CacheAsync( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), new RelativeTtl(ttl), cacheKeyStrategy, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -348,7 +370,9 @@ public static AsyncCachePolicy CacheAsync( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return CacheAsync(cacheProvider.AsyncFor(), ttlStrategy, cacheKeyStrategy, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -810,18 +834,34 @@ public static AsyncCachePolicy CacheAsync( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } + if (ttlStrategy == null) + { throw new ArgumentNullException(nameof(ttlStrategy)); + } + if (cacheKeyStrategy == null) + { throw new ArgumentNullException(nameof(cacheKeyStrategy)); + } if (onCacheGet == null) + { throw new ArgumentNullException(nameof(onCacheGet)); + } + if (onCacheMiss == null) + { throw new ArgumentNullException(nameof(onCacheMiss)); + } + if (onCachePut == null) + { throw new ArgumentNullException(nameof(onCachePut)); + } return new AsyncCachePolicy(cacheProvider, ttlStrategy, cacheKeyStrategy, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } diff --git a/src/Polly/Caching/CacheSyntax.cs b/src/Polly/Caching/CacheSyntax.cs index 350dd3b111..52fddb54f1 100644 --- a/src/Polly/Caching/CacheSyntax.cs +++ b/src/Polly/Caching/CacheSyntax.cs @@ -65,11 +65,19 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } + if (ttlStrategy == null) + { throw new ArgumentNullException(nameof(ttlStrategy)); + } + if (cacheKeyStrategy == null) + { throw new ArgumentNullException(nameof(cacheKeyStrategy)); + } Action emptyDelegate = (_, _) => { }; @@ -109,11 +117,19 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } + if (ttlStrategy == null) + { throw new ArgumentNullException(nameof(ttlStrategy)); + } + if (cacheKeyStrategy == null) + { throw new ArgumentNullException(nameof(cacheKeyStrategy)); + } Action emptyDelegate = (_, _) => { }; @@ -303,18 +319,34 @@ public static CachePolicy Cache( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } + if (ttlStrategy == null) + { throw new ArgumentNullException(nameof(ttlStrategy)); + } + if (cacheKeyStrategy == null) + { throw new ArgumentNullException(nameof(cacheKeyStrategy)); + } if (onCacheGet == null) + { throw new ArgumentNullException(nameof(onCacheGet)); + } + if (onCacheMiss == null) + { throw new ArgumentNullException(nameof(onCacheMiss)); + } + if (onCachePut == null) + { throw new ArgumentNullException(nameof(onCachePut)); + } return new CachePolicy(cacheProvider, ttlStrategy, cacheKeyStrategy, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } diff --git a/src/Polly/Caching/CacheTResultSyntax.cs b/src/Polly/Caching/CacheTResultSyntax.cs index 4f7c671226..cdee22416e 100644 --- a/src/Polly/Caching/CacheTResultSyntax.cs +++ b/src/Polly/Caching/CacheTResultSyntax.cs @@ -18,7 +18,9 @@ public partial class Policy public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), new RelativeTtl(ttl), DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError); } @@ -39,7 +41,9 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvid public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), ttlStrategy, DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheError); } @@ -61,7 +65,9 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvid public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, ICacheKeyStrategy cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheError); } @@ -84,7 +90,9 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvid public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), ttlStrategy, cacheKeyStrategy.GetCacheKey, onCacheError); } @@ -106,7 +114,9 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvid public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Func cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), new RelativeTtl(ttl), cacheKeyStrategy, onCacheError); } @@ -129,7 +139,9 @@ public static CachePolicy Cache(ISyncCacheProvider cacheProvid public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func cacheKeyStrategy, Action? onCacheError = null) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), ttlStrategy, cacheKeyStrategy, onCacheError); } @@ -163,7 +175,9 @@ public static CachePolicy Cache( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), new RelativeTtl(ttl), DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -198,7 +212,9 @@ public static CachePolicy Cache( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), ttlStrategy, DefaultCacheKeyStrategy.Instance.GetCacheKey, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -235,7 +251,9 @@ public static CachePolicy Cache( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), new RelativeTtl(ttl), cacheKeyStrategy.GetCacheKey, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -273,7 +291,9 @@ public static CachePolicy Cache( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), ttlStrategy, cacheKeyStrategy.GetCacheKey, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -310,7 +330,9 @@ public static CachePolicy Cache( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), new RelativeTtl(ttl), cacheKeyStrategy, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -348,7 +370,9 @@ public static CachePolicy Cache( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } return Cache(cacheProvider.For(), ttlStrategy, cacheKeyStrategy, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } @@ -815,18 +839,34 @@ public static CachePolicy Cache( Action? onCachePutError) { if (cacheProvider == null) + { throw new ArgumentNullException(nameof(cacheProvider)); + } + if (ttlStrategy == null) + { throw new ArgumentNullException(nameof(ttlStrategy)); + } + if (cacheKeyStrategy == null) + { throw new ArgumentNullException(nameof(cacheKeyStrategy)); + } if (onCacheGet == null) + { throw new ArgumentNullException(nameof(onCacheGet)); + } + if (onCacheMiss == null) + { throw new ArgumentNullException(nameof(onCacheMiss)); + } + if (onCachePut == null) + { throw new ArgumentNullException(nameof(onCachePut)); + } return new CachePolicy(cacheProvider, ttlStrategy, cacheKeyStrategy, onCacheGet, onCacheMiss, onCachePut, onCacheGetError, onCachePutError); } diff --git a/src/Polly/Caching/ContextualTtl.cs b/src/Polly/Caching/ContextualTtl.cs index c45e23a327..ac14b2f511 100644 --- a/src/Polly/Caching/ContextualTtl.cs +++ b/src/Polly/Caching/ContextualTtl.cs @@ -28,7 +28,9 @@ public class ContextualTtl : ITtlStrategy public Ttl GetTtl(Context context, object? result) { if (!context.ContainsKey(TimeSpanKey)) + { return _noTtl; + } bool sliding = false; diff --git a/src/Polly/Caching/RelativeTtl.cs b/src/Polly/Caching/RelativeTtl.cs index de192d9a8d..4f05440ca0 100644 --- a/src/Polly/Caching/RelativeTtl.cs +++ b/src/Polly/Caching/RelativeTtl.cs @@ -15,7 +15,9 @@ public class RelativeTtl : ITtlStrategy public RelativeTtl(TimeSpan ttl) { if (ttl < TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(ttl), "The ttl for items to cache must be greater than zero."); + } this.ttl = ttl; } diff --git a/src/Polly/Caching/ResultTtl.cs b/src/Polly/Caching/ResultTtl.cs index ae24f731ea..c3b1038c18 100644 --- a/src/Polly/Caching/ResultTtl.cs +++ b/src/Polly/Caching/ResultTtl.cs @@ -16,7 +16,10 @@ public class ResultTtl : ITtlStrategy public ResultTtl(Func ttlFunc) { if (ttlFunc == null) + { throw new ArgumentNullException(nameof(ttlFunc)); + } + _ttlFunc = (_, result) => ttlFunc(result); } diff --git a/src/Polly/Caching/SlidingTtl.cs b/src/Polly/Caching/SlidingTtl.cs index 3c446dced4..7adfdc0b2e 100644 --- a/src/Polly/Caching/SlidingTtl.cs +++ b/src/Polly/Caching/SlidingTtl.cs @@ -15,7 +15,9 @@ public class SlidingTtl : ITtlStrategy public SlidingTtl(TimeSpan slidingTtl) { if (slidingTtl < TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(slidingTtl), "The ttl for items to cache must be greater than zero."); + } ttl = new Ttl(slidingTtl, true); } diff --git a/src/Polly/CircuitBreaker/AdvancedCircuitBreakerSyntax.cs b/src/Polly/CircuitBreaker/AdvancedCircuitBreakerSyntax.cs index 2c30010871..2b91aeb1d0 100644 --- a/src/Polly/CircuitBreaker/AdvancedCircuitBreakerSyntax.cs +++ b/src/Polly/CircuitBreaker/AdvancedCircuitBreakerSyntax.cs @@ -224,22 +224,44 @@ public static CircuitBreakerPolicy AdvancedCircuitBreaker( var resolutionOfCircuit = TimeSpan.FromTicks(AdvancedCircuitController.ResolutionOfCircuitTimer); if (failureThreshold <= 0) + { throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be greater than zero."); + } + if (failureThreshold > 1) + { throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be less than or equal to one."); + } + if (samplingDuration < resolutionOfCircuit) + { throw new ArgumentOutOfRangeException(nameof(samplingDuration), $"Value must be equal to or greater than {resolutionOfCircuit.TotalMilliseconds} milliseconds. This is the minimum resolution of the CircuitBreaker timer."); + } + if (minimumThroughput <= 1) + { throw new ArgumentOutOfRangeException(nameof(minimumThroughput), "Value must be greater than one."); + } + if (durationOfBreak < TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(durationOfBreak), "Value must be greater than zero."); + } if (onBreak == null) + { throw new ArgumentNullException(nameof(onBreak)); + } + if (onReset == null) + { throw new ArgumentNullException(nameof(onReset)); + } + if (onHalfOpen == null) + { throw new ArgumentNullException(nameof(onHalfOpen)); + } var breakerController = new AdvancedCircuitController( failureThreshold, diff --git a/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs b/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs index bc19455523..5b521b5a0f 100644 --- a/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs +++ b/src/Polly/CircuitBreaker/AdvancedCircuitBreakerTResultSyntax.cs @@ -230,22 +230,44 @@ public static CircuitBreakerPolicy AdvancedCircuitBreaker( var resolutionOfCircuit = TimeSpan.FromTicks(AdvancedCircuitController.ResolutionOfCircuitTimer); if (failureThreshold <= 0) + { throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be greater than zero."); + } + if (failureThreshold > 1) + { throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be less than or equal to one."); + } + if (samplingDuration < resolutionOfCircuit) + { throw new ArgumentOutOfRangeException(nameof(samplingDuration), $"Value must be equal to or greater than {resolutionOfCircuit.TotalMilliseconds} milliseconds. This is the minimum resolution of the CircuitBreaker timer."); + } + if (minimumThroughput <= 1) + { throw new ArgumentOutOfRangeException(nameof(minimumThroughput), "Value must be greater than one."); + } + if (durationOfBreak < TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(durationOfBreak), "Value must be greater than zero."); + } if (onBreak == null) + { throw new ArgumentNullException(nameof(onBreak)); + } + if (onReset == null) + { throw new ArgumentNullException(nameof(onReset)); + } + if (onHalfOpen == null) + { throw new ArgumentNullException(nameof(onHalfOpen)); + } var breakerController = new AdvancedCircuitController( failureThreshold, diff --git a/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerSyntax.cs b/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerSyntax.cs index b5d464ac88..2901fcd57e 100644 --- a/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerSyntax.cs +++ b/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerSyntax.cs @@ -227,22 +227,44 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync( var resolutionOfCircuit = TimeSpan.FromTicks(AdvancedCircuitController.ResolutionOfCircuitTimer); if (failureThreshold <= 0) + { throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be greater than zero."); + } + if (failureThreshold > 1) + { throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be less than or equal to one."); + } + if (samplingDuration < resolutionOfCircuit) + { throw new ArgumentOutOfRangeException(nameof(samplingDuration), $"Value must be equal to or greater than {resolutionOfCircuit.TotalMilliseconds} milliseconds. This is the minimum resolution of the CircuitBreaker timer."); + } + if (minimumThroughput <= 1) + { throw new ArgumentOutOfRangeException(nameof(minimumThroughput), "Value must be greater than one."); + } + if (durationOfBreak < TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(durationOfBreak), "Value must be greater than zero."); + } if (onBreak == null) + { throw new ArgumentNullException(nameof(onBreak)); + } + if (onReset == null) + { throw new ArgumentNullException(nameof(onReset)); + } + if (onHalfOpen == null) + { throw new ArgumentNullException(nameof(onHalfOpen)); + } var breakerController = new AdvancedCircuitController( failureThreshold, diff --git a/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs b/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs index 67afe0c6ff..7d4b43f6eb 100644 --- a/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs +++ b/src/Polly/CircuitBreaker/AsyncAdvancedCircuitBreakerTResultSyntax.cs @@ -226,22 +226,44 @@ public static AsyncCircuitBreakerPolicy AdvancedCircuitBreakerAsync.ResolutionOfCircuitTimer); if (failureThreshold <= 0) + { throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be greater than zero."); + } + if (failureThreshold > 1) + { throw new ArgumentOutOfRangeException(nameof(failureThreshold), "Value must be less than or equal to one."); + } + if (samplingDuration < resolutionOfCircuit) + { throw new ArgumentOutOfRangeException(nameof(samplingDuration), $"Value must be equal to or greater than {resolutionOfCircuit.TotalMilliseconds} milliseconds. This is the minimum resolution of the CircuitBreaker timer."); + } + if (minimumThroughput <= 1) + { throw new ArgumentOutOfRangeException(nameof(minimumThroughput), "Value must be greater than one."); + } + if (durationOfBreak < TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(durationOfBreak), "Value must be greater than zero."); + } if (onBreak == null) + { throw new ArgumentNullException(nameof(onBreak)); + } + if (onReset == null) + { throw new ArgumentNullException(nameof(onReset)); + } + if (onHalfOpen == null) + { throw new ArgumentNullException(nameof(onHalfOpen)); + } var breakerController = new AdvancedCircuitController( failureThreshold, diff --git a/src/Polly/CircuitBreaker/AsyncCircuitBreakerSyntax.cs b/src/Polly/CircuitBreaker/AsyncCircuitBreakerSyntax.cs index 557469c803..8869618ce9 100644 --- a/src/Polly/CircuitBreaker/AsyncCircuitBreakerSyntax.cs +++ b/src/Polly/CircuitBreaker/AsyncCircuitBreakerSyntax.cs @@ -188,16 +188,29 @@ public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(this PolicyBuilder p public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action onBreak, Action onReset, Action onHalfOpen) { if (exceptionsAllowedBeforeBreaking <= 0) + { throw new ArgumentOutOfRangeException(nameof(exceptionsAllowedBeforeBreaking), "Value must be greater than zero."); + } + if (durationOfBreak < TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(durationOfBreak), "Value must be greater than zero."); + } if (onBreak == null) + { throw new ArgumentNullException(nameof(onBreak)); + } + if (onReset == null) + { throw new ArgumentNullException(nameof(onReset)); + } + if (onHalfOpen == null) + { throw new ArgumentNullException(nameof(onHalfOpen)); + } var breakerController = new ConsecutiveCountCircuitController( exceptionsAllowedBeforeBreaking, diff --git a/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs b/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs index 885777e73d..08b164941b 100644 --- a/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs +++ b/src/Polly/CircuitBreaker/AsyncCircuitBreakerTResultSyntax.cs @@ -194,16 +194,29 @@ public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(th public static AsyncCircuitBreakerPolicy CircuitBreakerAsync(this PolicyBuilder policyBuilder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action, CircuitState, TimeSpan, Context> onBreak, Action onReset, Action onHalfOpen) { if (handledEventsAllowedBeforeBreaking <= 0) + { throw new ArgumentOutOfRangeException(nameof(handledEventsAllowedBeforeBreaking), "Value must be greater than zero."); + } + if (durationOfBreak < TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(durationOfBreak), "Value must be greater than zero."); + } if (onBreak == null) + { throw new ArgumentNullException(nameof(onBreak)); + } + if (onReset == null) + { throw new ArgumentNullException(nameof(onReset)); + } + if (onHalfOpen == null) + { throw new ArgumentNullException(nameof(onHalfOpen)); + } var breakerController = new ConsecutiveCountCircuitController( handledEventsAllowedBeforeBreaking, diff --git a/src/Polly/CircuitBreaker/CircuitBreakerSyntax.cs b/src/Polly/CircuitBreaker/CircuitBreakerSyntax.cs index df960a15a1..aa8a4afe31 100644 --- a/src/Polly/CircuitBreaker/CircuitBreakerSyntax.cs +++ b/src/Polly/CircuitBreaker/CircuitBreakerSyntax.cs @@ -187,16 +187,29 @@ public static CircuitBreakerPolicy CircuitBreaker(this PolicyBuilder policyBuild public static CircuitBreakerPolicy CircuitBreaker(this PolicyBuilder policyBuilder, int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action onBreak, Action onReset, Action onHalfOpen) { if (exceptionsAllowedBeforeBreaking <= 0) + { throw new ArgumentOutOfRangeException(nameof(exceptionsAllowedBeforeBreaking), "Value must be greater than zero."); + } + if (durationOfBreak < TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(durationOfBreak), "Value must be greater than zero."); + } if (onBreak == null) + { throw new ArgumentNullException(nameof(onBreak)); + } + if (onReset == null) + { throw new ArgumentNullException(nameof(onReset)); + } + if (onHalfOpen == null) + { throw new ArgumentNullException(nameof(onHalfOpen)); + } var breakerController = new ConsecutiveCountCircuitController( exceptionsAllowedBeforeBreaking, diff --git a/src/Polly/CircuitBreaker/CircuitBreakerTResultSyntax.cs b/src/Polly/CircuitBreaker/CircuitBreakerTResultSyntax.cs index b001aa2db5..6cdfde61ff 100644 --- a/src/Polly/CircuitBreaker/CircuitBreakerTResultSyntax.cs +++ b/src/Polly/CircuitBreaker/CircuitBreakerTResultSyntax.cs @@ -193,16 +193,29 @@ public static CircuitBreakerPolicy CircuitBreaker(this PolicyB public static CircuitBreakerPolicy CircuitBreaker(this PolicyBuilder policyBuilder, int handledEventsAllowedBeforeBreaking, TimeSpan durationOfBreak, Action, CircuitState, TimeSpan, Context> onBreak, Action onReset, Action onHalfOpen) { if (handledEventsAllowedBeforeBreaking <= 0) + { throw new ArgumentOutOfRangeException(nameof(handledEventsAllowedBeforeBreaking), "Value must be greater than zero."); + } + if (durationOfBreak < TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(durationOfBreak), "Value must be greater than zero."); + } if (onBreak == null) + { throw new ArgumentNullException(nameof(onBreak)); + } + if (onReset == null) + { throw new ArgumentNullException(nameof(onReset)); + } + if (onHalfOpen == null) + { throw new ArgumentNullException(nameof(onHalfOpen)); + } ICircuitController breakerController = new ConsecutiveCountCircuitController( handledEventsAllowedBeforeBreaking, diff --git a/src/Polly/CircuitBreaker/RollingHealthMetrics.cs b/src/Polly/CircuitBreaker/RollingHealthMetrics.cs index 2117d3f8a6..167da0065f 100644 --- a/src/Polly/CircuitBreaker/RollingHealthMetrics.cs +++ b/src/Polly/CircuitBreaker/RollingHealthMetrics.cs @@ -70,8 +70,10 @@ private HealthCount ActualiseCurrentMetric_NeedsLock() } while (_windows.Count > 0 && now - _windows.Peek().StartedAt >= _samplingDuration) + { _windows.Dequeue(); + } return _currentWindow; } -} \ No newline at end of file +} diff --git a/src/Polly/Context.Dictionary.cs b/src/Polly/Context.Dictionary.cs index ff2c091d96..bbff2d05ed 100644 --- a/src/Polly/Context.Dictionary.cs +++ b/src/Polly/Context.Dictionary.cs @@ -26,7 +26,10 @@ internal Context(IDictionary contextData) : this() { if (contextData == null) + { throw new ArgumentNullException(nameof(contextData)); + } + wrappedDictionary = new Dictionary(contextData); } diff --git a/src/Polly/Fallback/AsyncFallbackSyntax.cs b/src/Polly/Fallback/AsyncFallbackSyntax.cs index d0b4cc9de9..6cc8dd5f0a 100644 --- a/src/Polly/Fallback/AsyncFallbackSyntax.cs +++ b/src/Polly/Fallback/AsyncFallbackSyntax.cs @@ -17,7 +17,9 @@ public static class AsyncFallbackSyntax public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func fallbackAction) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } Func doNothing = _ => TaskHelper.EmptyTask; return policyBuilder.FallbackAsync( @@ -37,9 +39,14 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func fallbackAction, Func onFallbackAsync) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallbackAsync == null) + { throw new ArgumentNullException(nameof(onFallbackAsync)); + } return policyBuilder.FallbackAsync( (_, _, ct) => fallbackAction(ct), @@ -58,9 +65,14 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func fallbackAction, Func onFallbackAsync) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallbackAsync == null) + { throw new ArgumentNullException(nameof(onFallbackAsync)); + } return policyBuilder.FallbackAsync((_, ctx, ct) => fallbackAction(ctx, ct), onFallbackAsync); } @@ -77,9 +89,14 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func fallbackAction, Func onFallbackAsync) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallbackAsync == null) + { throw new ArgumentNullException(nameof(onFallbackAsync)); + } return new AsyncFallbackPolicy(policyBuilder, onFallbackAsync, fallbackAction); } @@ -116,7 +133,9 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func> fallbackAction) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } Func, Task> doNothing = _ => TaskHelper.EmptyTask; return policyBuilder.FallbackAsync( @@ -136,7 +155,9 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, TResult fallbackValue, Func, Task> onFallbackAsync) { if (onFallbackAsync == null) + { throw new ArgumentNullException(nameof(onFallbackAsync)); + } return policyBuilder.FallbackAsync( (_, _, _) => Task.FromResult(fallbackValue), @@ -156,9 +177,14 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func> fallbackAction, Func, Task> onFallbackAsync) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallbackAsync == null) + { throw new ArgumentNullException(nameof(onFallbackAsync)); + } return policyBuilder.FallbackAsync( (_, _, ct) => fallbackAction(ct), @@ -177,7 +203,9 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, TResult fallbackValue, Func, Context, Task> onFallbackAsync) { if (onFallbackAsync == null) + { throw new ArgumentNullException(nameof(onFallbackAsync)); + } return policyBuilder.FallbackAsync( (_, _, _) => Task.FromResult(fallbackValue), @@ -197,9 +225,14 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func> fallbackAction, Func, Context, Task> onFallbackAsync) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallbackAsync == null) + { throw new ArgumentNullException(nameof(onFallbackAsync)); + } return policyBuilder.FallbackAsync((_, ctx, ct) => fallbackAction(ctx, ct), onFallbackAsync); } @@ -217,9 +250,14 @@ public static AsyncFallbackPolicy FallbackAsync(this PolicyBui public static AsyncFallbackPolicy FallbackAsync(this PolicyBuilder policyBuilder, Func, Context, CancellationToken, Task> fallbackAction, Func, Context, Task> onFallbackAsync) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallbackAsync == null) + { throw new ArgumentNullException(nameof(onFallbackAsync)); + } return new AsyncFallbackPolicy( policyBuilder, diff --git a/src/Polly/Fallback/FallbackSyntax.cs b/src/Polly/Fallback/FallbackSyntax.cs index 91143eaa60..f93ccba6cc 100644 --- a/src/Polly/Fallback/FallbackSyntax.cs +++ b/src/Polly/Fallback/FallbackSyntax.cs @@ -17,7 +17,9 @@ public static class FallbackSyntax public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action fallbackAction) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } Action doNothing = _ => { }; return policyBuilder.Fallback(fallbackAction, doNothing); @@ -33,7 +35,9 @@ public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action f public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action fallbackAction) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } Action doNothing = _ => { }; return policyBuilder.Fallback(fallbackAction, doNothing); @@ -51,9 +55,14 @@ public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action onFallback) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return policyBuilder.Fallback((_, _, _) => fallbackAction(), (exception, _) => onFallback(exception)); } @@ -70,9 +79,14 @@ public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action f public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action fallbackAction, Action onFallback) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return policyBuilder.Fallback((_, _, ct) => fallbackAction(ct), (exception, _) => onFallback(exception)); } @@ -89,9 +103,14 @@ public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action fallbackAction, Action onFallback) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return policyBuilder.Fallback((_, ctx, _) => fallbackAction(ctx), onFallback); } @@ -108,9 +127,14 @@ public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action fallbackAction, Action onFallback) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return policyBuilder.Fallback((_, ctx, ct) => fallbackAction(ctx, ct), onFallback); } @@ -127,9 +151,14 @@ public static FallbackPolicy Fallback(this PolicyBuilder policyBuilder, Action fallbackAction, Action onFallback) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return new FallbackPolicy( policyBuilder, @@ -167,7 +196,9 @@ public static FallbackPolicy Fallback(this PolicyBuilder Fallback(this PolicyBuilder policyBuilder, Func fallbackAction) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } Action> doNothing = _ => { }; return policyBuilder.Fallback(fallbackAction, doNothing); @@ -184,7 +215,9 @@ public static FallbackPolicy Fallback(this PolicyBuilder Fallback(this PolicyBuilder policyBuilder, Func fallbackAction) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } Action> doNothing = _ => { }; return policyBuilder.Fallback(fallbackAction, doNothing); @@ -202,7 +235,9 @@ public static FallbackPolicy Fallback(this PolicyBuilder Fallback(this PolicyBuilder policyBuilder, TResult fallbackValue, Action> onFallback) { if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return policyBuilder.Fallback((_, _, _) => fallbackValue, (outcome, _) => onFallback(outcome)); } @@ -220,9 +255,14 @@ public static FallbackPolicy Fallback(this PolicyBuilder Fallback(this PolicyBuilder policyBuilder, Func fallbackAction, Action> onFallback) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return policyBuilder.Fallback((_, _, _) => fallbackAction(), (outcome, _) => onFallback(outcome)); } @@ -240,9 +280,14 @@ public static FallbackPolicy Fallback(this PolicyBuilder Fallback(this PolicyBuilder policyBuilder, Func fallbackAction, Action> onFallback) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return policyBuilder.Fallback((_, _, ct) => fallbackAction(ct), (outcome, _) => onFallback(outcome)); } @@ -259,7 +304,9 @@ public static FallbackPolicy Fallback(this PolicyBuilder Fallback(this PolicyBuilder policyBuilder, TResult fallbackValue, Action, Context> onFallback) { if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return policyBuilder.Fallback((_, _, _) => fallbackValue, onFallback); } @@ -277,9 +324,14 @@ public static FallbackPolicy Fallback(this PolicyBuilder Fallback(this PolicyBuilder policyBuilder, Func fallbackAction, Action, Context> onFallback) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return policyBuilder.Fallback((_, ctx, _) => fallbackAction(ctx), onFallback); } @@ -297,9 +349,14 @@ public static FallbackPolicy Fallback(this PolicyBuilder Fallback(this PolicyBuilder policyBuilder, Func fallbackAction, Action, Context> onFallback) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return policyBuilder.Fallback((_, ctx, ct) => fallbackAction(ctx, ct), onFallback); } @@ -317,9 +374,14 @@ public static FallbackPolicy Fallback(this PolicyBuilder Fallback(this PolicyBuilder policyBuilder, Func, Context, CancellationToken, TResult> fallbackAction, Action, Context> onFallback) { if (fallbackAction == null) + { throw new ArgumentNullException(nameof(fallbackAction)); + } + if (onFallback == null) + { throw new ArgumentNullException(nameof(onFallback)); + } return new FallbackPolicy( policyBuilder, diff --git a/src/Polly/Policy.ContextAndKeys.cs b/src/Polly/Policy.ContextAndKeys.cs index f1fbbc18eb..cc68f5768d 100644 --- a/src/Polly/Policy.ContextAndKeys.cs +++ b/src/Polly/Policy.ContextAndKeys.cs @@ -10,7 +10,9 @@ public abstract partial class Policy public Policy WithPolicyKey(string policyKey) { if (policyKeyInternal != null) + { throw PolicyKeyMustBeImmutableException(nameof(policyKey)); + } policyKeyInternal = policyKey; return this; @@ -24,7 +26,9 @@ public Policy WithPolicyKey(string policyKey) ISyncPolicy ISyncPolicy.WithPolicyKey(string policyKey) { if (policyKeyInternal != null) + { throw PolicyKeyMustBeImmutableException(nameof(policyKey)); + } policyKeyInternal = policyKey; return this; @@ -41,7 +45,9 @@ public abstract partial class Policy public Policy WithPolicyKey(string policyKey) { if (policyKeyInternal != null) + { throw PolicyKeyMustBeImmutableException(nameof(policyKey)); + } policyKeyInternal = policyKey; return this; @@ -55,7 +61,9 @@ public Policy WithPolicyKey(string policyKey) ISyncPolicy ISyncPolicy.WithPolicyKey(string policyKey) { if (policyKeyInternal != null) + { throw PolicyKeyMustBeImmutableException(nameof(policyKey)); + } policyKeyInternal = policyKey; return this; diff --git a/src/Polly/Policy.ExecuteOverloads.cs b/src/Polly/Policy.ExecuteOverloads.cs index c4828d63f8..ce9e1ef6fa 100644 --- a/src/Polly/Policy.ExecuteOverloads.cs +++ b/src/Polly/Policy.ExecuteOverloads.cs @@ -60,7 +60,9 @@ public void Execute(Action action, IDictionary action, Context context, CancellationToken cancellationToken) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } SetPolicyContext(context, out string priorPolicyWrapKey, out string priorPolicyKey); @@ -146,7 +148,9 @@ public TResult Execute(Func action public TResult Execute(Func action, Context context, CancellationToken cancellationToken) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } SetPolicyContext(context, out string priorPolicyWrapKey, out string priorPolicyKey); @@ -229,7 +233,9 @@ public PolicyResult ExecuteAndCapture(Action action, public PolicyResult ExecuteAndCapture(Action action, Context context, CancellationToken cancellationToken) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } try { @@ -313,7 +319,9 @@ public PolicyResult ExecuteAndCapture(Func ExecuteAndCapture(Func action, Context context, CancellationToken cancellationToken) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } try { diff --git a/src/Polly/Policy.TResult.ExecuteOverloads.cs b/src/Polly/Policy.TResult.ExecuteOverloads.cs index 1aaa40a0cb..7050636310 100644 --- a/src/Polly/Policy.TResult.ExecuteOverloads.cs +++ b/src/Polly/Policy.TResult.ExecuteOverloads.cs @@ -68,7 +68,9 @@ public TResult Execute(Func action, IDictio public TResult Execute(Func action, Context context, CancellationToken cancellationToken) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } SetPolicyContext(context, out string priorPolicyWrapKey, out string priorPolicyKey); @@ -150,7 +152,9 @@ public PolicyResult ExecuteAndCapture(Func ExecuteAndCapture(Func action, Context context, CancellationToken cancellationToken) { if (context == null) + { throw new ArgumentNullException(nameof(context)); + } try { diff --git a/src/Polly/PolicyBuilder.OrSyntax.cs b/src/Polly/PolicyBuilder.OrSyntax.cs index 27ce21e8cd..5d493c5aac 100644 --- a/src/Polly/PolicyBuilder.OrSyntax.cs +++ b/src/Polly/PolicyBuilder.OrSyntax.cs @@ -64,7 +64,9 @@ internal static ExceptionPredicate HandleInner(Func predicate) { var matchedInAggregate = HandleInnerNested(predicate, innerException); if (matchedInAggregate != null) + { return matchedInAggregate; + } } } @@ -74,9 +76,14 @@ internal static ExceptionPredicate HandleInner(Func predicate) private static Exception HandleInnerNested(Func predicate, Exception current) { if (current == null) + { return null; + } + if (predicate(current)) + { return current; + } return HandleInnerNested(predicate, current.InnerException); } diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj index ef9bae12f9..891435d154 100644 --- a/src/Polly/Polly.csproj +++ b/src/Polly/Polly.csproj @@ -7,7 +7,7 @@ Library 70 true - $(NoWarn);IDE0011;S103;S3872;SA1402;SA1414;S3215 + $(NoWarn);S103;S3872;SA1402;SA1414;S3215 $(NoWarn);IDE1006;CA1062;S107;CA1068;S4039;CA1000;CA1063;CA1031;CA1051 $(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;CA1033 $(NoWarn);S4023;CA1010;S3442;CA1064;SA1649;SA1625;SA1623;SA1118 diff --git a/src/Polly/Polly.sln b/src/Polly/Polly.sln new file mode 100644 index 0000000000..cad27950ce --- /dev/null +++ b/src/Polly/Polly.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly", "Polly.csproj", "{1ABD065C-AE2F-4100-AFDB-68C4ABB52DCD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1ABD065C-AE2F-4100-AFDB-68C4ABB52DCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1ABD065C-AE2F-4100-AFDB-68C4ABB52DCD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1ABD065C-AE2F-4100-AFDB-68C4ABB52DCD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1ABD065C-AE2F-4100-AFDB-68C4ABB52DCD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D7A84C62-5D94-4AF0-8209-D648FCDBCA31} + EndGlobalSection +EndGlobal diff --git a/src/Polly/RateLimit/AsyncRateLimitSyntax.cs b/src/Polly/RateLimit/AsyncRateLimitSyntax.cs index 7901f7524c..0a28bc5861 100644 --- a/src/Polly/RateLimit/AsyncRateLimitSyntax.cs +++ b/src/Polly/RateLimit/AsyncRateLimitSyntax.cs @@ -29,11 +29,19 @@ public static AsyncRateLimitPolicy RateLimitAsync( int maxBurst) { if (numberOfExecutions < 1) + { throw new ArgumentOutOfRangeException(nameof(numberOfExecutions), numberOfExecutions, $"{nameof(numberOfExecutions)} per timespan must be an integer greater than or equal to 1."); + } + if (perTimeSpan <= TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(perTimeSpan), perTimeSpan, $"{nameof(perTimeSpan)} must be a positive timespan."); + } + if (maxBurst < 1) + { throw new ArgumentOutOfRangeException(nameof(maxBurst), maxBurst, $"{nameof(maxBurst)} must be an integer greater than or equal to 1."); + } var onePer = TimeSpan.FromTicks(perTimeSpan.Ticks / numberOfExecutions); diff --git a/src/Polly/RateLimit/AsyncRateLimitTResultSyntax.cs b/src/Polly/RateLimit/AsyncRateLimitTResultSyntax.cs index b1f92e9aaf..baf5c3cf05 100644 --- a/src/Polly/RateLimit/AsyncRateLimitTResultSyntax.cs +++ b/src/Polly/RateLimit/AsyncRateLimitTResultSyntax.cs @@ -65,11 +65,19 @@ public static AsyncRateLimitPolicy RateLimitAsync( Func? retryAfterFactory) { if (numberOfExecutions < 1) + { throw new ArgumentOutOfRangeException(nameof(numberOfExecutions), numberOfExecutions, $"{nameof(numberOfExecutions)} per timespan must be an integer greater than or equal to 1."); + } + if (perTimeSpan <= TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(perTimeSpan), perTimeSpan, $"{nameof(perTimeSpan)} must be a positive timespan."); + } + if (maxBurst < 1) + { throw new ArgumentOutOfRangeException(nameof(maxBurst), maxBurst, $"{nameof(maxBurst)} must be an integer greater than or equal to 1."); + } var onePer = TimeSpan.FromTicks(perTimeSpan.Ticks / numberOfExecutions); diff --git a/src/Polly/RateLimit/LockFreeTokenBucketRateLimiter.cs b/src/Polly/RateLimit/LockFreeTokenBucketRateLimiter.cs index 22057a9a05..bb2ab0829e 100644 --- a/src/Polly/RateLimit/LockFreeTokenBucketRateLimiter.cs +++ b/src/Polly/RateLimit/LockFreeTokenBucketRateLimiter.cs @@ -28,9 +28,14 @@ internal sealed class LockFreeTokenBucketRateLimiter : IRateLimiter public LockFreeTokenBucketRateLimiter(TimeSpan onePer, long bucketCapacity) { if (onePer <= TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(onePer), onePer, $"The {nameof(LockFreeTokenBucketRateLimiter)} must specify a positive TimeSpan for how often an execution is permitted."); + } + if (bucketCapacity <= 0) + { throw new ArgumentOutOfRangeException(nameof(bucketCapacity), bucketCapacity, $"{nameof(bucketCapacity)} must be greater than or equal to 1."); + } addTokenTickInterval = onePer.Ticks; this.bucketCapacity = bucketCapacity; diff --git a/src/Polly/RateLimit/RateLimitRejectedException.cs b/src/Polly/RateLimit/RateLimitRejectedException.cs index ec85760f6e..a1524edf27 100644 --- a/src/Polly/RateLimit/RateLimitRejectedException.cs +++ b/src/Polly/RateLimit/RateLimitRejectedException.cs @@ -61,7 +61,10 @@ private static string DefaultMessage(TimeSpan retryAfter) => private void SetRetryAfter(TimeSpan retryAfter) { if (retryAfter < TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(retryAfter), retryAfter, $"The {nameof(retryAfter)} parameter must be a TimeSpan greater than or equal to TimeSpan.Zero."); + } + RetryAfter = retryAfter; } diff --git a/src/Polly/RateLimit/RateLimitSyntax.cs b/src/Polly/RateLimit/RateLimitSyntax.cs index 8da7ec127e..26b27c096a 100644 --- a/src/Polly/RateLimit/RateLimitSyntax.cs +++ b/src/Polly/RateLimit/RateLimitSyntax.cs @@ -29,11 +29,19 @@ public static RateLimitPolicy RateLimit( int maxBurst) { if (numberOfExecutions < 1) + { throw new ArgumentOutOfRangeException(nameof(numberOfExecutions), numberOfExecutions, $"{nameof(numberOfExecutions)} per timespan must be an integer greater than or equal to 1."); + } + if (perTimeSpan <= TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(perTimeSpan), perTimeSpan, $"{nameof(perTimeSpan)} must be a positive timespan."); + } + if (maxBurst < 1) + { throw new ArgumentOutOfRangeException(nameof(maxBurst), maxBurst, $"{nameof(maxBurst)} must be an integer greater than or equal to 1."); + } var onePer = TimeSpan.FromTicks(perTimeSpan.Ticks / numberOfExecutions); diff --git a/src/Polly/RateLimit/RateLimitTResultSyntax.cs b/src/Polly/RateLimit/RateLimitTResultSyntax.cs index 67fc8fb5d0..c2d5e9867c 100644 --- a/src/Polly/RateLimit/RateLimitTResultSyntax.cs +++ b/src/Polly/RateLimit/RateLimitTResultSyntax.cs @@ -65,11 +65,19 @@ public static RateLimitPolicy RateLimit( Func? retryAfterFactory) { if (numberOfExecutions < 1) + { throw new ArgumentOutOfRangeException(nameof(numberOfExecutions), numberOfExecutions, $"{nameof(numberOfExecutions)} per timespan must be an integer greater than or equal to 1."); + } + if (perTimeSpan <= TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(perTimeSpan), perTimeSpan, $"{nameof(perTimeSpan)} must be a positive timespan."); + } + if (maxBurst < 1) + { throw new ArgumentOutOfRangeException(nameof(maxBurst), maxBurst, $"{nameof(maxBurst)} must be an integer greater than or equal to 1."); + } var onePer = TimeSpan.FromTicks(perTimeSpan.Ticks / numberOfExecutions); diff --git a/src/Polly/ResultPredicates.cs b/src/Polly/ResultPredicates.cs index 63b02ddec3..ed98c3b317 100644 --- a/src/Polly/ResultPredicates.cs +++ b/src/Polly/ResultPredicates.cs @@ -22,7 +22,9 @@ internal void Add(ResultPredicate predicate) public bool AnyMatch(TResult result) { if (_predicates == null) + { return false; + } return _predicates.Any(predicate => predicate(result)); } diff --git a/src/Polly/Retry/AsyncRetrySyntax.cs b/src/Polly/Retry/AsyncRetrySyntax.cs index 7cbb1d0607..8f7d13651e 100644 --- a/src/Polly/Retry/AsyncRetrySyntax.cs +++ b/src/Polly/Retry/AsyncRetrySyntax.cs @@ -64,7 +64,9 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, Func public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryAsync(retryCount, onRetryAsync: async (outcome, i, _) => onRetry(outcome, i)); @@ -84,7 +86,9 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.RetryAsync(retryCount, onRetryAsync: (outcome, i, _) => onRetryAsync(outcome, i)); } @@ -124,7 +128,9 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, Func public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryAsync(retryCount, @@ -145,9 +151,14 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func onRetryAsync) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -178,7 +189,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryForeverAsync( @@ -197,7 +210,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryForeverAsync( @@ -216,7 +231,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.RetryForeverAsync(onRetryAsync: (Exception outcome, Context _) => onRetryAsync(outcome)); } @@ -232,7 +249,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.RetryForeverAsync(onRetryAsync: (outcome, i, _) => onRetryAsync(outcome, i)); } @@ -248,7 +267,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryForeverAsync( @@ -267,7 +288,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryForeverAsync( @@ -286,7 +309,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -304,7 +329,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -343,7 +370,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -369,7 +398,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Func onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -396,7 +427,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde Func sleepDurationProvider, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -423,7 +456,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde Func sleepDurationProvider, Func onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryAsync( retryCount, @@ -447,7 +482,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -474,11 +511,19 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde Func sleepDurationProvider, Func onRetryAsync) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } IEnumerable sleepDurations = Enumerable.Range(1, retryCount) .Select(sleepDurationProvider); @@ -507,7 +552,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde Func sleepDurationProvider, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -534,7 +581,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde Func sleepDurationProvider, Func onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryAsync( retryCount, @@ -558,7 +607,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -585,7 +636,10 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde Func sleepDurationProvider, Func onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + return policyBuilder.WaitAndRetryAsync( retryCount, (i, _, ctx) => sleepDurationProvider(i, ctx), @@ -609,11 +663,19 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde Func sleepDurationProvider, Func onRetryAsync) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -651,7 +713,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -674,7 +738,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Func onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryAsync( sleepDurations, @@ -695,7 +761,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -718,7 +786,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Func onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryAsync( sleepDurations, @@ -739,7 +809,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -762,9 +834,14 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Func onRetryAsync) { if (sleepDurations == null) + { throw new ArgumentNullException(nameof(sleepDurations)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -784,7 +861,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilde public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } Action doNothing = (_, _) => { }; @@ -803,7 +882,9 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } Action doNothing = (_, _, _) => { }; @@ -825,9 +906,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetryForeverAsync( (retryCount, _) => sleepDurationProvider(retryCount), @@ -849,9 +935,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetryForeverAsync( (retryCount, _) => sleepDurationProvider(retryCount), @@ -873,9 +964,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Func onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryForeverAsync( (retryCount, _) => sleepDurationProvider(retryCount), @@ -897,9 +993,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Func onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryForeverAsync( (retryCount, _) => sleepDurationProvider(retryCount), @@ -921,9 +1022,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryForeverAsync( @@ -947,9 +1053,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryForeverAsync( @@ -973,7 +1084,9 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Func onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } return policyBuilder.WaitAndRetryForeverAsync( (i, _, ctx) => sleepDurationProvider(i, ctx), @@ -995,7 +1108,9 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Func onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } return policyBuilder.WaitAndRetryForeverAsync( (i, _, ctx) => sleepDurationProvider(i, ctx), @@ -1017,9 +1132,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Func onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -1042,9 +1162,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder polic public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Func onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, diff --git a/src/Polly/Retry/AsyncRetryTResultSyntax.cs b/src/Polly/Retry/AsyncRetryTResultSyntax.cs index 5d5a8ba922..799e3b3ee8 100644 --- a/src/Polly/Retry/AsyncRetryTResultSyntax.cs +++ b/src/Polly/Retry/AsyncRetryTResultSyntax.cs @@ -68,7 +68,9 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Action, int> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryAsync(retryCount, @@ -90,7 +92,9 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func, int, Task> onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.RetryAsync(retryCount, onRetryAsync: (outcome, i, _) => onRetryAsync(outcome, i)); } @@ -133,7 +137,9 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Action, int, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryAsync(retryCount, @@ -155,9 +161,14 @@ public static AsyncRetryPolicy RetryAsync(this PolicyBuilder RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func, int, Context, Task> onRetryAsync) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -190,7 +201,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryForeverAsync( @@ -210,7 +223,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action, int> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryForeverAsync( @@ -230,7 +245,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func, Task> onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.RetryForeverAsync(onRetryAsync: (DelegateResult outcome, Context _) => onRetryAsync(outcome)); } @@ -247,7 +264,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func, int, Task> onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.RetryForeverAsync(onRetryAsync: (outcome, i, _) => onRetryAsync(outcome, i)); } @@ -264,7 +283,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryForeverAsync( @@ -284,7 +305,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action, int, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.RetryForeverAsync( @@ -304,7 +327,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func, Context, Task> onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -323,7 +348,9 @@ public static AsyncRetryPolicy RetryForeverAsync(this PolicyBu public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func, int, Context, Task> onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -365,7 +392,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu Func sleepDurationProvider, Action, TimeSpan> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -392,7 +421,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Func, TimeSpan, Task> onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -420,7 +451,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu Func sleepDurationProvider, Action, TimeSpan, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -447,7 +480,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Func, TimeSpan, Context, Task> onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryAsync( retryCount, @@ -472,7 +507,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action, TimeSpan, int, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -500,11 +537,19 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu Func sleepDurationProvider, Func, TimeSpan, int, Context, Task> onRetryAsync) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } IEnumerable sleepDurations = Enumerable.Range(1, retryCount) .Select(sleepDurationProvider); @@ -534,7 +579,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu Func sleepDurationProvider, Action, TimeSpan, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -561,7 +608,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Func, TimeSpan, Context, Task> onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryAsync( retryCount, @@ -586,7 +635,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action, TimeSpan, int, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -614,7 +665,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu Func sleepDurationProvider, Func, TimeSpan, int, Context, Task> onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } return policyBuilder.WaitAndRetryAsync( retryCount, @@ -640,11 +693,19 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu Func, Context, TimeSpan> sleepDurationProvider, Func, TimeSpan, int, Context, Task> onRetryAsync) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -684,7 +745,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action, TimeSpan> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -708,7 +771,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Func, TimeSpan, Task> onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryAsync( sleepDurations, @@ -730,7 +795,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action, TimeSpan, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -754,7 +821,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Func, TimeSpan, Context, Task> onRetryAsync) { if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryAsync( sleepDurations, @@ -776,7 +845,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action, TimeSpan, int, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryAsync( @@ -800,9 +871,14 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Func, TimeSpan, int, Context, Task> onRetryAsync) { if (sleepDurations == null) + { throw new ArgumentNullException(nameof(sleepDurations)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -823,7 +899,9 @@ public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBu public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } Action, TimeSpan> doNothing = (_, _) => { }; @@ -843,7 +921,9 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } Action, TimeSpan, Context> doNothing = (_, _, _) => { }; @@ -866,9 +946,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action, TimeSpan> onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetryForeverAsync( (retryCount, _) => sleepDurationProvider(retryCount), @@ -891,9 +976,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action, int, TimeSpan> onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetryForeverAsync( (retryCount, _) => sleepDurationProvider(retryCount), @@ -916,9 +1006,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Func, TimeSpan, Task> onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryForeverAsync( (retryCount, _) => sleepDurationProvider(retryCount), @@ -941,9 +1036,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Func, int, TimeSpan, Task> onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return policyBuilder.WaitAndRetryForeverAsync( (retryCount, _) => sleepDurationProvider(retryCount), @@ -966,7 +1066,9 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action, TimeSpan, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryForeverAsync( @@ -991,7 +1093,9 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action, int, TimeSpan, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } #pragma warning disable 1998 // async method has no awaits, will run synchronously return policyBuilder.WaitAndRetryForeverAsync( @@ -1016,7 +1120,9 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Func, TimeSpan, Context, Task> onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } return policyBuilder.WaitAndRetryForeverAsync( (i, _, ctx) => sleepDurationProvider(i, ctx), @@ -1039,7 +1145,9 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Func, int, TimeSpan, Context, Task> onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } return policyBuilder.WaitAndRetryForeverAsync( (i, _, ctx) => sleepDurationProvider(i, ctx), @@ -1062,9 +1170,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func, Context, TimeSpan> sleepDurationProvider, Func, TimeSpan, Context, Task> onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, @@ -1088,9 +1201,14 @@ public static AsyncRetryPolicy WaitAndRetryForeverAsync(this P public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func, Context, TimeSpan> sleepDurationProvider, Func, int, TimeSpan, Context, Task> onRetryAsync) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetryAsync == null) + { throw new ArgumentNullException(nameof(onRetryAsync)); + } return new AsyncRetryPolicy( policyBuilder, diff --git a/src/Polly/Retry/RetrySyntax.cs b/src/Polly/Retry/RetrySyntax.cs index 8a371b9aa4..fb13862da0 100644 --- a/src/Polly/Retry/RetrySyntax.cs +++ b/src/Polly/Retry/RetrySyntax.cs @@ -50,9 +50,14 @@ public static RetryPolicy Retry(this PolicyBuilder policyBuilder, Action onRetry) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.Retry(retryCount, (outcome, i, _) => onRetry(outcome, i)); } @@ -81,9 +86,14 @@ public static RetryPolicy Retry(this PolicyBuilder policyBuilder, Action onRetry) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -114,7 +124,9 @@ public static RetryPolicy RetryForever(this PolicyBuilder policyBuilder) public static RetryPolicy RetryForever(this PolicyBuilder policyBuilder, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.RetryForever((Exception outcome, Context _) => onRetry(outcome)); } @@ -130,7 +142,9 @@ public static RetryPolicy RetryForever(this PolicyBuilder policyBuilder, Action< public static RetryPolicy RetryForever(this PolicyBuilder policyBuilder, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.RetryForever((outcome, i, _) => onRetry(outcome, i)); } @@ -146,7 +160,9 @@ public static RetryPolicy RetryForever(this PolicyBuilder policyBuilder, Action< public static RetryPolicy RetryForever(this PolicyBuilder policyBuilder, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -164,7 +180,9 @@ public static RetryPolicy RetryForever(this PolicyBuilder policyBuilder, Action< public static RetryPolicy RetryForever(this PolicyBuilder policyBuilder, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -203,7 +221,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetry( retryCount, @@ -227,7 +247,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetry( retryCount, @@ -251,11 +273,19 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action onRetry) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } var sleepDurations = Enumerable.Range(1, retryCount) .Select(sleepDurationProvider); @@ -299,7 +329,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetry( retryCount, @@ -323,7 +355,10 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + return policyBuilder.WaitAndRetry( retryCount, (i, _, ctx) => sleepDurationProvider(i, ctx), @@ -346,11 +381,19 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int ret public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action onRetry) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -386,7 +429,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, IEnumer public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetry(sleepDurations, (outcome, span, _, _) => onRetry(outcome, span)); } @@ -404,7 +449,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, IEnumer public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetry(sleepDurations, (outcome, span, _, ctx) => onRetry(outcome, span, ctx)); } @@ -422,9 +469,14 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, IEnumer public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action onRetry) { if (sleepDurations == null) + { throw new ArgumentNullException(nameof(sleepDurations)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -444,7 +496,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder policyBuilder, IEnumer public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } Action doNothing = (_, _) => { }; @@ -463,7 +517,9 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } Action doNothing = (_, _, _) => { }; @@ -485,9 +541,14 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetryForever( (retryCount, _) => sleepDurationProvider(retryCount), @@ -509,9 +570,14 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetryForever( (retryCount, _, _) => sleepDurationProvider(retryCount), @@ -533,7 +599,9 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } return policyBuilder.WaitAndRetryForever( (i, _, ctx) => sleepDurationProvider(i, ctx), @@ -555,7 +623,9 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } return policyBuilder.WaitAndRetryForever( (i, _, ctx) => sleepDurationProvider(i, ctx), @@ -577,9 +647,14 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -602,9 +677,14 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, diff --git a/src/Polly/Retry/RetryTResultSyntax.cs b/src/Polly/Retry/RetryTResultSyntax.cs index 3c1fbc30be..0f6e29fbd3 100644 --- a/src/Polly/Retry/RetryTResultSyntax.cs +++ b/src/Polly/Retry/RetryTResultSyntax.cs @@ -54,9 +54,14 @@ public static RetryPolicy Retry(this PolicyBuilder po public static RetryPolicy Retry(this PolicyBuilder policyBuilder, int retryCount, Action, int> onRetry) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.Retry(retryCount, (outcome, i, _) => onRetry(outcome, i)); } @@ -87,9 +92,14 @@ public static RetryPolicy Retry(this PolicyBuilder po public static RetryPolicy Retry(this PolicyBuilder policyBuilder, int retryCount, Action, int, Context> onRetry) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -122,7 +132,9 @@ public static RetryPolicy RetryForever(this PolicyBuilder RetryForever(this PolicyBuilder policyBuilder, Action> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.RetryForever((DelegateResult outcome, Context _) => onRetry(outcome)); } @@ -139,7 +151,9 @@ public static RetryPolicy RetryForever(this PolicyBuilder RetryForever(this PolicyBuilder policyBuilder, Action, int> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.RetryForever((outcome, i, _) => onRetry(outcome, i)); } @@ -156,7 +170,9 @@ public static RetryPolicy RetryForever(this PolicyBuilder RetryForever(this PolicyBuilder policyBuilder, Action, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -175,7 +191,9 @@ public static RetryPolicy RetryForever(this PolicyBuilder RetryForever(this PolicyBuilder policyBuilder, Action, int, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -216,7 +234,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action, TimeSpan> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetry( retryCount, @@ -241,7 +261,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action, TimeSpan, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetry( retryCount, @@ -266,11 +288,19 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action, TimeSpan, int, Context> onRetry) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } var sleepDurations = Enumerable.Range(1, retryCount) .Select(sleepDurationProvider); @@ -316,7 +346,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func sleepDurationProvider, Action, TimeSpan, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetry( retryCount, @@ -378,7 +410,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func, Context, TimeSpan> sleepDurationProvider, Action, TimeSpan, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetry( retryCount, @@ -403,11 +437,19 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder WaitAndRetry(this PolicyBuilder policyBuilder, int retryCount, Func, Context, TimeSpan> sleepDurationProvider, Action, TimeSpan, int, Context> onRetry) { if (retryCount < 0) + { throw new ArgumentOutOfRangeException(nameof(retryCount), "Value must be greater than or equal to zero."); + } + if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -445,7 +487,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder WaitAndRetry(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action, TimeSpan> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetry(sleepDurations, (outcome, span, _, _) => onRetry(outcome, span)); } @@ -464,7 +508,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder WaitAndRetry(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action, TimeSpan, Context> onRetry) { if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetry(sleepDurations, (outcome, span, _, ctx) => onRetry(outcome, span, ctx)); } @@ -483,9 +529,14 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder WaitAndRetry(this PolicyBuilder policyBuilder, IEnumerable sleepDurations, Action, TimeSpan, int, Context> onRetry) { if (sleepDurations == null) + { throw new ArgumentNullException(nameof(sleepDurations)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -506,7 +557,9 @@ public static RetryPolicy WaitAndRetry(this PolicyBuilder WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } Action, TimeSpan> doNothing = (_, _) => { }; @@ -526,7 +579,9 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } Action, TimeSpan, Context> doNothing = (_, _, _) => { }; @@ -549,9 +604,14 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action, TimeSpan> onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetryForever( (retryCount, _) => sleepDurationProvider(retryCount), @@ -574,9 +634,14 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action, int, TimeSpan> onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return policyBuilder.WaitAndRetryForever( (retryCount, _, _) => sleepDurationProvider(retryCount), @@ -599,7 +664,9 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action, TimeSpan, Context> onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } return policyBuilder.WaitAndRetryForever( (i, _, ctx) => sleepDurationProvider(i, ctx), @@ -622,7 +689,9 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func sleepDurationProvider, Action, int, TimeSpan, Context> onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } return policyBuilder.WaitAndRetryForever( (i, _, ctx) => sleepDurationProvider(i, ctx), @@ -645,9 +714,14 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func, Context, TimeSpan> sleepDurationProvider, Action, TimeSpan, Context> onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, @@ -671,9 +745,14 @@ public static RetryPolicy WaitAndRetryForever(this PolicyBuild public static RetryPolicy WaitAndRetryForever(this PolicyBuilder policyBuilder, Func, Context, TimeSpan> sleepDurationProvider, Action, int, TimeSpan, Context> onRetry) { if (sleepDurationProvider == null) + { throw new ArgumentNullException(nameof(sleepDurationProvider)); + } + if (onRetry == null) + { throw new ArgumentNullException(nameof(onRetry)); + } return new RetryPolicy( policyBuilder, diff --git a/src/Polly/Timeout/AsyncTimeoutSyntax.cs b/src/Polly/Timeout/AsyncTimeoutSyntax.cs index c268414569..5cb7153ac8 100644 --- a/src/Polly/Timeout/AsyncTimeoutSyntax.cs +++ b/src/Polly/Timeout/AsyncTimeoutSyntax.cs @@ -45,7 +45,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(int seconds, Func TimeSpan.FromSeconds(seconds), TimeoutStrategy.Optimistic, onTimeoutAsync); } @@ -62,9 +64,14 @@ public static AsyncTimeoutPolicy TimeoutAsync(int seconds, Func onTimeoutAsync) { if (seconds <= 0) + { throw new ArgumentOutOfRangeException(nameof(seconds)); + } + if (onTimeoutAsync == null) + { throw new ArgumentNullException(nameof(onTimeoutAsync)); + } return TimeoutAsync(_ => TimeSpan.FromSeconds(seconds), TimeoutStrategy.Optimistic, onTimeoutAsync); } @@ -99,7 +106,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(int seconds, TimeoutStrategy timeo public static AsyncTimeoutPolicy TimeoutAsync(int seconds, TimeoutStrategy timeoutStrategy, Func onTimeoutAsync) { if (seconds <= 0) + { throw new ArgumentOutOfRangeException(nameof(seconds)); + } return TimeoutAsync(_ => TimeSpan.FromSeconds(seconds), timeoutStrategy, onTimeoutAsync); } @@ -208,7 +217,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout, TimeoutStrategy public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } Func doNothingAsync = (_, _, _, _) => TaskHelper.EmptyTask; return TimeoutAsync(_ => timeoutProvider(), TimeoutStrategy.Optimistic, doNothingAsync); @@ -224,7 +235,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider) public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, TimeoutStrategy timeoutStrategy) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } Func doNothingAsync = (_, _, _, _) => TaskHelper.EmptyTask; return TimeoutAsync(_ => timeoutProvider(), timeoutStrategy, doNothingAsync); @@ -242,7 +255,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, Ti public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, Func onTimeoutAsync) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return TimeoutAsync(_ => timeoutProvider(), TimeoutStrategy.Optimistic, onTimeoutAsync); } @@ -259,7 +274,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, Fu public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, Func onTimeoutAsync) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return TimeoutAsync(_ => timeoutProvider(), TimeoutStrategy.Optimistic, onTimeoutAsync); } @@ -277,7 +294,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, Fu public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Func onTimeoutAsync) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return TimeoutAsync(_ => timeoutProvider(), timeoutStrategy, onTimeoutAsync); } @@ -295,7 +314,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, Ti public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Func onTimeoutAsync) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return TimeoutAsync(_ => timeoutProvider(), timeoutStrategy, onTimeoutAsync); } @@ -364,7 +385,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutPro public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Func onTimeoutAsync) { if (onTimeoutAsync == null) + { throw new ArgumentNullException(nameof(onTimeoutAsync)); + } return TimeoutAsync(timeoutProvider, timeoutStrategy, (ctx, timeout, task, _) => onTimeoutAsync(ctx, timeout, task)); } @@ -385,9 +408,14 @@ public static AsyncTimeoutPolicy TimeoutAsync( Func onTimeoutAsync) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } + if (onTimeoutAsync == null) + { throw new ArgumentNullException(nameof(onTimeoutAsync)); + } return new AsyncTimeoutPolicy( timeoutProvider, diff --git a/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs b/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs index ff1986a2ad..b951a31d7c 100644 --- a/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs +++ b/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs @@ -63,7 +63,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(int seconds, Fun public static AsyncTimeoutPolicy TimeoutAsync(int seconds, Func onTimeoutAsync) { if (seconds <= 0) + { throw new ArgumentOutOfRangeException(nameof(seconds)); + } return TimeoutAsync(_ => TimeSpan.FromSeconds(seconds), TimeoutStrategy.Optimistic, onTimeoutAsync); } @@ -100,7 +102,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(int seconds, Tim public static AsyncTimeoutPolicy TimeoutAsync(int seconds, TimeoutStrategy timeoutStrategy, Func onTimeoutAsync) { if (seconds <= 0) + { throw new ArgumentOutOfRangeException(nameof(seconds)); + } return TimeoutAsync(_ => TimeSpan.FromSeconds(seconds), timeoutStrategy, onTimeoutAsync); } @@ -150,7 +154,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout { TimeoutValidator.ValidateTimeSpanTimeout(timeout); if (onTimeoutAsync == null) + { throw new ArgumentNullException(nameof(onTimeoutAsync)); + } return TimeoutAsync(_ => timeout, TimeoutStrategy.Optimistic, onTimeoutAsync); } @@ -168,9 +174,14 @@ public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout, Func onTimeoutAsync) { if (timeout <= TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(timeout)); + } + if (onTimeoutAsync == null) + { throw new ArgumentNullException(nameof(onTimeoutAsync)); + } return TimeoutAsync(_ => timeout, TimeoutStrategy.Optimistic, onTimeoutAsync); } @@ -206,7 +217,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Func onTimeoutAsync) { if (timeout <= TimeSpan.Zero) + { throw new ArgumentOutOfRangeException(nameof(timeout)); + } return TimeoutAsync(_ => timeout, timeoutStrategy, onTimeoutAsync); } @@ -221,7 +234,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } Func doNothingAsync = (_, _, _, _) => Task.FromResult(default(TResult)); return TimeoutAsync(_ => timeoutProvider(), TimeoutStrategy.Optimistic, doNothingAsync); @@ -238,7 +253,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func t public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, TimeoutStrategy timeoutStrategy) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } Func doNothingAsync = (_, _, _, _) => Task.FromResult(default(TResult)); return TimeoutAsync(_ => timeoutProvider(), timeoutStrategy, doNothingAsync); @@ -257,7 +274,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func t public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, Func onTimeoutAsync) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return TimeoutAsync(_ => timeoutProvider(), TimeoutStrategy.Optimistic, onTimeoutAsync); } @@ -275,7 +294,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func t public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, Func onTimeoutAsync) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return TimeoutAsync(_ => timeoutProvider(), TimeoutStrategy.Optimistic, onTimeoutAsync); } @@ -294,7 +315,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func t public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Func onTimeoutAsync) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return TimeoutAsync(_ => timeoutProvider(), timeoutStrategy, onTimeoutAsync); } @@ -313,7 +336,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func t public static AsyncTimeoutPolicy TimeoutAsync(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Func onTimeoutAsync) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return TimeoutAsync(_ => timeoutProvider(), timeoutStrategy, onTimeoutAsync); } @@ -385,7 +410,9 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func TimeoutAsync(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Func onTimeoutAsync) { if (onTimeoutAsync == null) + { throw new ArgumentNullException(nameof(onTimeoutAsync)); + } return TimeoutAsync(timeoutProvider, timeoutStrategy, (ctx, timeout, task, _) => onTimeoutAsync(ctx, timeout, task)); } @@ -404,9 +431,14 @@ public static AsyncTimeoutPolicy TimeoutAsync(Func TimeoutAsync(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Func onTimeoutAsync) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } + if (onTimeoutAsync == null) + { throw new ArgumentNullException(nameof(onTimeoutAsync)); + } return new AsyncTimeoutPolicy( timeoutProvider, diff --git a/src/Polly/Timeout/TimeoutSyntax.cs b/src/Polly/Timeout/TimeoutSyntax.cs index e5e84ad903..11e93aef83 100644 --- a/src/Polly/Timeout/TimeoutSyntax.cs +++ b/src/Polly/Timeout/TimeoutSyntax.cs @@ -59,7 +59,9 @@ public static TimeoutPolicy Timeout(int seconds, Action public static TimeoutPolicy Timeout(int seconds, Action onTimeout) { if (seconds <= 0) + { throw new ArgumentOutOfRangeException(nameof(seconds)); + } return Timeout(_ => TimeSpan.FromSeconds(seconds), TimeoutStrategy.Optimistic, onTimeout); } @@ -94,7 +96,9 @@ public static TimeoutPolicy Timeout(int seconds, TimeoutStrategy timeoutStrategy public static TimeoutPolicy Timeout(int seconds, TimeoutStrategy timeoutStrategy, Action onTimeout) { if (seconds <= 0) + { throw new ArgumentOutOfRangeException(nameof(seconds)); + } return Timeout(_ => TimeSpan.FromSeconds(seconds), timeoutStrategy, onTimeout); } @@ -203,7 +207,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStr public static TimeoutPolicy Timeout(Func timeoutProvider) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } Action doNothing = (_, _, _, _) => { }; return Timeout(_ => timeoutProvider(), TimeoutStrategy.Optimistic, doNothing); @@ -219,7 +225,9 @@ public static TimeoutPolicy Timeout(Func timeoutProvider) public static TimeoutPolicy Timeout(Func timeoutProvider, TimeoutStrategy timeoutStrategy) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } Action doNothing = (_, _, _, _) => { }; return Timeout(_ => timeoutProvider(), timeoutStrategy, doNothing); @@ -237,7 +245,9 @@ public static TimeoutPolicy Timeout(Func timeoutProvider, TimeoutStrat public static TimeoutPolicy Timeout(Func timeoutProvider, Action onTimeout) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return Timeout(_ => timeoutProvider(), TimeoutStrategy.Optimistic, onTimeout); } @@ -254,7 +264,9 @@ public static TimeoutPolicy Timeout(Func timeoutProvider, Action timeoutProvider, Action onTimeout) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return Timeout(_ => timeoutProvider(), TimeoutStrategy.Optimistic, onTimeout); } @@ -272,7 +284,9 @@ public static TimeoutPolicy Timeout(Func timeoutProvider, Action timeoutProvider, TimeoutStrategy timeoutStrategy, Action onTimeout) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return Timeout(_ => timeoutProvider(), timeoutStrategy, onTimeout); } @@ -290,7 +304,9 @@ public static TimeoutPolicy Timeout(Func timeoutProvider, TimeoutStrat public static TimeoutPolicy Timeout(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Action onTimeout) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return Timeout(_ => timeoutProvider(), timeoutStrategy, onTimeout); } @@ -357,7 +373,9 @@ public static TimeoutPolicy Timeout(Func timeoutProvider, Act public static TimeoutPolicy Timeout(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Action onTimeout) { if (onTimeout == null) + { throw new ArgumentNullException(nameof(onTimeout)); + } return Timeout(timeoutProvider, timeoutStrategy, (ctx, timeout, task, _) => onTimeout(ctx, timeout, task)); } @@ -378,9 +396,14 @@ public static TimeoutPolicy Timeout( Action onTimeout) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } + if (onTimeout == null) + { throw new ArgumentNullException(nameof(onTimeout)); + } return new TimeoutPolicy( timeoutProvider, diff --git a/src/Polly/Timeout/TimeoutTResultSyntax.cs b/src/Polly/Timeout/TimeoutTResultSyntax.cs index cab88febc5..4bac3b4d8b 100644 --- a/src/Polly/Timeout/TimeoutTResultSyntax.cs +++ b/src/Polly/Timeout/TimeoutTResultSyntax.cs @@ -62,7 +62,9 @@ public static TimeoutPolicy Timeout(int seconds, Action Timeout(int seconds, Action onTimeout) { if (seconds <= 0) + { throw new ArgumentOutOfRangeException(nameof(seconds)); + } return Timeout(_ => TimeSpan.FromSeconds(seconds), TimeoutStrategy.Optimistic, onTimeout); } @@ -99,7 +101,9 @@ public static TimeoutPolicy Timeout(int seconds, TimeoutStrate public static TimeoutPolicy Timeout(int seconds, TimeoutStrategy timeoutStrategy, Action onTimeout) { if (seconds <= 0) + { throw new ArgumentOutOfRangeException(nameof(seconds)); + } return Timeout(_ => TimeSpan.FromSeconds(seconds), timeoutStrategy, onTimeout); } @@ -211,7 +215,9 @@ public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutS public static TimeoutPolicy Timeout(Func timeoutProvider) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } Action doNothing = (_, _, _, _) => { }; return Timeout(_ => timeoutProvider(), TimeoutStrategy.Optimistic, doNothing); @@ -228,7 +234,9 @@ public static TimeoutPolicy Timeout(Func timeoutProv public static TimeoutPolicy Timeout(Func timeoutProvider, TimeoutStrategy timeoutStrategy) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } Action doNothing = (_, _, _, _) => { }; return Timeout(_ => timeoutProvider(), timeoutStrategy, doNothing); @@ -247,7 +255,9 @@ public static TimeoutPolicy Timeout(Func timeoutProv public static TimeoutPolicy Timeout(Func timeoutProvider, Action onTimeout) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return Timeout(_ => timeoutProvider(), TimeoutStrategy.Optimistic, onTimeout); } @@ -265,7 +275,9 @@ public static TimeoutPolicy Timeout(Func timeoutProv public static TimeoutPolicy Timeout(Func timeoutProvider, Action onTimeout) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return Timeout(_ => timeoutProvider(), TimeoutStrategy.Optimistic, onTimeout); } @@ -284,7 +296,9 @@ public static TimeoutPolicy Timeout(Func timeoutProv public static TimeoutPolicy Timeout(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Action onTimeout) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return Timeout(_ => timeoutProvider(), timeoutStrategy, onTimeout); } @@ -303,7 +317,9 @@ public static TimeoutPolicy Timeout(Func timeoutProv public static TimeoutPolicy Timeout(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Action onTimeout) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } return Timeout(_ => timeoutProvider(), timeoutStrategy, onTimeout); } @@ -375,7 +391,9 @@ public static TimeoutPolicy Timeout(Func ti public static TimeoutPolicy Timeout(Func timeoutProvider, TimeoutStrategy timeoutStrategy, Action onTimeout) { if (onTimeout == null) + { throw new ArgumentNullException(nameof(onTimeout)); + } return Timeout(timeoutProvider, timeoutStrategy, (ctx, timeout, task, _) => onTimeout(ctx, timeout, task)); } @@ -397,9 +415,14 @@ public static TimeoutPolicy Timeout( Action onTimeout) { if (timeoutProvider == null) + { throw new ArgumentNullException(nameof(timeoutProvider)); + } + if (onTimeout == null) + { throw new ArgumentNullException(nameof(onTimeout)); + } return new TimeoutPolicy( timeoutProvider, diff --git a/src/Polly/Timeout/TimeoutValidator.cs b/src/Polly/Timeout/TimeoutValidator.cs index d240e983e4..ef0747eb98 100644 --- a/src/Polly/Timeout/TimeoutValidator.cs +++ b/src/Polly/Timeout/TimeoutValidator.cs @@ -5,7 +5,9 @@ internal static class TimeoutValidator internal static void ValidateSecondsTimeout(int seconds) { if (seconds <= 0) + { throw new ArgumentOutOfRangeException(nameof(seconds)); + } } internal static void ValidateTimeSpanTimeout(TimeSpan timeout) diff --git a/src/Polly/Utilities/SystemClock.cs b/src/Polly/Utilities/SystemClock.cs index 11a6c87143..abcadc847e 100644 --- a/src/Polly/Utilities/SystemClock.cs +++ b/src/Polly/Utilities/SystemClock.cs @@ -13,7 +13,9 @@ public static class SystemClock public static Action Sleep = (timeSpan, cancellationToken) => { if (cancellationToken.WaitHandle.WaitOne(timeSpan)) + { cancellationToken.ThrowIfCancellationRequested(); + } }; /// @@ -49,7 +51,9 @@ public static void Reset() Sleep = (timeSpan, cancellationToken) => { if (cancellationToken.WaitHandle.WaitOne(timeSpan)) + { cancellationToken.ThrowIfCancellationRequested(); + } }; SleepAsync = Task.Delay; diff --git a/src/Polly/Wrap/AsyncPolicyWrap.ContextAndKeys.cs b/src/Polly/Wrap/AsyncPolicyWrap.ContextAndKeys.cs index e8f62be902..55c3e43523 100644 --- a/src/Polly/Wrap/AsyncPolicyWrap.ContextAndKeys.cs +++ b/src/Polly/Wrap/AsyncPolicyWrap.ContextAndKeys.cs @@ -14,7 +14,9 @@ internal override void SetPolicyContext(Context executionContext, out string pri priorPolicyKey = executionContext.PolicyKey; if (executionContext.PolicyWrapKey == null) + { executionContext.PolicyWrapKey = PolicyKey; + } base.SetPolicyContext(executionContext, out _, out _); } @@ -34,7 +36,9 @@ internal override void SetPolicyContext(Context executionContext, out string pri priorPolicyKey = executionContext.PolicyKey; if (executionContext.PolicyWrapKey == null) + { executionContext.PolicyWrapKey = PolicyKey; + } base.SetPolicyContext(executionContext, out _, out _); } diff --git a/src/Polly/Wrap/AsyncPolicyWrapSyntax.cs b/src/Polly/Wrap/AsyncPolicyWrapSyntax.cs index cbc0cdd686..2e62bd01f3 100644 --- a/src/Polly/Wrap/AsyncPolicyWrapSyntax.cs +++ b/src/Polly/Wrap/AsyncPolicyWrapSyntax.cs @@ -14,7 +14,10 @@ public static class IAsyncPolicyPolicyWrapExtensions public static AsyncPolicyWrap WrapAsync(this IAsyncPolicy outerPolicy, IAsyncPolicy innerPolicy) { if (outerPolicy == null) + { throw new ArgumentNullException(nameof(outerPolicy)); + } + return ((AsyncPolicy)outerPolicy).WrapAsync(innerPolicy); } @@ -28,7 +31,10 @@ public static AsyncPolicyWrap WrapAsync(this IAsyncPolicy outerPolicy, IAsyncPol public static AsyncPolicyWrap WrapAsync(this IAsyncPolicy outerPolicy, IAsyncPolicy innerPolicy) { if (outerPolicy == null) + { throw new ArgumentNullException(nameof(outerPolicy)); + } + return ((AsyncPolicy)outerPolicy).WrapAsync(innerPolicy); } @@ -42,7 +48,10 @@ public static AsyncPolicyWrap WrapAsync(this IAsyncPolicy oute public static AsyncPolicyWrap WrapAsync(this IAsyncPolicy outerPolicy, IAsyncPolicy innerPolicy) { if (outerPolicy == null) + { throw new ArgumentNullException(nameof(outerPolicy)); + } + return ((AsyncPolicy)outerPolicy).WrapAsync(innerPolicy); } @@ -56,7 +65,10 @@ public static AsyncPolicyWrap WrapAsync(this IAsyncPolicy WrapAsync(this IAsyncPolicy outerPolicy, IAsyncPolicy innerPolicy) { if (outerPolicy == null) + { throw new ArgumentNullException(nameof(outerPolicy)); + } + return ((AsyncPolicy)outerPolicy).WrapAsync(innerPolicy); } } @@ -71,7 +83,9 @@ public partial class AsyncPolicy public AsyncPolicyWrap WrapAsync(IAsyncPolicy innerPolicy) { if (innerPolicy == null) + { throw new ArgumentNullException(nameof(innerPolicy)); + } return new AsyncPolicyWrap( this, @@ -87,7 +101,9 @@ public AsyncPolicyWrap WrapAsync(IAsyncPolicy innerPolicy) public AsyncPolicyWrap WrapAsync(IAsyncPolicy innerPolicy) { if (innerPolicy == null) + { throw new ArgumentNullException(nameof(innerPolicy)); + } return new AsyncPolicyWrap( this, @@ -105,7 +121,9 @@ public partial class AsyncPolicy public AsyncPolicyWrap WrapAsync(IAsyncPolicy innerPolicy) { if (innerPolicy == null) + { throw new ArgumentNullException(nameof(innerPolicy)); + } return new AsyncPolicyWrap( this, @@ -120,7 +138,9 @@ public AsyncPolicyWrap WrapAsync(IAsyncPolicy innerPolicy) public AsyncPolicyWrap WrapAsync(IAsyncPolicy innerPolicy) { if (innerPolicy == null) + { throw new ArgumentNullException(nameof(innerPolicy)); + } return new AsyncPolicyWrap( this, diff --git a/src/Polly/Wrap/IPolicyWrapExtension.cs b/src/Polly/Wrap/IPolicyWrapExtension.cs index cfe7d6f210..84f653993c 100644 --- a/src/Polly/Wrap/IPolicyWrapExtension.cs +++ b/src/Polly/Wrap/IPolicyWrapExtension.cs @@ -48,7 +48,9 @@ public static IEnumerable GetPolicies(this IPolicyWrap policyW public static IEnumerable GetPolicies(this IPolicyWrap policyWrap, Func filter) { if (filter == null) + { throw new ArgumentNullException(nameof(filter)); + } return policyWrap.GetPolicies().OfType().Where(filter); } @@ -74,7 +76,9 @@ public static TPolicy GetPolicy(this IPolicyWrap policyWrap) => public static TPolicy GetPolicy(this IPolicyWrap policyWrap, Func filter) { if (filter == null) + { throw new ArgumentNullException(nameof(filter)); + } return policyWrap.GetPolicies().OfType().SingleOrDefault(filter); } diff --git a/src/Polly/Wrap/PolicyWrap.ContextAndKeys.cs b/src/Polly/Wrap/PolicyWrap.ContextAndKeys.cs index 5e02d456d3..92c503dfbb 100644 --- a/src/Polly/Wrap/PolicyWrap.ContextAndKeys.cs +++ b/src/Polly/Wrap/PolicyWrap.ContextAndKeys.cs @@ -14,7 +14,9 @@ internal override void SetPolicyContext(Context executionContext, out string pri priorPolicyKey = executionContext.PolicyKey; if (executionContext.PolicyWrapKey == null) + { executionContext.PolicyWrapKey = PolicyKey; + } base.SetPolicyContext(executionContext, out _, out _); } @@ -34,7 +36,9 @@ internal override void SetPolicyContext(Context executionContext, out string pri priorPolicyKey = executionContext.PolicyKey; if (executionContext.PolicyWrapKey == null) + { executionContext.PolicyWrapKey = PolicyKey; + } base.SetPolicyContext(executionContext, out _, out _); } diff --git a/src/Polly/Wrap/PolicyWrapSyntax.cs b/src/Polly/Wrap/PolicyWrapSyntax.cs index e44fea20e3..08b35c73fb 100644 --- a/src/Polly/Wrap/PolicyWrapSyntax.cs +++ b/src/Polly/Wrap/PolicyWrapSyntax.cs @@ -14,7 +14,10 @@ public static class ISyncPolicyPolicyWrapExtensions public static PolicyWrap Wrap(this ISyncPolicy outerPolicy, ISyncPolicy innerPolicy) { if (outerPolicy == null) + { throw new ArgumentNullException(nameof(outerPolicy)); + } + return ((Policy)outerPolicy).Wrap(innerPolicy); } @@ -28,7 +31,10 @@ public static PolicyWrap Wrap(this ISyncPolicy outerPolicy, ISyncPolicy innerPol public static PolicyWrap Wrap(this ISyncPolicy outerPolicy, ISyncPolicy innerPolicy) { if (outerPolicy == null) + { throw new ArgumentNullException(nameof(outerPolicy)); + } + return ((Policy)outerPolicy).Wrap(innerPolicy); } @@ -42,7 +48,10 @@ public static PolicyWrap Wrap(this ISyncPolicy outerPolicy, IS public static PolicyWrap Wrap(this ISyncPolicy outerPolicy, ISyncPolicy innerPolicy) { if (outerPolicy == null) + { throw new ArgumentNullException(nameof(outerPolicy)); + } + return ((Policy)outerPolicy).Wrap(innerPolicy); } @@ -56,7 +65,10 @@ public static PolicyWrap Wrap(this ISyncPolicy outerP public static PolicyWrap Wrap(this ISyncPolicy outerPolicy, ISyncPolicy innerPolicy) { if (outerPolicy == null) + { throw new ArgumentNullException(nameof(outerPolicy)); + } + return ((Policy)outerPolicy).Wrap(innerPolicy); } } @@ -71,7 +83,9 @@ public partial class Policy public PolicyWrap Wrap(ISyncPolicy innerPolicy) { if (innerPolicy == null) + { throw new ArgumentNullException(nameof(innerPolicy)); + } return new PolicyWrap( this, @@ -87,7 +101,9 @@ public PolicyWrap Wrap(ISyncPolicy innerPolicy) public PolicyWrap Wrap(ISyncPolicy innerPolicy) { if (innerPolicy == null) + { throw new ArgumentNullException(nameof(innerPolicy)); + } return new PolicyWrap( this, @@ -105,7 +121,9 @@ public partial class Policy public PolicyWrap Wrap(ISyncPolicy innerPolicy) { if (innerPolicy == null) + { throw new ArgumentNullException(nameof(innerPolicy)); + } return new PolicyWrap( this, @@ -120,7 +138,9 @@ public PolicyWrap Wrap(ISyncPolicy innerPolicy) public PolicyWrap Wrap(ISyncPolicy innerPolicy) { if (innerPolicy == null) + { throw new ArgumentNullException(nameof(innerPolicy)); + } return new PolicyWrap( this, From 1053dd8640373766181b0486b6d089f8f05dab87 Mon Sep 17 00:00:00 2001 From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com> Date: Mon, 29 Apr 2024 13:55:24 +0300 Subject: [PATCH 6/9] Remove Polly.sln --- src/Polly/Polly.sln | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 src/Polly/Polly.sln diff --git a/src/Polly/Polly.sln b/src/Polly/Polly.sln deleted file mode 100644 index cad27950ce..0000000000 --- a/src/Polly/Polly.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.002.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Polly", "Polly.csproj", "{1ABD065C-AE2F-4100-AFDB-68C4ABB52DCD}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1ABD065C-AE2F-4100-AFDB-68C4ABB52DCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1ABD065C-AE2F-4100-AFDB-68C4ABB52DCD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1ABD065C-AE2F-4100-AFDB-68C4ABB52DCD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1ABD065C-AE2F-4100-AFDB-68C4ABB52DCD}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {D7A84C62-5D94-4AF0-8209-D648FCDBCA31} - EndGlobalSection -EndGlobal From 6ce9119fa71905eaea076133a49d02389b18db17 Mon Sep 17 00:00:00 2001 From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:00:08 +0300 Subject: [PATCH 7/9] Revert "Enable S6605" This reverts commit e013fa4861c0be80d876316638290488b98f8d70. --- src/Polly/Polly.csproj | 2 +- src/Polly/ResultPredicates.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj index 068d4bfc33..891435d154 100644 --- a/src/Polly/Polly.csproj +++ b/src/Polly/Polly.csproj @@ -11,7 +11,7 @@ $(NoWarn);IDE1006;CA1062;S107;CA1068;S4039;CA1000;CA1063;CA1031;CA1051 $(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;CA1033 $(NoWarn);S4023;CA1010;S3442;CA1064;SA1649;SA1625;SA1623;SA1118 - $(NoWarn);S3971;CA1724;CA1716;SA1108;CA1710;S4049;S3246 + $(NoWarn);S3253;S3971;S6605;CA1724;CA1716;SA1108;CA1710;S4049;S3246 $(NoWarn);CA1805 diff --git a/src/Polly/ResultPredicates.cs b/src/Polly/ResultPredicates.cs index d5007f19e6..ed98c3b317 100644 --- a/src/Polly/ResultPredicates.cs +++ b/src/Polly/ResultPredicates.cs @@ -26,7 +26,7 @@ public bool AnyMatch(TResult result) return false; } - return _predicates.Exists(predicate => predicate(result)); + return _predicates.Any(predicate => predicate(result)); } /// From c5371b2e4c2bb799b97a9502e3b8e35eadad6fdc Mon Sep 17 00:00:00 2001 From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:00:21 +0300 Subject: [PATCH 8/9] Revert "Disable S3253" This reverts commit f21b7836740ffaff08f4851f66f1579dfc78b24e. --- src/Polly/Polly.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj index 891435d154..7b5f8e7ed9 100644 --- a/src/Polly/Polly.csproj +++ b/src/Polly/Polly.csproj @@ -11,7 +11,7 @@ $(NoWarn);IDE1006;CA1062;S107;CA1068;S4039;CA1000;CA1063;CA1031;CA1051 $(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;CA1033 $(NoWarn);S4023;CA1010;S3442;CA1064;SA1649;SA1625;SA1623;SA1118 - $(NoWarn);S3253;S3971;S6605;CA1724;CA1716;SA1108;CA1710;S4049;S3246 + $(NoWarn);S3253;S3971;CA1724;CA1716;SA1108;CA1710;S4049;S3246 $(NoWarn);CA1805 From 3c4e6bd8f49c286137e3fdbf63b067340a7e217e Mon Sep 17 00:00:00 2001 From: iamdmitrij <3024338+iamdmitrij@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:02:17 +0300 Subject: [PATCH 9/9] Revert "Enable S6605" This reverts commit e013fa4861c0be80d876316638290488b98f8d70. --- src/Polly/Polly.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj index 7b5f8e7ed9..891435d154 100644 --- a/src/Polly/Polly.csproj +++ b/src/Polly/Polly.csproj @@ -11,7 +11,7 @@ $(NoWarn);IDE1006;CA1062;S107;CA1068;S4039;CA1000;CA1063;CA1031;CA1051 $(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;CA1033 $(NoWarn);S4023;CA1010;S3442;CA1064;SA1649;SA1625;SA1623;SA1118 - $(NoWarn);S3253;S3971;CA1724;CA1716;SA1108;CA1710;S4049;S3246 + $(NoWarn);S3253;S3971;S6605;CA1724;CA1716;SA1108;CA1710;S4049;S3246 $(NoWarn);CA1805