From 93595cf869af3014b237db16f27d267525cbfafe Mon Sep 17 00:00:00 2001 From: ShawnWu33 Date: Sat, 5 Oct 2024 21:24:00 +1000 Subject: [PATCH 1/3] fix SA1204; --- test/Polly.Specs/Bulkhead/BulkheadSpecsBase.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/Polly.Specs/Bulkhead/BulkheadSpecsBase.cs b/test/Polly.Specs/Bulkhead/BulkheadSpecsBase.cs index 365dd23f40a..da185b38fa2 100644 --- a/test/Polly.Specs/Bulkhead/BulkheadSpecsBase.cs +++ b/test/Polly.Specs/Bulkhead/BulkheadSpecsBase.cs @@ -3,6 +3,12 @@ [Collection(Constants.ParallelThreadDependentTestCollection)] public abstract class BulkheadSpecsBase : IDisposable { + protected static AssertionFailure? Expect(int expected, Func actualFunc, string measure) + { + int actual = actualFunc(); + return actual != expected ? new AssertionFailure(expected, actual, measure) : null; + } + #region Time constraints protected readonly TimeSpan ShimTimeSpan = TimeSpan.FromMilliseconds(50); // How frequently to retry the assertions. @@ -312,12 +318,6 @@ protected void EnsureNoUnbservedTaskExceptions() #endregion - protected static AssertionFailure? Expect(int expected, Func actualFunc, string measure) - { - int actual = actualFunc(); - return actual != expected ? new AssertionFailure(expected, actual, measure) : null; - } - protected void Within(TimeSpan timeSpan, Func actionContainingAssertions) { TimeSpan permitted = timeSpan; From ab9935907fd597553d498d6e95043f20858a9fb9 Mon Sep 17 00:00:00 2001 From: ShawnWu33 Date: Sat, 5 Oct 2024 21:36:35 +1000 Subject: [PATCH 2/3] Fix warning S2184 in Polly.Spec --- test/Polly.Specs/Retry/WaitAndRetryAsyncSpecs.cs | 2 +- test/Polly.Specs/Retry/WaitAndRetrySpecs.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Polly.Specs/Retry/WaitAndRetryAsyncSpecs.cs b/test/Polly.Specs/Retry/WaitAndRetryAsyncSpecs.cs index 9634a3eb186..863df54a03a 100644 --- a/test/Polly.Specs/Retry/WaitAndRetryAsyncSpecs.cs +++ b/test/Polly.Specs/Retry/WaitAndRetryAsyncSpecs.cs @@ -1070,7 +1070,7 @@ public async Task Should_honour_cancellation_immediately_during_wait_phase_of_wa attemptsInvoked.Should().Be(1); watch.Elapsed.Should().BeLessThan(retryDelay); - watch.Elapsed.Should().BeCloseTo(shimTimeSpan, precision: TimeSpan.FromMilliseconds((int)shimTimeSpan.TotalMilliseconds / 2)); // Consider increasing shimTimeSpan, or loosening precision, if test fails transiently in different environments. + watch.Elapsed.Should().BeCloseTo(shimTimeSpan, precision: TimeSpan.FromMilliseconds(shimTimeSpan.TotalMilliseconds / 2)); // Consider increasing shimTimeSpan, or loosening precision, if test fails transiently in different environments. } [Fact] diff --git a/test/Polly.Specs/Retry/WaitAndRetrySpecs.cs b/test/Polly.Specs/Retry/WaitAndRetrySpecs.cs index f94f29facd0..f0140c529fd 100644 --- a/test/Polly.Specs/Retry/WaitAndRetrySpecs.cs +++ b/test/Polly.Specs/Retry/WaitAndRetrySpecs.cs @@ -1098,7 +1098,7 @@ public void Should_honour_cancellation_immediately_during_wait_phase_of_waitandr attemptsInvoked.Should().Be(1); watch.Elapsed.Should().BeLessThan(retryDelay); - watch.Elapsed.Should().BeCloseTo(shimTimeSpan, precision: TimeSpan.FromMilliseconds((int)shimTimeSpan.TotalMilliseconds / 2)); // Consider increasing shimTimeSpan, or loosening precision, if test fails transiently in different environments. + watch.Elapsed.Should().BeCloseTo(shimTimeSpan, precision: TimeSpan.FromMilliseconds(shimTimeSpan.TotalMilliseconds / 2)); // Consider increasing shimTimeSpan, or loosening precision, if test fails transiently in different environments. } [Fact] From 2d9380bb04e60bb748ee056db4c97fee7b9c2d4b Mon Sep 17 00:00:00 2001 From: ShawnWu33 Date: Sat, 5 Oct 2024 22:15:53 +1000 Subject: [PATCH 3/3] Remove S2184 and SA1204 warning supression in Polly.Specs.csproj --- test/Polly.Specs/Polly.Specs.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Polly.Specs/Polly.Specs.csproj b/test/Polly.Specs/Polly.Specs.csproj index 6550cca3845..cc9cc0eacf4 100644 --- a/test/Polly.Specs/Polly.Specs.csproj +++ b/test/Polly.Specs/Polly.Specs.csproj @@ -9,8 +9,8 @@ [Polly]* true $(NoWarn);CA1030;CA1031;CA2008;CA2201 - $(NoWarn);S104;S2184;S6966 - $(NoWarn);SA1204;SA1402;SA1600 + $(NoWarn);S104;S6966 + $(NoWarn);SA1402;SA1600