From bf011627cf3808a7fd74045317ddc9e89c7d0f3a Mon Sep 17 00:00:00 2001
From: Adeel <3840695+am11@users.noreply.github.com>
Date: Mon, 27 Sep 2021 23:02:45 +0300
Subject: [PATCH] Add net7.0 runtime support
---
.../Jobs/RuntimeMoniker.cs | 17 ++++++++++++++++-
.../ConsoleArguments/ConfigParser.cs | 4 ++++
.../Environments/Runtimes/CoreRtRuntime.cs | 7 ++++++-
.../Environments/Runtimes/CoreRuntime.cs | 2 ++
.../Extensions/RuntimeMonikerExtensions.cs | 4 ++++
.../Toolchains/CoreRt/CoreRtToolchain.cs | 4 +++-
.../Toolchains/CsProj/CsProjCoreToolchain.cs | 3 ++-
.../Toolchains/DotNetCli/NetCoreAppSettings.cs | 3 ++-
.../Toolchains/ToolchainExtensions.cs | 6 +++++-
.../BenchmarkDotNet.Tests/ConfigParserTests.cs | 5 +++--
10 files changed, 47 insertions(+), 8 deletions(-)
diff --git a/src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs b/src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs
index 9f450fd7a6..7793710060 100644
--- a/src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs
+++ b/src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs
@@ -88,7 +88,12 @@ public enum RuntimeMoniker
///
/// .NET 6.0
///
- Net60, // it's after NetCoreApp50 and Net50 in the enum definition because the value of enumeration is used for framework version comparison using > < operators
+ Net60,
+
+ ///
+ /// .NET 7.0
+ ///
+ Net70,
///
/// CoreRT compiled as netcoreapp2.0
@@ -125,6 +130,11 @@ public enum RuntimeMoniker
///
CoreRt60,
+ ///
+ /// CoreRT compiled as net7.0
+ ///
+ CoreRt70,
+
///
/// WebAssembly with default .Net version
///
@@ -140,6 +150,11 @@ public enum RuntimeMoniker
///
WasmNet60,
+ ///
+ /// WebAssembly with .net7.0
+ ///
+ WasmNet70,
+
///
/// Mono with the Ahead of Time LLVM Compiler backend
///
diff --git a/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs b/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
index d7fd9e34e6..a38b002a65 100644
--- a/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
+++ b/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
@@ -352,6 +352,7 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
#pragma warning restore CS0618 // Type or member is obsolete
case RuntimeMoniker.Net50:
case RuntimeMoniker.Net60:
+ case RuntimeMoniker.Net70:
return baseJob
.WithRuntime(runtimeMoniker.GetRuntime())
.WithToolchain(CsProjCoreToolchain.From(new NetCoreAppSettings(runtimeId, null, runtimeId, options.CliPath?.FullName, options.RestorePath?.FullName, timeOut)));
@@ -364,6 +365,7 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
case RuntimeMoniker.CoreRt31:
case RuntimeMoniker.CoreRt50:
case RuntimeMoniker.CoreRt60:
+ case RuntimeMoniker.CoreRt70:
var builder = CoreRtToolchain.CreateBuilder();
if (options.CliPath != null)
@@ -391,6 +393,8 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma
return MakeWasmJob(baseJob, options, timeOut, "net5.0");
case RuntimeMoniker.WasmNet60:
return MakeWasmJob(baseJob, options, timeOut, "net6.0");
+ case RuntimeMoniker.WasmNet70:
+ return MakeWasmJob(baseJob, options, timeOut, "net7.0");
case RuntimeMoniker.MonoAOTLLVM:
var monoAotLLVMRuntime = new MonoAotLLVMRuntime(aotCompilerPath: options.AOTCompilerPath);
diff --git a/src/BenchmarkDotNet/Environments/Runtimes/CoreRtRuntime.cs b/src/BenchmarkDotNet/Environments/Runtimes/CoreRtRuntime.cs
index 8af91d00ba..a9dac4ddf2 100644
--- a/src/BenchmarkDotNet/Environments/Runtimes/CoreRtRuntime.cs
+++ b/src/BenchmarkDotNet/Environments/Runtimes/CoreRtRuntime.cs
@@ -34,7 +34,11 @@ public class CoreRtRuntime : Runtime
///
/// CoreRT compiled as net6.0
///
- public static readonly CoreRtRuntime CoreRt60 = new CoreRtRuntime(RuntimeMoniker.CoreRt50, "net6.0", "CoreRT 6.0");
+ public static readonly CoreRtRuntime CoreRt60 = new CoreRtRuntime(RuntimeMoniker.CoreRt60, "net6.0", "CoreRT 6.0");
+ ///
+ /// CoreRT compiled as net7.0
+ ///
+ public static readonly CoreRtRuntime CoreRt70 = new CoreRtRuntime(RuntimeMoniker.CoreRt70, "net7.0", "CoreRT 7.0");
private CoreRtRuntime(RuntimeMoniker runtimeMoniker, string msBuildMoniker, string displayName)
: base(runtimeMoniker, msBuildMoniker, displayName)
@@ -62,6 +66,7 @@ public static CoreRtRuntime GetCurrentVersion()
case Version v when v.Major == 3 && v.Minor == 1: return CoreRt31;
case Version v when v.Major == 5 && v.Minor == 0: return CoreRt50;
case Version v when v.Major == 6 && v.Minor == 0: return CoreRt60;
+ case Version v when v.Major == 7 && v.Minor == 0: return CoreRt70;
default:
return new CoreRtRuntime(RuntimeMoniker.NotRecognized, $"net{version.Major}.{version.Minor}", $"CoreRT {version.Major}.{version.Minor}");
}
diff --git a/src/BenchmarkDotNet/Environments/Runtimes/CoreRuntime.cs b/src/BenchmarkDotNet/Environments/Runtimes/CoreRuntime.cs
index 296d7b4834..99d1d2168f 100644
--- a/src/BenchmarkDotNet/Environments/Runtimes/CoreRuntime.cs
+++ b/src/BenchmarkDotNet/Environments/Runtimes/CoreRuntime.cs
@@ -18,6 +18,7 @@ public class CoreRuntime : Runtime
public static readonly CoreRuntime Core31 = new CoreRuntime(RuntimeMoniker.NetCoreApp31, "netcoreapp3.1", ".NET Core 3.1");
public static readonly CoreRuntime Core50 = new CoreRuntime(RuntimeMoniker.Net50, "net5.0", ".NET 5.0");
public static readonly CoreRuntime Core60 = new CoreRuntime(RuntimeMoniker.Net60, "net6.0", ".NET 6.0");
+ public static readonly CoreRuntime Core70 = new CoreRuntime(RuntimeMoniker.Net70, "net7.0", ".NET 7.0");
private CoreRuntime(RuntimeMoniker runtimeMoniker, string msBuildMoniker, string displayName)
: base(runtimeMoniker, msBuildMoniker, displayName)
@@ -66,6 +67,7 @@ internal static CoreRuntime FromVersion(Version version)
case Version v when v.Major == 3 && v.Minor == 1: return Core31;
case Version v when v.Major == 5 && v.Minor == 0: return GetPlatformSpecific(Core50);
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);
default:
return CreateForNewVersion($"net{version.Major}.{version.Minor}", $".NET {version.Major}.{version.Minor}");
}
diff --git a/src/BenchmarkDotNet/Extensions/RuntimeMonikerExtensions.cs b/src/BenchmarkDotNet/Extensions/RuntimeMonikerExtensions.cs
index 6a29f06b48..9ca0982c2a 100644
--- a/src/BenchmarkDotNet/Extensions/RuntimeMonikerExtensions.cs
+++ b/src/BenchmarkDotNet/Extensions/RuntimeMonikerExtensions.cs
@@ -39,6 +39,8 @@ internal static Runtime GetRuntime(this RuntimeMoniker runtimeMoniker)
return CoreRuntime.Core50;
case RuntimeMoniker.Net60:
return CoreRuntime.Core60;
+ case RuntimeMoniker.Net70:
+ return CoreRuntime.Core70;
case RuntimeMoniker.Mono:
return MonoRuntime.Default;
case RuntimeMoniker.CoreRt20:
@@ -55,6 +57,8 @@ internal static Runtime GetRuntime(this RuntimeMoniker runtimeMoniker)
return CoreRtRuntime.CoreRt50;
case RuntimeMoniker.CoreRt60:
return CoreRtRuntime.CoreRt60;
+ case RuntimeMoniker.CoreRt70:
+ return CoreRtRuntime.CoreRt70;
default:
throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, "Runtime Moniker not supported");
}
diff --git a/src/BenchmarkDotNet/Toolchains/CoreRt/CoreRtToolchain.cs b/src/BenchmarkDotNet/Toolchains/CoreRt/CoreRtToolchain.cs
index 982ff9a001..fd1048bac4 100644
--- a/src/BenchmarkDotNet/Toolchains/CoreRt/CoreRtToolchain.cs
+++ b/src/BenchmarkDotNet/Toolchains/CoreRt/CoreRtToolchain.cs
@@ -35,6 +35,8 @@ public class CoreRtToolchain : Toolchain
/// compiled as net6.0, targets latest (6.0.0-*) CoreRT build from the new feed: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json
///
public static readonly IToolchain Core60 = CreateBuilder().UseCoreRtNuGet().TargetFrameworkMoniker("net6.0").ToToolchain();
+ ///
+ public static readonly IToolchain Core70 = CreateBuilder().UseCoreRtNuGet().TargetFrameworkMoniker("net7.0").ToToolchain();
internal CoreRtToolchain(string displayName,
string coreRtVersion, string ilcPath, bool useCppCodeGenerator,
@@ -65,4 +67,4 @@ private static string GetExtraArguments(bool useCppCodeGenerator, string runtime
private static IReadOnlyList GetEnvironmentVariables(string ilcPath)
=> ilcPath == null ? Array.Empty() : new[] { new EnvironmentVariable("IlcPath", ilcPath) };
}
-}
\ No newline at end of file
+}
diff --git a/src/BenchmarkDotNet/Toolchains/CsProj/CsProjCoreToolchain.cs b/src/BenchmarkDotNet/Toolchains/CsProj/CsProjCoreToolchain.cs
index 08a4b6558e..b6ca5a0324 100644
--- a/src/BenchmarkDotNet/Toolchains/CsProj/CsProjCoreToolchain.cs
+++ b/src/BenchmarkDotNet/Toolchains/CsProj/CsProjCoreToolchain.cs
@@ -21,6 +21,7 @@ public class CsProjCoreToolchain : Toolchain, IEquatable
[PublicAPI] public static readonly IToolchain NetCoreApp31 = From(NetCoreAppSettings.NetCoreApp31);
[PublicAPI] public static readonly IToolchain NetCoreApp50 = From(NetCoreAppSettings.NetCoreApp50);
[PublicAPI] public static readonly IToolchain NetCoreApp60 = From(NetCoreAppSettings.NetCoreApp60);
+ [PublicAPI] public static readonly IToolchain NetCoreApp70 = From(NetCoreAppSettings.NetCoreApp70);
private CsProjCoreToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath)
: base(name, generator, builder, executor)
@@ -78,4 +79,4 @@ public override bool IsSupported(BenchmarkCase benchmarkCase, ILogger logger, IR
public override int GetHashCode() => Generator.GetHashCode();
}
-}
\ No newline at end of file
+}
diff --git a/src/BenchmarkDotNet/Toolchains/DotNetCli/NetCoreAppSettings.cs b/src/BenchmarkDotNet/Toolchains/DotNetCli/NetCoreAppSettings.cs
index d26f5f13a9..ee18e50a26 100644
--- a/src/BenchmarkDotNet/Toolchains/DotNetCli/NetCoreAppSettings.cs
+++ b/src/BenchmarkDotNet/Toolchains/DotNetCli/NetCoreAppSettings.cs
@@ -20,6 +20,7 @@ public class NetCoreAppSettings
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp31 = new NetCoreAppSettings("netcoreapp3.1", null, ".NET Core 3.1");
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp50 = new NetCoreAppSettings("net5.0", null, ".NET 5.0");
[PublicAPI] public static readonly NetCoreAppSettings NetCoreApp60 = new NetCoreAppSettings("net6.0", null, ".NET 6.0");
+ [PublicAPI] public static readonly NetCoreAppSettings NetCoreApp70 = new NetCoreAppSettings("net7.0", null, ".NET 7.0");
///
///
@@ -115,4 +116,4 @@ public NetCoreAppSettings WithCustomPackagesRestorePath(string packagesPath, str
public NetCoreAppSettings WithTimeout(TimeSpan? timeOut)
=> new NetCoreAppSettings(TargetFrameworkMoniker, RuntimeFrameworkVersion, Name, CustomDotNetCliPath, PackagesPath, timeOut ?? Timeout);
}
-}
\ No newline at end of file
+}
diff --git a/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs b/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs
index 065e58ab1c..a931e76699 100644
--- a/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs
+++ b/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs
@@ -106,6 +106,8 @@ private static IToolchain GetToolchain(RuntimeMoniker runtimeMoniker)
return CsProjCoreToolchain.NetCoreApp50;
case RuntimeMoniker.Net60:
return CsProjCoreToolchain.NetCoreApp60;
+ case RuntimeMoniker.Net70:
+ return CsProjCoreToolchain.NetCoreApp70;
case RuntimeMoniker.CoreRt20:
return CoreRtToolchain.Core20;
case RuntimeMoniker.CoreRt21:
@@ -120,9 +122,11 @@ private static IToolchain GetToolchain(RuntimeMoniker runtimeMoniker)
return CoreRtToolchain.Core50;
case RuntimeMoniker.CoreRt60:
return CoreRtToolchain.Core60;
+ case RuntimeMoniker.CoreRt70:
+ return CoreRtToolchain.Core70;
default:
throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, "RuntimeMoniker not supported");
}
}
}
-}
\ No newline at end of file
+}
diff --git a/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs b/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
index 64d3dd7ad1..fbeed436bb 100644
--- a/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
+++ b/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
@@ -309,7 +309,8 @@ public void NetFrameworkMonikerParsedCorrectly(string tfm)
[Theory]
[InlineData("net50")]
[InlineData("net60")]
- public void Net50AndNet60MonikersAreRecognizedAsNetCoreMonikers(string tfm)
+ [InlineData("net70")]
+ public void NetMonikersAreRecognizedAsNetCoreMonikers(string tfm)
{
var config = ConfigParser.Parse(new[] { "-r", tfm }, new OutputLogger(Output)).config;
@@ -482,4 +483,4 @@ public void InvalidEnvVarAreRecognized()
Assert.False(ConfigParser.Parse(new[] { "--envVars", "INVALID_NO_SEPARATOR" }, new OutputLogger(Output)).isSuccess);
}
}
-}
\ No newline at end of file
+}