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

Scary Nuget warnings when installing a testing package for .NET 7

Open DoctorKrolic opened this issue 2 years ago • 5 comments

To reproduce:

  1. Create .NET 7 console app
  2. Install Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit v1.1.1 (the latest currently available)
  3. Your .csproj should look like this after 2 previous steps:
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.1.1" />
  </ItemGroup>

</Project>
  1. Observe a bunch of Nuget warnings NU1707: Package '<A bunch of MS.CA packages>' was restored using '<A lot of .NET Framework versions>' instead the project target framework 'net7.0'. This package may not be fully compatible with your project.

Is that just a scary false-positive, or testing packages are really not supported on non-Windows platforms in 2023?

DoctorKrolic avatar Jan 05 '23 20:01 DoctorKrolic

You have to separately specify the version of Microsoft.CodeAnalysis you want to use for testing (by adding a package reference with an explicit version). The default/minimum one is Roslyn 1.x, which doesn't have packages compatible with net7.0.

This is by design, as it's required for the testing library to maintain support for Roslyn 1.x.

sharwell avatar Jan 19 '23 19:01 sharwell

Is there any work being done to support .NET Core?

peteraritchie avatar Feb 26 '23 17:02 peteraritchie

@peteraritchie I don't understand the question. The testing library has supported running tests on .NET Core for years.

sharwell avatar Mar 01 '23 16:03 sharwell

it's required for the testing library to maintain support for Roslyn 1.x

If not a secret, why? Is it connected with VS 2015 lifecycle?

DoctorKrolic avatar Apr 23 '23 10:04 DoctorKrolic

There are downstream analyzer packages which are built against an old version of Roslyn, and continue to work well in Visual Studio 2015 while also supporting the latest Visual Studio 2022. Over time there have been a variety of small internal changes in behavior, and it would not be sufficient for those projects to be restricted to testing execution against e.g. Roslyn 4.x+.

sharwell avatar Apr 24 '23 12:04 sharwell