Skip to content

Commit

Permalink
Add .NET 10 support (#2642)
Browse files Browse the repository at this point in the history
* Add .NET 10 support

* Use _

---------

Co-authored-by: Tim Cassell <35501420+timcassell@users.noreply.github.com>
Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
  • Loading branch information
3 people authored Jan 7, 2025
1 parent cac4f6e commit 3337a09
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 10 deletions.
1 change: 1 addition & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
<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" />
<add key="dotnet10" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10/nuget/v3/index.json" />
</packageSources>
</configuration>
25 changes: 25 additions & 0 deletions src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public enum RuntimeMoniker
/// </summary>
Net90,

/// <summary>
/// .NET 10.0
/// </summary>
Net10_0,

/// <summary>
/// NativeAOT compiled as net6.0
/// </summary>
Expand All @@ -135,6 +140,11 @@ public enum RuntimeMoniker
/// </summary>
NativeAot90,

/// <summary>
/// NativeAOT compiled as net10.0
/// </summary>
NativeAot10_0,

/// <summary>
/// WebAssembly with default .Net version
/// </summary>
Expand Down Expand Up @@ -165,6 +175,11 @@ public enum RuntimeMoniker
/// </summary>
WasmNet90,

/// <summary>
/// WebAssembly with net10.0
/// </summary>
WasmNet10_0,

/// <summary>
/// Mono with the Ahead of Time LLVM Compiler backend
/// </summary>
Expand All @@ -190,6 +205,11 @@ public enum RuntimeMoniker
/// </summary>
MonoAOTLLVMNet90,

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

/// <summary>
/// .NET 6 using MonoVM (not CLR which is the default)
/// </summary>
Expand All @@ -209,5 +229,10 @@ public enum RuntimeMoniker
/// .NET 9 using MonoVM (not CLR which is the default)
/// </summary>
Mono90,

/// <summary>
/// .NET 10 using MonoVM (not CLR which is the default)
/// </summary>
Mono10_0,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,33 @@ internal override bool IsSupported(RuntimeMoniker runtimeMoniker)
case RuntimeMoniker.Net70:
case RuntimeMoniker.Net80:
case RuntimeMoniker.Net90:
case RuntimeMoniker.Net10_0:
return true;
case RuntimeMoniker.NotRecognized:
case RuntimeMoniker.Mono:
case RuntimeMoniker.NativeAot60:
case RuntimeMoniker.NativeAot70:
case RuntimeMoniker.NativeAot80:
case RuntimeMoniker.NativeAot90:
case RuntimeMoniker.NativeAot10_0:
case RuntimeMoniker.Wasm:
case RuntimeMoniker.WasmNet50:
case RuntimeMoniker.WasmNet60:
case RuntimeMoniker.WasmNet70:
case RuntimeMoniker.WasmNet80:
case RuntimeMoniker.WasmNet90:
case RuntimeMoniker.WasmNet10_0:
case RuntimeMoniker.MonoAOTLLVM:
case RuntimeMoniker.MonoAOTLLVMNet60:
case RuntimeMoniker.MonoAOTLLVMNet70:
case RuntimeMoniker.MonoAOTLLVMNet80:
case RuntimeMoniker.MonoAOTLLVMNet90:
case RuntimeMoniker.MonoAOTLLVMNet10_0:
case RuntimeMoniker.Mono60:
case RuntimeMoniker.Mono70:
case RuntimeMoniker.Mono80:
case RuntimeMoniker.Mono90:
case RuntimeMoniker.Mono10_0:
#pragma warning disable CS0618 // Type or member is obsolete
case RuntimeMoniker.NetCoreApp50:
#pragma warning restore CS0618 // Type or member is obsolete
Expand All @@ -113,4 +118,4 @@ internal override bool IsSupported(RuntimeMoniker runtimeMoniker)
throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, $"Runtime moniker {runtimeMoniker} is not supported");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,33 @@ internal override bool IsSupported(RuntimeMoniker runtimeMoniker)
case RuntimeMoniker.Net70:
case RuntimeMoniker.Net80:
case RuntimeMoniker.Net90:
case RuntimeMoniker.Net10_0:
return true;
case RuntimeMoniker.NotRecognized:
case RuntimeMoniker.Mono:
case RuntimeMoniker.NativeAot60:
case RuntimeMoniker.NativeAot70:
case RuntimeMoniker.NativeAot80:
case RuntimeMoniker.NativeAot90:
case RuntimeMoniker.NativeAot10_0:
case RuntimeMoniker.Wasm:
case RuntimeMoniker.WasmNet50:
case RuntimeMoniker.WasmNet60:
case RuntimeMoniker.WasmNet70:
case RuntimeMoniker.WasmNet80:
case RuntimeMoniker.WasmNet90:
case RuntimeMoniker.WasmNet10_0:
case RuntimeMoniker.MonoAOTLLVM:
case RuntimeMoniker.MonoAOTLLVMNet60:
case RuntimeMoniker.MonoAOTLLVMNet70:
case RuntimeMoniker.MonoAOTLLVMNet80:
case RuntimeMoniker.MonoAOTLLVMNet90:
case RuntimeMoniker.MonoAOTLLVMNet10_0:
case RuntimeMoniker.Mono60:
case RuntimeMoniker.Mono70:
case RuntimeMoniker.Mono80:
case RuntimeMoniker.Mono90:
case RuntimeMoniker.Mono10_0:
#pragma warning disable CS0618 // Type or member is obsolete
case RuntimeMoniker.NetCoreApp50:
#pragma warning restore CS0618 // Type or member is obsolete
Expand All @@ -116,4 +121,4 @@ internal override bool IsSupported(RuntimeMoniker runtimeMoniker)
throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, $"Runtime moniker {runtimeMoniker} is not supported");
}
}
}
}
13 changes: 13 additions & 0 deletions src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
case RuntimeMoniker.Net70:
case RuntimeMoniker.Net80:
case RuntimeMoniker.Net90:
case RuntimeMoniker.Net10_0:
return baseJob
.WithRuntime(runtimeMoniker.GetRuntime())
.WithToolchain(CsProjCoreToolchain.From(new NetCoreAppSettings(runtimeId, null, runtimeId, options.CliPath?.FullName, options.RestorePath?.FullName)));
Expand All @@ -547,6 +548,9 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
case RuntimeMoniker.NativeAot90:
return CreateAotJob(baseJob, options, runtimeMoniker, "", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json");

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

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

Expand All @@ -565,6 +569,9 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
case RuntimeMoniker.WasmNet90:
return MakeWasmJob(baseJob, options, "net9.0", runtimeMoniker);

case RuntimeMoniker.WasmNet10_0:
return MakeWasmJob(baseJob, options, "net10.0", runtimeMoniker);

case RuntimeMoniker.MonoAOTLLVM:
return MakeMonoAOTLLVMJob(baseJob, options, RuntimeInformation.IsNetCore ? CoreRuntime.GetCurrentVersion().MsBuildMoniker : "net6.0", runtimeMoniker);

Expand All @@ -580,6 +587,9 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
case RuntimeMoniker.MonoAOTLLVMNet90:
return MakeMonoAOTLLVMJob(baseJob, options, "net9.0", runtimeMoniker);

case RuntimeMoniker.MonoAOTLLVMNet10_0:
return MakeMonoAOTLLVMJob(baseJob, options, "net10.0", runtimeMoniker);

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

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

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

default:
throw new NotSupportedException($"Runtime {runtimeId} is not supported");
}
Expand Down
4 changes: 3 additions & 1 deletion src/BenchmarkDotNet/Environments/Runtimes/CoreRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public class CoreRuntime : Runtime
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 readonly CoreRuntime Core10_0 = new (RuntimeMoniker.Net10_0, "net10.0", ".NET 10.0");

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

