roslyn-sdk
roslyn-sdk copied to clipboard
net5.0 + MsTest 2.3.0-preview = MissingMethodException
Repro Steps:
- Visual Studio 2022 17.3.3
- 'dotnet --version' = 6.0.400
- use VS template "Analyzer with Code Fix (.Net Standard) [C#]"
- Modify *.Testing csproj
<TargetFramework>net6.0</TargetFramework>
<!-- latest stable -->
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<!-- latest -->
<PackageReference Include="Microsoft.CodeAnalysis.***" Version="1.1.1" />
- run Tests => all ok
- use latest Preview of MsTest:
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0-preview-20220726-02" />
<PackageReference Include="MSTest.TestAdapter" Version="2.3.0-preview-20220810-02" />
<PackageReference Include="MSTest.TestFramework" Version="2.3.0-preview-20220810-02" />
- run Tests => all fail:
Message:
Test method Analyzer3.Test.Analyzer3UnitTest.TestMethod1 threw exception:
System.MissingMethodException: Method not found: 'Void Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(!!0, !!0)'.
Stack Trace:
MSTestVerifier.PushContext(String context)
CodeFixTest`1.RunImplAsync(CancellationToken cancellationToken) line 264
AnalyzerTest`1.RunAsync(CancellationToken cancellationToken) line 181
CSharpCodeFixVerifier`2.VerifyAnalyzerAsync(String source, DiagnosticResult[] expected) line 37
Analyzer3UnitTest.TestMethod1() line 18
ThreadOperations.ExecuteWithAbortSafety(Action action)
This seems to be caused by MsTest changing the signatures in the net5.0-variant. Now Assert-Methods 'message' is a null-default parameter on all functions, not an optional overload anymore.
(We are using Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.MSTest
(in prod) as a 'single easy' reference.)
This sounds like a bug in the MSTest.TestAdapter and/or MSTest.TestFramework package (unexpected binary breaking change in a minor release).
I confirm @sharwell diagnostic! We are sorry for the inconvenience and will work on reverting/fixing this change as soon as possible.