From: Aaron Robinson Date: Tue, 12 Feb 2019 16:33:58 +0000 (-0800) Subject: Update COM Activator class (dotnet/coreclr#22317) X-Git-Tag: submit/tizen/20210909.063632~11030^2~2522 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8b6823c9697ea2a1c8517b7c26c5c2cdd09a766e;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Update COM Activator class (dotnet/coreclr#22317) * Update COM Activator to use ALCs * Update tests to now supply an assembly name rather than an binary "path" since the COM activator is now using ALCs. * Add test for non-rooted assembly path. * Move the hostpolicy mock project to a Common area Move hostpolicy mock API to CoreCLR test library * Add test for COM server isolation * Move ComActivator class and logic to Internal namespace. Commit migrated from https://github.com/dotnet/coreclr/commit/09963dc2ee182e7e62212efbb205edd9c387961d --- diff --git a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj index 79659fb..62da9c9 100644 --- a/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/src/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -284,9 +284,9 @@ + - diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComActivator.cs b/src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs similarity index 69% rename from src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComActivator.cs rename to src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs index 785e9ac..1da9ffa 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComActivator.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs @@ -3,17 +3,24 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; - -namespace System.Runtime.InteropServices +using System.Runtime.InteropServices; +using System.Runtime.Loader; + +// +// Types in this file marked as 'public' are done so only to aid in +// testing of functionality and should not be considered publicly consumable. +// +namespace Internal.Runtime.InteropServices { [ComImport] [ComVisible(false)] [Guid("00000001-0000-0000-C000-000000000046")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - internal interface IClassFactory + public interface IClassFactory { void CreateInstance( [MarshalAs(UnmanagedType.Interface)] object pUnkOuter, @@ -67,22 +74,29 @@ namespace System.Runtime.InteropServices { public Guid ClassId; public Guid InterfaceId; + public string AssemblyPath; public string AssemblyName; public string TypeName; } [StructLayout(LayoutKind.Sequential)] - public struct ComActivationContextInternal + [CLSCompliant(false)] + public unsafe struct ComActivationContextInternal { public Guid ClassId; public Guid InterfaceId; - public IntPtr AssemblyNameBuffer; - public IntPtr TypeNameBuffer; + public char* AssemblyPathBuffer; + public char* AssemblyNameBuffer; + public char* TypeNameBuffer; public IntPtr ClassFactoryDest; } public static class ComActivator { + // Collection of all ALCs used for COM activation. In the event we want to support + // unloadable COM server ALCs, this will need to be changed. + private static Dictionary s_AssemblyLoadContexts = new Dictionary(StringComparer.InvariantCultureIgnoreCase); + /// /// Entry point for unmanaged COM activation API from managed code /// @@ -95,7 +109,12 @@ namespace System.Runtime.InteropServices throw new NotSupportedException(); } - Type classType = FindClassType(cxt.ClassId, cxt.AssemblyName, cxt.TypeName); + if (!Path.IsPathRooted(cxt.AssemblyPath)) + { + throw new ArgumentException(); + } + + Type classType = FindClassType(cxt.ClassId, cxt.AssemblyPath, cxt.AssemblyName, cxt.TypeName); return new BasicClassFactory(cxt.ClassId, classType); } @@ -103,7 +122,8 @@ namespace System.Runtime.InteropServices /// Internal entry point for unmanaged COM activation API from native code /// /// Reference to a instance - public static int GetClassFactoryForTypeInternal(ref ComActivationContextInternal cxtInt) + [CLSCompliant(false)] + public unsafe static int GetClassFactoryForTypeInternal(ref ComActivationContextInternal cxtInt) { if (IsLoggingEnabled()) { @@ -111,8 +131,9 @@ namespace System.Runtime.InteropServices $@"{nameof(GetClassFactoryForTypeInternal)} arguments: {cxtInt.ClassId} {cxtInt.InterfaceId} - 0x{cxtInt.AssemblyNameBuffer.ToInt64():x} - 0x{cxtInt.TypeNameBuffer.ToInt64():x} + 0x{(ulong)cxtInt.AssemblyPathBuffer:x} + 0x{(ulong)cxtInt.AssemblyNameBuffer:x} + 0x{(ulong)cxtInt.TypeNameBuffer:x} 0x{cxtInt.ClassFactoryDest.ToInt64():x}"); } @@ -122,8 +143,9 @@ $@"{nameof(GetClassFactoryForTypeInternal)} arguments: { ClassId = cxtInt.ClassId, InterfaceId = cxtInt.InterfaceId, - AssemblyName = Marshal.PtrToStringUTF8(cxtInt.AssemblyNameBuffer), - TypeName = Marshal.PtrToStringUTF8(cxtInt.TypeNameBuffer) + AssemblyPath = Marshal.PtrToStringUni(new IntPtr(cxtInt.AssemblyPathBuffer)), + AssemblyName = Marshal.PtrToStringUni(new IntPtr(cxtInt.AssemblyNameBuffer)), + TypeName = Marshal.PtrToStringUni(new IntPtr(cxtInt.TypeNameBuffer)) }; object cf = GetClassFactoryForType(cxt); @@ -154,11 +176,13 @@ $@"{nameof(GetClassFactoryForTypeInternal)} arguments: Debug.WriteLine(fmt, args); } - private static Type FindClassType(Guid clsid, string assemblyName, string typeName) + private static Type FindClassType(Guid clsid, string assemblyPath, string assemblyName, string typeName) { try { - Assembly assem = Assembly.LoadFrom(assemblyName); + AssemblyLoadContext alc = GetALC(assemblyPath); + var assemblyNameLocal = new AssemblyName(assemblyName); + Assembly assem = alc.LoadFromAssemblyName(assemblyNameLocal); Type t = assem.GetType(typeName); if (t != null) { @@ -177,6 +201,54 @@ $@"{nameof(GetClassFactoryForTypeInternal)} arguments: throw new COMException(string.Empty, CLASS_E_CLASSNOTAVAILABLE); } + private static AssemblyLoadContext GetALC(string assemblyPath) + { + AssemblyLoadContext alc; + + lock (s_AssemblyLoadContexts) + { + if (!s_AssemblyLoadContexts.TryGetValue(assemblyPath, out alc)) + { + alc = new ComServerLoadContext(assemblyPath); + s_AssemblyLoadContexts.Add(assemblyPath, alc); + } + } + + return alc; + } + + private class ComServerLoadContext : AssemblyLoadContext + { + private readonly AssemblyDependencyResolver _resolver; + + public ComServerLoadContext(string comServerAssemblyPath) + { + _resolver = new AssemblyDependencyResolver(comServerAssemblyPath); + } + + protected override Assembly Load(AssemblyName assemblyName) + { + string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName); + if (assemblyPath != null) + { + return LoadFromAssemblyPath(assemblyPath); + } + + return null; + } + + protected override IntPtr LoadUnmanagedDll(string unmanagedDllName) + { + string libraryPath = _resolver.ResolveUnmanagedDllToPath(unmanagedDllName); + if (libraryPath != null) + { + return LoadUnmanagedDllFromPath(libraryPath); + } + + return IntPtr.Zero; + } + } + [ComVisible(true)] internal class BasicClassFactory : IClassFactory2 { diff --git a/src/coreclr/src/coreclr/hosts/coreshim/ComActivation.cpp b/src/coreclr/src/coreclr/hosts/coreshim/ComActivation.cpp index 5df1d00..6c03be0 100644 --- a/src/coreclr/src/coreclr/hosts/coreshim/ComActivation.cpp +++ b/src/coreclr/src/coreclr/hosts/coreshim/ComActivation.cpp @@ -23,13 +23,12 @@ namespace "TRUSTED_PLATFORM_ASSEMBLIES", }; - // [TODO] Support UNICODE app path - char wd[MAX_PATH]; - (void)::GetCurrentDirectoryA(ARRAYSIZE(wd), wd); + std::string assemblyPath; + RETURN_IF_FAILED(Utility::GetCoreShimDirectory(assemblyPath)); const char *values[] = { - wd, + assemblyPath.c_str(), tpaList.c_str(), }; @@ -56,26 +55,33 @@ STDAPI DllGetClassObject( GetClassFactoryForTypeInternal_ptr GetClassFactoryForTypeInternal; RETURN_IF_FAILED(inst->CreateDelegate( "System.Private.CoreLib", - "System.Runtime.InteropServices.ComActivator", + "Internal.Runtime.InteropServices.ComActivator", "GetClassFactoryForTypeInternal", (void**)&GetClassFactoryForTypeInternal)); // Get assembly and type for activation - std::string assemblyName; + std::wstring assemblyName; RETURN_IF_FAILED(Utility::TryGetEnvVar(COMACT_ASSEMBLYNAME_ENVVAR, assemblyName)); - std::string typeName; + std::wstring typeName; RETURN_IF_FAILED(Utility::TryGetEnvVar(COMACT_TYPENAME_ENVVAR, typeName)); + // Compute the path to the assembly. This should be adjacent to CoreShim (i.e. this library). + std::wstring assemblyPath; + RETURN_IF_FAILED(Utility::GetCoreShimDirectory(assemblyPath)); + assemblyPath.append(assemblyName); + assemblyPath.append(W(".dll")); + IUnknown *ccw = nullptr; struct ComActivationContext { GUID ClassId; GUID InterfaceId; - const void *AssemblyName; - const void *TypeName; + const WCHAR *AssemblyPath; + const WCHAR *AssemblyName; + const WCHAR *TypeName; void **ClassFactoryDest; - } comCxt{ rclsid, riid, assemblyName.data(), typeName.data(), (void**)&ccw }; + } comCxt{ rclsid, riid, assemblyPath.data(), assemblyName.data(), typeName.data(), (void**)&ccw }; RETURN_IF_FAILED(GetClassFactoryForTypeInternal(&comCxt)); assert(ccw != nullptr); diff --git a/src/coreclr/src/coreclr/hosts/coreshim/CoreShim.cpp b/src/coreclr/src/coreclr/hosts/coreshim/CoreShim.cpp index f055b04..bb6ec8a 100644 --- a/src/coreclr/src/coreclr/hosts/coreshim/CoreShim.cpp +++ b/src/coreclr/src/coreclr/hosts/coreshim/CoreShim.cpp @@ -92,12 +92,11 @@ namespace namespace Utility { - HRESULT TryGetEnvVar(_In_z_ const WCHAR *env, _Inout_ std::string &envVar) + HRESULT TryGetEnvVar(_In_z_ const WCHAR *env, _Inout_ std::wstring &envVar) { try { - std::wstring envVarLocal = GetEnvVar(env); - envVar = ConvertWideToUtf8(envVarLocal); + envVar = GetEnvVar(env); } catch (HRESULT hr) { @@ -106,6 +105,49 @@ namespace Utility return S_OK; } + + HRESULT GetCoreShimDirectory(_Inout_ std::wstring &dir) + { + HMODULE hModule; + BOOL res = ::GetModuleHandleExW( + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + reinterpret_cast(&TryGetEnvVar), + &hModule); + if (res == FALSE) + return HRESULT_FROM_WIN32(::GetLastError()); + + std::wstring path; + size_t dwModuleFileName = MAX_PATH / 2; + + do + { + path.resize(dwModuleFileName * 2); + dwModuleFileName = GetModuleFileNameW(hModule, (LPWSTR)path.data(), static_cast(path.size())); + } while (dwModuleFileName == path.size()); + + if (dwModuleFileName == 0) + return HRESULT_FROM_WIN32(::GetLastError()); + + size_t idx = path.find_last_of(W('\\')); + if (idx == std::wstring::npos) + return E_UNEXPECTED; + + path.resize(idx + 1); + dir = std::move(path); + return S_OK; + } + + HRESULT GetCoreShimDirectory(_Inout_ std::string &dir) + { + HRESULT hr; + + std::wstring dir_wide; + RETURN_IF_FAILED(GetCoreShimDirectory(dir_wide)); + + dir = ConvertWideToUtf8(dir_wide); + + return S_OK; + } } HRESULT coreclr::GetCoreClrInstance(_Outptr_ coreclr **instance, _In_opt_z_ const WCHAR *path) @@ -116,6 +158,42 @@ HRESULT coreclr::GetCoreClrInstance(_Outptr_ coreclr **instance, _In_opt_z_ cons return S_FALSE; } + // Since the CoreShim is being loaded, there is a chance the scenario depends on + // other aspects of the offical host platform (e.g. hostpolicy). Verify a hostpolicy + // is _not_ already loaded and if not, attempt to load a hostpolicy library adjacent + // to the coreshim. If there isn't one, just keep going. + const WCHAR *hostpolicyName = W("hostpolicy.dll"); + HMODULE hMod = ::GetModuleHandleW(hostpolicyName); + if (hMod == nullptr) + { + HRESULT hr; + std::wstring coreShimPath; + RETURN_IF_FAILED(Utility::GetCoreShimDirectory(coreShimPath)); + + std::wstring hostpolicyPath{ coreShimPath }; + hostpolicyPath.append(hostpolicyName); + + // Check if a hostpolicy exists and if it does, load it. + if (INVALID_FILE_ATTRIBUTES != ::GetFileAttributesW(hostpolicyPath.c_str())) + { + hMod = ::LoadLibraryExW(hostpolicyPath.c_str(), nullptr, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); + if (hMod == nullptr) + return E_UNEXPECTED; + + // Initialize the hostpolicy mock to a default state + using Set_corehost_resolve_component_dependencies_Values_fn = void(STDMETHODCALLTYPE *)( + int returnValue, + const WCHAR *assemblyPaths, + const WCHAR *nativeSearchPaths, + const WCHAR *resourceSearchPaths); + auto set_comp_depend_values = (Set_corehost_resolve_component_dependencies_Values_fn) + ::GetProcAddress(hMod, "Set_corehost_resolve_component_dependencies_Values"); + + assert(set_comp_depend_values != nullptr); + set_comp_depend_values(0, W(""), W(""), W("")); + } + } + try { std::wstring pathLocal; diff --git a/src/coreclr/src/coreclr/hosts/coreshim/CoreShim.h b/src/coreclr/src/coreclr/hosts/coreshim/CoreShim.h index dd5e9d1..d4c8b0a 100644 --- a/src/coreclr/src/coreclr/hosts/coreshim/CoreShim.h +++ b/src/coreclr/src/coreclr/hosts/coreshim/CoreShim.h @@ -110,7 +110,13 @@ namespace Utility /// /// Get the supplied environment variable. /// - HRESULT TryGetEnvVar(_In_z_ const WCHAR *env, _Inout_ std::string &envVar); + HRESULT TryGetEnvVar(_In_z_ const WCHAR *env, _Inout_ std::wstring &envVar); + + /// + /// Get the CoreShim directory. + /// + HRESULT GetCoreShimDirectory(_Inout_ std::string &dir); + HRESULT GetCoreShimDirectory(_Inout_ std::wstring &dir); } // CoreShim environment variables used to indicate what assembly/type tuple diff --git a/src/coreclr/tests/src/Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj b/src/coreclr/tests/src/Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj index 7e210d0..ea0ee84 100644 --- a/src/coreclr/tests/src/Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj +++ b/src/coreclr/tests/src/Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj @@ -31,9 +31,8 @@ - - - + + diff --git a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/HostPolicyMock.cs b/src/coreclr/tests/src/Common/CoreCLRTestLibrary/HostPolicyMock.cs similarity index 90% rename from src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/HostPolicyMock.cs rename to src/coreclr/tests/src/Common/CoreCLRTestLibrary/HostPolicyMock.cs index 37cedbc..afa1fbc 100644 --- a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/HostPolicyMock.cs +++ b/src/coreclr/tests/src/Common/CoreCLRTestLibrary/HostPolicyMock.cs @@ -6,15 +6,15 @@ using System.IO; using System.Runtime.InteropServices; using System.Runtime.Loader; -namespace AssemblyDependencyResolverTests +namespace TestLibrary { - class HostPolicyMock + public class HostPolicyMock { -#if WINDOWS + #if PLATFORM_WINDOWS private const CharSet HostpolicyCharSet = CharSet.Unicode; -#else + #else private const CharSet HostpolicyCharSet = CharSet.Ansi; -#endif + #endif [DllImport("hostpolicy", CharSet = HostpolicyCharSet)] private static extern int Set_corehost_resolve_component_dependencies_Values( @@ -45,24 +45,32 @@ namespace AssemblyDependencyResolverTests public static string DeleteExistingHostpolicy(string coreRoot) { +#if REFERENCING_SYSTEMPRIVATECORELIB + throw new Exception("This API is not supported when compiled referencing SPCL"); + +#else string hostPolicyFileName = XPlatformUtils.GetStandardNativeLibraryFileName("hostpolicy"); string destinationPath = Path.Combine(coreRoot, hostPolicyFileName); + if (File.Exists(destinationPath)) { File.Delete(destinationPath); } return destinationPath; +#endif } public static void Initialize(string testBasePath, string coreRoot) { +#if !REFERENCING_SYSTEMPRIVATECORELIB string hostPolicyFileName = XPlatformUtils.GetStandardNativeLibraryFileName("hostpolicy"); string destinationPath = DeleteExistingHostpolicy(coreRoot); File.Copy( Path.Combine(testBasePath, hostPolicyFileName), destinationPath); +#endif _assemblyDependencyResolverType = typeof(AssemblyDependencyResolver); @@ -72,7 +80,7 @@ namespace AssemblyDependencyResolverTests _corehost_error_writer_fnType = _assemblyDependencyResolverType.GetNestedType("corehost_error_writer_fn", System.Reflection.BindingFlags.NonPublic); } - public static MockValues_corehost_resolve_componet_dependencies Mock_corehost_resolve_componet_dependencies( + public static MockValues_corehost_resolve_component_dependencies Mock_corehost_resolve_component_dependencies( int returnValue, string assemblyPaths, string nativeSearchPaths, @@ -84,10 +92,10 @@ namespace AssemblyDependencyResolverTests nativeSearchPaths, resourceSearchPaths); - return new MockValues_corehost_resolve_componet_dependencies(); + return new MockValues_corehost_resolve_component_dependencies(); } - internal class MockValues_corehost_resolve_componet_dependencies : IDisposable + public class MockValues_corehost_resolve_component_dependencies : IDisposable { private Callback_corehost_resolve_component_dependencies callback; @@ -133,7 +141,7 @@ namespace AssemblyDependencyResolverTests return new MockValues_corehost_set_error_writer(); } - internal class MockValues_corehost_set_error_writer : IDisposable + public class MockValues_corehost_set_error_writer : IDisposable { public IntPtr LastSetErrorWriterPtr { diff --git a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/XPlatformUtils.cs b/src/coreclr/tests/src/Common/CoreCLRTestLibrary/XPlatformUtils.cs similarity index 88% rename from src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/XPlatformUtils.cs rename to src/coreclr/tests/src/Common/CoreCLRTestLibrary/XPlatformUtils.cs index fd931f4..e8bcca2 100644 --- a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/XPlatformUtils.cs +++ b/src/coreclr/tests/src/Common/CoreCLRTestLibrary/XPlatformUtils.cs @@ -1,16 +1,17 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace AssemblyDependencyResolverTests + +namespace TestLibrary { - class XPlatformUtils + public class XPlatformUtils { -#if WINDOWS +#if PLATFORM_WINDOWS public const string NativeLibraryPrefix = ""; public const string NativeLibrarySuffix = ".dll"; #else public const string NativeLibraryPrefix = "lib"; -#if OSX +#if PLATFORM_OSX public const string NativeLibrarySuffix = ".dylib"; #else public const string NativeLibrarySuffix = ".so"; diff --git a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/CMakeLists.txt b/src/coreclr/tests/src/Common/hostpolicymock/CMakeLists.txt similarity index 100% rename from src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/CMakeLists.txt rename to src/coreclr/tests/src/Common/hostpolicymock/CMakeLists.txt diff --git a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/HostpolicyMock.cpp b/src/coreclr/tests/src/Common/hostpolicymock/HostpolicyMock.cpp similarity index 86% rename from src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/HostpolicyMock.cpp rename to src/coreclr/tests/src/Common/hostpolicymock/HostpolicyMock.cpp index b1a90d2..cd16afa 100644 --- a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/HostpolicyMock.cpp +++ b/src/coreclr/tests/src/Common/hostpolicymock/HostpolicyMock.cpp @@ -14,7 +14,17 @@ typedef wchar_t char_t; typedef std::wstring string_t; -#else //!_Win32 +// Only create undecorated exports on Windows x86 +#if defined _X86_ + +// Define undecorated exports to ease test set up from native code +#pragma comment(linker, "/export:Set_corehost_resolve_component_dependencies_Callback=_Set_corehost_resolve_component_dependencies_Callback@4") +#pragma comment(linker, "/export:Set_corehost_resolve_component_dependencies_Values=_Set_corehost_resolve_component_dependencies_Values@16") +#pragma comment(linker, "/export:Set_corehost_set_error_writer_returnValue=_Set_corehost_set_error_writer_returnValue@4") + +#endif + +#else //!_WIN32 #if __GNUC__ >= 4 #define SHARED_API extern "C" __attribute__ ((visibility ("default"))) diff --git a/src/coreclr/tests/src/Interop/COM/Activator/Activator.csproj b/src/coreclr/tests/src/Interop/COM/Activator/Activator.csproj index 792b8be..b656a5c 100644 --- a/src/coreclr/tests/src/Interop/COM/Activator/Activator.csproj +++ b/src/coreclr/tests/src/Interop/COM/Activator/Activator.csproj @@ -1,7 +1,6 @@ - Debug AnyCPU @@ -14,6 +13,8 @@ true true + + @@ -24,6 +25,30 @@ + + + + + + + + + + + $(OutDir)/Servers + + + + + + + + + + + diff --git a/src/coreclr/tests/src/Interop/COM/Activator/Program.cs b/src/coreclr/tests/src/Interop/COM/Activator/Program.cs index 4316736..451ecc7 100644 --- a/src/coreclr/tests/src/Interop/COM/Activator/Program.cs +++ b/src/coreclr/tests/src/Interop/COM/Activator/Program.cs @@ -4,7 +4,10 @@ namespace Activator { + using Internal.Runtime.InteropServices; + using System; + using System.IO; using System.Runtime.InteropServices; using TestLibrary; @@ -15,6 +18,8 @@ namespace Activator { static void InvalidInterfaceRequest() { + Console.WriteLine($"Running {nameof(InvalidInterfaceRequest)}..."); + Assert.Throws( () => { @@ -28,17 +33,36 @@ namespace Activator "Non-IClassFactory request should fail"); } + static void NonrootedAssemblyPath() + { + Console.WriteLine($"Running {nameof(NonrootedAssemblyPath)}..."); + + ArgumentException e = Assert.Throws( + () => + { + var cxt = new ComActivationContext() + { + InterfaceId = typeof(IClassFactory).GUID, + AssemblyPath = "foo.dll" + }; + ComActivator.GetClassFactoryForType(cxt); + }, + "Non-root assembly path should not be valid"); + } + static void ClassNotRegistered() { + Console.WriteLine($"Running {nameof(ClassNotRegistered)}..."); + COMException e = Assert.Throws( () => { var CLSID_NotRegistered = new Guid("328FF83E-3F6C-4BE9-A742-752562032925"); // Random GUID - var IID_IClassFactory = new Guid("00000001-0000-0000-C000-000000000046"); var cxt = new ComActivationContext() { ClassId = CLSID_NotRegistered, - InterfaceId = IID_IClassFactory + InterfaceId = typeof(IClassFactory).GUID, + AssemblyPath = @"C:\foo.dll" }; ComActivator.GetClassFactoryForType(cxt); }, @@ -48,12 +72,78 @@ namespace Activator Assert.AreEqual(CLASS_E_CLASSNOTAVAILABLE, e.HResult, "Unexpected HRESULT"); } + static void ValidateAssemblyIsolation() + { + Console.WriteLine($"Running {nameof(ValidateAssemblyIsolation)}..."); + + string assemblySubPath = Path.Combine(Environment.CurrentDirectory, "Servers"); + string assemblyAPath = Path.Combine(assemblySubPath, "AssemblyA.dll"); + string assemblyBPath = Path.Combine(assemblySubPath, "AssemblyB.dll"); + string assemblyCPath = Path.Combine(assemblySubPath, "AssemblyC.dll"); + string assemblyPaths = $"{assemblyAPath}{Path.PathSeparator}{assemblyBPath}{Path.PathSeparator}{assemblyCPath}"; + + HostPolicyMock.Initialize(Environment.CurrentDirectory, null); + + var CLSID_NotUsed = Guid.Empty; // During this phase of activation the GUID is not used. + Guid iid = typeof(IGetTypeFromC).GUID; + Type typeCFromAssemblyA; + Type typeCFromAssemblyB; + + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( + 0, + assemblyPaths, + string.Empty, + string.Empty)) + { + var cxt = new ComActivationContext() + { + ClassId = CLSID_NotUsed, + InterfaceId = typeof(IClassFactory).GUID, + AssemblyPath = assemblyAPath, + AssemblyName = "AssemblyA", + TypeName = "ClassFromA" + }; + + var factory = (IClassFactory)ComActivator.GetClassFactoryForType(cxt); + + object svr; + factory.CreateInstance(null, ref iid, out svr); + typeCFromAssemblyA = (Type)((IGetTypeFromC)svr).GetTypeFromC(); + } + + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( + 0, + assemblyPaths, + string.Empty, + string.Empty)) + { + var cxt = new ComActivationContext() + { + ClassId = CLSID_NotUsed, + InterfaceId = typeof(IClassFactory).GUID, + AssemblyPath = assemblyBPath, + AssemblyName = "AssemblyB", + TypeName = "ClassFromB" + }; + + var factory = (IClassFactory)ComActivator.GetClassFactoryForType(cxt); + + object svr; + factory.CreateInstance(null, ref iid, out svr); + typeCFromAssemblyB = (Type)((IGetTypeFromC)svr).GetTypeFromC(); + } + + Assert.AreNotEqual(typeCFromAssemblyA, typeCFromAssemblyB, "Types should be from different AssemblyLoadContexts"); + } + static int Main(string[] doNotUse) { try { InvalidInterfaceRequest(); ClassNotRegistered(); + NonrootedAssemblyPath(); + ValidateAssemblyIsolation(); } catch (Exception e) { diff --git a/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyA.cs b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyA.cs new file mode 100644 index 0000000..606f064 --- /dev/null +++ b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyA.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public class ClassFromA : IGetTypeFromC +{ + private readonly ClassFromC _fromC; + public ClassFromA() + { + this._fromC = new ClassFromC(); + } + + public object GetTypeFromC() + { + return this._fromC.GetType(); + } +} \ No newline at end of file diff --git a/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyA.csproj b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyA.csproj new file mode 100644 index 0000000..b5fbf3b --- /dev/null +++ b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyA.csproj @@ -0,0 +1,26 @@ + + + + + + Debug + AnyCPU + AssemblyA + 2.0 + library + {4948E98A-ECFC-4988-851E-68E1ADD2DD5A};{B850CC46-E8FB-4569-A28D-423F81E8A861} + + + + + + + + + + + + + + + diff --git a/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyB.cs b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyB.cs new file mode 100644 index 0000000..043434d --- /dev/null +++ b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyB.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public class ClassFromB : IGetTypeFromC +{ + private readonly ClassFromC _fromC; + public ClassFromB() + { + this._fromC = new ClassFromC(); + } + + public object GetTypeFromC() + { + return this._fromC.GetType(); + } +} \ No newline at end of file diff --git a/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyB.csproj b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyB.csproj new file mode 100644 index 0000000..8f0fb0a --- /dev/null +++ b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyB.csproj @@ -0,0 +1,26 @@ + + + + + + Debug + AnyCPU + AssemblyB + 2.0 + library + {4948E98A-ECFC-4988-851E-68E1ADD2DD5A};{B850CC46-E8FB-4569-A28D-423F81E8A861} + + + + + + + + + + + + + + + diff --git a/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyC.cs b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyC.cs new file mode 100644 index 0000000..fbb79f6 --- /dev/null +++ b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyC.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public class ClassFromC +{ +} \ No newline at end of file diff --git a/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyC.csproj b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyC.csproj new file mode 100644 index 0000000..8c5a84c --- /dev/null +++ b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyC.csproj @@ -0,0 +1,22 @@ + + + + + + Debug + AnyCPU + AssemblyC + 2.0 + library + {4948E98A-ECFC-4988-851E-68E1ADD2DD5A};{B850CC46-E8FB-4569-A28D-423F81E8A861} + + + + + + + + + + + diff --git a/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyContracts.cs b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyContracts.cs new file mode 100644 index 0000000..deb7b63 --- /dev/null +++ b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyContracts.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; +using System.Runtime.InteropServices; + +[Guid("6B002803-4C9B-4E4F-BDA2-46AEFFD8D559")] +public interface IGetTypeFromC +{ + object GetTypeFromC(); +} \ No newline at end of file diff --git a/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyContracts.csproj b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyContracts.csproj new file mode 100644 index 0000000..40cd185 --- /dev/null +++ b/src/coreclr/tests/src/Interop/COM/Activator/Servers/AssemblyContracts.csproj @@ -0,0 +1,22 @@ + + + + + + Debug + AnyCPU + AssemblyContracts + 2.0 + library + {4948E98A-ECFC-4988-851E-68E1ADD2DD5A};{B850CC46-E8FB-4569-A28D-423F81E8A861} + + + + + + + + + + + diff --git a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives.csproj b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives.csproj index 2aa9343..305f104 100644 --- a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives.csproj +++ b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives.csproj @@ -14,8 +14,9 @@ - + + diff --git a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ArrayTests.cpp b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ArrayTests.cpp index 1bbdc10..2e57bb9 100644 --- a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ArrayTests.cpp +++ b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ArrayTests.cpp @@ -299,7 +299,7 @@ void Run_ArrayTests() { HRESULT hr; - CoreShimComActivation csact{ W("NETServer.dll"), W("ArrayTesting") }; + CoreShimComActivation csact{ W("NETServer"), W("ArrayTesting") }; ComSmartPtr arrayTesting; THROW_IF_FAILED(::CoCreateInstance(CLSID_ArrayTesting, nullptr, CLSCTX_INPROC, IID_IArrayTesting, (void**)&arrayTesting)); diff --git a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ColorTests.cpp b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ColorTests.cpp index ab95740..9ce8a80 100644 --- a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ColorTests.cpp +++ b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ColorTests.cpp @@ -34,7 +34,7 @@ void Run_ColorTests() { HRESULT hr; - CoreShimComActivation csact{ W("NETServer.dll"), W("ColorTesting") }; + CoreShimComActivation csact{ W("NETServer"), W("ColorTesting") }; ComSmartPtr color; THROW_IF_FAILED(::CoCreateInstance(CLSID_ColorTesting, nullptr, CLSCTX_INPROC, IID_IColorTesting, (void**)&color)); diff --git a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ErrorTests.cpp b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ErrorTests.cpp index 7e40716..1708aca 100644 --- a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ErrorTests.cpp +++ b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/ErrorTests.cpp @@ -58,7 +58,7 @@ void Run_ErrorTests() { HRESULT hr; - CoreShimComActivation csact{ W("NETServer.dll"), W("ErrorMarshalTesting") }; + CoreShimComActivation csact{ W("NETServer"), W("ErrorMarshalTesting") }; ComSmartPtr errorMarshal; THROW_IF_FAILED(::CoCreateInstance(CLSID_ErrorMarshalTesting, nullptr, CLSCTX_INPROC, IID_IErrorMarshalTesting, (void**)&errorMarshal)); diff --git a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/NumericTests.cpp b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/NumericTests.cpp index a9af956..c951c8c 100644 --- a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/NumericTests.cpp +++ b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/NumericTests.cpp @@ -222,7 +222,7 @@ void Run_NumericTests() { HRESULT hr; - CoreShimComActivation csact{ W("NETServer.dll"), W("NumericTesting") }; + CoreShimComActivation csact{ W("NETServer"), W("NumericTesting") }; ComSmartPtr numericTesting; THROW_IF_FAILED(::CoCreateInstance(CLSID_NumericTesting, nullptr, CLSCTX_INPROC, IID_INumericTesting, (void**)&numericTesting)); diff --git a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/StringTests.cpp b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/StringTests.cpp index 96a713f..b003130 100644 --- a/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/StringTests.cpp +++ b/src/coreclr/tests/src/Interop/COM/NativeClients/Primitives/StringTests.cpp @@ -412,7 +412,7 @@ void Run_StringTests() { HRESULT hr; - CoreShimComActivation csact{ W("NETServer.dll"), W("StringTesting") }; + CoreShimComActivation csact{ W("NETServer"), W("StringTesting") }; ComSmartPtr stringTesting; THROW_IF_FAILED(::CoCreateInstance(CLSID_StringTesting, nullptr, CLSCTX_INPROC, IID_IStringTesting, (void**)&stringTesting)); diff --git a/src/coreclr/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDom.csproj b/src/coreclr/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDom.csproj index 5f17049..7725f2f 100644 --- a/src/coreclr/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDom.csproj +++ b/src/coreclr/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDom.csproj @@ -1,7 +1,6 @@ - Debug AnyCPU @@ -14,6 +13,8 @@ $(DefineConstants);STATIC true + + diff --git a/src/coreclr/tests/src/Interop/Interop.settings.targets b/src/coreclr/tests/src/Interop/Interop.settings.targets index e16b130..fc906f2 100644 --- a/src/coreclr/tests/src/Interop/Interop.settings.targets +++ b/src/coreclr/tests/src/Interop/Interop.settings.targets @@ -6,16 +6,22 @@ + $(DefineConstants);REFERENCING_SYSTEMPRIVATECORELIB - - - + + - + + + + + + + diff --git a/src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.csproj b/src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.csproj index 689e124..59cbe9d 100644 --- a/src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.csproj +++ b/src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.csproj @@ -1,7 +1,6 @@ - Debug AnyCPU @@ -15,6 +14,8 @@ true 1 + + diff --git a/src/coreclr/tests/src/Interop/PInvoke/CustomMarshalers/CustomMarshalersTest.csproj b/src/coreclr/tests/src/Interop/PInvoke/CustomMarshalers/CustomMarshalersTest.csproj index f92a778..dd3ac5e 100644 --- a/src/coreclr/tests/src/Interop/PInvoke/CustomMarshalers/CustomMarshalersTest.csproj +++ b/src/coreclr/tests/src/Interop/PInvoke/CustomMarshalers/CustomMarshalersTest.csproj @@ -1,7 +1,6 @@ - Debug AnyCPU @@ -19,6 +18,8 @@ true true + + diff --git a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests.cs b/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests.cs index 9499bee..3e74a66 100644 --- a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests.cs +++ b/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests.cs @@ -5,8 +5,11 @@ using System; using System.IO; using System.Reflection; using System.Runtime.Loader; +using TestLibrary; using Xunit; +using Assert = Xunit.Assert; + namespace AssemblyDependencyResolverTests { class AssemblyDependencyResolverTests : TestBase @@ -38,8 +41,8 @@ namespace AssemblyDependencyResolverTests using (HostPolicyMock.MockValues_corehost_set_error_writer errorWriterMock = HostPolicyMock.Mock_corehost_set_error_writer()) { - using (HostPolicyMock.MockValues_corehost_resolve_componet_dependencies resolverMock = - HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.MockValues_corehost_resolve_component_dependencies resolverMock = + HostPolicyMock.Mock_corehost_resolve_component_dependencies( 134, "", "", @@ -79,8 +82,8 @@ namespace AssemblyDependencyResolverTests using (HostPolicyMock.MockValues_corehost_set_error_writer errorWriterMock = HostPolicyMock.Mock_corehost_set_error_writer(previousWriter)) { - using (HostPolicyMock.MockValues_corehost_resolve_componet_dependencies resolverMock = - HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.MockValues_corehost_resolve_component_dependencies resolverMock = + HostPolicyMock.Mock_corehost_resolve_component_dependencies( 134, "", "", @@ -108,7 +111,7 @@ namespace AssemblyDependencyResolverTests using (HostPolicyMock.MockValues_corehost_set_error_writer errorWriterMock = HostPolicyMock.Mock_corehost_set_error_writer(previousWriter)) { - using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( 0, assemblyDependencyPath, "", @@ -131,7 +134,7 @@ namespace AssemblyDependencyResolverTests { // If the reqest is for assembly which is not listed in .deps.json // the resolver should return null. - using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( 0, "", "", @@ -148,7 +151,7 @@ namespace AssemblyDependencyResolverTests { // Even if the .deps.json can resolve the request, if the file is not present // the resolution should still return null. - using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( 0, Path.Combine(_componentDirectory, "NonExistingAssembly.dll"), "", @@ -164,7 +167,7 @@ namespace AssemblyDependencyResolverTests public void TestSingleResource() { string enResourcePath = CreateMockAssembly($"en{Path.DirectorySeparatorChar}TestComponent.resources.dll"); - using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( 0, "", "", @@ -183,7 +186,7 @@ namespace AssemblyDependencyResolverTests { string enResourcePath = CreateMockAssembly($"en{Path.DirectorySeparatorChar}TestComponent.resources.dll"); string csResourcePath = CreateMockAssembly($"cs{Path.DirectorySeparatorChar}TestComponent.resources.dll"); - using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( 0, "", "", @@ -205,7 +208,7 @@ namespace AssemblyDependencyResolverTests { string enResourcePath = CreateMockAssembly($"en{Path.DirectorySeparatorChar}TestComponent.resources.dll"); string frResourcePath = CreateMockAssembly($"SubComponent{Path.DirectorySeparatorChar}fr{Path.DirectorySeparatorChar}TestComponent.resources.dll"); - using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( 0, "", "", @@ -226,7 +229,7 @@ namespace AssemblyDependencyResolverTests public void TestAssemblyWithNeutralCulture() { string neutralAssemblyPath = CreateMockAssembly("NeutralAssembly.dll"); - using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( 0, neutralAssemblyPath, "", @@ -245,7 +248,7 @@ namespace AssemblyDependencyResolverTests { string nativeLibraryPath = CreateMockStandardNativeLibrary("native", "Single"); - using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( 0, "", Path.GetDirectoryName(nativeLibraryPath), @@ -265,7 +268,7 @@ namespace AssemblyDependencyResolverTests string oneNativeLibraryPath = CreateMockStandardNativeLibrary($"native{Path.DirectorySeparatorChar}one", "One"); string twoNativeLibraryPath = CreateMockStandardNativeLibrary($"native{Path.DirectorySeparatorChar}two", "Two"); - using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( 0, "", $"{Path.GetDirectoryName(oneNativeLibraryPath)}{Path.PathSeparator}{Path.GetDirectoryName(twoNativeLibraryPath)}", diff --git a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests.csproj b/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests.csproj index c8ba654..e2dd0a4 100644 --- a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests.csproj +++ b/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests.csproj @@ -11,20 +11,15 @@ true - - WINDOWS - OSX - - - - + + diff --git a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/InvalidHostingTest.cs b/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/InvalidHostingTest.cs index c51b055..d1fc56e 100644 --- a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/InvalidHostingTest.cs +++ b/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/InvalidHostingTest.cs @@ -4,8 +4,11 @@ using System; using System.IO; using System.Runtime.Loader; +using TestLibrary; using Xunit; +using Assert = Xunit.Assert; + namespace AssemblyDependencyResolverTests { class InvalidHostingTest : TestBase diff --git a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/NativeDependencyTests.cs b/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/NativeDependencyTests.cs index 43e721e..e7ac906 100644 --- a/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/NativeDependencyTests.cs +++ b/src/coreclr/tests/src/Loader/AssemblyDependencyResolverTests/NativeDependencyTests.cs @@ -5,8 +5,11 @@ using System; using System.IO; using System.Runtime.InteropServices; using System.Runtime.Loader; +using TestLibrary; using Xunit; +using Assert = Xunit.Assert; + namespace AssemblyDependencyResolverTests { class NativeDependencyTests : TestBase @@ -258,7 +261,7 @@ namespace AssemblyDependencyResolverTests string lookupName, OS resolvesOnOSes) { - using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies( + using (HostPolicyMock.Mock_corehost_resolve_component_dependencies( 0, "", $"{nativeLibraryPaths}",