From 2eb4c8132845ae6fd32d1800df50a88355d4d5f1 Mon Sep 17 00:00:00 2001 From: Javier Campos Date: Sun, 29 Dec 2019 17:44:59 +0100 Subject: [PATCH] feat: add ConfigureAwait(false) to all await calls --- .../Volo/Abp/Users/UserLookupService.cs | 32 +++++++++---------- .../Abp/Users/UserLookupServiceExtensions.cs | 4 +-- .../EfCoreAbpUserRepositoryBase.cs | 4 +-- .../Users/MongoDB/MongoUserRepositoryBase.cs | 4 +-- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/UserLookupService.cs b/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/UserLookupService.cs index 09979f00e1..a45bcec7ce 100644 --- a/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/UserLookupService.cs +++ b/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/UserLookupService.cs @@ -32,7 +32,7 @@ namespace Volo.Abp.Users public async Task FindByIdAsync(Guid id, CancellationToken cancellationToken = default) { - var localUser = await _userRepository.FindAsync(id, cancellationToken: cancellationToken); + var localUser = await _userRepository.FindAsync(id, cancellationToken: cancellationToken).ConfigureAwait(false); if (ExternalUserLookupServiceProvider == null) { @@ -48,13 +48,13 @@ namespace Volo.Abp.Users try { - externalUser = await ExternalUserLookupServiceProvider.FindByIdAsync(id, cancellationToken); + externalUser = await ExternalUserLookupServiceProvider.FindByIdAsync(id, cancellationToken).ConfigureAwait(false); if (externalUser == null) { if (localUser != null) { //TODO: Instead of deleting, should be make it inactive or something like that? - await WithNewUowAsync(() => _userRepository.DeleteAsync(localUser, cancellationToken: cancellationToken)); + await WithNewUowAsync(() => _userRepository.DeleteAsync(localUser, cancellationToken: cancellationToken)).ConfigureAwait(false); } return null; @@ -68,25 +68,25 @@ namespace Volo.Abp.Users if (localUser == null) { - await WithNewUowAsync(() => _userRepository.InsertAsync(CreateUser(externalUser), cancellationToken: cancellationToken)); - return await _userRepository.FindAsync(id, cancellationToken: cancellationToken); + await WithNewUowAsync(() => _userRepository.InsertAsync(CreateUser(externalUser), cancellationToken: cancellationToken)).ConfigureAwait(false); + return await _userRepository.FindAsync(id, cancellationToken: cancellationToken).ConfigureAwait(false); } if (localUser is IUpdateUserData && ((IUpdateUserData)localUser).Update(externalUser)) { - await WithNewUowAsync(() => _userRepository.UpdateAsync(localUser, cancellationToken: cancellationToken)); + await WithNewUowAsync(() => _userRepository.UpdateAsync(localUser, cancellationToken: cancellationToken)).ConfigureAwait(false); } else { return localUser; } - return await _userRepository.FindAsync(id, cancellationToken: cancellationToken); + return await _userRepository.FindAsync(id, cancellationToken: cancellationToken).ConfigureAwait(false); } public async Task FindByUserNameAsync(string userName, CancellationToken cancellationToken = default) { - var localUser = await _userRepository.FindByUserNameAsync(userName, cancellationToken); + var localUser = await _userRepository.FindByUserNameAsync(userName, cancellationToken).ConfigureAwait(false); if (ExternalUserLookupServiceProvider == null) { @@ -102,13 +102,13 @@ namespace Volo.Abp.Users try { - externalUser = await ExternalUserLookupServiceProvider.FindByUserNameAsync(userName, cancellationToken); + externalUser = await ExternalUserLookupServiceProvider.FindByUserNameAsync(userName, cancellationToken).ConfigureAwait(false); if (externalUser == null) { if (localUser != null) { //TODO: Instead of deleting, should be make it passive or something like that? - await WithNewUowAsync(() => _userRepository.DeleteAsync(localUser, cancellationToken: cancellationToken)); + await WithNewUowAsync(() => _userRepository.DeleteAsync(localUser, cancellationToken: cancellationToken)).ConfigureAwait(false); } return null; @@ -122,20 +122,20 @@ namespace Volo.Abp.Users if (localUser == null) { - await WithNewUowAsync(() => _userRepository.InsertAsync(CreateUser(externalUser), cancellationToken: cancellationToken)); - return await _userRepository.FindAsync(externalUser.Id, cancellationToken: cancellationToken); + await WithNewUowAsync(() => _userRepository.InsertAsync(CreateUser(externalUser), cancellationToken: cancellationToken)).ConfigureAwait(false); + return await _userRepository.FindAsync(externalUser.Id, cancellationToken: cancellationToken).ConfigureAwait(false); } if (localUser is IUpdateUserData && ((IUpdateUserData)localUser).Update(externalUser)) { - await WithNewUowAsync(() => _userRepository.UpdateAsync(localUser, cancellationToken: cancellationToken)); + await WithNewUowAsync(() => _userRepository.UpdateAsync(localUser, cancellationToken: cancellationToken)).ConfigureAwait(false); } else { return localUser; } - return await _userRepository.FindAsync(externalUser.Id, cancellationToken: cancellationToken); + return await _userRepository.FindAsync(externalUser.Id, cancellationToken: cancellationToken).ConfigureAwait(false); } protected abstract TUser CreateUser(IUserData externalUser); @@ -144,8 +144,8 @@ namespace Volo.Abp.Users { using (var uow = _unitOfWorkManager.Begin(requiresNew: true)) { - await func(); - await uow.SaveChangesAsync(); + await func().ConfigureAwait(false); + await uow.SaveChangesAsync().ConfigureAwait(false); } } } diff --git a/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/UserLookupServiceExtensions.cs b/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/UserLookupServiceExtensions.cs index 88781ea026..a605db88bc 100644 --- a/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/UserLookupServiceExtensions.cs +++ b/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/UserLookupServiceExtensions.cs @@ -10,7 +10,7 @@ namespace Volo.Abp.Users public static async Task GetByIdAsync(this IUserLookupService userLookupService, Guid id, CancellationToken cancellationToken = default) where TUser : class, IUser { - var user = await userLookupService.FindByIdAsync(id, cancellationToken); + var user = await userLookupService.FindByIdAsync(id, cancellationToken).ConfigureAwait(false); if (user == null) { throw new EntityNotFoundException(typeof(TUser), id); @@ -22,7 +22,7 @@ namespace Volo.Abp.Users public static async Task GetByUserNameAsync(this IUserLookupService userLookupService, string userName, CancellationToken cancellationToken = default) where TUser : class, IUser { - var user = await userLookupService.FindByUserNameAsync(userName, cancellationToken); + var user = await userLookupService.FindByUserNameAsync(userName, cancellationToken).ConfigureAwait(false); if (user == null) { throw new EntityNotFoundException(typeof(TUser), userName); diff --git a/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/EfCoreAbpUserRepositoryBase.cs b/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/EfCoreAbpUserRepositoryBase.cs index 5d0958101c..6dbc5b7d0c 100644 --- a/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/EfCoreAbpUserRepositoryBase.cs +++ b/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/EfCoreAbpUserRepositoryBase.cs @@ -21,12 +21,12 @@ namespace Volo.Abp.Users.EntityFrameworkCore public async Task FindByUserNameAsync(string userName, CancellationToken cancellationToken = default) { - return await this.FirstOrDefaultAsync(u => u.UserName == userName, GetCancellationToken(cancellationToken)); + return await this.FirstOrDefaultAsync(u => u.UserName == userName, GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public virtual async Task> GetListAsync(IEnumerable ids, CancellationToken cancellationToken = default) { - return await DbSet.Where(u => ids.Contains(u.Id)).ToListAsync(GetCancellationToken(cancellationToken)); + return await DbSet.Where(u => ids.Contains(u.Id)).ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/modules/users/src/Volo.Abp.Users.MongoDB/Volo/Abp/Users/MongoDB/MongoUserRepositoryBase.cs b/modules/users/src/Volo.Abp.Users.MongoDB/Volo/Abp/Users/MongoDB/MongoUserRepositoryBase.cs index 3c5bb66b25..a176db97b4 100644 --- a/modules/users/src/Volo.Abp.Users.MongoDB/Volo/Abp/Users/MongoDB/MongoUserRepositoryBase.cs +++ b/modules/users/src/Volo.Abp.Users.MongoDB/Volo/Abp/Users/MongoDB/MongoUserRepositoryBase.cs @@ -22,12 +22,12 @@ namespace Volo.Abp.Users.MongoDB public virtual async Task FindByUserNameAsync(string userName, CancellationToken cancellationToken = default) { - return await GetMongoQueryable().FirstOrDefaultAsync(u => u.UserName == userName, GetCancellationToken(cancellationToken)); + return await GetMongoQueryable().FirstOrDefaultAsync(u => u.UserName == userName, GetCancellationToken(cancellationToken)).ConfigureAwait(false); } public virtual async Task> GetListAsync(IEnumerable ids, CancellationToken cancellationToken = default) { - return await GetMongoQueryable().Where(u => ids.Contains(u.Id)) .ToListAsync(GetCancellationToken(cancellationToken)); + return await GetMongoQueryable().Where(u => ids.Contains(u.Id)).ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false); } } } \ No newline at end of file