[mono] Use ALC and throw FileNotFound in RuntimeAssembly.InternalLoad (#32933)
authorRyan Lucia <rylucia@microsoft.com>
Fri, 28 Feb 2020 10:45:14 +0000 (05:45 -0500)
committerGitHub <noreply@github.com>
Fri, 28 Feb 2020 10:45:14 +0000 (11:45 +0100)
https://github.com/dotnet/runtime/commit/7c6ec46a637017971d3eaa210fd2b6e4d4a6b737#diff-53c474033a1751601becf0eb958fcb5dL287-R287 broke a bunch of tests, this should fix them all.

Fixes #22110
Fixes #32436
Fixes #32437
Fixes #32435
Fixes #32439
Fixes #32434
Fixes #32433
Fixes #32432

src/libraries/System.Reflection/tests/CoreCLR/AssemblyTests.cs
src/libraries/System.Runtime.Loader/tests/AssemblyLoadContextTest.cs
src/libraries/System.Runtime.Loader/tests/DefaultContext/DefaultLoadContextTest.cs
src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs

index 0c4a117..dcc602e 100644 (file)
@@ -24,7 +24,6 @@ namespace System.Reflection.Tests
         }
 
         [Fact]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/22110", TestRuntimes.Mono)]
         public void LoadFromStream_Location_IsEmpty()
         {
             Assembly assembly = new TestStreamLoadContext().LoadFromAssemblyName(new AssemblyName("TinyAssembly"));
index 0b85d43..b2091fd 100644 (file)
@@ -70,7 +70,6 @@ namespace System.Runtime.Loader.Tests
         }
 
         [Fact]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/32436", TestRuntimes.Mono)]
         public static void LoadAssemblyByPath_ValidUserAssembly()
         {
             var asmName = new AssemblyName(TestAssembly);
@@ -84,7 +83,6 @@ namespace System.Runtime.Loader.Tests
         }
 
         [Fact]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/32437", TestRuntimes.Mono)]
         public static void LoadAssemblyByStream_ValidUserAssembly()
         {
             var asmName = new AssemblyName(TestAssembly);
@@ -98,7 +96,6 @@ namespace System.Runtime.Loader.Tests
         }
 
         [Fact]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/32435", TestRuntimes.Mono)]
         public static void LoadFromAssemblyName_AssemblyNotFound()
         {
             var asmName = new AssemblyName("Non.Existing.Assembly.dll");
@@ -109,7 +106,6 @@ namespace System.Runtime.Loader.Tests
         }
 
         [Fact]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/32439", TestRuntimes.Mono)]
         public static void LoadFromAssemblyName_ValidTrustedPlatformAssembly()
         {
             var asmName = typeof(System.Linq.Enumerable).Assembly.GetName();
@@ -126,7 +122,6 @@ namespace System.Runtime.Loader.Tests
         }
 
         [Fact]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/32434", TestRuntimes.Mono)]
         public static void GetLoadContextTest_ValidUserAssembly()
         {
             var asmName = new AssemblyName(TestAssembly);
index 32c1c15..2c0f997 100644 (file)
@@ -84,7 +84,6 @@ namespace System.Runtime.Loader.Tests
         }
 
         [Fact]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/32433", TestRuntimes.Mono)]
         public void LoadInDefaultContext()
         {
             // This will attempt to load an assembly, by path, in the Default Load context via the Resolving event
@@ -177,7 +176,6 @@ namespace System.Runtime.Loader.Tests
         }
 
         [Fact]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/32432", TestRuntimes.Mono)]
         public static void LoadNonExistentInDefaultContext()
         {
             // Now, try to load an assembly that does not exist
index aaf9bfe..8d394d2 100644 (file)
@@ -406,8 +406,10 @@ namespace System.Reflection
 
                internal static RuntimeAssembly InternalLoad (AssemblyName assemblyRef, ref StackCrawlMark stackMark, AssemblyLoadContext assemblyLoadContext)
                {
-                       // TODO: Use assemblyLoadContext
-                       return (RuntimeAssembly) InternalLoad (assemblyRef.FullName, ref stackMark, IntPtr.Zero);
+                       var assembly = (RuntimeAssembly) InternalLoad (assemblyRef.FullName, ref stackMark, assemblyLoadContext != null ? assemblyLoadContext.NativeALC : IntPtr.Zero);
+                       if (assembly == null)
+                               throw new FileNotFoundException (null, assemblyRef.Name);
+                       return assembly;
                }
 
                // FIXME: Merge some of these