From 059af43a8c3a4f78852235e1fbcc2cf412da5e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Baranyai?= Date: Fri, 15 Mar 2024 12:48:10 +0100 Subject: [PATCH] Fix SA1515/SA/1612/S2681 --- src/Polly/AsyncPolicy.ExecuteOverloads.cs | 12 ++++++------ src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs | 10 +++++----- src/Polly/IAsyncPolicy.TResult.cs | 6 +++--- src/Polly/IAsyncPolicy.cs | 12 ++++++------ src/Polly/Polly.csproj | 4 ++-- .../RateLimit/LockFreeTokenBucketRateLimiter.cs | 1 + src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs | 7 +++---- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Polly/AsyncPolicy.ExecuteOverloads.cs b/src/Polly/AsyncPolicy.ExecuteOverloads.cs index 2bb15cd021a..744a3dfb869 100644 --- a/src/Polly/AsyncPolicy.ExecuteOverloads.cs +++ b/src/Polly/AsyncPolicy.ExecuteOverloads.cs @@ -63,8 +63,8 @@ public Task ExecuteAsync(Func action, Context /// Executes the specified asynchronous action within the policy. /// /// The action to perform. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. [DebuggerStepThrough] public Task ExecuteAsync(Func action, CancellationToken cancellationToken, bool continueOnCapturedContext) => @@ -87,8 +87,8 @@ public Task ExecuteAsync(Func action, IDiction /// /// The action to perform. /// Context data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. [DebuggerStepThrough] public async Task ExecuteAsync(Func action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) @@ -180,8 +180,8 @@ public Task ExecuteAsync(Func /// The type of the result. /// The action to perform. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The value returned by the action. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. [DebuggerStepThrough] @@ -207,8 +207,8 @@ public Task ExecuteAsync(FuncThe type of the result. /// The action to perform. /// Context data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The value returned by the action. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. [DebuggerStepThrough] @@ -325,8 +325,8 @@ public Task ExecuteAndCaptureAsync(Func /// The action to perform. /// Context data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. [DebuggerStepThrough] public async Task ExecuteAndCaptureAsync(Func action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext) @@ -435,8 +435,8 @@ public Task> ExecuteAndCaptureAsync(FuncThe type of the result. /// The action to perform. /// Arbitrary data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The captured result. /// Thrown when is . [DebuggerStepThrough] diff --git a/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs b/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs index 8941c58fa76..74a178f3948 100644 --- a/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs +++ b/src/Polly/AsyncPolicy.TResult.ExecuteOverloads.cs @@ -47,8 +47,8 @@ public Task ExecuteAsync(Func> action, /// Executes the specified asynchronous action within the policy and returns the result. /// /// The action to perform. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The value returned by the action. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. [DebuggerStepThrough] @@ -95,8 +95,8 @@ public Task ExecuteAsync(Func /// /// The action to perform. /// Context data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The value returned by the action. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. [DebuggerStepThrough] @@ -165,8 +165,8 @@ public Task> ExecuteAndCaptureAsync(Func /// The action to perform. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The captured result. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. [DebuggerStepThrough] @@ -201,8 +201,8 @@ public Task> ExecuteAndCaptureAsync(Func /// The action to perform. /// Arbitrary data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The captured result. /// Thrown when is . [DebuggerStepThrough] @@ -214,8 +214,8 @@ public Task> ExecuteAndCaptureAsync(Func /// The action to perform. /// Context data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The captured result. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. [DebuggerStepThrough] diff --git a/src/Polly/IAsyncPolicy.TResult.cs b/src/Polly/IAsyncPolicy.TResult.cs index 305c66dcff2..51519a248f3 100644 --- a/src/Polly/IAsyncPolicy.TResult.cs +++ b/src/Polly/IAsyncPolicy.TResult.cs @@ -66,8 +66,8 @@ public interface IAsyncPolicy : IsPolicy /// Executes the specified asynchronous action within the policy and returns the result. /// /// The action to perform. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The value returned by the action. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. Task ExecuteAsync(Func> action, CancellationToken cancellationToken, bool continueOnCapturedContext); @@ -88,8 +88,8 @@ public interface IAsyncPolicy : IsPolicy /// /// The action to perform. /// Context data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The value returned by the action. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. Task ExecuteAsync(Func> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext); @@ -160,8 +160,8 @@ public interface IAsyncPolicy : IsPolicy /// /// The action to perform. /// Arbitrary data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The captured result. /// Thrown when is . Task> ExecuteAndCaptureAsync(Func> action, IDictionary contextData, CancellationToken cancellationToken, bool continueOnCapturedContext); diff --git a/src/Polly/IAsyncPolicy.cs b/src/Polly/IAsyncPolicy.cs index 3878d0299cb..faa75d2f241 100644 --- a/src/Polly/IAsyncPolicy.cs +++ b/src/Polly/IAsyncPolicy.cs @@ -59,8 +59,8 @@ public interface IAsyncPolicy : IsPolicy /// Executes the specified asynchronous action within the policy. /// /// The action to perform. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. Task ExecuteAsync(Func action, CancellationToken cancellationToken, bool continueOnCapturedContext); @@ -79,8 +79,8 @@ public interface IAsyncPolicy : IsPolicy /// /// The action to perform. /// Context data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. Task ExecuteAsync(Func action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext); @@ -142,8 +142,8 @@ public interface IAsyncPolicy : IsPolicy /// /// The type of the result. /// The action to perform. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The value returned by the action. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. Task ExecuteAsync(Func> action, CancellationToken cancellationToken, bool continueOnCapturedContext); @@ -165,8 +165,8 @@ public interface IAsyncPolicy : IsPolicy /// The type of the result. /// The action to perform. /// Context data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The value returned by the action. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. Task ExecuteAsync(Func> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext); @@ -245,8 +245,8 @@ public interface IAsyncPolicy : IsPolicy /// /// The action to perform. /// Context data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods. Task ExecuteAndCaptureAsync(Func action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext); @@ -324,8 +324,8 @@ public interface IAsyncPolicy : IsPolicy /// The type of the result. /// The action to perform. /// Arbitrary data that is passed to the exception policy. - /// Whether to continue on a captured synchronization context. /// A cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries. + /// Whether to continue on a captured synchronization context. /// The captured result. /// Thrown when is . Task> ExecuteAndCaptureAsync(Func> action, IDictionary contextData, CancellationToken cancellationToken, bool continueOnCapturedContext); diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj index b22ac9d790b..967d93bde1a 100644 --- a/src/Polly/Polly.csproj +++ b/src/Polly/Polly.csproj @@ -9,8 +9,8 @@ true $(NoWarn);IDE0011;S103;S3872;SA1402;SA1414;S3215;S2955 $(NoWarn);IDE1006;CA1062;S107;CA1068;S4039;CA1000;CA1063;CA1031;CA1051 - $(NoWarn);SA1612;CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;SA1618;CA1033 - $(NoWarn);SA1515;S4023;CA1010;S2681;S3442;S3880;CA1064;SA1649;SA1625;SA1623;SA1118 + $(NoWarn);CA2211;S2223;CA1032;CA1815;CA1816;S4457;SA1615;SA1618;CA1033 + $(NoWarn);S4023;CA1010;S3442;S3880;CA1064;SA1649;SA1625;SA1623;SA1118 $(NoWarn);S3253;S3971;S6605;CA1724;CA1716;SA1108;CA1710;S4049;S3246 $(NoWarn);CA1805;CA1821 diff --git a/src/Polly/RateLimit/LockFreeTokenBucketRateLimiter.cs b/src/Polly/RateLimit/LockFreeTokenBucketRateLimiter.cs index 917fd37f3c7..22057a9a051 100644 --- a/src/Polly/RateLimit/LockFreeTokenBucketRateLimiter.cs +++ b/src/Polly/RateLimit/LockFreeTokenBucketRateLimiter.cs @@ -77,6 +77,7 @@ public LockFreeTokenBucketRateLimiter(TimeSpan onePer, long bucketCapacity) // Work out when tokens would next be due to be added, if we add these tokens. long newAddNextTokenAtTicks = currentAddNextTokenAtTicks + (tokensToAdd * addTokenTickInterval); + // But if we were way overdue refilling the bucket (there was inactivity for a while), that value would be out-of-date: the next time we add tokens must be at least addTokenTickInterval from now. newAddNextTokenAtTicks = Math.Max(newAddNextTokenAtTicks, now + addTokenTickInterval); diff --git a/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs b/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs index 461dfce33f0..7e73cdfe099 100644 --- a/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs +++ b/src/Polly/Timeout/AsyncTimeoutTResultSyntax.cs @@ -169,9 +169,9 @@ 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 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. /// The Task parameter will be null if the executed action responded cooperatively to cancellation before the policy timed it out. - /// The timeout strategy. /// The policy instance. /// timeout;Value must be a positive TimeSpan (or Timeout.InfiniteTimeSpan to indicate no timeout). /// Thrown when is . @@ -186,10 +186,9 @@ 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 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. /// The timeout strategy. - /// The policy instance. + /// 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./// The policy instance. /// timeout;Value must be greater than zero. /// Thrown when is . public static AsyncTimeoutPolicy TimeoutAsync(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Func onTimeoutAsync)