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

Detect arm64 hostfxr.dll #24512

Merged
merged 2 commits into from
Mar 24, 2022
Merged
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
1 change: 1 addition & 0 deletions src/Resolvers/Microsoft.DotNet.NativeWrapper/Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ private static void PreloadWindowsLibrary(string dllFileName)
{
string basePath = Path.GetDirectoryName(typeof(Interop).Assembly.Location);
string architecture = IntPtr.Size == 8 ? "x64" : "x86";
architecture = RuntimeInformation.ProcessArchitecture == Architecture.Arm64 ? "arm64" : architecture;
Comment on lines 42 to +43
Copy link
Contributor

Choose a reason for hiding this comment

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

why not:

Suggested change
string architecture = IntPtr.Size == 8 ? "x64" : "x86";
architecture = RuntimeInformation.ProcessArchitecture == Architecture.Arm64 ? "arm64" : architecture;
string architecture = Enum.GetName(RuntimeInformation.ProcessArchitecture).ToLowerInvariant();

Copy link
Member Author

Choose a reason for hiding this comment

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

For the sake of time, I decided not to consider the other code paths it could potentially go down if it were on a different arch. Though I suspect this to be the better way to go about it

string dllPath = Path.Combine(basePath, architecture, $"{dllFileName}.dll");

// return value is intentionally ignored as we let the subsequent P/Invokes fail naturally.
Expand Down