Skip to content

Commit 0719338

Browse files
authored
Fix SA1602/S6608/S4144 warnings (#1936)
- Remove redundant SA1602. - Fix S6608. - Fix S4144.
1 parent 19b5e73 commit 0719338

9 files changed

+10
-50
lines changed

test/Polly.Core.Tests/Polly.Core.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ProjectType>Test</ProjectType>
66
<Nullable>enable</Nullable>
77
<Threshold>100</Threshold>
8-
<NoWarn>$(NoWarn);SA1600;SA1204;SA1602;S6608</NoWarn>
8+
<NoWarn>$(NoWarn);SA1600;SA1204</NoWarn>
99
<Include>[Polly.Core]*</Include>
1010
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
1111
</PropertyGroup>

test/Polly.Core.Tests/Retry/RetryResilienceStrategyTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public void ExecuteAsync_MultipleRetries_EnsureDiscardedResultsDisposed()
8989
// assert
9090
result.IsDisposed.Should().BeFalse();
9191
results.Count.Should().Be(_options.MaxRetryAttempts + 1);
92-
results.Last().IsDisposed.Should().BeFalse();
92+
results[results.Count - 1].IsDisposed.Should().BeFalse();
9393

94-
results.Remove(results.Last());
94+
results.Remove(results[results.Count - 1]);
9595
results.Should().AllSatisfy(r => r.IsDisposed.Should().BeTrue());
9696
}
9797

test/Polly.Core.Tests/Utils/ObjectPoolTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void MaxCapacityOverflow_Respected()
5252
var items2 = GetStoreReturn(pool, count);
5353

5454
// Assert
55-
items1.Last().Should().NotBeSameAs(items2.Last());
55+
items1[items1.Count - 1].Should().NotBeSameAs(items2[items2.Count - 1]);
5656
}
5757

5858
[Fact]

test/Polly.Extensions.Tests/Polly.Extensions.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ProjectType>Test</ProjectType>
66
<Nullable>enable</Nullable>
77
<Threshold>100</Threshold>
8-
<NoWarn>$(NoWarn);SA1600;SA1204;S6608</NoWarn>
8+
<NoWarn>$(NoWarn);SA1600;SA1204</NoWarn>
99
<Include>[Polly.Extensions]*</Include>
1010
</PropertyGroup>
1111

test/Polly.Extensions.Tests/ReloadableResiliencePipelineTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public void AddResiliencePipeline_EnsureReloadable(string? name)
7474
resList[i].Received(1).Dispose();
7575
}
7676

77-
resList.Last().Received(0).Dispose();
77+
resList[resList.Count - 1].Received(0).Dispose();
7878

7979
// check disposal of service provider
8080
serviceProvider.Dispose();
81-
resList.Last().Received(1).Dispose();
81+
resList[resList.Count - 1].Received(1).Dispose();
8282
pipeline.Invoking(p => p.Execute(() => { })).Should().Throw<ObjectDisposedException>();
8383

8484
foreach (var ev in fakeListener.Events)

test/Polly.Specs/Fallback/FallbackTResultAsyncSpecs.cs

-28
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,6 @@ public void Should_throw_when_onFallback_delegate_is_null()
6161
.And.ParamName.Should().Be("onFallbackAsync");
6262
}
6363

64-
[Fact]
65-
public void Should_throw_when_onFallback_delegate_is_null_with_action_with_cancellation()
66-
{
67-
Func<CancellationToken, Task<ResultPrimitive>> fallbackAction = _ => Task.FromResult(ResultPrimitive.Substitute);
68-
Func<DelegateResult<ResultPrimitive>, Task> onFallbackAsync = null!;
69-
70-
Action policy = () => Policy
71-
.HandleResult(ResultPrimitive.Fault)
72-
.FallbackAsync(fallbackAction, onFallbackAsync);
73-
74-
policy.Should().Throw<ArgumentNullException>()
75-
.And.ParamName.Should().Be("onFallbackAsync");
76-
}
77-
7864
[Fact]
7965
public void Should_throw_when_onFallback_delegate_is_null_with_context()
8066
{
@@ -89,20 +75,6 @@ public void Should_throw_when_onFallback_delegate_is_null_with_context()
8975
.And.ParamName.Should().Be("onFallbackAsync");
9076
}
9177

