Skip to content

VSTHRD010 mis-fires when calling async method #226

@AArnott

Description

@AArnott

The VSTHRD010 analyzer will misfire on ShowToolWindow in the sample below when adding the call to the async method that switches itself to the main thread:

        private void ShowToolWindow(object sender, EventArgs e)
        {
            ThreadHelper.JoinableTaskFactory.RunAsync(async delegate
            {
                await FooAsync(); // this line is what adds the VSTHRD010 diagnostic
            });
        }
        
        private async Task FooAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
        }

This would be a regression from #220 which merged into master and even 9869911 which merged the same into v15.7

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions