Skip to content

Forward cancellation token to awaited methods #234

@giggio

Description

@giggio

If a method receives a CancellationToken and then later awaits on a method that has an overload that takes a CancellationToken that exactly matches the current called method, and it is not used, then raise a diagnostic and offer a fix to it.

This will raise a diagnostic:

async Task FooAync(CancellationToken cancellationToken)
{
    await BarAsync();
}
async Task BarAync(CancellationToken cancellationToken)
{
}

It will be fixed to this:

async Task FooAync(CancellationToken cancellationToken)
{
    await BarAsync(cancellationToken);
}
async Task BarAync(CancellationToken cancellationToken)
{
}

Diagnostic Id: CC0069
Severity: Warning
Style: Usage

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions