Skip to content

Commit 91f5332

Browse files
authored
Replace .ConfigureAwait(false) by .ConfigureAwaitFalse() which is conditionally no-op (#398)
1 parent 66fc245 commit 91f5332

File tree

7 files changed

+32
-29
lines changed

7 files changed

+32
-29
lines changed

Extensions/Xtensive.Orm.BulkOperations/BulkExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Linq.Expressions;
99
using System.Threading;
1010
using System.Threading.Tasks;
11+
using Xtensive.Core;
1112

1213
namespace Xtensive.Orm.BulkOperations
1314
{
@@ -178,7 +179,7 @@ public static async Task<Key> InsertAsync<T>(this QueryEndpoint queryEndpoint, E
178179
CancellationToken token = default) where T : Entity
179180
{
180181
var operation = new InsertOperation<T>(queryEndpoint.Provider, evaluator);
181-
await operation.ExecuteAsync(token).ConfigureAwait(false);
182+
await operation.ExecuteAsync(token).ConfigureAwaitFalse();
182183
return operation.Key;
183184
}
184185
}

Extensions/Xtensive.Orm.BulkOperations/Internals/BulkDeleteOperation.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Linq;
77
using System.Threading;
88
using System.Threading.Tasks;
9+
using Xtensive.Core;
910
using Xtensive.Orm.Linq;
1011
using Xtensive.Orm.Providers;
1112
using Xtensive.Orm.Services;
@@ -46,8 +47,8 @@ protected async override Task<int> ExecuteInternalAsync(CancellationToken token
4647
Bindings = request.ParameterBindings.ToList();
4748

4849
var command = CreateCommand(request);
49-
await using (command.ConfigureAwait(false)) {
50-
return await command.ExecuteNonQueryAsync(token).ConfigureAwait(false);
50+
await using (command.ConfigureAwaitFalse()) {
51+
return await command.ExecuteNonQueryAsync(token).ConfigureAwaitFalse();
5152
}
5253
}
5354

Extensions/Xtensive.Orm.BulkOperations/Internals/BulkUpdateOperation.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Reflection;
1010
using System.Threading;
1111
using System.Threading.Tasks;
12+
using Xtensive.Core;
1213
using Xtensive.Orm.Linq;
1314
using Xtensive.Orm.Providers;
1415
using Xtensive.Orm.Services;
@@ -49,8 +50,8 @@ protected async override Task<int> ExecuteInternalAsync(CancellationToken token
4950
Bindings = request.ParameterBindings.ToList();
5051

5152
var command = CreateCommand(request);
52-
await using (command.ConfigureAwait(false)) {
53-
return await command.ExecuteNonQueryAsync(token).ConfigureAwait(false);
53+
await using (command.ConfigureAwaitFalse()) {
54+
return await command.ExecuteNonQueryAsync(token).ConfigureAwaitFalse();
5455
}
5556
}
5657

Extensions/Xtensive.Orm.BulkOperations/Internals/Operation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public int Execute()
4545
public async Task<int> ExecuteAsync(CancellationToken token = default)
4646
{
4747
EnsureTransactionIsStarted();
48-
await QueryProvider.Session.SaveChangesAsync(token).ConfigureAwait(false);
49-
var value = await ExecuteInternalAsync(token).ConfigureAwait(false);
48+
await QueryProvider.Session.SaveChangesAsync(token).ConfigureAwaitFalse();
49+
var value = await ExecuteInternalAsync(token).ConfigureAwaitFalse();
5050
DirectStateAccessor.Get(QueryProvider.Session).Invalidate();
5151
return value;
5252
}

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_0/Extractor.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ protected override async Task InitializeAsync(CancellationToken token)
202202
var q = CreateCatalogOidSql();
203203

204204
var cmd = Connection.CreateCommand(q);
205-
await using (cmd.ConfigureAwait(false)) {
206-
var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwait(false);
207-
await using (reader.ConfigureAwait(false)) {
208-
while (await reader.ReadAsync(token).ConfigureAwait(false)) {
205+
await using (cmd.ConfigureAwaitFalse()) {
206+
var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse();
207+
await using (reader.ConfigureAwaitFalse()) {
208+
while (await reader.ReadAsync(token).ConfigureAwaitFalse()) {
209209
var oid = Convert.ToInt64(reader[0]);
210210
var name = reader.GetString(1);
211211
if (name == "pg_class") {
@@ -356,8 +356,8 @@ public override async Task<Catalog> ExtractSchemesAsync(
356356
{
357357
var (catalog, context) = CreateCatalogAndContext(catalogName, schemaNames);
358358

359-
await ExtractRoles(context, true, token).ConfigureAwait(false);
360-
await ExtractSchemasAsync(context, token).ConfigureAwait(false);
359+
await ExtractRoles(context, true, token).ConfigureAwaitFalse();
360+
await ExtractSchemasAsync(context, token).ConfigureAwaitFalse();
361361
return catalog;
362362
}
363363

@@ -385,15 +385,15 @@ private async ValueTask ExtractRoles(ExtractionContext context, bool isAsync, Ca
385385

386386

387387
if (isAsync) {
388-
await using (extractCurentUserCommand.ConfigureAwait(false)) {
389-
context.CurrentUserName = (string) await extractCurentUserCommand.ExecuteScalarAsync(token).ConfigureAwait(false);
388+
await using (extractCurentUserCommand.ConfigureAwaitFalse()) {
389+
context.CurrentUserName = (string) await extractCurentUserCommand.ExecuteScalarAsync(token).ConfigureAwaitFalse();
390390
}
391391

392392
var getAllUsersCommand = Connection.CreateCommand(string.Format(ExtractRolesQueryTemplate, context.CurrentUserName));
393-
await using (getAllUsersCommand.ConfigureAwait(false)) {
394-
var reader = await getAllUsersCommand.ExecuteReaderAsync(token).ConfigureAwait(false);
395-
await using (reader.ConfigureAwait(false)) {
396-
while (await reader.ReadAsync(token).ConfigureAwait(false)) {
393+
await using (getAllUsersCommand.ConfigureAwaitFalse()) {
394+
var reader = await getAllUsersCommand.ExecuteReaderAsync(token).ConfigureAwaitFalse();
395+
await using (reader.ConfigureAwaitFalse()) {
396+
while (await reader.ReadAsync(token).ConfigureAwaitFalse()) {
397397
ReadUserData(reader, context);
398398
}
399399
}
@@ -461,22 +461,22 @@ private void ExtractSchemas(ExtractionContext context)
461461

462462
private async Task ExtractSchemasAsync(ExtractionContext context, CancellationToken token)
463463
{
464-
context.CurrentUserIdentifier = await GetMyUserSysIdAsync(context.CurrentUserSysId, token).ConfigureAwait(false);
464+
context.CurrentUserIdentifier = await GetMyUserSysIdAsync(context.CurrentUserSysId, token).ConfigureAwaitFalse();
465465

466466
//Extraction of public schemas and schemas which is owned by current user
467-
await ExtractSchemasInfoAsync(context, token).ConfigureAwait(false);
467+
await ExtractSchemasInfoAsync(context, token).ConfigureAwaitFalse();
468468

469469
//Extraction of tables, views and sequences
470-
await ExtractSchemaContentsAsync(context, token).ConfigureAwait(false);
470+
await ExtractSchemaContentsAsync(context, token).ConfigureAwaitFalse();
471471

472472
//Extraction of columns of table and view
473-
await ExtractTableAndViewColumnsAsync(context, token).ConfigureAwait(false);
473+
await ExtractTableAndViewColumnsAsync(context, token).ConfigureAwaitFalse();
474474

475475
//Extraction of table indexes
476-
await ExtractTableIndexesAsync(context, token).ConfigureAwait(false);
476+
await ExtractTableIndexesAsync(context, token).ConfigureAwaitFalse();
477477

478478
//Extraction of domains
479-
await ExtractDomainsAsync(context, token).ConfigureAwait(false);
479+
await ExtractDomainsAsync(context, token).ConfigureAwaitFalse();
480480

481481
//Extraction of table and domain constraints
482482
await ExtractTableAndDomainConstraintsAsync(context, token).ConfigureAwait(false);

Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/BatchingCommandProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public override async Task ExecuteTasksAsync(CommandProcessorContext context, Ca
8181

8282
var processingTasks = context.ProcessingTasks;
8383
while (processingTasks.Count >= batchSize) {
84-
_ = await ExecuteBatchAsync(batchSize, null, context, token).ConfigureAwait(false);
84+
_ = await ExecuteBatchAsync(batchSize, null, context, token).ConfigureAwaitFalse();
8585
}
8686

8787
if (!context.AllowPartialExecution) {
@@ -128,7 +128,7 @@ public override async Task<DataReader> ExecuteTasksWithReaderAsync(QueryRequest
128128

129129
for (; ; ) {
130130
var currentBatchSize = (context.ProcessingTasks.Count > batchSize) ? batchSize : context.ProcessingTasks.Count;
131-
var result = await ExecuteBatchAsync(currentBatchSize, request, context, token).ConfigureAwait(false);
131+
var result = await ExecuteBatchAsync(currentBatchSize, request, context, token).ConfigureAwaitFalse();
132132
if (result != null && context.ProcessingTasks.Count == 0) {
133133
return result.CreateReader(request.GetAccessor());
134134
}

Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ private sealed class QueryAsAsyncEnumerable<T> : IAsyncEnumerable<T>
3030
/// <inheritdoc/>
3131
public async IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
3232
{
33-
var result = await queryProvider.ExecuteSequenceAsync<T>(expression, cancellationToken).ConfigureAwait(false);
34-
var asyncSource = result.AsAsyncEnumerable().WithCancellation(cancellationToken).ConfigureAwait(false);
33+
var result = await queryProvider.ExecuteSequenceAsync<T>(expression, cancellationToken).ConfigureAwaitFalse();
34+
var asyncSource = result.AsAsyncEnumerable().WithCancellation(cancellationToken).ConfigureAwaitFalse();
3535
await foreach (var element in asyncSource) {
3636
yield return element;
3737
}

0 commit comments

Comments
 (0)