Skip to content

Replace .ConfigureAwait(false) by .ConfigureAwaitFalse() which is conditionally no-op #398

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

Merged
merged 1 commit into from
Jun 24, 2025
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
3 changes: 2 additions & 1 deletion Extensions/Xtensive.Orm.BulkOperations/BulkExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Xtensive.Core;

namespace Xtensive.Orm.BulkOperations
{
Expand Down Expand Up @@ -178,7 +179,7 @@ public static async Task<Key> InsertAsync<T>(this QueryEndpoint queryEndpoint, E
CancellationToken token = default) where T : Entity
{
var operation = new InsertOperation<T>(queryEndpoint.Provider, evaluator);
await operation.ExecuteAsync(token).ConfigureAwait(false);
await operation.ExecuteAsync(token).ConfigureAwaitFalse();
return operation.Key;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Xtensive.Core;
using Xtensive.Orm.Linq;
using Xtensive.Orm.Providers;
using Xtensive.Orm.Services;
Expand Down Expand Up @@ -46,8 +47,8 @@ protected async override Task<int> ExecuteInternalAsync(CancellationToken token
Bindings = request.ParameterBindings.ToList();

var command = CreateCommand(request);
await using (command.ConfigureAwait(false)) {
return await command.ExecuteNonQueryAsync(token).ConfigureAwait(false);
await using (command.ConfigureAwaitFalse()) {
return await command.ExecuteNonQueryAsync(token).ConfigureAwaitFalse();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Xtensive.Core;
using Xtensive.Orm.Linq;
using Xtensive.Orm.Providers;
using Xtensive.Orm.Services;
Expand Down Expand Up @@ -49,8 +50,8 @@ protected async override Task<int> ExecuteInternalAsync(CancellationToken token
Bindings = request.ParameterBindings.ToList();

var command = CreateCommand(request);
await using (command.ConfigureAwait(false)) {
return await command.ExecuteNonQueryAsync(token).ConfigureAwait(false);
await using (command.ConfigureAwaitFalse()) {
return await command.ExecuteNonQueryAsync(token).ConfigureAwaitFalse();
}
}

Expand Down
4 changes: 2 additions & 2 deletions Extensions/Xtensive.Orm.BulkOperations/Internals/Operation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public int Execute()
public async Task<int> ExecuteAsync(CancellationToken token = default)
{
EnsureTransactionIsStarted();
await QueryProvider.Session.SaveChangesAsync(token).ConfigureAwait(false);
var value = await ExecuteInternalAsync(token).ConfigureAwait(false);
await QueryProvider.Session.SaveChangesAsync(token).ConfigureAwaitFalse();
var value = await ExecuteInternalAsync(token).ConfigureAwaitFalse();
DirectStateAccessor.Get(QueryProvider.Session).Invalidate();
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ protected override async Task InitializeAsync(CancellationToken token)
var q = CreateCatalogOidSql();

var cmd = Connection.CreateCommand(q);
await using (cmd.ConfigureAwait(false)) {
var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwait(false);
await using (reader.ConfigureAwait(false)) {
while (await reader.ReadAsync(token).ConfigureAwait(false)) {
await using (cmd.ConfigureAwaitFalse()) {
var reader = await cmd.ExecuteReaderAsync(token).ConfigureAwaitFalse();
await using (reader.ConfigureAwaitFalse()) {
while (await reader.ReadAsync(token).ConfigureAwaitFalse()) {
var oid = Convert.ToInt64(reader[0]);
var name = reader.GetString(1);
if (name == "pg_class") {
Expand Down Expand Up @@ -356,8 +356,8 @@ public override async Task<Catalog> ExtractSchemesAsync(
{
var (catalog, context) = CreateCatalogAndContext(catalogName, schemaNames);

await ExtractRoles(context, true, token).ConfigureAwait(false);
await ExtractSchemasAsync(context, token).ConfigureAwait(false);
await ExtractRoles(context, true, token).ConfigureAwaitFalse();
await ExtractSchemasAsync(context, token).ConfigureAwaitFalse();
return catalog;
}

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


if (isAsync) {
await using (extractCurentUserCommand.ConfigureAwait(false)) {
context.CurrentUserName = (string) await extractCurentUserCommand.ExecuteScalarAsync(token).ConfigureAwait(false);
await using (extractCurentUserCommand.ConfigureAwaitFalse()) {
context.CurrentUserName = (string) await extractCurentUserCommand.ExecuteScalarAsync(token).ConfigureAwaitFalse();
}

var getAllUsersCommand = Connection.CreateCommand(string.Format(ExtractRolesQueryTemplate, context.CurrentUserName));
await using (getAllUsersCommand.ConfigureAwait(false)) {
var reader = await getAllUsersCommand.ExecuteReaderAsync(token).ConfigureAwait(false);
await using (reader.ConfigureAwait(false)) {
while (await reader.ReadAsync(token).ConfigureAwait(false)) {
await using (getAllUsersCommand.ConfigureAwaitFalse()) {
var reader = await getAllUsersCommand.ExecuteReaderAsync(token).ConfigureAwaitFalse();
await using (reader.ConfigureAwaitFalse()) {
while (await reader.ReadAsync(token).ConfigureAwaitFalse()) {
ReadUserData(reader, context);
}
}
Expand Down Expand Up @@ -461,22 +461,22 @@ private void ExtractSchemas(ExtractionContext context)

private async Task ExtractSchemasAsync(ExtractionContext context, CancellationToken token)
{
context.CurrentUserIdentifier = await GetMyUserSysIdAsync(context.CurrentUserSysId, token).ConfigureAwait(false);
context.CurrentUserIdentifier = await GetMyUserSysIdAsync(context.CurrentUserSysId, token).ConfigureAwaitFalse();

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

//Extraction of tables, views and sequences
await ExtractSchemaContentsAsync(context, token).ConfigureAwait(false);
await ExtractSchemaContentsAsync(context, token).ConfigureAwaitFalse();

//Extraction of columns of table and view
await ExtractTableAndViewColumnsAsync(context, token).ConfigureAwait(false);
await ExtractTableAndViewColumnsAsync(context, token).ConfigureAwaitFalse();

//Extraction of table indexes
await ExtractTableIndexesAsync(context, token).ConfigureAwait(false);
await ExtractTableIndexesAsync(context, token).ConfigureAwaitFalse();

//Extraction of domains
await ExtractDomainsAsync(context, token).ConfigureAwait(false);
await ExtractDomainsAsync(context, token).ConfigureAwaitFalse();

//Extraction of table and domain constraints
await ExtractTableAndDomainConstraintsAsync(context, token).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override async Task ExecuteTasksAsync(CommandProcessorContext context, Ca

var processingTasks = context.ProcessingTasks;
while (processingTasks.Count >= batchSize) {
_ = await ExecuteBatchAsync(batchSize, null, context, token).ConfigureAwait(false);
_ = await ExecuteBatchAsync(batchSize, null, context, token).ConfigureAwaitFalse();
}

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

for (; ; ) {
var currentBatchSize = (context.ProcessingTasks.Count > batchSize) ? batchSize : context.ProcessingTasks.Count;
var result = await ExecuteBatchAsync(currentBatchSize, request, context, token).ConfigureAwait(false);
var result = await ExecuteBatchAsync(currentBatchSize, request, context, token).ConfigureAwaitFalse();
if (result != null && context.ProcessingTasks.Count == 0) {
return result.CreateReader(request.GetAccessor());
}
Expand Down
4 changes: 2 additions & 2 deletions Orm/Xtensive.Orm/Orm/QueryableExtensions.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ private sealed class QueryAsAsyncEnumerable<T> : IAsyncEnumerable<T>
/// <inheritdoc/>
public async IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
{
var result = await queryProvider.ExecuteSequenceAsync<T>(expression, cancellationToken).ConfigureAwait(false);
var asyncSource = result.AsAsyncEnumerable().WithCancellation(cancellationToken).ConfigureAwait(false);
var result = await queryProvider.ExecuteSequenceAsync<T>(expression, cancellationToken).ConfigureAwaitFalse();
var asyncSource = result.AsAsyncEnumerable().WithCancellation(cancellationToken).ConfigureAwaitFalse();
await foreach (var element in asyncSource) {
yield return element;
}
Expand Down