Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement full .NET 9 support #2456

Merged
merged 1 commit into from Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions NuGet.Config
Expand Up @@ -12,5 +12,6 @@
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
<add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
<add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
</packageSources>
</configuration>
20 changes: 20 additions & 0 deletions src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs
Expand Up @@ -105,6 +105,11 @@ public enum RuntimeMoniker
/// </summary>
Net80,

/// <summary>
/// .NET 9.0
/// </summary>
Net90,

/// <summary>
/// NativeAOT compiled as net6.0
/// </summary>
Expand All @@ -120,6 +125,11 @@ public enum RuntimeMoniker
/// </summary>
NativeAot80,

/// <summary>
/// NativeAOT compiled as net9.0
/// </summary>
NativeAot90,

/// <summary>
/// WebAssembly with default .Net version
/// </summary>
Expand Down Expand Up @@ -170,6 +180,11 @@ public enum RuntimeMoniker
/// </summary>
MonoAOTLLVMNet80,

/// <summary>
/// Mono with the Ahead of Time LLVM Compiler backend and net9.0
/// </summary>
MonoAOTLLVMNet90,

/// <summary>
/// .NET 6 using MonoVM (not CLR which is the default)
/// </summary>
Expand All @@ -184,5 +199,10 @@ public enum RuntimeMoniker
/// .NET 8 using MonoVM (not CLR which is the default)
/// </summary>
Mono80,

