fix(core-tests): 修复 AsyncKeyLockManagerTests 的 MA0004 warning

- 修复 Task.Run 内 await using 的异步释放上下文捕获 warning
- 保持 AsyncKeyLockManager 并发测试语义与可读性不变
This commit is contained in:
gewuyou 2026-04-27 08:09:35 +08:00
parent 650618b5ab
commit e19e60ea1a
2 changed files with 7 additions and 2 deletions

View File

@ -176,6 +176,6 @@ public sealed class TrackingPipelineBehavior<TRequest, TResponse> : IPipelineBeh
CancellationToken cancellationToken)
{
InvocationCount++;
return await next(message, cancellationToken);
return await next(message, cancellationToken).ConfigureAwait(false);
}
}

View File

@ -227,12 +227,17 @@ public class AsyncExtensionsTests
[Test]
public async Task WithRetry_Should_Respect_ShouldRetry_Predicate()
{
static Task<int> ThrowShouldNotRetry(string parameterName)
{
throw new ArgumentException("Should not retry", nameof(parameterName));
}
// Arrange
var attemptCount = 0;
Func<Task<int>> taskFactory = () =>
{
attemptCount++;
throw new ArgumentException("Should not retry");
return ThrowShouldNotRetry(nameof(taskFactory));
};
// Act & Assert