roslyn-sdk icon indicating copy to clipboard operation
roslyn-sdk copied to clipboard

net5.0 + MsTest 2.3.0-preview = MissingMethodException

Open LukasGelke opened this issue 2 years ago • 2 comments

Repro Steps:

  • Visual Studio 2022 17.3.3
  • 'dotnet --version' = 6.0.400
  1. use VS template "Analyzer with Code Fix (.Net Standard) [C#]"
  2. 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" />
  1. run Tests => all ok
  2. 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" />
  1. 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.)

LukasGelke avatar Sep 08 '22 13:09 LukasGelke

This sounds like a bug in the MSTest.TestAdapter and/or MSTest.TestFramework package (unexpected binary breaking change in a minor release).

sharwell avatar Sep 12 '22 12:09 sharwell

I confirm @sharwell diagnostic! We are sorry for the inconvenience and will work on reverting/fixing this change as soon as possible.

Evangelink avatar Sep 12 '22 13:09 Evangelink