From 925f88001e0ac9bf4da3d4b61d74bdeed37a68da Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Sat, 9 Nov 2019 08:04:17 -0500 Subject: [PATCH] Move AssemblyLoadContext.GetResolvedUnmanagedDll to shared (dotnet/coreclr#27775) Commit migrated from https://github.com/dotnet/coreclr/commit/a87fc81b54da6c8738c6b1ca1247f637c85f9dd5 --- .../Runtime/Loader/AssemblyLoadContext.CoreCLR.cs | 22 ---------------------- .../System/Runtime/Loader/AssemblyLoadContext.cs | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs index dfcbf13..c50cdc7 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs @@ -99,28 +99,6 @@ namespace System.Runtime.Loader return context.GetResolvedUnmanagedDll(assembly, unmanagedDllName); } - private IntPtr GetResolvedUnmanagedDll(Assembly assembly, string unmanagedDllName) - { - IntPtr resolvedDll = IntPtr.Zero; - - Func? dllResolveHandler = _resolvingUnmanagedDll; - - if (dllResolveHandler != null) - { - // Loop through the event subscribers and return the first non-null native library handle - foreach (Func handler in dllResolveHandler.GetInvocationList()) - { - resolvedDll = handler(assembly, unmanagedDllName); - if (resolvedDll != IntPtr.Zero) - { - return resolvedDll; - } - } - } - - return IntPtr.Zero; - } - [DllImport(RuntimeHelpers.QCall, CharSet = CharSet.Unicode)] private static extern void LoadTypeForWinRTTypeNameInContextInternal(IntPtr ptrNativeAssemblyLoadContext, string typeName, ObjectHandleOnStack loadedType); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs index 39b5335..56882da 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs @@ -737,6 +737,28 @@ namespace System.Runtime.Loader return null; } + + private IntPtr GetResolvedUnmanagedDll(Assembly assembly, string unmanagedDllName) + { + IntPtr resolvedDll = IntPtr.Zero; + + Func? dllResolveHandler = _resolvingUnmanagedDll; + + if (dllResolveHandler != null) + { + // Loop through the event subscribers and return the first non-null native library handle + foreach (Func handler in dllResolveHandler.GetInvocationList()) + { + resolvedDll = handler(assembly, unmanagedDllName); + if (resolvedDll != IntPtr.Zero) + { + return resolvedDll; + } + } + } + + return IntPtr.Zero; + } } internal sealed class DefaultAssemblyLoadContext : AssemblyLoadContext -- 2.7.4