Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,11 @@ private unsafe object ReturnTransform(ref byte byref, bool wrapInTargetInvocatio
Debug.Assert(type.IsPointer);
obj = Pointer.Box((void*)Unsafe.As<byte, IntPtr>(ref byref), type);
}
else if ((_returnTransform & Transform.FunctionPointer) != 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this change, a checked build would throw in the else statement below where it tried to box _returnType.

{
Debug.Assert(Type.GetTypeFromMethodTable(_returnType.ToPointer()).IsFunctionPointer);
obj = RuntimeImports.RhBox(EETypePtr.EETypePtrOf<IntPtr>(), ref byref);
}
else if ((_returnTransform & Transform.Reference) != 0)
{
Debug.Assert((_returnTransform & Transform.ByRef) != 0);
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Reflection/tests/MethodInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ private static void SecondCall(MethodInfo mi)
Assert.Contains("TestAssembly", asm.ToString());
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/71095", TestRuntimes.Mono)]
private static unsafe void TestFunctionPointersWithFunctionPointerArgs()
{
Expand All @@ -911,7 +912,6 @@ private static unsafe void TestFunctionPointersWithFunctionPointerArgs()
Assert.True((IntPtr)ret != 0);
}

// Mono will throw System.ArgumentException : Object of type 'System.IntPtr' cannot be converted to type 'System.Boolean(System.Int32)'.
[Fact]
private static unsafe void TestFunctionPointersWithIntPtrArgs()
{
Expand Down