Skip to content

Commit ae49148

Browse files
authored
implement full .NET 9 support (#2456)
1 parent 0a734a9 commit ae49148

File tree

14 files changed

+75
-1
lines changed

14 files changed

+75
-1
lines changed

NuGet.Config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
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" />
1414
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
15+
<add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
1516
</packageSources>
1617
</configuration>

src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ public enum RuntimeMoniker
105105
/// </summary>
106106
Net80,
107107

108+
/// <summary>
109+
/// .NET 9.0
110+
/// </summary>
111+
Net90,
112+
108113
/// <summary>
109114
/// NativeAOT compiled as net6.0
110115
/// </summary>
@@ -120,6 +125,11 @@ public enum RuntimeMoniker
120125
/// </summary>
121126
NativeAot80,
122127

128+
/// <summary>
129+
/// NativeAOT compiled as net9.0
130+
/// </summary>
131+
NativeAot90,
132+
123133
/// <summary>
124134
/// WebAssembly with default .Net version
125135
/// </summary>
@@ -170,6 +180,11 @@ public enum RuntimeMoniker
170180
/// </summary>
171181
MonoAOTLLVMNet80,
172182

183+
/// <summary>
184+
/// Mono with the Ahead of Time LLVM Compiler backend and net9.0
185+
/// </summary>
186+
MonoAOTLLVMNet90,
187+
173188
/// <summary>
174189
/// .NET 6 using MonoVM (not CLR which is the default)
175190
/// </summary>
@@ -184,5 +199,10 @@ public enum RuntimeMoniker
184199
/// .NET 8 using MonoVM (not CLR which is the default)
185200
/// </summary>
186201
Mono80,
202+
203+
/// <summary>
204+
/// .NET 9 using MonoVM (not CLR which is the default)
205+
/// </summary>
206+
Mono90,
187207
}
188208
}

src/BenchmarkDotNet.Diagnostics.dotTrace/DotTraceDiagnoser.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,14 @@ internal static bool IsSupported(RuntimeMoniker runtimeMoniker)
9797
case RuntimeMoniker.Net60:
9898
case RuntimeMoniker.Net70:
9999
case RuntimeMoniker.Net80:
100+
case RuntimeMoniker.Net90:
100101
return true;
101102
case RuntimeMoniker.NotRecognized:
102103
case RuntimeMoniker.Mono:
103104
case RuntimeMoniker.NativeAot60:
104105
case RuntimeMoniker.NativeAot70:
105106
case RuntimeMoniker.NativeAot80:
107+
case RuntimeMoniker.NativeAot90:
106108
case RuntimeMoniker.Wasm:
107109
case RuntimeMoniker.WasmNet50:
108110
case RuntimeMoniker.WasmNet60:
@@ -113,9 +115,11 @@ internal static bool IsSupported(RuntimeMoniker runtimeMoniker)
113115
case RuntimeMoniker.MonoAOTLLVMNet60:
114116
case RuntimeMoniker.MonoAOTLLVMNet70:
115117
case RuntimeMoniker.MonoAOTLLVMNet80:
118+
case RuntimeMoniker.MonoAOTLLVMNet90:
116119
case RuntimeMoniker.Mono60:
117120
case RuntimeMoniker.Mono70:
118121
case RuntimeMoniker.Mono80:
122+
case RuntimeMoniker.Mono90:
119123
#pragma warning disable CS0618 // Type or member is obsolete
120124
case RuntimeMoniker.NetCoreApp50:
121125
#pragma warning restore CS0618 // Type or member is obsolete

