Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove redundant ConfigureAwait #867

Merged
merged 6 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Polly.Specs/Bulkhead/BulkheadAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public void Should_call_onBulkheadRejected_with_passed_context()
Context contextPassedToExecute = new Context(operationKey);

Context contextPassedToOnRejected = null;
Func<Context, Task> onRejectedAsync = async ctx => { contextPassedToOnRejected = ctx; await TaskHelper.EmptyTask.ConfigureAwait(false); };
Func<Context, Task> onRejectedAsync = async ctx => { contextPassedToOnRejected = ctx; await TaskHelper.EmptyTask; };

using (var bulkhead = Policy.BulkheadAsync(1, onRejectedAsync))
{
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
using (CancellationTokenSource cancellationSource = new CancellationTokenSource())
{
Task.Run(() => { bulkhead.ExecuteAsync(async () => { await tcs.Task.ConfigureAwait(false); }); });
Task.Run(() => { bulkhead.ExecuteAsync(async () => { await tcs.Task; }); });

Within(CohesionTimeLimit, () => Expect(0, () => bulkhead.BulkheadAvailableCount, nameof(bulkhead.BulkheadAvailableCount)));

Expand Down
4 changes: 2 additions & 2 deletions src/Polly.Specs/Bulkhead/BulkheadTResultAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void Should_call_onBulkheadRejected_with_passed_context()
Context contextPassedToExecute = new Context(operationKey);

Context contextPassedToOnRejected = null;
Func<Context, Task> onRejectedAsync = async ctx => { contextPassedToOnRejected = ctx; await TaskHelper.EmptyTask.ConfigureAwait(false); };
Func<Context, Task> onRejectedAsync = async ctx => { contextPassedToOnRejected = ctx; await TaskHelper.EmptyTask; };

using (var bulkhead = Policy.BulkheadAsync<int>(1, onRejectedAsync))
{
Expand All @@ -70,7 +70,7 @@ public void Should_call_onBulkheadRejected_with_passed_context()
Task.Run(() => {
bulkhead.ExecuteAsync(async () =>
{
await tcs.Task.ConfigureAwait(false);
await tcs.Task;
return 0;
});
});
Expand Down
165 changes: 78 additions & 87 deletions src/Polly.Specs/Caching/CacheAsyncSpecs.cs

Large diffs are not rendered by default.

120 changes: 57 additions & 63 deletions src/Polly.Specs/Caching/CacheTResultAsyncSpecs.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Polly.Specs/Caching/GenericCacheProviderAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task Should_not_error_for_executions_on_non_nullable_types_if_cache

ResultPrimitive result = await cache.ExecuteAsync(async ctx =>
{
await TaskHelper.EmptyTask.ConfigureAwait(false);
await TaskHelper.EmptyTask;
return ResultPrimitive.Substitute;
}, new Context(operationKey));

Expand All @@ -52,7 +52,7 @@ public async Task Should_execute_delegate_and_put_value_in_cache_for_non_nullabl

(await cache.ExecuteAsync(async ctx =>
{
await TaskHelper.EmptyTask.ConfigureAwait(false);
await TaskHelper.EmptyTask;
return ResultPrimitive.Substitute;
}, new Context(operationKey))).Should().Be(valueToReturn);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3058,7 +3058,7 @@ public void Should_execute_func_returning_value_when_cancellationToken_not_cance
AttemptDuringWhichToCancel = null,
};

breaker.Awaiting(async x => result = await x.RaiseExceptionAndOrCancellationAsync<DivideByZeroException, bool>(scenario, cancellationTokenSource, onExecute, true).ConfigureAwait(false))
breaker.Awaiting(async x => result = await x.RaiseExceptionAndOrCancellationAsync<DivideByZeroException, bool>(scenario, cancellationTokenSource, onExecute, true))
.Should().NotThrow();

result.Should().BeTrue();
Expand Down Expand Up @@ -3089,7 +3089,7 @@ public void Should_honour_and_report_cancellation_during_func_execution()
ActionObservesCancellation = true
};

breaker.Awaiting(async x => result = await x.RaiseExceptionAndOrCancellationAsync<DivideByZeroException, bool>(scenario, cancellationTokenSource, onExecute, true).ConfigureAwait(false))
breaker.Awaiting(async x => result = await x.RaiseExceptionAndOrCancellationAsync<DivideByZeroException, bool>(scenario, cancellationTokenSource, onExecute, true))
.Should().Throw<OperationCanceledException>().And.CancellationToken.Should().Be(cancellationToken);

result.Should().Be(null);
Expand Down
4 changes: 2 additions & 2 deletions src/Polly.Specs/CircuitBreaker/CircuitBreakerAsyncSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ public void Should_execute_func_returning_value_when_cancellationToken_not_cance
AttemptDuringWhichToCancel = null,
};

breaker.Awaiting(async x => result = await x.RaiseExceptionAndOrCancellationAsync<DivideByZeroException, bool>(scenario, cancellationTokenSource, onExecute, true).ConfigureAwait(false))
breaker.Awaiting(async x => result = await x.RaiseExceptionAndOrCancellationAsync<DivideByZeroException, bool>(scenario, cancellationTokenSource, onExecute, true))
.Should().NotThrow();

result.Should().BeTrue();
Expand Down Expand Up @@ -1676,7 +1676,7 @@ public void Should_honour_and_report_cancellation_during_func_execution()
ActionObservesCancellation = true
};

breaker.Awaiting(async x => result = await x.RaiseExceptionAndOrCancellationAsync<DivideByZeroException, bool>(scenario, cancellationTokenSource, onExecute, true).ConfigureAwait(false))
breaker.Awaiting(async x => result = await x.RaiseExceptionAndOrCancellationAsync<DivideByZeroException, bool>(scenario, cancellationTokenSource, onExecute, true))
.Should().Throw<OperationCanceledException>().And.CancellationToken.Should().Be(cancellationToken);

result.Should().Be(null);
Expand Down
Loading