Use cancellation token overload (ARCH106)
Esta página aún no está disponible en tu idioma.
Key dotnet.async.use-cancellation-token-overload · Severity warning · Category async
When a method has an overload that accepts a CancellationToken, pass the available token to that overload. Otherwise cancellation requests never reach the downstream call.
Incorrect
Section titled “Incorrect”public async Task SaveAsync(Order order, CancellationToken cancellationToken){ await _context.SaveChangesAsync();}Correct
Section titled “Correct”public async Task SaveAsync(Order order, CancellationToken cancellationToken){ await _context.SaveChangesAsync(cancellationToken);}Call the existing CancellationToken overload and pass the token. If needed, suppress the rule per project/workspace via except/ignore.