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

Skip to content

Commit 96d2bf0

Browse files
Use IsCopyConstructed modreq consistently in test (dotnet#40168)
- X86 calling convention for copy constructed arguments is special, therefore the delegate must have the IsCopyConstructed modreq as well as the callsite
1 parent 0f36487 commit 96d2bf0

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/tests/Interop/PInvoke/Miscellaneous/CopyCtor/CopyCtorTest.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ public static unsafe int StructWithCtorTest(StructWithCtor* ptrStruct, ref Struc
2626
return 100;
2727
}
2828

29-
[UnmanagedFunctionPointerAttribute(CallingConvention.StdCall)]
30-
public delegate int TestDelegate(StructWithCtor* ptrStruct, ref StructWithCtor refStruct);
31-
3229
public static unsafe int Main()
3330
{
34-
TestDelegate del = (TestDelegate)StructWithCtorTest;
31+
TestDelegate del = (TestDelegate)Delegate.CreateDelegate(typeof(TestDelegate), typeof(CopyCtor).GetMethod("StructWithCtorTest"));
3532
StructWithCtor s1 = new StructWithCtor();
3633
StructWithCtor s2 = new StructWithCtor();
3734
s1._instanceField = 1;

src/tests/Interop/PInvoke/Miscellaneous/CopyCtor/CopyCtorUtil.il

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,39 @@
55
.assembly extern System.Runtime.CompilerServices.VisualC { }
66
.assembly CopyCtorUtil { }
77

8+
.class auto ansi sealed public TestDelegate
9+
extends [mscorlib]System.MulticastDelegate
10+
{
11+
.custom instance void [mscorlib]System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute::.ctor(valuetype [mscorlib]System.Runtime.InteropServices.CallingConvention) = ( 01 00 03 00 00 00 00 00 )
12+
.method public hidebysig specialname rtspecialname
13+
instance void .ctor(object 'object',
14+
native int 'method') runtime managed
15+
{
16+
} // end of method TestDelegate::.ctor
17+
18+
.method public hidebysig newslot virtual
19+
instance int32 Invoke(valuetype [CopyCtorUtil]StructWithCtor modreq([mscorlib]System.Runtime.CompilerServices.IsCopyConstructed)* ptrStruct,
20+
valuetype [CopyCtorUtil]StructWithCtor modreq([mscorlib]System.Runtime.CompilerServices.IsCopyConstructed)& refStruct) runtime managed
21+
{
22+
} // end of method TestDelegate::Invoke
23+
24+
.method public hidebysig newslot virtual
25+
instance class [mscorlib]System.IAsyncResult
26+
BeginInvoke(valuetype [CopyCtorUtil]StructWithCtor modreq([mscorlib]System.Runtime.CompilerServices.IsCopyConstructed)* ptrStruct,
27+
valuetype [CopyCtorUtil]StructWithCtor modreq([mscorlib]System.Runtime.CompilerServices.IsCopyConstructed)& refStruct,
28+
class [mscorlib]System.AsyncCallback callback,
29+
object 'object') runtime managed
30+
{
31+
} // end of method TestDelegate::BeginInvoke
32+
33+
.method public hidebysig newslot virtual
34+
instance int32 EndInvoke(valuetype [CopyCtorUtil]StructWithCtor modreq([mscorlib]System.Runtime.CompilerServices.IsCopyConstructed)& refStruct,
35+
class [mscorlib]System.IAsyncResult result) runtime managed
36+
{
37+
} // end of method TestDelegate::EndInvoke
38+
39+
} // end of class TestDelegate
40+
841
.class public sealed sequential ansi beforefieldinit StructWithCtor
942
extends [mscorlib]System.ValueType
1043
{

0 commit comments

Comments
 (0)