From c3d2bc57e130e6132970b26233e9294c923ded79 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Sat, 20 Apr 2019 12:06:47 -0400 Subject: [PATCH 1/6] Add ContextualReflection LoadWithPartialName case --- tests/src/Loader/ContextualReflection/ContextualReflection.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/src/Loader/ContextualReflection/ContextualReflection.cs b/tests/src/Loader/ContextualReflection/ContextualReflection.cs index 1612c141b2d4..91b148a2746e 100644 --- a/tests/src/Loader/ContextualReflection/ContextualReflection.cs +++ b/tests/src/Loader/ContextualReflection/ContextualReflection.cs @@ -321,6 +321,9 @@ void TestAssemblyLoad(bool isolated) { TestAssemblyLoad(isolated, (string assemblyName) => Assembly.Load(assemblyName)); TestAssemblyLoad(isolated, (string assemblyName) => Assembly.Load(new AssemblyName(assemblyName))); +#pragma warning disable 618 + TestAssemblyLoad(isolated, (string assemblyName) => Assembly.LoadWithPartialName(assemblyName)); +#pragma warning restore 618 } void TestAssemblyLoad(bool isolated, Func assemblyLoad) From a0f34217ee838e84a11cbb78808dbb8ab246b5a7 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Sat, 20 Apr 2019 11:44:37 -0400 Subject: [PATCH 2/6] Remove unnecessary MethodImplOptions.NoInlining --- tests/src/Loader/ContextualReflection/ContextualReflection.cs | 1 - .../ContextualReflection/ContextualReflectionDependency.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/src/Loader/ContextualReflection/ContextualReflection.cs b/tests/src/Loader/ContextualReflection/ContextualReflection.cs index 91b148a2746e..2c1d081db6f3 100644 --- a/tests/src/Loader/ContextualReflection/ContextualReflection.cs +++ b/tests/src/Loader/ContextualReflection/ContextualReflection.cs @@ -751,7 +751,6 @@ public void RunTests(bool isolated) TestMockAssemblyThrows(); } - [MethodImplAttribute(MethodImplOptions.NoInlining)] public void RunTestsIsolated() { VerifyIsolationAlc(); diff --git a/tests/src/Loader/ContextualReflection/ContextualReflectionDependency.cs b/tests/src/Loader/ContextualReflection/ContextualReflectionDependency.cs index f498db49a758..933194a304ef 100644 --- a/tests/src/Loader/ContextualReflection/ContextualReflectionDependency.cs +++ b/tests/src/Loader/ContextualReflection/ContextualReflectionDependency.cs @@ -16,7 +16,6 @@ public interface IProgram Assembly alcAssembly { get; } Type alcProgramType { get; } IProgram alcProgramInstance { get; } - [MethodImplAttribute(MethodImplOptions.NoInlining)] void RunTestsIsolated(); } From b8c0632b7a5ad9a9bf61b615761c3b1991562ed1 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Sat, 20 Apr 2019 11:37:20 -0400 Subject: [PATCH 3/6] Remove m_assembly warning --- .../src/System/Reflection/RuntimeAssembly.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index 16dc8ec474be..a97fddc782b5 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -25,7 +25,9 @@ internal class RuntimeAssembly : Assembly private event ModuleResolveEventHandler _ModuleResolve; private string? m_fullname; private object? m_syncRoot; // Used to keep collectible types alive and as the syncroot for reflection.emit +#pragma warning disable 169 private IntPtr m_assembly; // slack for ptr datum on unmanaged side +#pragma warning restore 169 #endregion From 9b736b0cc90e8f8e87b1cbfce678ac78f7068863 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Sun, 21 Apr 2019 00:46:48 -0400 Subject: [PATCH 4/6] AssemblyNative::Load fix stackMark usage Do not use the stackMark if (ptrLoadContextBinder != NULL) --- src/vm/assemblynative.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vm/assemblynative.cpp b/src/vm/assemblynative.cpp index aa830932ed5c..cc9515140885 100644 --- a/src/vm/assemblynative.cpp +++ b/src/vm/assemblynative.cpp @@ -78,18 +78,18 @@ FCIMPL6(Object*, AssemblyNative::Load, AssemblyNameBaseObject* assemblyNameUNSAF else { // Compute parent assembly - if (gc.requestingAssembly == NULL) + if (gc.requestingAssembly != NULL) { - pRefAssembly = SystemDomain::GetCallersAssembly(stackMark); + pRefAssembly = gc.requestingAssembly->GetAssembly(); } - else + else if (ptrLoadContextBinder == NULL) { - pRefAssembly = gc.requestingAssembly->GetAssembly(); + pRefAssembly = SystemDomain::GetCallersAssembly(stackMark); } if (pRefAssembly) { - pParentAssembly= pRefAssembly->GetDomainAssembly(); + pParentAssembly = pRefAssembly->GetDomainAssembly(); } } From 41fac7684a175fc8dd39e8af1d245e44ed3644d6 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Sun, 21 Apr 2019 00:44:24 -0400 Subject: [PATCH 5/6] Fix AssemblyName hash function --- src/binder/assemblyname.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/binder/assemblyname.cpp b/src/binder/assemblyname.cpp index 616869b3f903..bc978140b143 100644 --- a/src/binder/assemblyname.cpp +++ b/src/binder/assemblyname.cpp @@ -486,6 +486,15 @@ namespace BINDER_SPACE { dwUseIdentityFlags &= ~AssemblyIdentity::IDENTITY_FLAG_CONTENT_TYPE; } + if ((dwIncludeFlags & INCLUDE_PUBLIC_KEY_TOKEN) == 0) + { + dwUseIdentityFlags &= ~AssemblyIdentity::IDENTITY_FLAG_PUBLIC_KEY; + dwUseIdentityFlags &= ~AssemblyIdentity::IDENTITY_FLAG_PUBLIC_KEY_TOKEN; + } + if ((dwIncludeFlags & EXCLUDE_CULTURE) != 0) + { + dwUseIdentityFlags &= ~AssemblyIdentity::IDENTITY_FLAG_CULTURE; + } dwHash ^= static_cast(HashCaseInsensitive(GetSimpleName())); dwHash = _rotl(dwHash, 4); From 5fc59df8b4fceb37f49094056090e3a60ba74b7f Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Sun, 21 Apr 2019 05:30:38 -0400 Subject: [PATCH 6/6] Temporarily disable DefaultContextOverrideTPA Test is failing due to a logic error. Fix is pending in https://github.com/dotnet/corefx/pull/37071 --- tests/CoreFX/CoreFX.issues.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/CoreFX/CoreFX.issues.json b/tests/CoreFX/CoreFX.issues.json index b0eb61c7d44d..e8428f5a928b 100644 --- a/tests/CoreFX/CoreFX.issues.json +++ b/tests/CoreFX/CoreFX.issues.json @@ -1149,6 +1149,20 @@ ] } }, + { + "name": "System.Runtime.Loader.DefaultContext.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name" : "System.Runtime.Loader.Tests.DefaultLoadContextTests.LoadInDefaultContext", + "reason" : "Waiting for https://github.com/dotnet/corefx/pull/37071" + } + ] + } + }, { "name": "System.Runtime.Loader.Tests", "enabled": true,