Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 891 Bytes

MA0079.md

File metadata and controls

20 lines (15 loc) · 891 Bytes

MA0079 - Forward the CancellationToken using .WithCancellation()

CancellationToken cancellationToken;
IAsyncEnumeration<string> enumerable;
await foreach (var item in enumerable) // not compliant
{
}

await foreach (var item in enumerable.WithCancellation(cancellationToken)) // compliant
{
}

This rule only reports diagnostics when the calling method returns a Task or a ValueTask. MA0080 detects the same cases, but reports them even if applying a fix would require you to change the calling method's signature.

Additional resources