Skip to content

Add VSSDK009 analyzer to flag non-UI thread related VsTaskRunContext arguments#390

Merged
AArnott merged 1 commit into
mainfrom
dev/andarno/vssdk009-uicontext
Jun 16, 2026
Merged

Add VSSDK009 analyzer to flag non-UI thread related VsTaskRunContext arguments#390
AArnott merged 1 commit into
mainfrom
dev/andarno/vssdk009-uicontext

Conversation

@AArnott

@AArnott AArnott commented Jun 16, 2026

Copy link
Copy Markdown
Member

Passing a non-UI thread related VsTaskRunContext to any of a few methods on VsTaskLibraryHelper leads to an ArgumentOutOfRangeException being thrown. Such a bug has been introduced to the product and merged multiple times.

Copilot AI review requested due to automatic review settings June 16, 2026 16:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new Roslyn analyzer (VSSDK009) to prevent passing non-UI-thread-related VsTaskRunContext values into selected VsTaskLibraryHelper helpers, which can otherwise lead to ArgumentOutOfRangeException at runtime.

Changes:

  • Added VSSDK009UseUIThreadVsTaskRunContextAnalyzer to flag disallowed VsTaskRunContext arguments for StartOnIdle, RunAsync, and WithPriority.
  • Added unit tests covering flagged and non-flagged call patterns.
  • Updated analyzer metadata and documentation (unshipped releases list, docs page, and docs index).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/Microsoft.VisualStudio.SDK.Analyzers.Tests/VSSDK009UseUIThreadVsTaskRunContextAnalyzerTests.cs Adds unit tests for VSSDK009 diagnostics and non-diagnostics.
src/Microsoft.VisualStudio.SDK.Analyzers/VSSDK009UseUIThreadVsTaskRunContextAnalyzer.cs Implements the VSSDK009 analyzer logic and diagnostic descriptor.
src/Microsoft.VisualStudio.SDK.Analyzers/Types.cs Adds Types.VsTaskLibraryHelper / Types.VsTaskRunContext symbols used by the analyzer.
src/Microsoft.VisualStudio.SDK.Analyzers/AnalyzerReleases.Unshipped.md Registers the new analyzer as unshipped.
doc/VSSDK009.md Adds end-user documentation for VSSDK009 with examples and solution.
doc/index.md Links VSSDK009 from the analyzer index.

Comment thread doc/index.md Outdated
@AArnott AArnott force-pushed the dev/andarno/vssdk009-uicontext branch from c254acd to fa9b73e Compare June 16, 2026 17:06
@AArnott AArnott enabled auto-merge June 16, 2026 17:40
@AArnott AArnott merged commit 91000d6 into main Jun 16, 2026
8 checks passed
@AArnott AArnott deleted the dev/andarno/vssdk009-uicontext branch June 16, 2026 23:55
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

Successfully merging this pull request may close these issues.

3 participants