Skip to content

Commit

Permalink
Add ConfigOption for disabling the .NET SDK Validator
Browse files Browse the repository at this point in the history
  • Loading branch information
caaavik-msft committed Sep 21, 2024
1 parent 3a2d115 commit e2b78af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/BenchmarkDotNet/Configs/ConfigOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ public enum ConfigOptions
/// <summary>
/// Continue the execution if the last run was stopped.
/// </summary>
Resume = 1 << 9
Resume = 1 << 9,
/// <summary>
/// Determines if the .NET SDK Version validator should be entirely turned off
/// </summary>
DisableDotnetSdkVersionValidator = 1 << 10,
}

internal static class ConfigOptionsExtensions
Expand Down
13 changes: 12 additions & 1 deletion src/BenchmarkDotNet/Validators/DotNetSdkVersionValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using System;
Expand All @@ -17,6 +18,11 @@ internal static class DotNetSdkValidator

public static IEnumerable<ValidationError> ValidateCoreSdks(string? customDotNetCliPath, BenchmarkCase benchmark)
{
if (benchmark.Config.Options.IsSet(ConfigOptions.DisableDotnetSdkVersionValidator))
{
yield break;
}

if (IsCliPathInvalid(customDotNetCliPath, benchmark, out ValidationError? cliPathError))
{
yield return cliPathError;
Expand All @@ -33,6 +39,11 @@ public static IEnumerable<ValidationError> ValidateCoreSdks(string? customDotNet

public static IEnumerable<ValidationError> ValidateFrameworkSdks(BenchmarkCase benchmark)
{
if (benchmark.Config.Options.IsSet(ConfigOptions.DisableDotnetSdkVersionValidator))
{
yield break;
}

if (!TryGetSdkVersion(benchmark, out string requiredSdkVersionString))
{
yield break;
Expand Down

0 comments on commit e2b78af

Please sign in to comment.