</ItemGroup>
<ItemGroup Condition="'$(FeatureCominterop)' == 'true'">
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\InteropServices\WindowsRuntime\ExceptionSupport.cs" />
+ <Compile Include="$(BclSourcesRoot)\Internal\Runtime\InteropServices\ComActivator.cs" Condition="'$(FeatureCominteropUnmanagedActivation)' == 'true'" />
<Compile Include="$(BclSourcesRoot)\Microsoft\Win32\OAVariantLib.cs" Condition="'$(FeatureClassicCominterop)' == 'true'" />
<Compile Include="$(BclSourcesRoot)\System\__ComObject.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\ComActivator.cs" Condition="'$(FeatureCominteropUnmanagedActivation)' == 'true'" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\ComEventsHelper.cs" Condition="'$(FeatureClassicCominterop)' == 'true'" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\ComEventsInfo.cs" Condition="'$(FeatureClassicCominterop)' == 'true'" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\InteropServices\ComEventsMethod.cs" Condition="'$(FeatureClassicCominterop)' == 'true'" />
// 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,
{
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<string, AssemblyLoadContext> s_AssemblyLoadContexts = new Dictionary<string, AssemblyLoadContext>(StringComparer.InvariantCultureIgnoreCase);
+
/// <summary>
/// Entry point for unmanaged COM activation API from managed code
/// </summary>
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);
}
/// Internal entry point for unmanaged COM activation API from native code
/// </summary>
/// <param name="cxtInt">Reference to a <see cref="ComActivationContextInternal"/> instance</param>
- public static int GetClassFactoryForTypeInternal(ref ComActivationContextInternal cxtInt)
+ [CLSCompliant(false)]
+ public unsafe static int GetClassFactoryForTypeInternal(ref ComActivationContextInternal cxtInt)
{
if (IsLoggingEnabled())
{
$@"{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}");
}
{
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);
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)
{
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
{
"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(),
};
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);
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)
{
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<LPCWSTR>(&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<DWORD>(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)
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;
/// <summary>
/// Get the supplied environment variable.
/// </summary>
- HRESULT TryGetEnvVar(_In_z_ const WCHAR *env, _Inout_ std::string &envVar);
+ HRESULT TryGetEnvVar(_In_z_ const WCHAR *env, _Inout_ std::wstring &envVar);
+
+ /// <summary>
+ /// Get the CoreShim directory.
+ /// </summary>
+ HRESULT GetCoreShimDirectory(_Inout_ std::string &dir);
+ HRESULT GetCoreShimDirectory(_Inout_ std::wstring &dir);
}
// CoreShim environment variables used to indicate what assembly/type tuple
<Compile Include="Logging.cs" />
<Compile Include="TestFramework.cs" />
<Compile Include="Utilities.cs" />
- </ItemGroup>
- <ItemGroup>
- <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ <Compile Include="HostPolicyMock.cs" />
+ <Compile Include="XPlatformUtils.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
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(
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);
_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,
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;
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
{
// 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";
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")))
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<TestUnsupportedOutsideWindows>true</TestUnsupportedOutsideWindows>
<DisableProjectBuild Condition="'$(TargetsWindows)' != 'true'">true</DisableProjectBuild>
</PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" />
+
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
</PropertyGroup>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NetServer\NetServer.csproj" />
+ <ProjectReference Include="Servers\AssemblyA.csproj" />
+ <ProjectReference Include="Servers\AssemblyB.csproj" />
+ <ProjectReference Include="Servers\AssemblyC.csproj" />
+ <ProjectReference Include="Servers\AssemblyContracts.csproj" />
+ <ProjectReference Include="../../../Common/hostpolicymock/CMakeLists.txt" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+
+ <!-- Set up an isolated directory for the server assemblies -->
+ <Target Name="SetUpIsolatedDirectory"
+ AfterTargets="CopyFilesToOutputDirectory">
+
+ <PropertyGroup>
+ <ServerAssemblyDest>$(OutDir)/Servers</ServerAssemblyDest>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ServerAssembly Include="$(OutDir)/AssemblyA.*" />
+ <ServerAssembly Include="$(OutDir)/AssemblyB.*" />
+ <ServerAssembly Include="$(OutDir)/AssemblyC.*" />
+ </ItemGroup>
+
+ <Move SourceFiles="@(ServerAssembly)"
+ DestinationFolder="$(ServerAssemblyDest)" />
+ </Target>
+
</Project>
namespace Activator
{
+ using Internal.Runtime.InteropServices;
+
using System;
+ using System.IO;
using System.Runtime.InteropServices;
using TestLibrary;
{
static void InvalidInterfaceRequest()
{
+ Console.WriteLine($"Running {nameof(InvalidInterfaceRequest)}...");
+
Assert.Throws<NotSupportedException>(
() =>
{
"Non-IClassFactory request should fail");
}
+ static void NonrootedAssemblyPath()
+ {
+ Console.WriteLine($"Running {nameof(NonrootedAssemblyPath)}...");
+
+ ArgumentException e = Assert.Throws<ArgumentException>(
+ () =>
+ {
+ 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<COMException>(
() =>
{
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);
},
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)
{
--- /dev/null
+// 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
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>AssemblyA</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <OutputType>library</OutputType>
+ <ProjectTypeGuids>{4948E98A-ECFC-4988-851E-68E1ADD2DD5A};{B850CC46-E8FB-4569-A28D-423F81E8A861}</ProjectTypeGuids>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyA.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="AssemblyC.csproj" />
+ <ProjectReference Include="AssemblyContracts.csproj" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
--- /dev/null
+// 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
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>AssemblyB</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <OutputType>library</OutputType>
+ <ProjectTypeGuids>{4948E98A-ECFC-4988-851E-68E1ADD2DD5A};{B850CC46-E8FB-4569-A28D-423F81E8A861}</ProjectTypeGuids>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyB.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="AssemblyC.csproj" />
+ <ProjectReference Include="AssemblyContracts.csproj" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
--- /dev/null
+// 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
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>AssemblyC</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <OutputType>library</OutputType>
+ <ProjectTypeGuids>{4948E98A-ECFC-4988-851E-68E1ADD2DD5A};{B850CC46-E8FB-4569-A28D-423F81E8A861}</ProjectTypeGuids>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyC.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
--- /dev/null
+// 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
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>AssemblyContracts</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <OutputType>library</OutputType>
+ <ProjectTypeGuids>{4948E98A-ECFC-4988-851E-68E1ADD2DD5A};{B850CC46-E8FB-4569-A28D-423F81E8A861}</ProjectTypeGuids>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyContracts.cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
<Compile Include="$(InteropCommonDir)ExeLauncherProgram.cs" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="Primitives/CMakeLists.txt"/>
+ <ProjectReference Include="Primitives/CMakeLists.txt" />
<ProjectReference Include="../NetServer/NetServer.csproj" />
+ <ProjectReference Include="../../../Common/hostpolicymock/CMakeLists.txt" />
<ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
{
HRESULT hr;
- CoreShimComActivation csact{ W("NETServer.dll"), W("ArrayTesting") };
+ CoreShimComActivation csact{ W("NETServer"), W("ArrayTesting") };
ComSmartPtr<IArrayTesting> arrayTesting;
THROW_IF_FAILED(::CoCreateInstance(CLSID_ArrayTesting, nullptr, CLSCTX_INPROC, IID_IArrayTesting, (void**)&arrayTesting));
{
HRESULT hr;
- CoreShimComActivation csact{ W("NETServer.dll"), W("ColorTesting") };
+ CoreShimComActivation csact{ W("NETServer"), W("ColorTesting") };
ComSmartPtr<IColorTesting> color;
THROW_IF_FAILED(::CoCreateInstance(CLSID_ColorTesting, nullptr, CLSCTX_INPROC, IID_IColorTesting, (void**)&color));
{
HRESULT hr;
- CoreShimComActivation csact{ W("NETServer.dll"), W("ErrorMarshalTesting") };
+ CoreShimComActivation csact{ W("NETServer"), W("ErrorMarshalTesting") };
ComSmartPtr<IErrorMarshalTesting> errorMarshal;
THROW_IF_FAILED(::CoCreateInstance(CLSID_ErrorMarshalTesting, nullptr, CLSCTX_INPROC, IID_IErrorMarshalTesting, (void**)&errorMarshal));
{
HRESULT hr;
- CoreShimComActivation csact{ W("NETServer.dll"), W("NumericTesting") };
+ CoreShimComActivation csact{ W("NETServer"), W("NumericTesting") };
ComSmartPtr<INumericTesting> numericTesting;
THROW_IF_FAILED(::CoCreateInstance(CLSID_NumericTesting, nullptr, CLSCTX_INPROC, IID_INumericTesting, (void**)&numericTesting));
{
HRESULT hr;
- CoreShimComActivation csact{ W("NETServer.dll"), W("StringTesting") };
+ CoreShimComActivation csact{ W("NETServer"), W("StringTesting") };
ComSmartPtr<IStringTesting> stringTesting;
THROW_IF_FAILED(::CoCreateInstance(CLSID_StringTesting, nullptr, CLSCTX_INPROC, IID_IStringTesting, (void**)&stringTesting));
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<DefineConstants>$(DefineConstants);STATIC</DefineConstants>
<ReferenceSystemPrivateCoreLib>true</ReferenceSystemPrivateCoreLib>
</PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" />
+
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"></PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"></PropertyGroup>
<!-- Environment properties -->
<PropertyGroup>
+ <DefineConstants Condition="'$(ReferenceSystemPrivateCoreLib)' == 'true'">$(DefineConstants);REFERENCING_SYSTEMPRIVATECORELIB</DefineConstants>
</PropertyGroup>
- <!-- Required source files -->
- <ItemGroup>
- <ProjectReference
- Condition="('$(IgnoreCoreCLRTestLibraryDependency)' != 'true') And ('$(ReferenceSystemPrivateCoreLib)' != 'true')"
+ <!-- Add the CoreCLRTestLibrary dependency -->
+ <ItemGroup Condition="('$(IgnoreCoreCLRTestLibraryDependency)' != 'true') And ('$(ReferenceSystemPrivateCoreLib)' != 'true')">
+ <ProjectReference
Include="$(MSBuildThisFileDirectory)\..\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj" />
- <Compile
- Condition="('$(IgnoreCoreCLRTestLibraryDependency)' != 'true') And ('$(ReferenceSystemPrivateCoreLib)' == 'true')"
- Include="$(MSBuildThisFileDirectory)\..\Common\CoreCLRTestLibrary\Assertion.cs" />
+ </ItemGroup>
+
+ <!-- Add the CoreCLRTestLibrary dependency
+ If a target project references System.Private.Corelib, we are unable to reference CoreCLRTestLibrary.
+ Compile in relevant files used for testing interop. -->
+ <ItemGroup Condition="('$(IgnoreCoreCLRTestLibraryDependency)' != 'true') And ('$(ReferenceSystemPrivateCoreLib)' == 'true')">
+ <Compile Include="$(MSBuildThisFileDirectory)\..\Common\CoreCLRTestLibrary\Assertion.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)\..\Common\CoreCLRTestLibrary\HostPolicyMock.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)\..\Common\CoreCLRTestLibrary\XPlatformUtils.cs" />
</ItemGroup>
<!-- Required debug vcruntime and UCRT dlls -->
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferenceSystemPrivateCoreLib>true</ReferenceSystemPrivateCoreLib>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" />
+
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"></PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"></PropertyGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
- <Import Project="../../Interop.settings.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<TestUnsupportedOutsideWindows>true</TestUnsupportedOutsideWindows>
<DisableProjectBuild Condition="'$(TargetsUnix)' == 'true'">true</DisableProjectBuild>
</PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Interop.settings.targets))\Interop.settings.targets" />
+
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"></PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"></PropertyGroup>
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
+using TestLibrary;
using Xunit;
+using Assert = Xunit.Assert;
+
namespace AssemblyDependencyResolverTests
{
class AssemblyDependencyResolverTests : TestBase
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,
"",
"",
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,
"",
"",
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,
"",
{
// 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,
"",
"",
{
// 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"),
"",
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,
"",
"",
{
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,
"",
"",
{
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,
"",
"",
public void TestAssemblyWithNeutralCulture()
{
string neutralAssemblyPath = CreateMockAssembly("NeutralAssembly.dll");
- using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies(
+ using (HostPolicyMock.Mock_corehost_resolve_component_dependencies(
0,
neutralAssemblyPath,
"",
{
string nativeLibraryPath = CreateMockStandardNativeLibrary("native", "Single");
- using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies(
+ using (HostPolicyMock.Mock_corehost_resolve_component_dependencies(
0,
"",
Path.GetDirectoryName(nativeLibraryPath),
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)}",
<!-- The test fails if ran twice in the same process. In one of the test cases, it expects a hostpolicy to not to be found, but it actually is found in the second pass -->
<UnloadabilityIncompatible>true</UnloadabilityIncompatible>
</PropertyGroup>
- <PropertyGroup>
- <DefineConstants Condition="$(OSGroup) == 'Windows_NT'">WINDOWS</DefineConstants>
- <DefineConstants Condition="$(OSGroup) == 'OSX'">OSX</DefineConstants>
- </PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyDependencyResolverTests.cs" />
- <Compile Include="HostPolicyMock.cs" />
<Compile Include="InvalidHostingTest.cs" />
<Compile Include="NativeDependencyTests.cs" />
<Compile Include="TestBase.cs" />
- <Compile Include="XPlatformUtils.cs" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="CMakeLists.txt" />
+ <ProjectReference Include="../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+ <ProjectReference Include="../../Common/hostpolicymock/CMakeLists.txt" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
using System;
using System.IO;
using System.Runtime.Loader;
+using TestLibrary;
using Xunit;
+using Assert = Xunit.Assert;
+
namespace AssemblyDependencyResolverTests
{
class InvalidHostingTest : TestBase
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
+using TestLibrary;
using Xunit;
+using Assert = Xunit.Assert;
+
namespace AssemblyDependencyResolverTests
{
class NativeDependencyTests : TestBase
string lookupName,
OS resolvesOnOSes)
{
- using (HostPolicyMock.Mock_corehost_resolve_componet_dependencies(
+ using (HostPolicyMock.Mock_corehost_resolve_component_dependencies(
0,
"",
$"{nativeLibraryPaths}",