Skip to content

.Net SDK Validation #2523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public override IEnumerable<ValidationError> Validate(BenchmarkCase benchmarkCas
{
yield return invalidCliError;
}

foreach (var validationError in DotNetSdkVersionValidator.ValidateFrameworkSdks(benchmarkCase))
{
yield return validationError;
}
}
}
}
5 changes: 5 additions & 0 deletions src/BenchmarkDotNet/Toolchains/CsProj/CsProjCoreToolchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public override IEnumerable<ValidationError> Validate(BenchmarkCase benchmarkCas
$"Currently CsProjCoreToolchain does not support LINQPad 6+. Please use {nameof(InProcessEmitToolchain)} instead.",
benchmarkCase);
}

foreach (var validationError in DotNetSdkVersionValidator.ValidateCoreSdks(CustomDotNetCliPath, benchmarkCase))
{
yield return validationError;
}
}

public override bool Equals(object obj) => obj is CsProjCoreToolchain typed && Equals(typed);
Expand Down
43 changes: 32 additions & 11 deletions src/BenchmarkDotNet/Toolchains/MonoAotLLVM/MonoAotLLVMToolChain.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
using BenchmarkDotNet.Characteristics;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.DotNetCli;
using BenchmarkDotNet.Validators;
using System.Collections.Generic;

namespace BenchmarkDotNet.Toolchains.MonoAotLLVM
{
public class MonoAotLLVMToolChain : Toolchain
{
public MonoAotLLVMToolChain(string name, IGenerator generator, IBuilder builder, IExecutor executor)
private readonly string _customDotNetCliPath;

public MonoAotLLVMToolChain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath)
: base(name, generator, builder, executor)
{
_customDotNetCliPath = customDotNetCliPath;
}

public static IToolchain From(NetCoreAppSettings netCoreAppSettings)
=> new MonoAotLLVMToolChain(netCoreAppSettings.Name,
new MonoAotLLVMGenerator(netCoreAppSettings.TargetFrameworkMoniker,
netCoreAppSettings.CustomDotNetCliPath,
netCoreAppSettings.PackagesPath,
netCoreAppSettings.CustomRuntimePack,
netCoreAppSettings.AOTCompilerPath,
netCoreAppSettings.AOTCompilerMode),
new DotNetCliBuilder(netCoreAppSettings.TargetFrameworkMoniker,
netCoreAppSettings.CustomDotNetCliPath),
new Executor());
=> new MonoAotLLVMToolChain(netCoreAppSettings.Name,
new MonoAotLLVMGenerator(netCoreAppSettings.TargetFrameworkMoniker,
netCoreAppSettings.CustomDotNetCliPath,
netCoreAppSettings.PackagesPath,
netCoreAppSettings.CustomRuntimePack,
netCoreAppSettings.AOTCompilerPath,
netCoreAppSettings.AOTCompilerMode),
new DotNetCliBuilder(netCoreAppSettings.TargetFrameworkMoniker,
netCoreAppSettings.CustomDotNetCliPath),
new Executor(),
netCoreAppSettings.CustomDotNetCliPath);

public override IEnumerable<ValidationError> Validate(BenchmarkCase benchmarkCase, IResolver resolver)
{
foreach (var validationError in base.Validate(benchmarkCase, resolver))
{
yield return validationError;
}

foreach (var validationError in DotNetSdkVersionValidator.ValidateCoreSdks(_customDotNetCliPath, benchmarkCase))
{
yield return validationError;
}
}
}
}
5 changes: 5 additions & 0 deletions src/BenchmarkDotNet/Toolchains/MonoWasm/WasmToolchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public override IEnumerable<ValidationError> Validate(BenchmarkCase benchmarkCas
{
yield return invalidCliError;
}

foreach (var validationError in DotNetSdkVersionValidator.ValidateCoreSdks(CustomDotNetCliPath, benchmarkCase))
{
yield return validationError;
}
}

[PublicAPI]
Expand Down
16 changes: 16 additions & 0 deletions src/BenchmarkDotNet/Toolchains/NativeAot/NativeAotToolchain.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Collections.Generic;
using BenchmarkDotNet.Characteristics;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.DotNetCli;
using BenchmarkDotNet.Validators;

namespace BenchmarkDotNet.Toolchains.NativeAot
{
Expand Down Expand Up @@ -60,5 +63,18 @@ internal NativeAotToolchain(string displayName,
public static NativeAotToolchainBuilder CreateBuilder() => NativeAotToolchainBuilder.Create();

public static string GetExtraArguments(string runtimeIdentifier) => $"-r {runtimeIdentifier}";

public override IEnumerable<ValidationError> Validate(BenchmarkCase benchmarkCase, IResolver resolver)
{
foreach (var error in base.Validate(benchmarkCase, resolver))
{
yield return error;
}

foreach (var validationError in DotNetSdkVersionValidator.ValidateCoreSdks(CustomDotNetCliPath, benchmarkCase))
{
yield return validationError;
}
}
}
}
Loading