public void IsMatchingNativeLibraryNegativeMatches(string os, Platform platform, string requestedFileName, string actualFileName) { Assert.False(NativeLibPathUtils.IsMatchingNativeLibrary( new FakeRuntimeEnvironment { OperatingSystem = os, OperatingSystemPlatform = platform }, requestedFileName, actualFileName)); }
public void IsMatchingNativeLibraryPositiveMatches(string os, string requestedFileName, string actualFileName) { Assert.True(NativeLibPathUtils.IsMatchingNativeLibrary( new FakeRuntimeEnvironment { OperatingSystem = os }, requestedFileName, actualFileName)); }
public IntPtr LoadUnmanagedLibrary(string name) { if (_unloadableNativeLibs.Contains(name)) { return(IntPtr.Zero); } foreach (var projectPath in _projects.Values.Select(p => p.Project.ProjectDirectory)) { foreach (var folder in NativeLibPathUtils.GetNativeSubfolderCandidates(RuntimeEnvironmentHelper.RuntimeEnvironment)) { var path = NativeLibPathUtils.GetProjectNativeLibPath(projectPath, folder); if (Directory.Exists(path)) { var handle = LoadUnamangedLibrary(path, name); if (handle != IntPtr.Zero) { return(handle); } } } } _unloadableNativeLibs.Add(name); return(IntPtr.Zero); }
private IntPtr LoadUnamangedLibrary(string path, string name) { foreach (var nativeLibFullPath in Directory.EnumerateFiles(path)) { if (NativeLibPathUtils.IsMatchingNativeLibrary(RuntimeEnvironmentHelper.RuntimeEnvironment, name, Path.GetFileName(nativeLibFullPath))) { return(_loadContextAccessor.Default.LoadUnmanagedLibraryFromPath(nativeLibFullPath)); } } return(IntPtr.Zero); }
public void GetNativeSubfolderCandidatesRetunsExpectedFolders(string os, string version, string architecture, string[] expected) { if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DNX_RUNTIME_ID"))) { return; } var runtimeEnvironment = new FakeRuntimeEnvironment { OperatingSystem = os, OperatingSystemVersion = version, RuntimeArchitecture = architecture }; var actual = NativeLibPathUtils.GetNativeSubfolderCandidates(runtimeEnvironment); Assert.Equal(expected, actual); }
public void GetProjectNativeLibPathReturnsCorrectPath() { var expected = Path.Combine("project", "runtimes", "win7-x86", "native"); Assert.Equal(expected, NativeLibPathUtils.GetProjectNativeLibPath("project", "win7-x86")); }