From 0099b95dfc110a3b018ec3df1ade5320635c03f6 Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Fri, 28 Feb 2020 05:45:14 -0500 Subject: [PATCH] [mono] Use ALC and throw FileNotFound in RuntimeAssembly.InternalLoad (#32933) 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 | 1 - .../System.Runtime.Loader/tests/AssemblyLoadContextTest.cs | 5 ----- .../tests/DefaultContext/DefaultLoadContextTest.cs | 2 -- .../System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs | 6 ++++-- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/libraries/System.Reflection/tests/CoreCLR/AssemblyTests.cs b/src/libraries/System.Reflection/tests/CoreCLR/AssemblyTests.cs index 0c4a117..dcc602e 100644 --- a/src/libraries/System.Reflection/tests/CoreCLR/AssemblyTests.cs +++ b/src/libraries/System.Reflection/tests/CoreCLR/AssemblyTests.cs @@ -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")); diff --git a/src/libraries/System.Runtime.Loader/tests/AssemblyLoadContextTest.cs b/src/libraries/System.Runtime.Loader/tests/AssemblyLoadContextTest.cs index 0b85d43..b2091fd 100644 --- a/src/libraries/System.Runtime.Loader/tests/AssemblyLoadContextTest.cs +++ b/src/libraries/System.Runtime.Loader/tests/AssemblyLoadContextTest.cs @@ -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); diff --git a/src/libraries/System.Runtime.Loader/tests/DefaultContext/DefaultLoadContextTest.cs b/src/libraries/System.Runtime.Loader/tests/DefaultContext/DefaultLoadContextTest.cs index 32c1c15..2c0f997 100644 --- a/src/libraries/System.Runtime.Loader/tests/DefaultContext/DefaultLoadContextTest.cs +++ b/src/libraries/System.Runtime.Loader/tests/DefaultContext/DefaultLoadContextTest.cs @@ -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 diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index aaf9bfe..8d394d2 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -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 -- 2.7.4