CppSharp
CppSharp copied to clipboard
Object storage address changes when its passed by value
The only solution I can think of to this problem is generating native wrappers to avoid passing objects by value. This is working right now in some cases because depending on the size of the structure or the platform / architecture, Struct may be passed indirectly by a pointer.
[Test]
public void TestObjectPassByValue1449()
{
using (var s = new Issue1449())
{
Assert.IsTrue(CSharp.CSharp.TestObjectPassByValue(s));
}
Assert.IsTrue(Issue1449.Success);
}
struct DLL_API Issue1449 {
void* constructor_this;
static bool success;
Issue1449();
Issue1449(const Issue1449& c);
~Issue1449();
};
bool Issue1449::success = true;
Issue1449::Issue1449()
{
constructor_this = this;
}
Issue1449::Issue1449(const Issue1449& c)
{
constructor_this = this;
}
Issue1449::~Issue1449() {
if (constructor_this != this)
success = false;
}
bool TestObjectPassByValue(Issue1449 s)
{
return true;
}