Skip to content

Pass CancellationTokens in the Visual Studio layer#52276

Merged
jmarolf merged 1 commit intodotnet:mainfrom
jmarolf:always-pass-cancellation-tokens-visualstudio
Mar 31, 2021
Merged

Pass CancellationTokens in the Visual Studio layer#52276
jmarolf merged 1 commit intodotnet:mainfrom
jmarolf:always-pass-cancellation-tokens-visualstudio

Conversation

@jmarolf
Copy link
Contributor

@jmarolf jmarolf commented Mar 31, 2021

Redo of #52247

This cleans up passing cancellation tokens in the Visual Studio layer

@jmarolf jmarolf requested a review from a team as a code owner March 31, 2021 01:20
@ghost ghost added the Area-IDE label Mar 31, 2021
Comment on lines +114 to +115
// TODO: Should we pass in cancellationToken here insead of CancellationToken.None?
return await ((IVsAsyncFileChangeEx)_fileChangeService).AdviseFileChangeAsync(_filePath, _fileChangeFlags, this, CancellationToken.None).ConfigureAwait(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

@jasonmalinowski to review this line

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this is fine since if you look at the call to _fileChangeCookie.GetValueAsync it's passing in CancellationToken.None anyways. Passing in cancellationToken would have had the same effect since it would have been None in practice. That said any attempt to make this cancellation safe is going to require an audit of the entire type which is definitely out of scope.

Copy link
Member

Choose a reason for hiding this comment

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

(I admit it's not entirely clear to me why this is using AsyncLazy in the first place...)

@mavasani
Copy link
Contributor

Your original PR had an editorconfig entry that was enforcing this analyzer at the root of the repo: .

# CA2016: Forward the 'CancellationToken' parameter to methods
dotnet_diagnostic.CA2016.severity = warning

Given you are breaking the change into multiple PRs, each of your PR should add/update an editorconfig entry with the correct globbing section header enforcing the analyzer in that layer.

[src/{VisualStudio}/**/*.{cs,vb}]
# CA2016: Forward the 'CancellationToken' parameter to methods
dotnet_diagnostic.CA2016.severity = warning

@jmarolf
Copy link
Contributor Author

jmarolf commented Mar 31, 2021

@mavasani I plan to turn the big switch here: #52282

@mavasani
Copy link
Contributor

I plan to turn the big switch here: #52282

As long as you are confident to get all those PRs in, sounds good to me.

@jmarolf jmarolf merged commit 2232e90 into dotnet:main Mar 31, 2021
@ghost ghost added this to the Next milestone Mar 31, 2021
@dibarbet dibarbet modified the milestones: Next, 16.10.P3 Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants