Skip to content

Analyzer for VSTHRD010 doesn't properly recognize switches to worker thread #455

Open

Description

Bug description

The analyzer for VSTHRD010 is only checking for the existence of a main thread switching call above the offending code. But that's not sufficient if the code were to also switch to a worker thread after having switched to the main thread.

Repro steps

public async Task TestAsync(EnvDTE.DTE dte)
{
    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
    await TaskScheduler.Default;
    var debugger = dte.Debugger;
}

Expected behavior

A VSTHRD010 warning should occur for this code because the 3rd line is not running on the main thread.

Actual behavior

No warning is produced.

  • Version used:
  • Application (if applicable):

Additional context

Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions