From e1b3fd033c88889277f76b8c0c5e2f8c28a3c917 Mon Sep 17 00:00:00 2001 From: Javier Campos Date: Sun, 29 Dec 2019 17:37:00 +0100 Subject: [PATCH] feat: add ConfigureAwait(false) to all await calls --- .../Volo/Abp/AuditLogging/AuditingStore.cs | 8 ++++---- .../EfCoreAuditLogRepository.cs | 6 +++--- .../MongoDB/MongoAuditLogRepository.cs | 6 +++--- .../AuditLogging/AuditLogRepository_Tests.cs | 18 +++++++++--------- .../Abp/AuditLogging/AuditStore_Basic_Tests.cs | 12 ++++++------ .../AuditLogging/MultiTenantAuditLog_Tests.cs | 4 ++-- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditingStore.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditingStore.cs index 0fc757b5e9..6674233de6 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditingStore.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditingStore.cs @@ -37,13 +37,13 @@ namespace Volo.Abp.AuditLogging { if (!Options.HideErrors) { - await SaveLogAsync(auditInfo); + await SaveLogAsync(auditInfo).ConfigureAwait(false); return; } try { - await SaveLogAsync(auditInfo); + await SaveLogAsync(auditInfo).ConfigureAwait(false); } catch (Exception ex) { @@ -55,8 +55,8 @@ namespace Volo.Abp.AuditLogging { using (var uow = _unitOfWorkManager.Begin(true)) { - await _auditLogRepository.InsertAsync(new AuditLog(_guidGenerator, auditInfo)); - await uow.SaveChangesAsync(); + await _auditLogRepository.InsertAsync(new AuditLog(_guidGenerator, auditInfo)).ConfigureAwait(false); + await uow.SaveChangesAsync().ConfigureAwait(false); } } } diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs index 094f946777..0b68932224 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs @@ -54,7 +54,7 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore var auditLogs = await query.OrderBy(sorting ?? "executionTime desc") .PageBy(skipCount, maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); + .ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); return auditLogs; } @@ -87,7 +87,7 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore httpStatusCode ); - var totalCount = await query.LongCountAsync(GetCancellationToken(cancellationToken)); + var totalCount = await query.LongCountAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); return totalCount; } @@ -129,7 +129,7 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore .OrderBy(t => t.ExecutionTime) .GroupBy(t => new { t.ExecutionTime.Date }) .Select(g => new { Day = g.Min(t => t.ExecutionTime), avgExecutionTime = g.Average(t => t.ExecutionDuration) }) - .ToListAsync(); + .ToListAsync().ConfigureAwait(false); return result.ToDictionary(element => element.Day.ClearTime(), element => element.avgExecutionTime); } diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs index 8beeff86a3..51ae55d86a 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs @@ -55,7 +55,7 @@ namespace Volo.Abp.AuditLogging.MongoDB return await query.OrderBy(sorting ?? "executionTime desc").As>() .PageBy>(skipCount, maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); + .ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public async Task GetCountAsync( @@ -87,7 +87,7 @@ namespace Volo.Abp.AuditLogging.MongoDB ); var count = await query.As>() - .LongCountAsync(GetCancellationToken(cancellationToken)); + .LongCountAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); return count; } @@ -134,7 +134,7 @@ namespace Volo.Abp.AuditLogging.MongoDB t.ExecutionTime.Day }) .Select(g => new { Day = g.Min(t => t.ExecutionTime), avgExecutionTime = g.Average(t => t.ExecutionDuration) }) - .ToListAsync(); + .ToListAsync().ConfigureAwait(false); return result.ToDictionary(element => element.Day.ClearTime(), element => element.avgExecutionTime); } diff --git a/modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditLogRepository_Tests.cs b/modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditLogRepository_Tests.cs index 54092ea248..d635a62123 100644 --- a/modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditLogRepository_Tests.cs +++ b/modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditLogRepository_Tests.cs @@ -119,11 +119,11 @@ namespace Volo.Abp.AuditLogging } }; - await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log1)); - await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log2)); + await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log1)).ConfigureAwait(false); + await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log2)).ConfigureAwait(false); //Assert - var logs = await AuditLogRepository.GetListAsync(); + var logs = await AuditLogRepository.GetListAsync().ConfigureAwait(false); logs.ShouldNotBeNull(); logs.ShouldContain(x => x.UserId == userId); logs.ShouldContain(x => x.UserId == userId2); @@ -223,11 +223,11 @@ namespace Volo.Abp.AuditLogging } }; - await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log1)); - await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log2)); + await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log1)).ConfigureAwait(false); + await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log2)).ConfigureAwait(false); //Assert - var logs = await AuditLogRepository.GetCountAsync(); + var logs = await AuditLogRepository.GetCountAsync().ConfigureAwait(false); logs.ShouldBe(2); } @@ -325,12 +325,12 @@ namespace Volo.Abp.AuditLogging } }; - await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log1)); - await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log2)); + await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log1)).ConfigureAwait(false); + await AuditLogRepository.InsertAsync(new AuditLog(GuidGenerator, log2)).ConfigureAwait(false); //Assert var date = DateTime.Parse("2020-01-01"); - var results = await AuditLogRepository.GetAverageExecutionDurationPerDayAsync(date, date); + var results = await AuditLogRepository.GetAverageExecutionDurationPerDayAsync(date, date).ConfigureAwait(false); results.Count.ShouldBe(1); results.Values.First().ShouldBe(50); // (45 + 55) / 2 } diff --git a/modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditStore_Basic_Tests.cs b/modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditStore_Basic_Tests.cs index 05dc829440..9744930c09 100644 --- a/modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditStore_Basic_Tests.cs +++ b/modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditStore_Basic_Tests.cs @@ -64,7 +64,7 @@ namespace Volo.Abp.AuditLogging }; //Act - await _auditingStore.SaveAsync(auditLog); + await _auditingStore.SaveAsync(auditLog).ConfigureAwait(false); //Assert @@ -170,14 +170,14 @@ namespace Volo.Abp.AuditLogging } }; - await _auditingStore.SaveAsync(log1); - await _auditingStore.SaveAsync(log2); + await _auditingStore.SaveAsync(log1).ConfigureAwait(false); + await _auditingStore.SaveAsync(log2).ConfigureAwait(false); - var allLogsCount = await _auditLogRepository.GetCountAsync(); + var allLogsCount = await _auditLogRepository.GetCountAsync().ConfigureAwait(false); - var onlyLog1QueryResult = await _auditLogRepository.GetListAsync(includeDetails: true, userName: "Douglas"); + var onlyLog1QueryResult = await _auditLogRepository.GetListAsync(includeDetails: true, userName: "Douglas").ConfigureAwait(false); - var onlyLog2QueryResult = await _auditLogRepository.GetListAsync(includeDetails: true, httpStatusCode: HttpStatusCode.BadGateway); + var onlyLog2QueryResult = await _auditLogRepository.GetListAsync(includeDetails: true, httpStatusCode: HttpStatusCode.BadGateway).ConfigureAwait(false); allLogsCount.ShouldBe(2); diff --git a/modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo/Abp/AuditLogging/MultiTenantAuditLog_Tests.cs b/modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo/Abp/AuditLogging/MultiTenantAuditLog_Tests.cs index 6e92bc6f7f..04c885be20 100644 --- a/modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo/Abp/AuditLogging/MultiTenantAuditLog_Tests.cs +++ b/modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo/Abp/AuditLogging/MultiTenantAuditLog_Tests.cs @@ -59,12 +59,12 @@ namespace Volo.Abp.AuditLogging } ); - await scope.SaveAsync(); + await scope.SaveAsync().ConfigureAwait(false); } //Assert - var auditLogs = await _auditLogRepository.GetListAsync(applicationName: applicationName, includeDetails: true); + var auditLogs = await _auditLogRepository.GetListAsync(applicationName: applicationName, includeDetails: true).ConfigureAwait(false); auditLogs.Count.ShouldBe(1); var auditLog = auditLogs.First(); auditLog.EntityChanges.ShouldNotBeNull();