Skip to content

Tests fail due to code fixes in bad locations #1364

@AArnott

Description

@AArnott

Bug description

A couple tests fail with:

Message: 
System.InvalidOperationException : Code fix is attempting to provide a fix for a non-local analyzer diagnostic

  Stack Trace: 
DefaultVerifier.False(Boolean assert, String message)
CodeFixTest`1.FixEachAnalyzerDiagnosticAsync(ImmutableArray`1 analyzers, ImmutableArray`1 codeFixProviders, Nullable`1 codeFixIndex, String codeFixEquivalenceKey, Action`2 codeActionVerifier, Project project, Int32 numberOfIterations, IVerifier verifier, CancellationToken cancellationToken)
CodeFixTest`1.VerifyFixAsync(String language, ImmutableArray`1 analyzers, ImmutableArray`1 codeFixProviders, SolutionState oldState, SolutionState newState, Int32 numberOfIterations, Func`10 getFixedProject, IVerifier verifier, CancellationToken cancellationToken)
CodeFixTest`1.VerifyFixAsync(SolutionState testState, SolutionState fixedState, SolutionState batchFixedState, IVerifier verifier, CancellationToken cancellationToken)
CodeFixTest`1.RunImplAsync(CancellationToken cancellationToken)
AnalyzerTest`1.RunAsync(CancellationToken cancellationToken)
VSTHRD010MainThreadUsageAnalyzerTests.RequiresUIThreadTransitive_MultipleInMember() line 580
--- End of stack trace from previous location ---

These are the tests that fail:

RequiresUIThreadTransitive_MultipleInMember
TransitiveNoCheck_InCtor

Repro steps

Enable the tests and run them.

Expected behavior

Tests should pass.

Actual behavior

Tests fail when enabled.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions