Watch
2
0
Fork
You've already forked raylib-cs
0

Update tests and dll resolver (#336)

This commit is contained in:
Rgebee 2026-05-17 19:24:49 +01:00 committed by GitHub
commit a657bb6367
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 45 additions and 94 deletions

View file

@ -26,25 +26,27 @@ public static unsafe partial class Raylib
static Raylib()
{
NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), (libraryName, assembly, searchPath) =>
NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), ResolveDllImport);
}
public static IntPtr ResolveDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
{
IntPtr handle = IntPtr.Zero;
string libraryPath = GetLibraryPath(libraryName);
if (NativeLibrary.TryLoad(libraryName, assembly, searchPath, out handle))
{
IntPtr handle = IntPtr.Zero;
string libraryPath = GetLibraryPath(libraryName);
return handle;
}
if (NativeLibrary.TryLoad(libraryPath, out handle))
{
return handle;
}
if (NativeLibrary.TryLoad(libraryPath, out handle))
{
return handle;
}
if (NativeLibrary.TryLoad(libraryName, assembly, searchPath, out handle))
{
return handle;
}
throw new DllNotFoundException(
$"Failed to load {libraryName} using {libraryPath}."
);
});
throw new DllNotFoundException(
$"Failed to load {libraryName}."
);
}
public static string GetLibraryPath(string libraryName)