Remove reflection-based wraper for AssemblyDependencyResolver. (#22195)
authorJeremy Koritzinsky <jkoritzinsky@gmail.com>
Fri, 25 Jan 2019 16:37:43 +0000 (08:37 -0800)
committerGitHub <noreply@github.com>
Fri, 25 Jan 2019 16:37:43 +0000 (08:37 -0800)
Now that AssemblyDependencyResolver is exposed in CoreFX and has propogated back to CoreCLR, we can remove the reflection-based wrapper for the unit tests for it.

tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolver.cs [deleted file]
tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests.cs
tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests.csproj
tests/src/Loader/AssemblyDependencyResolverTests/HostPolicyMock.cs
tests/src/Loader/AssemblyDependencyResolverTests/InvalidHostingTest.cs
tests/src/Loader/AssemblyDependencyResolverTests/NativeDependencyTests.cs

diff --git a/tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolver.cs b/tests/src/Loader/AssemblyDependencyResolverTests/AssemblyDependencyResolver.cs
deleted file mode 100644 (file)
index 40d7a41..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// 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;
-            }
-        }
-    }
-}
index 28bd068..ee13f90 100644 (file)
     <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" />
index ca4d698..37cedbc 100644 (file)
@@ -4,6 +4,7 @@
 using System;
 using System.IO;
 using System.Runtime.InteropServices;
+using System.Runtime.Loader;
 
 namespace AssemblyDependencyResolverTests
 {
@@ -63,9 +64,9 @@ 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);
index 616b5ee..c51b055 100644 (file)
@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 using System;
 using System.IO;
+using System.Runtime.Loader;
 using Xunit;
 
 namespace AssemblyDependencyResolverTests
index e7dcf20..43e721e 100644 (file)
@@ -4,6 +4,7 @@
 using System;
 using System.IO;
 using System.Runtime.InteropServices;
+using System.Runtime.Loader;
 using Xunit;
 
 namespace AssemblyDependencyResolverTests