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
Ref/out value type method params not working correctly #1820
Comments
Looked more into this and it looks like the following constructor:
Which is called from
Is causing my issue. The struct instance isn't set to the same address as the passed in native pointer. Unsure how to handle this because this seems like the correct behavior for a value type. Possibly an override for __CreateInstance that uses the native pointer, specifically used for ref/out value type params? |
Can you post |
Sure, here's the struct in C++:
I've stripped out all the imported methods from the __Internal struct and removed the passthrough methods for the following generated class to make it more readable. It doesn't inherit from anything and has none of the vtable stuff/the imported methods were just called directly. Generated Class
|
Yep, still looks to be an issue. This is specifically for a virtual method with an out param. So implemented in C# and called from C++ via the delegate, it seems a copy is still made in the create instance call in the delegate hook. |
For reference, to resolve
Which produces the following instead of the direct member ref return
|
Brief Description
I have an abstract method in C++ that is implemented in C# and called from C++ at runtime. Some parameters are passed by reference and the caller in C++ expects the implementer to modify these param values. It works correctly when the params are either marshaled as classes or are primitives. If one of the params is marshaled as a struct and configured in CppSharp to be passed by
ref
(parameterUsage
set toInOut
), the value in the implemented method isn't correctly passed out to C++.The text was updated successfully, but these errors were encountered: