Skip to content
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

[Linux] Incorrect bindings generated for virtual methods overridden in C++ #1814

Open
JordanL8 opened this issue Dec 18, 2023 · 0 comments
Open
Assignees
Labels

Comments

@JordanL8
Copy link

JordanL8 commented Dec 18, 2023

Apparent incorrect bindings generated for virtual method overridden in C++ and then called from C#. Works correctly in Windows.

  • Methods implemented in the base class are callable from C#.
  • Methods declared in the base class then implemented in the intermediary class in C++ are not callable from C# (no errors, just nothing happens)

repro drawio (1)

OS: Linux (Ubuntu 22.04.3 LTS)

Repro

C++
// .h
class IBaseClass
{
public:
	virtual void BaseMethod();
	virtual void CPPImplementedVirtualMethod() = 0;
	virtual void CSharpImplementVirtualMethod() = 0;
};

class IIntermediaryClass : public IBaseClass
{
	virtual void CPPImplementedVirtualMethod() override;
};
// .cpp
void IBaseClass::BaseMethod()
{
    // ... log that displays "Base Method"
}

void IIntermediaryClass::CPPImplementedVirtualMethod()
{
    // ... log that displays "Intermediary Method"
}
C#
class CSharpClass : IIntermediaryClass
{
    public override void CSharpImplementVirtualMethod()
    {
        Console.WriteLine("C# Method");
    }
}
CSharpClass @class = new CSharpClass();
@class.BaseMethod();
@class.CPPImplementedVirtualMethod();
@class.CSharpImplementVirtualMethod();

When generating bindings for Windows and running the above code, the following is logged:

  • Base Method
  • Intermediary Method
  • C# Method

When generating bindings for Linux and running the above code, the following is logged:

  • Base Method
  • C# Method
@tritao tritao added the bug label Jan 2, 2024
@tritao tritao self-assigned this Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants