Skip to content

Commit 761590e

Browse files
authored
Add net8.0 support to all existing runtimes and toolchains (#2192)
* add support for net8.0 * add support for NativeAOT .NET 8 * add support for MonoVM .NET 8 * add support for Mono AOT .NET 8 * add support for WASM .NET 8 * moniker name does not start with a dot * disable the CA1825 warning for samples and test projects
1 parent 36f9e73 commit 761590e

File tree

16 files changed

+98
-27
lines changed

16 files changed

+98
-27
lines changed

NuGet.Config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<!-- reuquired to run Mono AOT benchmarks -->
1212
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
1313
<add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
14+
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
1415
</packageSources>
1516
</configuration>

samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<GenerateDocumentationFile>false</GenerateDocumentationFile>
1111
<PlatformTarget>AnyCPU</PlatformTarget>
1212
<DebugSymbols>true</DebugSymbols>
13-
<NoWarn>$(NoWarn);CA1018;CA5351</NoWarn>
13+
<NoWarn>$(NoWarn);CA1018;CA5351;CA1825</NoWarn>
1414
</PropertyGroup>
1515
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
1616
<Reference Include="System.Reflection" />

src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ public enum RuntimeMoniker
100100
/// </summary>
101101
Net70,
102102

103+
/// <summary>
104+
/// .NET 8.0
105+
/// </summary>
106+
Net80,
107+
103108
/// <summary>
104109
/// NativeAOT compiled as net6.0
105110
/// </summary>
@@ -110,41 +115,56 @@ public enum RuntimeMoniker
110115
/// </summary>
111116
NativeAot70,
112117

118+
/// <summary>
119+
/// NativeAOT compiled as net8.0
120+
/// </summary>
121+
NativeAot80,
122+
113123
/// <summary>
114124
/// WebAssembly with default .Net version
115125
/// </summary>
116126
Wasm,
117127

118128
/// <summary>
119-
/// WebAssembly with .net5.0
129+
/// WebAssembly with net5.0
120130
/// </summary>
121131
WasmNet50,
122132

123133
/// <summary>
124-
/// WebAssembly with .net6.0
134+
/// WebAssembly with net6.0
125135
/// </summary>
126136
WasmNet60,
127137

128138
/// <summary>
129-
/// WebAssembly with .net7.0
139+
/// WebAssembly with net7.0
130140
/// </summary>
131141
WasmNet70,
132142

143+
/// <summary>
144+
/// WebAssembly with net8.0
145+
/// </summary>
146+
WasmNet80,
147+
133148
/// <summary>
134149
/// Mono with the Ahead of Time LLVM Compiler backend
135150
/// </summary>
136151
MonoAOTLLVM,
137152

138153
/// <summary>
139-
/// Mono with the Ahead of Time LLVM Compiler backend and .net6.0
154+
/// Mono with the Ahead of Time LLVM Compiler backend and net6.0
140155
/// </summary>
141156
MonoAOTLLVMNet60,
142157

143158
/// <summary>
144-
/// Mono with the Ahead of Time LLVM Compiler backend and .net7.0
159+
/// Mono with the Ahead of Time LLVM Compiler backend and net7.0
145160
/// </summary>
146161
MonoAOTLLVMNet70,
147162

163+
/// <summary>
164+
/// Mono with the Ahead of Time LLVM Compiler backend and net8.0
165+
/// </summary>
166+
MonoAOTLLVMNet80,
167+
148168
/// <summary>
149169
/// .NET 6 using MonoVM (not CLR which is the default)
150170
/// </summary>
@@ -154,5 +174,10 @@ public enum RuntimeMoniker
154174
/// .NET 7 using MonoVM (not CLR which is the default)
155175
/// </summary>
156176
Mono70,
177+
178+
/// <summary>
179+
/// .NET 8 using MonoVM (not CLR which is the default)
180+
/// </summary>
181+
Mono80,
157182
}
158183
}

