Browse Source

feat: add ConfigureAwait(false) to all await calls

pull/2500/head
Javier Campos 7 years ago
parent
commit
e1b3fd033c
  1. 8
      modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditingStore.cs
  2. 6
      modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs
  3. 6
      modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs
  4. 18
      modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditLogRepository_Tests.cs
  5. 12
      modules/audit-logging/test/Volo.Abp.AuditLogging.TestBase/Volo/Abp/AuditLogging/AuditStore_Basic_Tests.cs
  6. 4
      modules/audit-logging/test/Volo.Abp.AuditLogging.Tests/Volo/Abp/AuditLogging/MultiTenantAuditLog_Tests.cs

8
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);
}
}
}

6
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);
}

6
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<IMongoQueryable<AuditLog>>()
.PageBy<AuditLog, IMongoQueryable<AuditLog>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public async Task<long> GetCountAsync(
@ -87,7 +87,7 @@ namespace Volo.Abp.AuditLogging.MongoDB
);
var count = await query.As<IMongoQueryable<AuditLog>>()
.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);
}

18
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
}

12
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);

4
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();

Loading…
Cancel
Save