src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
532532
case RuntimeMoniker.Net60:
533533
case RuntimeMoniker.Net70:
534534
case RuntimeMoniker.Net80:
535+
case RuntimeMoniker.Net90:
535536
return baseJob
536537
.WithRuntime(runtimeMoniker.GetRuntime())
537538
.WithToolchain(CsProjCoreToolchain.From(new NetCoreAppSettings(runtimeId, null, runtimeId, options.CliPath?.FullName, options.RestorePath?.FullName)));
@@ -548,6 +549,9 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
548549
case RuntimeMoniker.NativeAot80:
549550
return CreateAotJob(baseJob, options, runtimeMoniker, "", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json");
550551

552+
case RuntimeMoniker.NativeAot90:
553+
return CreateAotJob(baseJob, options, runtimeMoniker, "", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json");
554+
551555
case RuntimeMoniker.Wasm:
552556
return MakeWasmJob(baseJob, options, RuntimeInformation.IsNetCore ? CoreRuntime.GetCurrentVersion().MsBuildMoniker : "net5.0", runtimeMoniker);
553557

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

585+
case RuntimeMoniker.MonoAOTLLVMNet90:
586+
return MakeMonoAOTLLVMJob(baseJob, options, "net9.0");
587+
581588
case RuntimeMoniker.Mono60:
582589
return MakeMonoJob(baseJob, options, MonoRuntime.Mono60);
583590

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

597+
case RuntimeMoniker.Mono90:
598+
return MakeMonoJob(baseJob, options, MonoRuntime.Mono90);
599+
590600
default:
591601
throw new NotSupportedException($"Runtime {runtimeId} is not supported");
592602
}

src/BenchmarkDotNet/Environments/Runtimes/CoreRuntime.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ public class CoreRuntime : Runtime
2020
public static readonly CoreRuntime Core60 = new (RuntimeMoniker.Net60, "net6.0", ".NET 6.0");
2121
public static readonly CoreRuntime Core70 = new (RuntimeMoniker.Net70, "net7.0", ".NET 7.0");
2222
public static readonly CoreRuntime Core80 = new (RuntimeMoniker.Net80, "net8.0", ".NET 8.0");
23+
public static readonly CoreRuntime Core90 = new (RuntimeMoniker.Net90, "net9.0", ".NET 9.0");
2324

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

2627
private CoreRuntime(RuntimeMoniker runtimeMoniker, string msBuildMoniker, string displayName)
2728
: base(runtimeMoniker, msBuildMoniker, displayName)
@@ -72,6 +73,7 @@ internal static CoreRuntime FromVersion(Version version)
7273
case Version v when v.Major == 6 && v.Minor == 0: return GetPlatformSpecific(Core60);
7374
case Version v when v.Major == 7 && v.Minor == 0: return GetPlatformSpecific(Core70);
7475
case Version v when v.Major == 8 && v.Minor == 0: return GetPlatformSpecific(Core80);
76+
case Version v when v.Major == 9 && v.Minor == 0: return GetPlatformSpecific(Core90);
7577
default:
7678
return CreateForNewVersion($"net{version.Major}.{version.Minor}", $".NET {version.Major}.{version.Minor}");
7779
}

src/BenchmarkDotNet/Environments/Runtimes/MonoRuntime.cs

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

1314
public string CustomPath { get; }
1415

src/BenchmarkDotNet/Environments/Runtimes/NativeAotRuntime.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public class NativeAotRuntime : Runtime
1818
/// NativeAOT compiled as net8.0
1919
/// </summary>
2020
public static readonly NativeAotRuntime Net80 = new NativeAotRuntime(RuntimeMoniker.NativeAot80, "net8.0", "NativeAOT 8.0");
21+
/// <summary>
22+
/// NativeAOT compiled as net9.0
23+
/// </summary>
24+
public static readonly NativeAotRuntime Net90 = new NativeAotRuntime(RuntimeMoniker.NativeAot90, "net9.0", "NativeAOT 9.0");
2125

2226
public override bool IsAOT => true;
2327

@@ -42,6 +46,8 @@ public static NativeAotRuntime GetCurrentVersion()
4246
{
4347
case Version v when v.Major == 6 && v.Minor == 0: return Net60;
4448
case Version v when v.Major == 7 && v.Minor == 0: return Net70;
49+
case Version v when v.Major == 8 && v.Minor == 0: return Net80;
50+
case Version v when v.Major == 9 && v.Minor == 0: return Net90;
4551
default:
4652
return new NativeAotRuntime(RuntimeMoniker.NotRecognized, $"net{version.Major}.{version.Minor}", $"NativeAOT {version.Major}.{version.Minor}");
4753
}

src/BenchmarkDotNet/Extensions/RuntimeMonikerExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ internal static Runtime GetRuntime(this RuntimeMoniker runtimeMoniker)
4545
return CoreRuntime.Core70;
4646
case RuntimeMoniker.Net80:
4747
return CoreRuntime.Core80;
48+
case RuntimeMoniker.Net90:
49+
return CoreRuntime.Core90;
4850
case RuntimeMoniker.Mono:
4951
return MonoRuntime.Default;
5052
case RuntimeMoniker.NativeAot60:
@@ -53,10 +55,16 @@ internal static Runtime GetRuntime(this RuntimeMoniker runtimeMoniker)
5355
return NativeAotRuntime.Net70;
5456
case RuntimeMoniker.NativeAot80:
5557
return NativeAotRuntime.Net80;
58+
case RuntimeMoniker.NativeAot90:
59+
return NativeAotRuntime.Net90;
5660
case RuntimeMoniker.Mono60:
5761
return MonoRuntime.Mono60;
5862
case RuntimeMoniker.Mono70:
5963
return MonoRuntime.Mono70;
64+
case RuntimeMoniker.Mono80:
65+
return MonoRuntime.Mono80;
66+
case RuntimeMoniker.Mono90:
67+
return MonoRuntime.Mono90;
6068
default:
6169
throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, "Runtime Moniker not supported");
6270
}

src/BenchmarkDotNet/Toolchains/CsProj/CsProjCoreToolchain.cs

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

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

src/BenchmarkDotNet/Toolchains/DotNetCli/NetCoreAppSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class NetCoreAppSettings
1818
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp60 = new ("net6.0", null, ".NET 6.0");
1919
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp70 = new ("net7.0", null, ".NET 7.0");
2020
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp80 = new ("net8.0", null, ".NET 8.0");
21+
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp90 = new ("net9.0", null, ".NET 9.0");
2122

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

0 commit comments

Comments
 (0)