From 2ad40a880f0b5e38c6d8d450172d9c93948a0ee3 Mon Sep 17 00:00:00 2001 From: gintsk <3540004+gintsk@users.noreply.github.com> Date: Sat, 10 Feb 2024 01:57:28 +0200 Subject: [PATCH] Fix SA1129 (#1964) --- test/Polly.Specs/Caching/ResultTtlSpecs.cs | 4 ++-- test/Polly.Specs/Polly.Specs.csproj | 2 +- test/Polly.Specs/Retry/WaitAndRetryForeverSpecs.cs | 4 ++-- test/Polly.Specs/Retry/WaitAndRetrySpecs.cs | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/test/Polly.Specs/Caching/ResultTtlSpecs.cs b/test/Polly.Specs/Caching/ResultTtlSpecs.cs index ef1a0757e9..20263362f1 100644 --- a/test/Polly.Specs/Caching/ResultTtlSpecs.cs +++ b/test/Polly.Specs/Caching/ResultTtlSpecs.cs @@ -21,7 +21,7 @@ public void Should_throw_when_func_is_null_using_context() [Fact] public void Should_not_throw_when_func_is_set() { - Action configure = () => _ = new ResultTtl(_ => new Ttl()); + Action configure = () => _ = new ResultTtl(_ => default); configure.Should().NotThrow(); } @@ -29,7 +29,7 @@ public void Should_not_throw_when_func_is_set() [Fact] public void Should_not_throw_when_func_is_set_using_context() { - Action configure = () => _ = new ResultTtl((_, _) => new Ttl()); + Action configure = () => _ = new ResultTtl((_, _) => default); configure.Should().NotThrow(); } diff --git a/test/Polly.Specs/Polly.Specs.csproj b/test/Polly.Specs/Polly.Specs.csproj index e627c0bdb5..9296d06124 100644 --- a/test/Polly.Specs/Polly.Specs.csproj +++ b/test/Polly.Specs/Polly.Specs.csproj @@ -9,7 +9,7 @@ [Polly]* true $(NoWarn);S103;S104;IDE0011;SA1600;SA1204;CA2008;CA2201; - $(NoWarn);S3878;CA1030;S3717;SA1129;S1402;SA1649;SA1402;CA1031 + $(NoWarn);S3878;CA1030;S3717;S1402;SA1649;SA1402;CA1031 $(NoWarn);S2184; diff --git a/test/Polly.Specs/Retry/WaitAndRetryForeverSpecs.cs b/test/Polly.Specs/Retry/WaitAndRetryForeverSpecs.cs index ff961e72e5..dc99f6f3ba 100644 --- a/test/Polly.Specs/Retry/WaitAndRetryForeverSpecs.cs +++ b/test/Polly.Specs/Retry/WaitAndRetryForeverSpecs.cs @@ -66,7 +66,7 @@ public void Should_not_throw_regardless_of_how_many_times_the_specified_exceptio { var policy = Policy .Handle() - .WaitAndRetryForever(_ => new TimeSpan()); + .WaitAndRetryForever(_ => default); policy.Invoking(x => x.RaiseException(3)) .Should().NotThrow(); @@ -78,7 +78,7 @@ public void Should_not_throw_regardless_of_how_many_times_one_of_the_specified_e var policy = Policy .Handle() .Or() - .WaitAndRetryForever(_ => new TimeSpan()); + .WaitAndRetryForever(_ => default); policy.Invoking(x => x.RaiseException(3)) .Should().NotThrow(); diff --git a/test/Polly.Specs/Retry/WaitAndRetrySpecs.cs b/test/Polly.Specs/Retry/WaitAndRetrySpecs.cs index db0c52307a..71d06c4794 100644 --- a/test/Polly.Specs/Retry/WaitAndRetrySpecs.cs +++ b/test/Polly.Specs/Retry/WaitAndRetrySpecs.cs @@ -551,7 +551,7 @@ public void Should_throw_when_retry_count_is_less_than_zero_without_context() Action policy = () => Policy .Handle() - .WaitAndRetry(-1, _ => new TimeSpan(), onRetry); + .WaitAndRetry(-1, _ => default, onRetry); policy.Should().Throw().And .ParamName.Should().Be("retryCount"); @@ -564,7 +564,7 @@ public void Should_throw_when_retry_count_is_less_than_zero_with_context() Action policy = () => Policy .Handle() - .WaitAndRetry(-1, _ => new TimeSpan(), onRetry); + .WaitAndRetry(-1, _ => default, onRetry); policy.Should().Throw().And .ParamName.Should().Be("retryCount"); @@ -577,7 +577,7 @@ public void Should_throw_when_retry_count_is_less_than_zero_with_attempts_with_c Action policy = () => Policy .Handle() - .WaitAndRetry(-1, _ => new TimeSpan(), onRetry); + .WaitAndRetry(-1, _ => default, onRetry); policy.Should().Throw().And .ParamName.Should().Be("retryCount"); @@ -629,7 +629,7 @@ public void Should_throw_when_onretry_action_is_null_without_context_when_using_ Action policy = () => Policy .Handle() - .WaitAndRetry(1, _ => new TimeSpan(), nullOnRetry); + .WaitAndRetry(1, _ => default, nullOnRetry); policy.Should().Throw().And .ParamName.Should().Be("onRetry"); @@ -642,7 +642,7 @@ public void Should_throw_when_onretry_action_is_null_with_context_when_using_pro Action policy = () => Policy .Handle() - .WaitAndRetry(1, _ => new TimeSpan(), nullOnRetry); + .WaitAndRetry(1, _ => default, nullOnRetry); policy.Should().Throw().And .ParamName.Should().Be("onRetry"); @@ -655,7 +655,7 @@ public void Should_throw_when_onretry_action_is_null_with_attempts_with_context_ Action policy = () => Policy .Handle() - .WaitAndRetry(1, _ => new TimeSpan(), nullOnRetry); + .WaitAndRetry(1, _ => default, nullOnRetry); policy.Should().Throw().And .ParamName.Should().Be("onRetry");