/// <summary>
/// .NET 9 using MonoVM (not CLR which is the default)
/// </summary>
Mono90,
}
}
4 changes: 4 additions & 0 deletions src/BenchmarkDotNet.Diagnostics.dotTrace/DotTraceDiagnoser.cs
Expand Up @@ -97,12 +97,14 @@ internal static bool IsSupported(RuntimeMoniker runtimeMoniker)
case RuntimeMoniker.Net60:
case RuntimeMoniker.Net70:
case RuntimeMoniker.Net80:
case RuntimeMoniker.Net90:
return true;
case RuntimeMoniker.NotRecognized:
case RuntimeMoniker.Mono:
case RuntimeMoniker.NativeAot60:
case RuntimeMoniker.NativeAot70:
case RuntimeMoniker.NativeAot80:
case RuntimeMoniker.NativeAot90:
case RuntimeMoniker.Wasm:
case RuntimeMoniker.WasmNet50:
case RuntimeMoniker.WasmNet60:
Expand All @@ -113,9 +115,11 @@ internal static bool IsSupported(RuntimeMoniker runtimeMoniker)
case RuntimeMoniker.MonoAOTLLVMNet60:
case RuntimeMoniker.MonoAOTLLVMNet70:
case RuntimeMoniker.MonoAOTLLVMNet80:
case RuntimeMoniker.MonoAOTLLVMNet90:
case RuntimeMoniker.Mono60:
case RuntimeMoniker.Mono70:
case RuntimeMoniker.Mono80:
case RuntimeMoniker.Mono90:
#pragma warning disable CS0618 // Type or member is obsolete
case RuntimeMoniker.NetCoreApp50:
#pragma warning restore CS0618 // Type or member is obsolete
Expand Down
10 changes: 10 additions & 0 deletions src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
Expand Up @@ -532,6 +532,7 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
case RuntimeMoniker.Net60:
case RuntimeMoniker.Net70:
case RuntimeMoniker.Net80:
case RuntimeMoniker.Net90:
return baseJob
.WithRuntime(runtimeMoniker.GetRuntime())
.WithToolchain(CsProjCoreToolchain.From(new NetCoreAppSettings(runtimeId, null, runtimeId, options.CliPath?.FullName, options.RestorePath?.FullName)));
Expand All @@ -548,6 +549,9 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
case RuntimeMoniker.NativeAot80:
return CreateAotJob(baseJob, options, runtimeMoniker, "", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json");

case RuntimeMoniker.NativeAot90:
return CreateAotJob(baseJob, options, runtimeMoniker, "", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json");

case RuntimeMoniker.Wasm:
return MakeWasmJob(baseJob, options, RuntimeInformation.IsNetCore ? CoreRuntime.GetCurrentVersion().MsBuildMoniker : "net5.0", runtimeMoniker);

Expand Down Expand Up @@ -578,6 +582,9 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
case RuntimeMoniker.MonoAOTLLVMNet80:
return MakeMonoAOTLLVMJob(baseJob, options, "net8.0");

case RuntimeMoniker.MonoAOTLLVMNet90:
return MakeMonoAOTLLVMJob(baseJob, options, "net9.0");

case RuntimeMoniker.Mono60:
return MakeMonoJob(baseJob, options, MonoRuntime.Mono60);

Expand All @@ -587,6 +594,9 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
case RuntimeMoniker.Mono80:
return MakeMonoJob(baseJob, options, MonoRuntime.Mono80);

case RuntimeMoniker.Mono90:
return MakeMonoJob(baseJob, options, MonoRuntime.Mono90);

default:
throw new NotSupportedException($"Runtime {runtimeId} is not supported");
}
Expand Down
4 changes: 3 additions & 1 deletion src/BenchmarkDotNet/Environments/Runtimes/CoreRuntime.cs
Expand Up @@ -20,8 +20,9 @@ public class CoreRuntime : Runtime
public static readonly CoreRuntime Core60 = new (RuntimeMoniker.Net60, "net6.0", ".NET 6.0");
public static readonly CoreRuntime Core70 = new (RuntimeMoniker.Net70, "net7.0", ".NET 7.0");
public static readonly CoreRuntime Core80 = new (RuntimeMoniker.Net80, "net8.0", ".NET 8.0");
public static readonly CoreRuntime Core90 = new (RuntimeMoniker.Net90, "net9.0", ".NET 9.0");

public static CoreRuntime Latest => Core80; // when dotnet/runtime branches for 9.0, this will need to get updated
public static CoreRuntime Latest => Core90; // when dotnet/runtime branches for 10.0, this will need to get updated

private CoreRuntime(RuntimeMoniker runtimeMoniker, string msBuildMoniker, string displayName)
: base(runtimeMoniker, msBuildMoniker, displayName)
Expand Down Expand Up @@ -72,6 +73,7 @@ internal static CoreRuntime FromVersion(Version version)
case Version v when v.Major == 6 && v.Minor == 0: return GetPlatformSpecific(Core60);
case Version v when v.Major == 7 && v.Minor == 0: return GetPlatformSpecific(Core70);
case Version v when v.Major == 8 && v.Minor == 0: return GetPlatformSpecific(Core80);
case Version v when v.Major == 9 && v.Minor == 0: return GetPlatformSpecific(Core90);
default:
return CreateForNewVersion($"net{version.Major}.{version.Minor}", $".NET {version.Major}.{version.Minor}");
}
Expand Down
1 change: 1 addition & 0 deletions src/BenchmarkDotNet/Environments/Runtimes/MonoRuntime.cs
Expand Up @@ -9,6 +9,7 @@ public class MonoRuntime : Runtime, IEquatable<MonoRuntime>
public static readonly MonoRuntime Mono60 = new ("Mono with .NET 6.0", RuntimeMoniker.Mono60, "net6.0", isDotNetBuiltIn: true);
public static readonly MonoRuntime Mono70 = new ("Mono with .NET 7.0", RuntimeMoniker.Mono70, "net7.0", isDotNetBuiltIn: true);
public static readonly MonoRuntime Mono80 = new ("Mono with .NET 8.0", RuntimeMoniker.Mono80, "net8.0", isDotNetBuiltIn: true);
public static readonly MonoRuntime Mono90 = new ("Mono with .NET 9.0", RuntimeMoniker.Mono90, "net9.0", isDotNetBuiltIn: true);

public string CustomPath { get; }

