Add .NET 10 enum in `ReferenceAssemblies.Net` ahead of next month's release
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!
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"));
Looks like this was done in https://github.com/dotnet/roslyn-sdk/pull/1221 by @333fred
@jjonescz Any sense of when an update to the Microsoft.CodeAnalysis.CSharp.Analyzer.Testing package might be released with the new enum?
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
Ah, I see - that's a different NuGet feed. Any chance you know when it might show up on NuGet.org (preview or not)?
Any update on the new version with the updated enum now that .Net 10 has been out for a week?
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;
Too bad that this is still not updated, given that .Net10 is out for over a month now. Any ETA on this?
Same here, please update!