Skip to content

Commit

Permalink
Use using var
Browse files Browse the repository at this point in the history
Use using var to simplify code as `Dispose()` was the last call in the scope anyway.
  • Loading branch information
martincostello committed Feb 4, 2024
1 parent e3238c1 commit 8927e79
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions test/Polly.Specs/RateLimit/RateLimitPolicySpecsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public void Given_immediate_parallel_contention_ratelimiter_still_only_permits_o
var rateLimiter = GetPolicyViaSyntax(1, onePer);

// Arrange - parallel tasks all waiting on a manual reset event.
ManualResetEventSlim gate = new();
using var gate = new ManualResetEventSlim();
Task<(bool PermitExecution, TimeSpan RetryAfter)>[] tasks = new Task<(bool, TimeSpan)>[parallelContention];
for (int i = 0; i < parallelContention; i++)
{
Expand All @@ -302,7 +302,5 @@ public void Given_immediate_parallel_contention_ratelimiter_still_only_permits_o
var results = tasks.Select(t => t.Result).ToList();
results.Count(r => r.PermitExecution).Should().Be(1);
results.Count(r => !r.PermitExecution).Should().Be(parallelContention - 1);

gate.Dispose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void Given_immediate_parallel_contention_ratelimiter_still_only_permits_o
var rateLimiter = GetRateLimiter(onePer, 1);

// Arrange - parallel tasks all waiting on a manual reset event.
ManualResetEventSlim gate = new();
using var gate = new ManualResetEventSlim();
Task<(bool PermitExecution, TimeSpan RetryAfter)>[] tasks = new Task<(bool, TimeSpan)>[parallelContention];
for (int i = 0; i < parallelContention; i++)
{
Expand All @@ -201,7 +201,5 @@ public void Given_immediate_parallel_contention_ratelimiter_still_only_permits_o
var results = tasks.Select(t => t.Result).ToList();
results.Count(r => r.PermitExecution).Should().Be(1);
results.Count(r => !r.PermitExecution).Should().Be(parallelContention - 1);

gate.Dispose();
}
}

0 comments on commit 8927e79

Please sign in to comment.