Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/BenchmarkDotNet.Annotations/Jobs/RuntimeMoniker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ public enum RuntimeMoniker
/// <summary>
/// .NET 6.0
/// </summary>
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,

/// <summary>
/// .NET 7.0
/// </summary>
Net70,

/// <summary>
/// CoreRT compiled as netcoreapp2.0
Expand Down Expand Up @@ -125,6 +130,11 @@ public enum RuntimeMoniker
/// </summary>
CoreRt60,

/// <summary>
/// CoreRT compiled as net7.0
/// </summary>
CoreRt70,

/// <summary>
/// WebAssembly with default .Net version
/// </summary>
Expand All @@ -140,6 +150,11 @@ public enum RuntimeMoniker
/// </summary>
WasmNet60,

/// <summary>
/// WebAssembly with .net7.0
/// </summary>
WasmNet70,

/// <summary>
/// Mono with the Ahead of Time LLVM Compiler backend
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand All @@ -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)
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 6 additions & 1 deletion src/BenchmarkDotNet/Environments/Runtimes/CoreRtRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public class CoreRtRuntime : Runtime
/// <summary>
/// CoreRT compiled as net6.0
/// </summary>
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");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed like a bug so I fixed it.

/// <summary>
/// CoreRT compiled as net7.0
/// </summary>
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)
Expand Down Expand Up @@ -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}");
}
Expand Down
2 changes: 2 additions & 0 deletions src/BenchmarkDotNet/Environments/Runtimes/CoreRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}");
}
Expand Down
4 changes: 4 additions & 0 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.Core50;
case RuntimeMoniker.Net60:
return CoreRuntime.Core60;
case RuntimeMoniker.Net70:
return CoreRuntime.Core70;
case RuntimeMoniker.Mono:
return MonoRuntime.Default;
case RuntimeMoniker.CoreRt20:
Expand All @@ -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");
}
Expand Down
4 changes: 3 additions & 1 deletion src/BenchmarkDotNet/Toolchains/CoreRt/CoreRtToolchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
/// </summary>
public static readonly IToolchain Core60 = CreateBuilder().UseCoreRtNuGet().TargetFrameworkMoniker("net6.0").ToToolchain();
/// </summary>
public static readonly IToolchain Core70 = CreateBuilder().UseCoreRtNuGet().TargetFrameworkMoniker("net7.0").ToToolchain();

internal CoreRtToolchain(string displayName,
string coreRtVersion, string ilcPath, bool useCppCodeGenerator,
Expand Down Expand Up @@ -65,4 +67,4 @@ private static string GetExtraArguments(bool useCppCodeGenerator, string runtime
private static IReadOnlyList<EnvironmentVariable> GetEnvironmentVariables(string ilcPath)
=> ilcPath == null ? Array.Empty<EnvironmentVariable>() : new[] { new EnvironmentVariable("IlcPath", ilcPath) };
}
}
}
3 changes: 2 additions & 1 deletion src/BenchmarkDotNet/Toolchains/CsProj/CsProjCoreToolchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class CsProjCoreToolchain : Toolchain, IEquatable<CsProjCoreToolchain>
[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)
Expand Down Expand Up @@ -78,4 +79,4 @@ public override bool IsSupported(BenchmarkCase benchmarkCase, ILogger logger, IR

public override int GetHashCode() => Generator.GetHashCode();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");

/// <summary>
/// <param name="targetFrameworkMoniker">
Expand Down Expand Up @@ -115,4 +116,4 @@ public NetCoreAppSettings WithCustomPackagesRestorePath(string packagesPath, str
public NetCoreAppSettings WithTimeout(TimeSpan? timeOut)
=> new NetCoreAppSettings(TargetFrameworkMoniker, RuntimeFrameworkVersion, Name, CustomDotNetCliPath, PackagesPath, timeOut ?? Timeout);
}
}
}
6 changes: 5 additions & 1 deletion src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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");
}
}
}
}
}
5 changes: 3 additions & 2 deletions tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -482,4 +483,4 @@ public void InvalidEnvVarAreRecognized()
Assert.False(ConfigParser.Parse(new[] { "--envVars", "INVALID_NO_SEPARATOR" }, new OutputLogger(Output)).isSuccess);
}
}
}
}