Expand Down
6 changes: 6 additions & 0 deletions src/BenchmarkDotNet/Environments/Runtimes/NativeAotRuntime.cs
Expand Up @@ -18,6 +18,10 @@ public class NativeAotRuntime : Runtime
/// NativeAOT compiled as net8.0
/// </summary>
public static readonly NativeAotRuntime Net80 = new NativeAotRuntime(RuntimeMoniker.NativeAot80, "net8.0", "NativeAOT 8.0");
/// <summary>
/// NativeAOT compiled as net9.0
/// </summary>
public static readonly NativeAotRuntime Net90 = new NativeAotRuntime(RuntimeMoniker.NativeAot90, "net9.0", "NativeAOT 9.0");

public override bool IsAOT => true;

Expand All @@ -42,6 +46,8 @@ public static NativeAotRuntime GetCurrentVersion()
{
case Version v when v.Major == 6 && v.Minor == 0: return Net60;
case Version v when v.Major == 7 && v.Minor == 0: return Net70;
case Version v when v.Major == 8 && v.Minor == 0: return Net80;
case Version v when v.Major == 9 && v.Minor == 0: return Net90;
default:
return new NativeAotRuntime(RuntimeMoniker.NotRecognized, $"net{version.Major}.{version.Minor}", $"NativeAOT {version.Major}.{version.Minor}");
}
Expand Down
8 changes: 8 additions & 0 deletions src/BenchmarkDotNet/Extensions/RuntimeMonikerExtensions.cs
Expand Up @@ -45,6 +45,8 @@ internal static Runtime GetRuntime(this RuntimeMoniker runtimeMoniker)
return CoreRuntime.Core70;
case RuntimeMoniker.Net80:
return CoreRuntime.Core80;
case RuntimeMoniker.Net90:
return CoreRuntime.Core90;
case RuntimeMoniker.Mono:
return MonoRuntime.Default;
case RuntimeMoniker.NativeAot60:
Expand All @@ -53,10 +55,16 @@ internal static Runtime GetRuntime(this RuntimeMoniker runtimeMoniker)
return NativeAotRuntime.Net70;
case RuntimeMoniker.NativeAot80:
return NativeAotRuntime.Net80;
case RuntimeMoniker.NativeAot90:
return NativeAotRuntime.Net90;
case RuntimeMoniker.Mono60:
return MonoRuntime.Mono60;
case RuntimeMoniker.Mono70:
return MonoRuntime.Mono70;
case RuntimeMoniker.Mono80:
return MonoRuntime.Mono80;
case RuntimeMoniker.Mono90:
return MonoRuntime.Mono90;
default:
throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, "Runtime Moniker not supported");
}
Expand Down
Expand Up @@ -24,6 +24,7 @@ public class CsProjCoreToolchain : Toolchain, IEquatable<CsProjCoreToolchain>
[PublicAPI] public static readonly IToolchain NetCoreApp60 = From(NetCoreAppSettings.NetCoreApp60);
[PublicAPI] public static readonly IToolchain NetCoreApp70 = From(NetCoreAppSettings.NetCoreApp70);
[PublicAPI] public static readonly IToolchain NetCoreApp80 = From(NetCoreAppSettings.NetCoreApp80);
[PublicAPI] public static readonly IToolchain NetCoreApp90 = From(NetCoreAppSettings.NetCoreApp90);

internal CsProjCoreToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath)
: base(name, generator, builder, executor)
Expand Down
Expand Up @@ -18,6 +18,7 @@ public class NetCoreAppSettings
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp60 = new ("net6.0", null, ".NET 6.0");
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp70 = new ("net7.0", null, ".NET 7.0");
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp80 = new ("net8.0", null, ".NET 8.0");
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp90 = new ("net9.0", null, ".NET 9.0");