private CoreRuntime(RuntimeMoniker runtimeMoniker, string msBuildMoniker, string displayName)
: base(runtimeMoniker, msBuildMoniker, displayName)
Expand Down Expand Up @@ -74,6 +75,7 @@ internal static CoreRuntime FromVersion(Version version)
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);
case Version v when v.Major == 10 && v.Minor == 0: return GetPlatformSpecific(Core10_0);
default:
return version >= new Version(3, 1)
? 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class MonoRuntime : Runtime, IEquatable<MonoRuntime>
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 static readonly MonoRuntime Mono10_0 = new ("Mono with .NET 10.0", RuntimeMoniker.Mono10_0, "net10.0", isDotNetBuiltIn: true);

public string CustomPath { get; }

Expand Down
5 changes: 5 additions & 0 deletions src/BenchmarkDotNet/Environments/Runtimes/NativeAotRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class NativeAotRuntime : Runtime
/// NativeAOT compiled as net9.0
/// </summary>
public static readonly NativeAotRuntime Net90 = new NativeAotRuntime(RuntimeMoniker.NativeAot90, "net9.0", "NativeAOT 9.0");
/// <summary>
/// NativeAOT compiled as net10.0
/// </summary>
public static readonly NativeAotRuntime Net10_0 = new NativeAotRuntime(RuntimeMoniker.NativeAot10_0, "net10.0", "NativeAOT 10.0");

public override bool IsAOT => true;

