-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected results returning struct with floats in RCW #10901
Comments
cc @luqunl |
It will work on some platforms, but not others, depending on calling convention details. |
Thanks. @davidwrighton mentioned that to me too- I should have called that out lest anyone think this is a good workaround. :) |
Here is what I see with
|
@AaronRobinsonMSFT , are you working on this? if not, I can try to fix this bug. |
If you need anything else from me, let me know. I'm finding this particular pattern all over the DirectX APIs (struct return). |
We have this worked around in SharpGenTools (as @JeremyKuhne noticed, this pattern is common in DirectX). See the following code: As I read the documentation referenced in the PR I notice that our condition for |
Submitted PR to link the workaround to this issue: SharpGenTools/SharpGenTools#82 |
@jkoritzinsky Do we have any additional thoughts on this work for Core 3.0? |
Luqun's solution looked like it would work from a cursory glance, so I'm going to try it out and see what I get with it. |
In trying to wrap
ID2D1RenderTarget::GetSize
which returns [D2D_SIZE_F
] the expected way it would corrupt the stack.Flipping it to an out parameter made it work, but I'm unclear as to why. Discussing with @davidwrighton, there might be a bug here. I was unable to create the same scenario via straight
[DllImport]
s against a sample project. I'll see if I can get a smaller repro together.In
d2d1.h
it is defined as:STDMETHOD_(D2D1_SIZE_F, GetSize)( ) CONST PURE;
Which expands to:
The struct is:
I wrapped this here (
SizeF
is from System.Drawing):In the WInterop project I have a test
Direct2dTests.RenderTarget.GetSize()
that exercises it. One can also look at this by tweaking the Direct2dDemo project (i.e. call the method) which runs on .NET Core and sets up a render target that you can use.As stated, I'll try and get a smaller COM repro together for this.
The text was updated successfully, but these errors were encountered: