From: Michal Strehovský Date: Thu, 10 Jun 2021 17:25:33 +0000 (+0200) Subject: Simplify how CheckGCMode gets the Marshal type (#54000) X-Git-Tag: submit/tizen/20210909.063632~848 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=50d2e31ae1e100170300833749f4caeef020b794;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Simplify how CheckGCMode gets the Marshal type (#54000) Unless I'm missing something, this is equivalent. The previous version was incomprehensible to static analysis. --- 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);