microsoft / microsoft/vs-threading
Analyzer proposal: Async methods should take a CancellationToken
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1k
- Forks
- 160
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 28
Description
Is your feature request related to a problem?
Based on the idea in https://github.com/DotNetAnalyzers/AsyncUsageAnalyzers/pull/40 and discussed in https://github.com/Microsoft/vs-threading/issues/382#issuecomment-423817451, 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the AsyncUsageAnalyzers pull request and the linked vs-threading discussion. Clarify whether the goal is a hidden diagnostic with a code fix, a conditional warning, or a call-site diagnostic; the work is complete only when one behavior and its scope are agreed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100