Expand All @@ -48,6 +52,7 @@ public static NativeAotRuntime GetCurrentVersion()
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;
case Version v when v.Major == 10 && v.Minor == 0: return Net10_0;
default:
return new NativeAotRuntime(RuntimeMoniker.NotRecognized, $"net{version.Major}.{version.Minor}", $"NativeAOT {version.Major}.{version.Minor}");
}
Expand Down
10 changes: 6 additions & 4 deletions src/BenchmarkDotNet/Extensions/RuntimeMonikerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ internal static Runtime GetRuntime(this RuntimeMoniker runtimeMoniker)
return CoreRuntime.Core80;
case RuntimeMoniker.Net90:
return CoreRuntime.Core90;
case RuntimeMoniker.Net10_0:
return CoreRuntime.Core10_0;
case RuntimeMoniker.Mono:
return MonoRuntime.Default;
case RuntimeMoniker.NativeAot60:
Expand All @@ -47,16 +49,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.NativeAot10_0:
return NativeAotRuntime.Net10_0;
case RuntimeMoniker.Mono60:
return MonoRuntime.Mono60;
case RuntimeMoniker.Mono70:
return MonoRuntime.Mono70;
case RuntimeMoniker.Mono80:
return MonoRuntime.Mono80;
case RuntimeMoniker.Mono90:
return MonoRuntime.Mono90;
case RuntimeMoniker.Mono10_0:
return MonoRuntime.Mono10_0;
default:
throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, "Runtime Moniker not supported");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class CsProjCoreToolchain : Toolchain, IEquatable<CsProjCoreToolchain>
[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);
[PublicAPI] public static readonly IToolchain NetCoreApp10_0 = From(NetCoreAppSettings.NetCoreApp10_0);

internal CsProjCoreToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath)
: base(name, generator, builder, executor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ private static string Map(Capture capture)
return "net8.0";
case ".NETCoreApp,Version=v9.0":
return "net9.0";
case ".NETCoreApp,Version=v10.0":
return "net10.0";
default:
return capture.Value; // we don't want to throw for future versions of .NET
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class NetCoreAppSettings
[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");
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp10_0 = new ("net10.0", null, ".NET 10.0");

/// <summary>
/// <param name="targetFrameworkMoniker">
Expand Down
1 change: 1 addition & 0 deletions src/BenchmarkDotNet/Toolchains/Mono/MonoToolchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class MonoToolchain : CsProjCoreToolchain, IEquatable<MonoToolchain>
[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"));
[PublicAPI] public static readonly IToolchain Mono10_0 = From(new NetCoreAppSettings("net10.0", null, "mono10_0"));

private MonoToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath)
: base(name, generator, builder, executor, customDotNetCliPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public class NativeAotToolchain : Toolchain
.TargetFrameworkMoniker("net9.0")
.ToToolchain();

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

internal NativeAotToolchain(string displayName,
string ilCompilerVersion,
string runtimeFrameworkVersion, string targetFrameworkMoniker, string runtimeIdentifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public NativeAotToolchainBuilder UseLocalBuild(DirectoryInfo ilcPackages)
if (!ilcPackages.Exists) throw new DirectoryNotFoundException($"{ilcPackages} provided as {nameof(ilcPackages)} does NOT exist");

Feeds["local"] = ilcPackages.FullName;
ilCompilerVersion = "9.0.0-dev";
Feeds["dotnet9"] = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json";
ilCompilerVersion = "10.0.0-dev";
Feeds["dotnet10"] = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10/nuget/v3/index.json";
useTempFolderForRestore = true;
DisplayName("local ILCompiler build");

Expand Down
10 changes: 10 additions & 0 deletions src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ internal static IToolchain GetToolchain(this Runtime runtime, Descriptor? descri
RuntimeMoniker.Mono70 => GetToolchain(RuntimeMoniker.Net70),
RuntimeMoniker.Mono80 => GetToolchain(RuntimeMoniker.Net80),
RuntimeMoniker.Mono90 => GetToolchain(RuntimeMoniker.Net90),
RuntimeMoniker.Mono10_0 => GetToolchain(RuntimeMoniker.Net10_0),
_ => CsProjCoreToolchain.From(new NetCoreAppSettings(mono.MsBuildMoniker, null, mono.Name))
};
}
Expand Down Expand Up @@ -143,6 +144,9 @@ private static IToolchain GetToolchain(RuntimeMoniker runtimeMoniker)
case RuntimeMoniker.Net90:
return CsProjCoreToolchain.NetCoreApp90;

case RuntimeMoniker.Net10_0:
return CsProjCoreToolchain.NetCoreApp10_0;

case RuntimeMoniker.NativeAot60:
return NativeAotToolchain.Net60;

Expand All @@ -155,6 +159,9 @@ private static IToolchain GetToolchain(RuntimeMoniker runtimeMoniker)
case RuntimeMoniker.NativeAot90:
return NativeAotToolchain.Net90;

case RuntimeMoniker.NativeAot10_0:
return NativeAotToolchain.Net10_0;

case RuntimeMoniker.Mono60:
return MonoToolchain.Mono60;

Expand All @@ -167,6 +174,9 @@ private static IToolchain GetToolchain(RuntimeMoniker runtimeMoniker)
case RuntimeMoniker.Mono90:
return MonoToolchain.Mono90;

case RuntimeMoniker.Mono10_0:
return MonoToolchain.Mono10_0;

default:
throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, "RuntimeMoniker not supported");
}
Expand Down
Loading

0 comments on commit 3337a09

Please sign in to comment.