src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
394394
case RuntimeMoniker.Net50:
395395
case RuntimeMoniker.Net60:
396396
case RuntimeMoniker.Net70:
397+
case RuntimeMoniker.Net80:
397398
return baseJob
398399
.WithRuntime(runtimeMoniker.GetRuntime())
399400
.WithToolchain(CsProjCoreToolchain.From(new NetCoreAppSettings(runtimeId, null, runtimeId, options.CliPath?.FullName, options.RestorePath?.FullName)));
@@ -407,6 +408,9 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
407408
case RuntimeMoniker.NativeAot70:
408409
return CreateAotJob(baseJob, options, runtimeMoniker, "", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json");
409410

411+
case RuntimeMoniker.NativeAot80:
412+
return CreateAotJob(baseJob, options, runtimeMoniker, "", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json");
413+
410414
case RuntimeMoniker.Wasm:
411415
return MakeWasmJob(baseJob, options, RuntimeInformation.IsNetCore ? CoreRuntime.GetCurrentVersion().MsBuildMoniker : "net5.0", runtimeMoniker);
412416

@@ -419,6 +423,9 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
419423
case RuntimeMoniker.WasmNet70:
420424
return MakeWasmJob(baseJob, options, "net7.0", runtimeMoniker);
421425

426+
case RuntimeMoniker.WasmNet80:
427+
return MakeWasmJob(baseJob, options, "net8.0", runtimeMoniker);
428+
422429
case RuntimeMoniker.MonoAOTLLVM:
423430
return MakeMonoAOTLLVMJob(baseJob, options, RuntimeInformation.IsNetCore ? CoreRuntime.GetCurrentVersion().MsBuildMoniker : "net6.0");
424431

@@ -428,12 +435,18 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
428435
case RuntimeMoniker.MonoAOTLLVMNet70:
429436
return MakeMonoAOTLLVMJob(baseJob, options, "net7.0");
430437

438+
case RuntimeMoniker.MonoAOTLLVMNet80:
439+
return MakeMonoAOTLLVMJob(baseJob, options, "net8.0");
440+
431441
case RuntimeMoniker.Mono60:
432442
return MakeMonoJob(baseJob, options, MonoRuntime.Mono60);
433443

434444
case RuntimeMoniker.Mono70:
435445
return MakeMonoJob(baseJob, options, MonoRuntime.Mono70);
436446

447+
case RuntimeMoniker.Mono80:
448+
return MakeMonoJob(baseJob, options, MonoRuntime.Mono80);
449+
437450
default:
438451
throw new NotSupportedException($"Runtime {runtimeId} is not supported");
439452
}

src/BenchmarkDotNet/Environments/Runtimes/CoreRuntime.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ namespace BenchmarkDotNet.Environments
1111
{
1212
public class CoreRuntime : Runtime
1313
{
14-
public static readonly CoreRuntime Core20 = new CoreRuntime(RuntimeMoniker.NetCoreApp20, "netcoreapp2.0", ".NET Core 2.0");
15-
public static readonly CoreRuntime Core21 = new CoreRuntime(RuntimeMoniker.NetCoreApp21, "netcoreapp2.1", ".NET Core 2.1");
16-
public static readonly CoreRuntime Core22 = new CoreRuntime(RuntimeMoniker.NetCoreApp22, "netcoreapp2.2", ".NET Core 2.2");
17-
public static readonly CoreRuntime Core30 = new CoreRuntime(RuntimeMoniker.NetCoreApp30, "netcoreapp3.0", ".NET Core 3.0");
18-
public static readonly CoreRuntime Core31 = new CoreRuntime(RuntimeMoniker.NetCoreApp31, "netcoreapp3.1", ".NET Core 3.1");
19-
public static readonly CoreRuntime Core50 = new CoreRuntime(RuntimeMoniker.Net50, "net5.0", ".NET 5.0");
20-
public static readonly CoreRuntime Core60 = new CoreRuntime(RuntimeMoniker.Net60, "net6.0", ".NET 6.0");
21-
public static readonly CoreRuntime Core70 = new CoreRuntime(RuntimeMoniker.Net70, "net7.0", ".NET 7.0");
22-
23-
public static CoreRuntime Latest => Core70; // when dotnet/runtime branches for 8.0, this will need to get updated
14+
public static readonly CoreRuntime Core20 = new (RuntimeMoniker.NetCoreApp20, "netcoreapp2.0", ".NET Core 2.0");
15+
public static readonly CoreRuntime Core21 = new (RuntimeMoniker.NetCoreApp21, "netcoreapp2.1", ".NET Core 2.1");
16+
public static readonly CoreRuntime Core22 = new (RuntimeMoniker.NetCoreApp22, "netcoreapp2.2", ".NET Core 2.2");
17+
public static readonly CoreRuntime Core30 = new (RuntimeMoniker.NetCoreApp30, "netcoreapp3.0", ".NET Core 3.0");
18+
public static readonly CoreRuntime Core31 = new (RuntimeMoniker.NetCoreApp31, "netcoreapp3.1", ".NET Core 3.1");
19+
public static readonly CoreRuntime Core50 = new (RuntimeMoniker.Net50, "net5.0", ".NET 5.0");
20+
public static readonly CoreRuntime Core60 = new (RuntimeMoniker.Net60, "net6.0", ".NET 6.0");
21+
public static readonly CoreRuntime Core70 = new (RuntimeMoniker.Net70, "net7.0", ".NET 7.0");
22+
public static readonly CoreRuntime Core80 = new (RuntimeMoniker.Net80, "net8.0", ".NET 8.0");
23+
24+
public static CoreRuntime Latest => Core80; // when dotnet/runtime branches for 9.0, this will need to get updated
2425

2526
private CoreRuntime(RuntimeMoniker runtimeMoniker, string msBuildMoniker, string displayName)
2627
: base(runtimeMoniker, msBuildMoniker, displayName)

src/BenchmarkDotNet/Environments/Runtimes/MonoRuntime.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class MonoRuntime : Runtime, IEquatable<MonoRuntime>
88
public static readonly MonoRuntime Default = new MonoRuntime("Mono");
99
public static readonly MonoRuntime Mono60 = new MonoRuntime("Mono with .NET 6.0", RuntimeMoniker.Mono60, "net6.0", isDotNetBuiltIn: true);
1010
public static readonly MonoRuntime Mono70 = new MonoRuntime("Mono with .NET 7.0", RuntimeMoniker.Mono70, "net7.0", isDotNetBuiltIn: true);
11+
public static readonly MonoRuntime Mono80 = new MonoRuntime("Mono with .NET 8.0", RuntimeMoniker.Mono80, "net8.0", isDotNetBuiltIn: true);
1112

1213
public string CustomPath { get; }
1314

src/BenchmarkDotNet/Environments/Runtimes/NativeAotRuntime.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public class NativeAotRuntime : Runtime
1414
/// NativeAOT compiled as net7.0
1515
/// </summary>
1616
public static readonly NativeAotRuntime Net70 = new NativeAotRuntime(RuntimeMoniker.NativeAot70, "net7.0", "NativeAOT 7.0");
17+
/// <summary>
18+
/// NativeAOT compiled as net8.0
19+
/// </summary>
20+
public static readonly NativeAotRuntime Net80 = new NativeAotRuntime(RuntimeMoniker.NativeAot80, "net8.0", "NativeAOT 8.0");
1721

1822
public override bool IsAOT => true;
1923

src/BenchmarkDotNet/Extensions/RuntimeMonikerExtensions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ internal static Runtime GetRuntime(this RuntimeMoniker runtimeMoniker)
4343
return CoreRuntime.Core60;
4444
case RuntimeMoniker.Net70:
4545
return CoreRuntime.Core70;
46+
case RuntimeMoniker.Net80:
47+
return CoreRuntime.Core80;
4648
case RuntimeMoniker.Mono:
4749
return MonoRuntime.Default;
4850
case RuntimeMoniker.NativeAot60:
4951
return NativeAotRuntime.Net60;
5052
case RuntimeMoniker.NativeAot70:
5153
return NativeAotRuntime.Net70;
54+
case RuntimeMoniker.NativeAot80:
55+
return NativeAotRuntime.Net80;
5256
case RuntimeMoniker.Mono60:
5357
return MonoRuntime.Mono60;
5458
case RuntimeMoniker.Mono70:

src/BenchmarkDotNet/Toolchains/CsProj/CsProjCoreToolchain.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class CsProjCoreToolchain : Toolchain, IEquatable<CsProjCoreToolchain>
2323
[PublicAPI] public static readonly IToolchain NetCoreApp50 = From(NetCoreAppSettings.NetCoreApp50);
2424
[PublicAPI] public static readonly IToolchain NetCoreApp60 = From(NetCoreAppSettings.NetCoreApp60);
2525
[PublicAPI] public static readonly IToolchain NetCoreApp70 = From(NetCoreAppSettings.NetCoreApp70);
26+
[PublicAPI] public static readonly IToolchain NetCoreApp80 = From(NetCoreAppSettings.NetCoreApp80);
2627

2728
internal CsProjCoreToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath)
2829
: base(name, generator, builder, executor)

src/BenchmarkDotNet/Toolchains/DotNetCli/NetCoreAppSettings.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ namespace BenchmarkDotNet.Toolchains.DotNetCli
99
[PublicAPI]
1010
public class NetCoreAppSettings
1111
{
12-
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp20 = new NetCoreAppSettings("netcoreapp2.0", null, ".NET Core 2.0");
13-
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp21 = new NetCoreAppSettings("netcoreapp2.1", null, ".NET Core 2.1");
14-
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp22 = new NetCoreAppSettings("netcoreapp2.2", null, ".NET Core 2.2");
15-
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp30 = new NetCoreAppSettings("netcoreapp3.0", null, ".NET Core 3.0");
16-
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp31 = new NetCoreAppSettings("netcoreapp3.1", null, ".NET Core 3.1");
17-
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp50 = new NetCoreAppSettings("net5.0", null, ".NET 5.0");
18-
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp60 = new NetCoreAppSettings("net6.0", null, ".NET 6.0");
19-
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp70 = new NetCoreAppSettings("net7.0", null, ".NET 7.0");
12+
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp20 = new ("netcoreapp2.0", null, ".NET Core 2.0");
13+
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp21 = new ("netcoreapp2.1", null, ".NET Core 2.1");
14+
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp22 = new ("netcoreapp2.2", null, ".NET Core 2.2");
15+
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp30 = new ("netcoreapp3.0", null, ".NET Core 3.0");
16+
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp31 = new ("netcoreapp3.1", null, ".NET Core 3.1");
17+
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp50 = new ("net5.0", null, ".NET 5.0");
18+
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp60 = new ("net6.0", null, ".NET 6.0");
19+
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp70 = new ("net7.0", null, ".NET 7.0");
20+
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp80 = new ("net8.0", null, ".NET 8.0");
2021

2122
/// <summary>
2223
/// <param name="targetFrameworkMoniker">

0 commit comments

Comments
 (0)