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

Add .NET 10 enum in `ReferenceAssemblies.Net` ahead of next month's release

Open WhitWaldo opened this issue 2 months ago • 7 comments

With the upcoming release of .NET 10 next month, could we get a new version of the Microsoft.CodeAnalysis.CSharp.Analyzer.Testing package that updates the ReferenceAssemblies.Net to include an enum for .NET 10?

This is blocking me from releasing a new Dapr .NET SDK version targeting the preview of .NET 10 because it prevents our test projects from testing the analyzers against the right reference assembly version.

Thank you!

WhitWaldo avatar Oct 29 '25 18:10 WhitWaldo

Note that you can already use .NET 10 in your tests without built-in support in the testing package. A bit more verbose, but possible.

From: https://www.meziantou.net/how-to-test-a-roslyn-analyzer.htm#using-custom-referen

var context = new CSharpAnalyzerTest<MyAnalyzer, DefaultVerifier>();
context.ReferenceAssemblies =
    new ReferenceAssemblies(
        targetFramework: "net10.0",
        referenceAssemblyPackage: new PackageIdentity("Microsoft.NETCore.App.Ref", "10.0.0-rc.2.25502.107"),
        referenceAssemblyPath: Path.Combine("ref", "net10.0"));

meziantou avatar Oct 29 '25 19:10 meziantou

Looks like this was done in https://github.com/dotnet/roslyn-sdk/pull/1221 by @333fred

jjonescz avatar Oct 30 '25 07:10 jjonescz

@jjonescz Any sense of when an update to the Microsoft.CodeAnalysis.CSharp.Analyzer.Testing package might be released with the new enum?

WhitWaldo avatar Nov 04 '25 17:11 WhitWaldo

The package has prerelease versions at https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-tools/NuGet/Microsoft.CodeAnalysis.CSharp.Analyzer.Testing, the recent ones should already have that change in

jjonescz avatar Nov 05 '25 11:11 jjonescz

Ah, I see - that's a different NuGet feed. Any chance you know when it might show up on NuGet.org (preview or not)?

WhitWaldo avatar Nov 06 '25 13:11 WhitWaldo

Any update on the new version with the updated enum now that .Net 10 has been out for a week?

drew-cooper avatar Nov 18 '25 01:11 drew-cooper

It'd be great if Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net100 was published to NuGet given that .NET 10 debuted nearly 10 days ago. This is a blocker for all of us who have written Unit Tests for our Analyzers and need to support .NET 10.

In the meantime, here's an Extension Member I created for my library, CommunityToolkit.Maui, using @meziantou's code, above:

https://github.com/CommunityToolkit/Maui/pull/2956

using Microsoft.CodeAnalysis.Testing;

namespace CommunityToolkit.Maui.Analyzers.UnitTests;

static class ReferenceAssembliesExtensions
{
	static readonly Lazy<ReferenceAssemblies> lazyNet100 = new(() =>
		new(targetFramework: "net10.0",
			referenceAssemblyPackage: new PackageIdentity("Microsoft.NETCore.App.Ref", "10.0.0-rc.2.25502.107"),
			referenceAssemblyPath: Path.Combine("ref", "net10.0")));

	extension(ReferenceAssemblies.Net)
	{
		public static ReferenceAssemblies Net100 => lazyNet100.Value;
	}
}

Then you can use it in your code the same way we use any of the existing ReferenceAssemblies:

var context = new CSharpAnalyzerTest<MyAnalyzer, DefaultVerifier>();
context.ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net100;

TheCodeTraveler avatar Nov 20 '25 23:11 TheCodeTraveler

Too bad that this is still not updated, given that .Net10 is out for over a month now. Any ETA on this?

MichaelHochriegl avatar Dec 17 '25 14:12 MichaelHochriegl

Same here, please update!

yaron2 avatar Dec 17 '25 20:12 yaron2