Skip to content

Analyzer proposal: Async methods should take a CancellationToken #394

@AArnott

Description

@AArnott

Is your feature request related to a problem?

Based on the idea in DotNetAnalyzers/AsyncUsageAnalyzers#40 and discussed in #382 (comment), let's use this issue to track the proposal for an analyzer that creates a diagnostic for async methods that do not accept a CancellationToken.

Describe the solution you'd like

This could be a Hidden diagnostic with a code fix that makes adding a CancellationToken parameter easy.
It might also be a more visible Info or Warning diagnostic that activates when no CancellationToken is taken, but only after the async method calls into other code that can take a CancellationToken.

Another idea is to have an analyzer that highlights any calls to async methods where a CancellationToken that is available is not provided, but could be.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions