Skip to content

Commit df06a8f

Browse files
AArnottCopilot
andauthored
Re-enable some analyzer tests (#1550)
* Re-enable tests that were disabled for #1364 * Initial plan * Add SkipLocalDiagnosticCheck to transitive code fix tests The VSTHRD010 analyzer reports transitive diagnostics via RegisterCompilationEndAction, which the Roslyn testing framework classifies as 'non-local'. The test framework throws 'Code fix is attempting to provide a fix for a non-local analyzer diagnostic' unless CodeFixTestBehaviors.SkipLocalDiagnosticCheck is set. This adds that flag to the three affected test instances. Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
1 parent 34ec670 commit df06a8f

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

test/Microsoft.VisualStudio.Threading.Analyzers.Tests/VSTHRD010MainThreadUsageAnalyzerTests.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class Test {
215215
}.RunAsync();
216216
}
217217

218-
[Fact(Skip = "Started failing after CodeAnalysis upgrade that caught a bug in the code fix. #1364")]
218+
[Fact]
219219
public async Task TransitiveNoCheck_InCtor()
220220
{
221221
var test = @"
@@ -285,6 +285,10 @@ static void VerifyOnUIThread() {
285285
ExpectedDiagnostics = { expected },
286286
FixedCode = fix1,
287287
CodeActionIndex = CodeFixIndex.VerifyOnUIThread,
288+
289+
// SkipLocalDiagnosticCheck is required because this diagnostic is reported at compilation-end
290+
// (as a transitive/indirect diagnostic), not as a local one. See https://github.com/microsoft/vs-threading/issues/1364.
291+
CodeFixTestBehaviors = CodeFixTestBehaviors.SkipLocalDiagnosticCheck,
288292
}.RunAsync();
289293

290294
await new CSVerify.Test
@@ -293,6 +297,10 @@ static void VerifyOnUIThread() {
293297
ExpectedDiagnostics = { expected },
294298
FixedCode = fix2,
295299
CodeActionIndex = CodeFixIndex.ThrowIfNotOnUIThreadIndex1,
300+
301+
// SkipLocalDiagnosticCheck is required because this diagnostic is reported at compilation-end
302+
// (as a transitive/indirect diagnostic), not as a local one. See https://github.com/microsoft/vs-threading/issues/1364.
303+
CodeFixTestBehaviors = CodeFixTestBehaviors.SkipLocalDiagnosticCheck,
296304
}.RunAsync();
297305
}
298306

@@ -522,7 +530,7 @@ void VerifyOnUIThread() {
522530
await CSVerify.VerifyAnalyzerAsync(test, expected);
523531
}
524532

525-
[Fact(Skip = "Started failing after CodeAnalysis upgrade that caught a bug in the code fix. #1364")]
533+
[Fact]
526534
public async Task RequiresUIThreadTransitive_MultipleInMember()
527535
{
528536
var test = @"
@@ -587,6 +595,10 @@ static void VerifyOnUIThread() { }
587595
},
588596
FixedCode = fix,
589597
CodeActionIndex = CodeFixIndex.VerifyOnUIThread,
598+
599+
// SkipLocalDiagnosticCheck is required because this diagnostic is reported at compilation-end
600+
// (as a transitive/indirect diagnostic), not as a local one. See https://github.com/microsoft/vs-threading/issues/1364.
601+
CodeFixTestBehaviors = CodeFixTestBehaviors.SkipLocalDiagnosticCheck,
590602
}.RunAsync();
591603
}
592604

0 commit comments

Comments
 (0)