From 50d2e31ae1e100170300833749f4caeef020b794 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 10 Jun 2021 19:25:33 +0200 Subject: [PATCH] Simplify how CheckGCMode gets the Marshal type (#54000) Unless I'm missing something, this is equivalent. The previous version was incomprehensible to static analysis. --- src/tests/Interop/common/CheckGCMode.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/Interop/common/CheckGCMode.cs b/src/tests/Interop/common/CheckGCMode.cs index e895cd5..e3c6da3 100644 --- a/src/tests/Interop/common/CheckGCMode.cs +++ b/src/tests/Interop/common/CheckGCMode.cs @@ -3,6 +3,7 @@ using System; using System.Reflection; +using System.Runtime.InteropServices; using TestLibrary; @@ -13,8 +14,7 @@ unsafe internal class CheckGCMode { // GetIsInCooperativeGCModeFunctionPointer is conditionally included based on the runtime build configuration, // so we check for its existence and only do the explicit mode validation if it is available. - Type marshalType = typeof(object).Assembly.GetType(typeof(System.Runtime.InteropServices.Marshal).FullName); - MethodInfo getFunctionPtr = marshalType.GetMethod("GetIsInCooperativeGCModeFunctionPointer", BindingFlags.NonPublic | BindingFlags.Static); + MethodInfo getFunctionPtr = typeof(Marshal).GetMethod("GetIsInCooperativeGCModeFunctionPointer", BindingFlags.NonPublic | BindingFlags.Static); if (getFunctionPtr != null) { var isInCooperativeModeFunc = (delegate* unmanaged)(IntPtr)getFunctionPtr.Invoke(null, null); -- 2.7.4