Skip to content

Commit

Permalink
Update threading analyzers
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Nov 8, 2023
1 parent d6dfd97 commit d3f767a
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 15 deletions.
3 changes: 2 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<SourceGeneratorMicrosoftCodeAnalysisVersion>4.1.0</SourceGeneratorMicrosoftCodeAnalysisVersion>
<MicrosoftILVerificationVersion>7.0.0-alpha.1.22060.1</MicrosoftILVerificationVersion>
<MicrosoftVisualStudioThreadingPackagesVersion>17.7.30</MicrosoftVisualStudioThreadingPackagesVersion>
<MicrosoftVisualStudioThreadingAnalyzersPackagesVersion>17.9.12-alpha</MicrosoftVisualStudioThreadingAnalyzersPackagesVersion>
<MicrosoftTestPlatformVersion>17.4.1</MicrosoftTestPlatformVersion>
</PropertyGroup>
<!--
Expand Down Expand Up @@ -198,7 +199,7 @@
<MicrosoftVisualStudioTextLogicVersion>$(VisualStudioEditorPackagesVersion)</MicrosoftVisualStudioTextLogicVersion>
<MicrosoftVisualStudioTextUIVersion>$(VisualStudioEditorPackagesVersion)</MicrosoftVisualStudioTextUIVersion>
<MicrosoftVisualStudioTextUIWpfVersion>$(VisualStudioEditorPackagesVersion)</MicrosoftVisualStudioTextUIWpfVersion>
<MicrosoftVisualStudioThreadingAnalyzersVersion>$(MicrosoftVisualStudioThreadingPackagesVersion)</MicrosoftVisualStudioThreadingAnalyzersVersion>
<MicrosoftVisualStudioThreadingAnalyzersVersion>$(MicrosoftVisualStudioThreadingAnalyzersPackagesVersion)</MicrosoftVisualStudioThreadingAnalyzersVersion>
<MicrosoftVisualStudioThreadingVersion>$(MicrosoftVisualStudioThreadingPackagesVersion)</MicrosoftVisualStudioThreadingVersion>
<MicrosoftVisualStudioUtilitiesVersion>$(MicrosoftVisualStudioShellPackagesVersion)</MicrosoftVisualStudioUtilitiesVersion>
<MicrosoftVisualStudioUtilitiesInternalVersion>16.3.53</MicrosoftVisualStudioUtilitiesInternalVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ internal partial class NavigationBarController
private async ValueTask<NavigationBarModel?> ComputeModelAndSelectItemAsync(ImmutableSegmentedList<bool> unused, CancellationToken cancellationToken)
{
// Jump back to the UI thread to determine what snapshot the user is processing.
#pragma warning disable VSTHRD004 // Await SwitchToMainThreadAsync
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken).NoThrowAwaitable();
#pragma warning restore VSTHRD004 // Await SwitchToMainThreadAsync

// Cancellation exceptions are ignored in AsyncBatchingWorkQueue, so return without throwing if cancellation
// occurred while switching to the main thread.
Expand Down Expand Up @@ -108,9 +106,7 @@ private async ValueTask SelectItemAsync(CancellationToken cancellationToken)
{
// Switch to the UI so we can determine where the user is and determine the state the last time we updated
// the UI.
#pragma warning disable VSTHRD004 // Await SwitchToMainThreadAsync
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken).NoThrowAwaitable();
#pragma warning restore VSTHRD004 // Await SwitchToMainThreadAsync

// Cancellation exceptions are ignored in AsyncBatchingWorkQueue, so return without throwing if cancellation
// occurred while switching to the main thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ public TrackingSession(
_isRenamableIdentifierTask.SafeContinueWithFromAsync(
async t =>
{
#pragma warning disable VSTHRD004 // Await SwitchToMainThreadAsync
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, _cancellationToken).NoThrowAwaitable();
#pragma warning restore VSTHRD004 // Await SwitchToMainThreadAsync

// Avoid throwing an exception in this common case
if (_cancellationToken.IsCancellationRequested)
Expand Down Expand Up @@ -115,9 +113,7 @@ private void QueueUpdateToStateMachine(StateMachine stateMachine, Task task)

task.SafeContinueWithFromAsync(async t =>
{
#pragma warning disable VSTHRD004 // Await SwitchToMainThreadAsync
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, _cancellationToken).NoThrowAwaitable();
#pragma warning restore VSTHRD004 // Await SwitchToMainThreadAsync

// Avoid throwing an exception in this common case
if (_cancellationToken.IsCancellationRequested)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,7 @@ private ValueTask<VoidResult> ProcessEventChangeAsync(ImmutableSegmentedList<boo
/// </param>
private async Task<VoidResult> RecomputeTagsAsync(bool highPriority, CancellationToken cancellationToken)
{
#pragma warning disable VSTHRD004 // Await SwitchToMainThreadAsync
await _dataSource.ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken).NoThrowAwaitable();
#pragma warning restore VSTHRD004 // Await SwitchToMainThreadAsync
if (cancellationToken.IsCancellationRequested)
return default;

Expand Down Expand Up @@ -251,9 +249,7 @@ await _visibilityTracker.DelayWhileNonVisibleAsync(
var bufferToChanges = ProcessNewTagTrees(spansToTag, oldTagTrees, newTagTrees, cancellationToken);

// Then switch back to the UI thread to update our state and kick off the work to notify the editor.
#pragma warning disable VSTHRD004 // Await SwitchToMainThreadAsync
await _dataSource.ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken).NoThrowAwaitable();
#pragma warning restore VSTHRD004 // Await SwitchToMainThreadAsync
if (cancellationToken.IsCancellationRequested)
return default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ async Task DelayWhileNonVisibleWorkerAsync()
if (cancellationToken.IsCancellationRequested)
return;

#pragma warning disable VSTHRD004 // Await SwitchToMainThreadAsync
await threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken).NoThrowAwaitable();
#pragma warning restore VSTHRD004 // Await SwitchToMainThreadAsync
if (cancellationToken.IsCancellationRequested)
return;

Expand Down

0 comments on commit d3f767a

Please sign in to comment.