92-
[Fact]
93-
public void Should_throw_when_onFallback_delegate_is_null_with_context_with_action_with_cancellation()
94-
{
95-
Func<Context, CancellationToken, Task<ResultPrimitive>> fallbackAction = (_, _) => Task.FromResult(ResultPrimitive.Substitute);
96-
Func<DelegateResult<ResultPrimitive>, Context, Task> onFallbackAsync = null!;
97-
98-
Action policy = () => Policy
99-
.HandleResult(ResultPrimitive.Fault)
100-
.FallbackAsync(fallbackAction, onFallbackAsync);
101-
102-
policy.Should().Throw<ArgumentNullException>()
103-
.And.ParamName.Should().Be("onFallbackAsync");
104-
}
105-
10678
#endregion
10779

10880
#region Policy operation tests

test/Polly.Specs/PolicyTResultAsyncSpecs.cs

-12
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,6 @@ public async Task Executing_the_policy_function_should_throw_when_context_is_nul
110110
ex.And.ParamName.Should().Be("context");
111111
}
112112

113-
[Fact]
114-
public async Task Execute_and_capturing_the_policy_function_should_throw_when_context_data_is_null()
115-
{
116-
var policy = Policy
117-
.HandleResult(ResultPrimitive.Fault)
118-
.RetryAsync((_, _, _) => { });
119-
120-
var ex = await policy.Awaiting(p => p.ExecuteAndCaptureAsync(_ => Task.FromResult(ResultPrimitive.Good), null!))
121-
.Should().ThrowAsync<ArgumentNullException>();
122-
ex.And.ParamName.Should().Be("context");
123-
}
124-
125113
[Fact]
126114
public async Task Executing_the_policy_function_should_pass_context_to_executed_delegate()
127115
{

test/Polly.Specs/Polly.Specs.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<Threshold>75,60,70</Threshold>
99
<Include>[Polly]*</Include>
1010
<IncludePollyUsings>true</IncludePollyUsings>
11-
<NoWarn>$(NoWarn);S103;S104;CA2000;IDE0011;SA1600;SA1204;SA1602;CA2008;CA1806;CA2201;</NoWarn>
12-
<NoWarn>$(NoWarn);S3878;CA1030;S4144;S3717;SA1129;SA1407;S1402;SA1649;SA1402;S4056;CA1031</NoWarn>
11+
<NoWarn>$(NoWarn);S103;S104;CA2000;IDE0011;SA1600;SA1204;CA2008;CA1806;CA2201;</NoWarn>
12+
<NoWarn>$(NoWarn);S3878;CA1030;S3717;SA1129;SA1407;S1402;SA1649;SA1402;S4056;CA1031</NoWarn>
1313
<NoWarn>$(NoWarn);S2184;</NoWarn>
1414
</PropertyGroup>
1515

test/Polly.TestUtils/Polly.TestUtils.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(TargetFrameworks);net481</TargetFrameworks>
55
<ProjectType>Library</ProjectType>
66
<Nullable>enable</Nullable>
7-
<NoWarn>$(NoWarn);SA1600;SA1204;SA1602;CA1062</NoWarn>
7+
<NoWarn>$(NoWarn);SA1600;SA1204;CA1062</NoWarn>
88
<IsPackable>false</IsPackable>
99
<EnablePackageValidation>false</EnablePackageValidation>
1010
<UsePublicApiAnalyzers>false</UsePublicApiAnalyzers>

0 commit comments

Comments
 (0)