Skip to content
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

Closed
wants to merge 11 commits into from
Closed

Conversation

MattFromRVA
Copy link
Contributor

Fixes #2199

@MattFromRVA
Copy link
Contributor Author

@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

@MattFromRVA MattFromRVA marked this pull request as ready for review February 9, 2024 21:19
@timcassell
Copy link
Collaborator

@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.

@MattFromRVA
Copy link
Contributor Author

@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)
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Will do. Should I do the same thing with customDotNetCliPath in NativeAotToolchain as well?

Copy link
Collaborator

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
@MattFromRVA MattFromRVA marked this pull request as draft February 11, 2024 02:56
: base(name, generator, builder, executor)
private readonly ISdkProvider sdkProvider;

public ISdkProvider SdkProvider => sdkProvider;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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)
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public ISdkProvider SdkProvider => sdkProvider;
internal ISdkProvider SdkProvider => sdkProvider;

public interface ISdkProvider
{
IEnumerable<string> GetInstalledSdks();
string CustomDotNetCliPath { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
string CustomDotNetCliPath { get; set; }
string CustomDotNetCliPath { get; }

}
}

private bool IsSdkInstalled(RuntimeMoniker runtimeMoniker)
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Comment on lines 19 to 22
if (!string.IsNullOrEmpty(CustomDotNetCliPath))
{
return installedSdks;
}
Copy link
Collaborator

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.

Copy link
Contributor Author

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;
Copy link
Collaborator

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());
Copy link
Collaborator

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())
Copy link
Collaborator

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).

Copy link
Contributor Author

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.

Comment on lines +13 to +17
public string CustomDotNetCliPath
{
get => _customDotNetCliPath;
set => _customDotNetCliPath = value;
}
Copy link
Collaborator

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
Copy link
Collaborator

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@MattFromRVA
Copy link
Contributor Author

MattFromRVA commented Feb 14, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deadlock when SDK is not installed
2 participants