Skip to content

Commit

Permalink
RM-9395 Update CSharpAnalyzerVerifier for .NET 9
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKetting committed Nov 8, 2024
1 parent 7876272 commit a6f9433
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ private class Test : CSharpAnalyzerTest<TAnalyzer, DefaultVerifier>
{
}

private static readonly Lazy<ReferenceAssemblies> s_net80 =
new(() => new ReferenceAssemblies("net8.0", new PackageIdentity("Microsoft.NETCore.App.Ref", "8.0.0"), Path.Combine("ref", "net8.0")));
// Workaround when .NET version is not yet available as a ReferenceAsseblies entry.
private static readonly Lazy<ReferenceAssemblies> s_net100 =
new(() => new ReferenceAssemblies("net10.0", new PackageIdentity("Microsoft.NETCore.App.Ref", "10.0.0"), Path.Combine("ref", "net10.0")));

public static DiagnosticResult Diagnostic (DiagnosticDescriptor desc) => CSharpAnalyzerVerifier<TAnalyzer, DefaultVerifier>.Diagnostic(desc);

Expand Down Expand Up @@ -70,8 +71,9 @@ private static ReferenceAssemblies GetReferenceAssemblies (Assembly assembly)
{
return assembly.GetCustomAttribute<TargetFrameworkAttribute>()!.FrameworkName switch
{
// RM-8930 Previous syntax for when the assemblies were easily accessible: ".NETCoreApp,Version=v6.0" => ReferenceAssemblies.Net.Net60
".NETCoreApp,Version=v8.0" => s_net80.Value,
".NETCoreApp,Version=v8.0" => ReferenceAssemblies.Net.Net80,
".NETCoreApp,Version=v9.0" => ReferenceAssemblies.Net.Net90,
".NETCoreApp,Version=v10.0" => s_net100.Value,
var frameworkName => throw new NotSupportedException($"'{frameworkName}' is not supported.")
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ private class Test : CSharpAnalyzerTest<TAnalyzer, DefaultVerifier>
{
}

private static readonly Lazy<ReferenceAssemblies> s_net80 =
new(() => new ReferenceAssemblies("net8.0", new PackageIdentity("Microsoft.NETCore.App.Ref", "8.0.0"), Path.Combine("ref", "net8.0")));
// Workaround when .NET version is not yet available as a ReferenceAsseblies entry.
private static readonly Lazy<ReferenceAssemblies> s_net100 =
new(() => new ReferenceAssemblies("net10.0", new PackageIdentity("Microsoft.NETCore.App.Ref", "10.0.0"), Path.Combine("ref", "net10.0")));

public static DiagnosticResult Diagnostic () => CSharpAnalyzerVerifier<TAnalyzer, DefaultVerifier>.Diagnostic();

Expand Down Expand Up @@ -68,8 +69,9 @@ private static ReferenceAssemblies GetReferenceAssemblies (Assembly assembly)
{
return assembly.GetCustomAttribute<TargetFrameworkAttribute>()!.FrameworkName switch
{
// RM-8930 Previous syntax for when the assemblies were easily accessible: ".NETCoreApp,Version=v6.0" => ReferenceAssemblies.Net.Net60
".NETCoreApp,Version=v8.0" => s_net80.Value,
".NETCoreApp,Version=v8.0" => ReferenceAssemblies.Net.Net80,
".NETCoreApp,Version=v9.0" => ReferenceAssemblies.Net.Net90,
".NETCoreApp,Version=v10.0" => s_net100.Value,
var frameworkName => throw new NotSupportedException($"'{frameworkName}' is not supported.")
};
}
Expand Down

0 comments on commit a6f9433

Please sign in to comment.