/// <summary>
/// <param name="targetFrameworkMoniker">
Expand Down
1 change: 1 addition & 0 deletions src/BenchmarkDotNet/Toolchains/Mono/MonoToolchain.cs
Expand Up @@ -11,6 +11,7 @@ public class MonoToolchain : CsProjCoreToolchain, IEquatable<MonoToolchain>
[PublicAPI] public static readonly IToolchain Mono60 = From(new NetCoreAppSettings("net6.0", null, "mono60"));
[PublicAPI] public static readonly IToolchain Mono70 = From(new NetCoreAppSettings("net7.0", null, "mono70"));
[PublicAPI] public static readonly IToolchain Mono80 = From(new NetCoreAppSettings("net8.0", null, "mono80"));
[PublicAPI] public static readonly IToolchain Mono90 = From(new NetCoreAppSettings("net9.0", null, "mono90"));

private MonoToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath)
: base(name, generator, builder, executor, customDotNetCliPath)
Expand Down
Expand Up @@ -29,6 +29,14 @@ public class NativeAotToolchain : Toolchain
.TargetFrameworkMoniker("net8.0")
.ToToolchain();

/// <summary>
/// compiled as net9.0, targets latest NativeAOT build from the .NET 9 feed: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json
/// </summary>
public static readonly IToolchain Net90 = CreateBuilder()
.UseNuGet("", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json")
.TargetFrameworkMoniker("net9.0")
.ToToolchain();

internal NativeAotToolchain(string displayName,
string ilCompilerVersion,
string runtimeFrameworkVersion, string targetFrameworkMoniker, string runtimeIdentifier,
Expand Down
10 changes: 10 additions & 0 deletions src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs
Expand Up @@ -66,6 +66,7 @@ internal static IToolchain GetToolchain(this Runtime runtime, Descriptor? descri
RuntimeMoniker.Mono60 => GetToolchain(RuntimeMoniker.Net60),
RuntimeMoniker.Mono70 => GetToolchain(RuntimeMoniker.Net70),
RuntimeMoniker.Mono80 => GetToolchain(RuntimeMoniker.Net80),
RuntimeMoniker.Mono90 => GetToolchain(RuntimeMoniker.Net90),
_ => CsProjCoreToolchain.From(new NetCoreAppSettings(mono.MsBuildMoniker, null, mono.Name))
};
}
Expand Down Expand Up @@ -152,6 +153,9 @@ private static IToolchain GetToolchain(RuntimeMoniker runtimeMoniker)
case RuntimeMoniker.Net80:
return CsProjCoreToolchain.NetCoreApp80;

case RuntimeMoniker.Net90:
return CsProjCoreToolchain.NetCoreApp90;

case RuntimeMoniker.NativeAot60:
return NativeAotToolchain.Net60;

Expand All @@ -161,6 +165,9 @@ private static IToolchain GetToolchain(RuntimeMoniker runtimeMoniker)
case RuntimeMoniker.NativeAot80:
return NativeAotToolchain.Net80;

case RuntimeMoniker.NativeAot90:
return NativeAotToolchain.Net90;

case RuntimeMoniker.Mono60:
return MonoToolchain.Mono60;

Expand All @@ -170,6 +177,9 @@ private static IToolchain GetToolchain(RuntimeMoniker runtimeMoniker)
case RuntimeMoniker.Mono80:
return MonoToolchain.Mono80;

case RuntimeMoniker.Mono90:
return MonoToolchain.Mono90;

default:
throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, "RuntimeMoniker not supported");
}
Expand Down
1 change: 1 addition & 0 deletions tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
Expand Up @@ -386,6 +386,7 @@ public void NetFrameworkMonikerParsedCorrectly(string tfm)
[InlineData("net60")]
[InlineData("net70")]
[InlineData("net80")]
[InlineData("net90")]
public void NetMonikersAreRecognizedAsNetCoreMonikers(string tfm)
{
var config = ConfigParser.Parse(new[] { "-r", tfm }, new OutputLogger(Output)).config;
Expand Down