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

Add cancellation tokens to methods that have a parameter but we don't pass #52

Merged
merged 6 commits into from
Jun 6, 2024

Conversation

rjmurillo
Copy link
Owner

Most often this was while getting the type information from the semantic model. In cases where the asynchronous operation is cancelled, the underlying calls would not be aborted because we did not propagate forward the cancellation token. This was not picked up by analyzer CA2016 because the cancellation token is not provided on the method used by DiagnosticAnalyzer, but rather on the SyntaxNodeAnalysisContext instance passed in.

The issue was corrected by adding a new analyzer package and enabling an analyzer rule within that package. Both rules are set to error in .editorconfig to avoid introducing new code with this issue

Fixes #43

@rjmurillo rjmurillo marked this pull request as draft June 4, 2024 19:55
@rjmurillo rjmurillo force-pushed the cancellation-tokens branch from d06e313 to 6abd680 Compare June 4, 2024 20:00
@rjmurillo rjmurillo marked this pull request as ready for review June 4, 2024 20:03
@rjmurillo rjmurillo added this to the Future milestone Jun 4, 2024
Copy link
Collaborator

@MattKotsenas MattKotsenas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a single comment about lifting code analysis packages into a build slice. Also happy to do that as a follow up change (if so, file an issue).

Thanks!

@rjmurillo rjmurillo requested a review from MattKotsenas June 5, 2024 23:57
.editorconfig Outdated Show resolved Hide resolved
@rjmurillo rjmurillo modified the milestones: Future, vNext Jun 6, 2024
@rjmurillo rjmurillo merged commit 77f1ff3 into master Jun 6, 2024
3 checks passed
@rjmurillo rjmurillo deleted the cancellation-tokens branch June 6, 2024 20:54
@github-actions github-actions bot added dependencies Pull requests that update a dependency file build labels Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build dependencies Pull requests that update a dependency file enhancement housekeeping
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable analyzer to check for cancellation token method overloads
2 participants