diff --git a/src/coreclr/tests/src/Interop/MarshalAPI/FunctionPointer/SingleMulticastTest.cs b/src/coreclr/tests/src/Interop/MarshalAPI/FunctionPointer/SingleMulticastTest.cs index fb30bb9d31010c..99af2d20522a56 100644 --- a/src/coreclr/tests/src/Interop/MarshalAPI/FunctionPointer/SingleMulticastTest.cs +++ b/src/coreclr/tests/src/Interop/MarshalAPI/FunctionPointer/SingleMulticastTest.cs @@ -10,35 +10,35 @@ partial class FunctionPtr public delegate bool DelegateWithLong(long l); //Singlecast delegate public delegate void MultiDelegateWithLong(long l); //Multicast delegate + public static DelegateWithLong s_DelWithLongBool = new DelegateWithLong(MethodWithLongBool); + public static MultiDelegateWithLong s_MultidelWithLong = new MultiDelegateWithLong(MethodWithLong); + public static void RunGetFcnPtrSingleMulticastTest() { Console.WriteLine($"Running {nameof(RunGetFcnPtrSingleMulticastTest)}..."); - DelegateWithLong del = new DelegateWithLong(Method); - MultiDelegateWithLong multidel = new MultiDelegateWithLong(Method2); - { - IntPtr fcnptr = Marshal.GetFunctionPointerForDelegate(del); + IntPtr fcnptr = Marshal.GetFunctionPointerForDelegate(s_DelWithLongBool); Assert.IsTrue(FunctionPointerNative.CheckFcnPtr(fcnptr)); } { - IntPtr fcnptr = Marshal.GetFunctionPointerForDelegate(multidel); + IntPtr fcnptr = Marshal.GetFunctionPointerForDelegate(s_MultidelWithLong); FunctionPointerNative.CheckFcnPtr(fcnptr); } + } - bool Method(long l) - { - if (l != 999999999999) - return false; - else - return true; - } + private static bool MethodWithLongBool(long l) + { + if (l != 999999999999) + return false; + else + return true; + } - void Method2(long l) - { - if (l != 999999999999) - throw new Exception("Failed multicast call"); - } + private static void MethodWithLong(long l) + { + if (l != 999999999999) + throw new Exception("Failed multicast call"); } }