perf: add ConfigureAwait(false) to all async calls in library projects
Add ConfigureAwait(false) to all await expressions in Application and Infrastructure projects (111 files). This follows .NET best practices for library code to avoid potential deadlocks when consumed from synchronization contexts (legacy, unit test runners). Also fix 4 test assertions that check SaveChangesAsync — update to SaveChangesWithRetryAsync to match the handler changes from Fix 4.
This commit is contained in:
1 parent
1635d005cd
commit
45c6ce82eb
115 files changed
+270
-270
No files matched your search
@@ -20,7 +20,7 @@ public class UpdateUserHandler : IRequestHandler<UpdateUserCommand, ServiceResul
|
||||
|
||||
public async Task<ServiceResult<UserResponse>> Handle(UpdateUserCommand command, CancellationToken ct)
|
||||
{
|
||||
var user = await _userManager.FindByIdAsync(command.Id.ToString());
|
||||
var user = await _userManager.FindByIdAsync(command.Id.ToString()).ConfigureAwait(false);
|
||||
if (user is null)
|
||||
return ServiceResult<UserResponse>.NotFound("User not found");
|
||||
|
||||
@@ -28,12 +28,12 @@ public class UpdateUserHandler : IRequestHandler<UpdateUserCommand, ServiceResul
|
||||
user.Theme = command.Theme ?? user.Theme;
|
||||
user.Language = command.Language ?? user.Language;
|
||||
|
||||
var result = await _userManager.UpdateAsync(user);
|
||||
var result = await _userManager.UpdateAsync(user).ConfigureAwait(false);
|
||||
if (!result.Succeeded)
|
||||
return ServiceResult<UserResponse>.Failure(
|
||||
string.Join(", ", result.Errors.Select(e => e.Description)));
|
||||
|
||||
var response = await _repository.GetByIdAsync(user.Id, ct);
|
||||
var response = await _repository.GetByIdAsync(user.Id, ct).ConfigureAwait(false);
|
||||
return ServiceResult<UserResponse>.Success(response!);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user