private static int CallAsFunctionPointer(int expected) { Console.WriteLine($"{nameof(CallAsFunctionPointer)} ({expected}) ..."); IntPtr fptr = SuppressGCTransitionNative.GetNextUIntFunctionPointer(); int n = 0; int * pn = &n; object boxedN = Pointer.Box(pn, typeof(int *)); MethodInfo callNextUInt = typeof(FunctionPointer).GetMethod("Call_NextUInt"); callNextUInt.Invoke(null, new object[] { fptr, boxedN }); Assert.AreEqual(expected, n); return(n + 1); }