Fakes SDK Style MSTest projects build is broken in VS 16.7 and .NET Core SDK 3.1.400 for 2020.1.4, EAP9

Completed

We had to change global.json to redirect to use .NET SDK 3.1.302, can't believe it is so broken in stable version of VS, we have a few projects which are SDK style project format, but targeting 4.8 and all builds are showing errors during build using latest sdk 3.1.400, funny enough that there is no such .NET Core SDK released yet!

Also all tests disappeared and error is related to not able generation fakes, we are using special property to switch to old generation behavior:

<FakeUseV2Generation>false</FakeUseV2Generation>

Which seems like undocumented feature until .NET Core SDK is released to support Fakes generation...

Had to install 16.6.5 to get back to normal, first time ever crazy broken after upgrade to LTS version:

https://docs.microsoft.com/en-us/visualstudio/releases/2019/history

https://download.visualstudio.microsoft.com/download/pr/067fd8d0-753e-4161-8780-dfa3e577839e/75ec991e1ceb0de45076a04c6505a2dd5f199597f32b9e93639c4935585838bd/vs_Enterprise.exe

 

21 comments
Comment actions Permalink

Hello Alexander,

 

Could you please clarify details: do you experience problems with building MS Fakes test projects or with running them? Please note that ReSharper cannot affect VS compiling problems.

Is the following setting enabled in VS options?

You've mentioned that installing VS 16.6.5 returned everything to normal. Does ReSharper EAP9 run tests with this version?

Thank you.

0
Comment actions Permalink

Yes, it is enabled, I guess, something changed in Fakes generation in SDK released with VS 16.7, but we noticed this issues was happening before upgrading to latest version, so could be related to something else?

0
Comment actions Permalink

16.6.5 run tests fine, we also had issue with COR_PROFILE not found when running with 16.7

0
Comment actions Permalink

we did try install EAP, but result was negative, only after we redirected to 3.1.302 SDK using global.json, but we still had issue with errors when covering tests like in this bug report:

https://youtrack.jetbrains.com/issue/RSRP-447662

Also MSTest options page was appearing empty...

0
Comment actions Permalink

Hello Alexander,

 

Could you please specify what are actual problems you are experiencing for:

VS 16.6.5 + ReSharper 2020.2 EAP9

VS 16.7 + ReSharper 2020.2 EAP9

Please specify for each combination what problem is reproduced (building project, running tests,  "COR_PROFILE not found" error etc)

MSTest empty page is a known issue - https://youtrack.jetbrains.com/issue/RSRP-479970.

Thank you.

0
Comment actions Permalink

16.6.5 everything is fine, 16.7 everything is broken

0
Comment actions Permalink

Hello Alexander,

 

thank you for the reply.

Please try installing the latest ReSharper 2020.2 and check the issue once again.

If the problem is still reproduced could you please provide a sample solution demonstrating the problem. You can share it privately via "Submit a request" form.

Thank you.

1
Comment actions Permalink

Thank you, it just a bit of a hassle to install VS 2019 16.7 and if it does not work again downgrade is a bit of pain.

How about you try it and let us know it is working for you?

Create new .net core mstest project with targeting 4.8 .net and fakes generated for system. You can create simple test for System.Fakes.DateTime.NowGet...

0
Comment actions Permalink

It could be issue on Visual Studio side, we submitted support ticket with Microsoft as well and will let you know what is the outcome...

0
Comment actions Permalink

I've got great idea and will install 2019 16.8.1 preview to check side by side and will let you know...

0
Comment actions Permalink

Result: 2019 16.8.1 with ReSharper 2020.2 - Issues with building project with Fakes references, probably related to .NET Core SDK changes as the same issue for dotnet build from command line...

But when ReSharper build is enabled - all fakes are re-generated and then showing errors about Syste.Fakes not able to be found:

Error CS0234: The type or namespace name 'Fakes' does not exist in the namespace 'System' (are you missing an assembly reference?) (119, 17)

0
Comment actions Permalink

Also, tests are showing the following error when running from ReSharper Tests:

