Skip to content

Commit

Permalink
Add VSTHRD010 transitive test async methods
Browse files Browse the repository at this point in the history
Repros #226
  • Loading branch information
AArnott committed Mar 17, 2018
1 parent ab7c221 commit 01bde1d
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,32 @@ void VerifyOnUIThread() {
this.VerifyCSharpDiagnostic(test, this.expect);
}

[Fact]
public void RequiresUIThread_NotTransitiveThroughAsyncCalls()
{
var test = @"
using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Threading;
class Test {
private JoinableTaskFactory jtf;
private void ShowToolWindow(object sender, EventArgs e) {
jtf.RunAsync(async delegate {
await FooAsync(); // this line is what adds the VSTHRD010 diagnostic
});
}
private async Task FooAsync() {
await jtf.SwitchToMainThreadAsync();
}
}
";

this.VerifyCSharpDiagnostic(test);
}

[Fact]
public void InvokeVsSolutionAfterSwitchedToMainThreadAsync()
{
Expand Down

0 comments on commit 01bde1d

Please sign in to comment.