diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs index ff98d77ee098ce..f354e92fcd9aca 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs @@ -20,7 +20,7 @@ internal static int SizeOfHelper(RuntimeType t, bool throwIfNotMarshalable) { Debug.Assert(throwIfNotMarshalable); - if (t.IsPointer /* or IsFunctionPointer */) + if (t.IsPointer || t.IsFunctionPointer) return IntPtr.Size; if (t.IsByRef || t.IsArray || t.ContainsGenericParameters) diff --git a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SizeOfTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SizeOfTests.cs index 2d0c0b2b93d8a4..538b323a433923 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SizeOfTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/SizeOfTests.cs @@ -31,6 +31,12 @@ public void SizeOf_Object_ReturnsExpected() Assert.NotEqual(0, Marshal.SizeOf(typeof(SomeTestStruct))); } + [Fact] + public unsafe void SizeOf_FunctionPointer_ReturnsExpected() + { + Assert.Equal(IntPtr.Size, Marshal.SizeOf(typeof(delegate*))); + } + [Fact] public void SizeOf_Pointer_ReturnsExpected() {