Skip to content

Commit

Permalink
Hardcode our chosen binary name format
Browse files Browse the repository at this point in the history
  • Loading branch information
Saalvage committed Nov 29, 2024
1 parent 5e0b5fe commit 16c6d1c
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions AssimpNet/Unmanaged/AssimpLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,33 +76,16 @@ static AssimpLibrary()
Platform.Mac => "macos",
} + '-' + RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();

static IntPtr TryLoadLibraryVariations(string dir, string lib)
var binaryFile = GetPlatform() switch

Check warning on line 79 in AssimpNet/Unmanaged/AssimpLibrary.cs

View workflow job for this annotation

GitHub Actions / Build Windows x64 Release

The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value. For example, the pattern '(Assimp.Unmanaged.Platform)3' is not covered.

Check warning on line 79 in AssimpNet/Unmanaged/AssimpLibrary.cs

View workflow job for this annotation

GitHub Actions / Build Windows x64 Debug

The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value. For example, the pattern '(Assimp.Unmanaged.Platform)3' is not covered.

Check warning on line 79 in AssimpNet/Unmanaged/AssimpLibrary.cs

View workflow job for this annotation

GitHub Actions / Build Windows x86 Release

The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value. For example, the pattern '(Assimp.Unmanaged.Platform)3' is not covered.

Check warning on line 79 in AssimpNet/Unmanaged/AssimpLibrary.cs

View workflow job for this annotation

GitHub Actions / Build Windows x86 Debug

The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value. For example, the pattern '(Assimp.Unmanaged.Platform)3' is not covered.

Check warning on line 79 in AssimpNet/Unmanaged/AssimpLibrary.cs

View workflow job for this annotation

GitHub Actions / Build Linux Release

The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value. For example, the pattern '(Assimp.Unmanaged.Platform)3' is not covered.

Check warning on line 79 in AssimpNet/Unmanaged/AssimpLibrary.cs

View workflow job for this annotation

GitHub Actions / Build Linux Debug

The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value. For example, the pattern '(Assimp.Unmanaged.Platform)3' is not covered.

Check warning on line 79 in AssimpNet/Unmanaged/AssimpLibrary.cs

View workflow job for this annotation

GitHub Actions / Build MacOS x64 Release

The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value. For example, the pattern '(Assimp.Unmanaged.Platform)3' is not covered.

Check warning on line 79 in AssimpNet/Unmanaged/AssimpLibrary.cs

View workflow job for this annotation

GitHub Actions / Build MacOS x64 Debug

The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value. For example, the pattern '(Assimp.Unmanaged.Platform)3' is not covered.

Check warning on line 79 in AssimpNet/Unmanaged/AssimpLibrary.cs

View workflow job for this annotation

GitHub Actions / Build MacOS ARM64 Release

The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value. For example, the pattern '(Assimp.Unmanaged.Platform)3' is not covered.

Check warning on line 79 in AssimpNet/Unmanaged/AssimpLibrary.cs

View workflow job for this annotation

GitHub Actions / Build MacOS ARM64 Debug

The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value. For example, the pattern '(Assimp.Unmanaged.Platform)3' is not covered.
{
// This is not strictly equivalent to the built-in order, but it's good enough.
var ext = GetPlatform() switch
{
Platform.Windows => "dll",
Platform.Linux => "so",
Platform.Mac => "dylib",
};

foreach (var path in (Span<string>)
[
$"{dir}{lib}.{ext}",
$"{dir}lib{lib}.{ext}",
$"{dir}{lib}",
$"{dir}lib{lib}",
]) {
if (NativeLibrary.TryLoad(path, out var handle))
return handle;
}

return IntPtr.Zero;
}
Platform.Windows => $"{DefaultLibName}.dll",
Platform.Linux => $"lib{DefaultLibName}.so",
Platform.Mac => $"lib{DefaultLibName}.dylib",
};

NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), (libraryName, _, _) => {
if (libraryName == DefaultLibName)
return TryLoadLibraryVariations($"{AppContext.BaseDirectory}runtimes/{rid}/native/", DefaultLibName);
return NativeLibrary.Load($"{AppContext.BaseDirectory}runtimes/{rid}/native/{binaryFile}");

return IntPtr.Zero;
});
Expand Down

0 comments on commit 16c6d1c

Please sign in to comment.