+++ /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.Reflection;
-
-namespace AssemblyDependencyResolverTests
-{
- /// <summary>
- /// Temporary until the actual public API gets propagated through CoreFX.
- /// </summary>
- public class AssemblyDependencyResolver
- {
- private object _implementation;
- private Type _implementationType;
- private MethodInfo _resolveAssemblyPathInfo;
- private MethodInfo _resolveUnmanagedDllPathInfo;
-
- public AssemblyDependencyResolver(string componentAssemblyPath)
- {
- _implementationType = typeof(object).Assembly.GetType("System.Runtime.Loader.AssemblyDependencyResolver");
- _resolveAssemblyPathInfo = _implementationType.GetMethod("ResolveAssemblyToPath");
- _resolveUnmanagedDllPathInfo = _implementationType.GetMethod("ResolveUnmanagedDllToPath");
-
- try
- {
- _implementation = Activator.CreateInstance(_implementationType, componentAssemblyPath);
- }
- catch (TargetInvocationException tie)
- {
- throw tie.InnerException;
- }
- }
-
- public string ResolveAssemblyToPath(AssemblyName assemblyName)
- {
- try
- {
- return (string)_resolveAssemblyPathInfo.Invoke(_implementation, new object[] { assemblyName });
- }
- catch (TargetInvocationException tie)
- {
- throw tie.InnerException;
- }
- }
-
- public string ResolveUnmanagedDllToPath(string unmanagedDllName)
- {
- try
- {
- return (string)_resolveUnmanagedDllPathInfo.Invoke(_implementation, new object[] { unmanagedDllName });
- }
- catch (TargetInvocationException tie)
- {
- throw tie.InnerException;
- }
- }
- }
-}
<DefineConstants Condition="$(OSGroup) == 'Windows_NT'">WINDOWS</DefineConstants>
<DefineConstants Condition="$(OSGroup) == 'OSX'">OSX</DefineConstants>
</PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
- </PropertyGroup>
<ItemGroup>
- <Compile Include="AssemblyDependencyResolver.cs" />
<Compile Include="AssemblyDependencyResolverTests.cs" />
<Compile Include="HostPolicyMock.cs" />
<Compile Include="InvalidHostingTest.cs" />
using System;
using System.IO;
using System.Runtime.InteropServices;
+using System.Runtime.Loader;
namespace AssemblyDependencyResolverTests
{
Path.Combine(testBasePath, hostPolicyFileName),
destinationPath);
- _assemblyDependencyResolverType = typeof(object).Assembly.GetType("System.Runtime.Loader.AssemblyDependencyResolver");
+ _assemblyDependencyResolverType = typeof(AssemblyDependencyResolver);
- // This is needed for marshalling of function pointers to work - requires private access to the CDR unfortunately
+ // This is needed for marshalling of function pointers to work - requires private access to the ADR unfortunately
// Delegate marshalling doesn't support casting delegates to anything but the original type
// so we need to use the original type.
_corehost_error_writer_fnType = _assemblyDependencyResolverType.GetNestedType("corehost_error_writer_fn", System.Reflection.BindingFlags.NonPublic);