From d80aae8ae083369874b15d38970749c321b9ce60 Mon Sep 17 00:00:00 2001 From: Steve Harter Date: Wed, 11 May 2022 21:03:25 -0500 Subject: [PATCH] Fix Assembly.GetCallingAssembly() --- src/coreclr/vm/appdomain.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index c0741f5c50ee69..1ed177fdb6c7bc 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -1521,9 +1521,15 @@ bool SystemDomain::IsReflectionInvocationMethod(MethodDesc* pMeth) } CONTRACTL_END; - MethodTable* pCaller = pMeth->GetMethodTable(); + // Check for dynamically generated Invoke methods. + if (pMeth->IsDynamicMethod()) + { + if (strncmp(pMeth->GetName(), "InvokeStub_", ARRAY_SIZE("InvokeStub_") - 1) == 0) + return true; + } - // All Reflection Invocation methods are defined in CoreLib + // All other reflection invocation methods are defined in CoreLib. + MethodTable* pCaller = pMeth->GetMethodTable(); if (!pCaller->GetModule()->IsSystem()) return false; @@ -1579,13 +1585,6 @@ bool SystemDomain::IsReflectionInvocationMethod(MethodDesc* pMeth) if (CoreLibBinder::GetExistingClass(reflectionInvocationTypes[i]) == pCaller) return true; } - - // Check for dynamically generated Invoke methods. - if (pMeth->IsDynamicMethod()) - { - if (strncmp(pMeth->GetName(), "InvokeStub_", ARRAY_SIZE("InvokeStub_") - 1) == 0) - return true; - } } return false;