Test method *** threw exception:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: Failed to get address of function SetDetourProvider from library 'C:\Users\akachalkov\AppData\Local\JetBrains\Installations\ReSharperPlatformVs16_ac76d559\x64\JetBrains.Profiler.Core.dll'.
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.LibraryMethods.GetProcAddress(IntPtr hModule, String functionName)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.LibraryMethods.GetFunction[T](IntPtr hModule, String functionName)
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.IntelliTraceInstrumentationProvider.Initialize()
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider()
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.CreateContext()
at Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create()

 

 

0
Comment actions Permalink

Managed to crash Visual Studio and empty unit test list,

14/08/2020 01:42:22 Critical Some of the projects might not be read correctly. You may disable solution loading from disk or do that for certain projects.|
Project 'MSFakes.Tests' load failed:
[MSB4236] The SDK 'Microsoft.NET.Sdk' specified could not be found. D:\Temp\MSFakes.Tests.csproj at (0:0)

0
Comment actions Permalink

tried uploading file (UploadID:2020_08_14_FkVjeZySdZDFLNCd), but it did not work, so here is the sample project:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProductVersion />
<TargetFramework>net48</TargetFramework>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AssemblyTitle>Aec.Ecl.Common.Tests</AssemblyTitle>
<Company>Australian Electoral Commission</Company>
<Product>Electronic Certified List Application</Product>
<Copyright>Australian Electoral Commission 2013</Copyright>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyVersion>4.2.30.55713</AssemblyVersion>
<FileVersion>4.2.30.55713</FileVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<FakeUseV2Generation>false</FakeUseV2Generation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Remove="FakesAssemblies\**" />
<EmbeddedResource Remove="FakesAssemblies\**" />
<None Remove="FakesAssemblies\**" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.QualityTools.Testing.Fakes">
<HintPath>Microsoft.QualityTools.Testing.Fakes</HintPath>
</Reference>
<Reference Include="mscorlib.4.0.0.0.Fakes">
<HintPath>FakesAssemblies\mscorlib.4.0.0.0.Fakes.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.4.0.0.0.Fakes">
<HintPath>FakesAssemblies\System.4.0.0.0.Fakes.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.configuration" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.Net" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Microsoft.QualityTools.Testing.Fakes" Version="16.7.4-beta.20330.2" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
</ItemGroup>
<ItemGroup>
<AdditionalDesignTimeBuildInput Remove="FakesAssemblies\**" />
</ItemGroup>
</Project>

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.QualityTools.Testing.Fakes;

namespace MSFakes.Tests.Unit
{
[TestClass]
public class BirthDateTests
{
[TestMethod, TestCategory("Unit")]
public void TestBirthDateStringConstructorSetsBirthDateCorrectlyForPartialDateOnYear()
{
var now = new DateTime(2000, 12, 31);

using (ShimsContext.Create())
{
System.Fakes.ShimDateTime.NowGet = () => now;

}
}
}
}

 

0
Comment actions Permalink

works fine in VS Test Explorer

0
Comment actions Permalink

we raised premium support request with Microsoft support and they reproduced the issue with MSFakes, but we had to rollback to 2020.1.4 to get coverage working back as expected as looks like empty settings page for MSTest affects code coverage not picking up settings file selected in the solution and all code coverage is affected, generally feels like 2020.2 is step backwards rather than forward... 

0
Comment actions Permalink

Alexander Kachalkov, please use the following page to specify the settings file in ReSharper 2020.2.2: ReSharper | Options | Tools | Unit Testing | Test Runner. 

Please let us know how it works for you.

-1
Comment actions Permalink

Maria Pleskunina thank you, but we don't have an option to install ReSharper side by side and we don't have time to install latest version to find out that it is still all broken :(

0
Comment actions Permalink

installed 2020.2.2 - still broken, so?

0
Comment actions Permalink

MSFakes issue is fixed in 16.8 Preview 3

1
Comment actions Permalink

Hello Alexander,

 

thank you for letting us know.

 

0

Please sign in to leave a comment.