Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA2016 - Flag cases where called methods accept a CancellationToken #7325

Open
MattKotsenas opened this issue Jun 4, 2024 · 1 comment
Open

Comments

@MattKotsenas
Copy link
Member

Analyzer

Diagnostic ID: CA2016

Describe the improvement

Currently rule CA2016 appears to be limited to cases where the containing method has a CancellationToken as a parameter. However, there are cases where a CancellationToken is available some other way (i.e. code analyzer's AnalysisContext).

It's also a signal to refactor when code is calling methods that take CancellationTokens but no token is available.

Describe suggestions on how to achieve the rule

Here's a good blog post that shows additional cases that can be caught: https://www.meziantou.net/detect-missing-cancellationtoken-using-a-roslyn-analyzer.htm

Additional context

I'm happy to take a first pass at this, but wanted to make sure this wasn't already considered and rejected.

@sharwell
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants