Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 213833e

Browse files
Fix issue with reflection invoke and pointer types (#92922)
1 parent 1d352cb commit 213833e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -769,13 +769,11 @@ private unsafe void CopyBackToArray(ref object? src, object?[] dest)
769769
Debug.Assert(type.IsPointer);
770770
obj = Pointer.Box((void*)Unsafe.As<byte, IntPtr>(ref obj.GetRawData()), type);
771771
}
772-
if ((transform & Transform.FunctionPointer) != 0)
773-
{
774-
obj = RuntimeImports.RhBox(EETypePtr.EETypePtrOf<IntPtr>(), ref obj.GetRawData());
775-
}
776772
else
777773
{
778-
obj = RuntimeImports.RhBox(argumentInfo.Type, ref obj.GetRawData());
774+
obj = RuntimeImports.RhBox(
775+
(transform & Transform.FunctionPointer) != 0 ? EETypePtr.EETypePtrOf<IntPtr>() : argumentInfo.Type,
776+
ref obj.GetRawData());
779777
}
780778
}
781779

@@ -806,13 +804,11 @@ private unsafe void CopyBackToSpan(Span<object?> src, Span<object?> dest)
806804
Debug.Assert(type.IsPointer);
807805
obj = Pointer.Box((void*)Unsafe.As<byte, IntPtr>(ref obj.GetRawData()), type);
808806
}
809-
if ((transform & Transform.FunctionPointer) != 0)
810-
{
811-
obj = RuntimeImports.RhBox(EETypePtr.EETypePtrOf<IntPtr>(), ref obj.GetRawData());
812-
}
813807
else
814808
{
815-
obj = RuntimeImports.RhBox(argumentInfo.Type, ref obj.GetRawData());
809+
obj = RuntimeImports.RhBox(
810+
(transform & Transform.FunctionPointer) != 0 ? EETypePtr.EETypePtrOf<IntPtr>() : argumentInfo.Type,
811+
ref obj.GetRawData());
816812
}
817813
}
818814

0 commit comments

Comments
 (0)