-
-
Notifications
You must be signed in to change notification settings - Fork 945
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
Sdk Validation Fix #2511
Sdk Validation Fix #2511
Conversation
@timcassell I am not sure why the linux and macos checks are failing. According to the result report all tests have passed. Am I missing something? https://github.com/dotnet/BenchmarkDotNet/pull/2511/checks?check_run_id=21320355764 |
I ran into the same issue in some of my PRs. I opened an issue for it. #2520. You'll have to search the logs or run it locally to find the culprit. |
Ok sounds good. I will do some digging. @timcassell |
@@ -26,8 +26,8 @@ public class CsProjCoreToolchain : Toolchain, IEquatable<CsProjCoreToolchain> | |||
[PublicAPI] public static readonly IToolchain NetCoreApp80 = From(NetCoreAppSettings.NetCoreApp80); | |||
[PublicAPI] public static readonly IToolchain NetCoreApp90 = From(NetCoreAppSettings.NetCoreApp90); | |||
|
|||
internal CsProjCoreToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath) | |||
: base(name, generator, builder, executor) | |||
internal CsProjCoreToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath, ISdkProvider sdkProvider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we merge the customDotNetCliPath
into the ISdkProvider
? They seem very related, and the validation likely would change depending on the custom path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we merge the
customDotNetCliPath
into theISdkProvider
? They seem very related, and the validation likely would change depending on the custom path.
Will do. Should I do the same thing with customDotNetCliPath
in NativeAotToolchain
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please. All the toolchains that use it.
…hat use it. Will need to update some ConfigParserTests
: base(name, generator, builder, executor) | ||
private readonly ISdkProvider sdkProvider; | ||
|
||
public ISdkProvider SdkProvider => sdkProvider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public ISdkProvider SdkProvider => sdkProvider; | |
internal ISdkProvider SdkProvider => sdkProvider; |
@@ -15,7 +15,7 @@ public class MonoAotToolchain : Toolchain | |||
public static readonly IToolchain Instance = new MonoAotToolchain(); | |||
|
|||
[PublicAPI] | |||
public MonoAotToolchain() : base("MonoAot", new Generator(), new MonoAotBuilder(), new Executor()) | |||
public MonoAotToolchain() : base("MonoAot", new Generator(), new MonoAotBuilder(), new Executor(), null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not every toolchain needs an ISdkProvider
, why is it part of the base toolchain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot about this one. I am not familiar with Mono and just put null
for the time being while I did more research. From what I found it is possible that Mono can use the .NET SDK since .NET 5.
I will work on its implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do that in a separate PR if you're going to do it. But it's the same thing for in process toolchains and Roslyn toolchain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok. I just committed some more changes but I will update my code.
@@ -13,8 +13,8 @@ public class WasmToolchain : Toolchain | |||
{ | |||
private string CustomDotNetCliPath { get; } | |||
|
|||
private WasmToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath) | |||
: base(name, generator, builder, executor) | |||
private WasmToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath, ISdkProvider sdkProvider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private WasmToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, string customDotNetCliPath, ISdkProvider sdkProvider) | |
private WasmToolchain(string name, IGenerator generator, IBuilder builder, IExecutor executor, ISdkProvider sdkProvider) |
private readonly ISdkProvider sdkProvider; | ||
#pragma warning restore CS0649 | ||
|
||
public ISdkProvider SdkProvider => sdkProvider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public ISdkProvider SdkProvider => sdkProvider; | |
internal ISdkProvider SdkProvider => sdkProvider; |
public interface ISdkProvider | ||
{ | ||
IEnumerable<string> GetInstalledSdks(); | ||
string CustomDotNetCliPath { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string CustomDotNetCliPath { get; set; } | |
string CustomDotNetCliPath { get; } |
} | ||
} | ||
|
||
private bool IsSdkInstalled(RuntimeMoniker runtimeMoniker) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be updated to check the CustomDotNetCliPath
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch. The path info is passed into DotNetSdkProvider
but I forgot to update my method there. I will revise it.
if (!string.IsNullOrEmpty(CustomDotNetCliPath)) | ||
{ | ||
return installedSdks; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this check. Both branches return the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Me neither. 😄
@@ -11,12 +11,12 @@ namespace BenchmarkDotNet.Toolchains.MonoWasm | |||
[PublicAPI] | |||
public class WasmToolchain : Toolchain | |||
{ | |||
private string CustomDotNetCliPath { get; } | |||
private readonly string CustomDotNetCliPath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this field is needed.
netCoreAppSettings.CustomDotNetCliPath, | ||
new DotNetSdkProvider()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to pass the custom path to the provider.
@@ -15,7 +15,7 @@ public class MonoAotToolchain : Toolchain | |||
public static readonly IToolchain Instance = new MonoAotToolchain(); | |||
|
|||
[PublicAPI] | |||
public MonoAotToolchain() : base("MonoAot", new Generator(), new MonoAotBuilder(), new Executor(), null) | |||
public MonoAotToolchain() : base("MonoAot", new Generator(), new MonoAotBuilder(), new Executor(), new DotNetSdkProvider()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that MonoAotToolchain uses a variant of Roslyn. So it doesn't need the ISdkProvider (unless Roslyn toolchain needs to validate the sdk also, but it seems different than csproj toolchains).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok. Good info. I will definitely need a different approach in implementing this validation to just certain toolchains then.
public string CustomDotNetCliPath | ||
{ | ||
get => _customDotNetCliPath; | ||
set => _customDotNetCliPath = value; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make this a read only property and pass the string into the constructor (can make it an optional argument).
|
||
namespace BenchmarkDotNet.Validators | ||
{ | ||
public interface ISdkProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ISdkProvider
name implies that a different sdk besides dotnet could be used. Does that make sense? Does RoslynToolchain
use an sdk that isn't dotnet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think this interface should be moved to BenchmarkDotNet.Toolchains
namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes perfect sense. I appreciate the valuable insight.
@timcassell I am closing this PR and opening a new one. After doing some more reworking I found that the scope of this .Net validation is much smaller than I was originally assuming with Toolchains. The new PR #2523 has a simpler approach instead of using inheritance which was messing up other Toolchains. I appreciate all the feedback so far. |
Fixes #2199