Skip to content

Using ExtractInterfacePass results in duplicated methods in internal class #1679

Open
@timotheetallon

Description

@timotheetallon
Brief Description

When adding the ExtractInterfacePass in SetupPasses, the interface is correctly generated, but the internal class associated is implemented with duplicated methods. After being renamed by the CheckDuplicatedNamesPass, the code is uncompilable because the renamed method overrides nothing.

OS: Windows / OS X / Linux (include version and/or distro)
Windows 10
Using CppSharp 1.0.1

Used headers
class Callback {
public:
    virtual ~Callback() {}
    virtual void OnAppInitialized() = 0;
    ...
};
Used settings

Target: MSVC/GCC/Clang

Other settings

Stack trace or incompilable generated code

Logs:

Pass 'CppSharp.Passes.CheckDuplicatedNamesPass'
    Duplicate name CallbackInternal::OnAppInitialized, renamed to OnAppInitialized1

Generated code:

public unsafe partial interface ICallback : IDisposable
{
    void OnAppInitialized();
    ...
}
...
public unsafe partial class CallbackInternal : global::Module.Callback, IDisposable
{
    ...
    public override void OnAppInitialized_()
    {
        var ___OnAppInitializedDelegate = __VTables.GetMethodDelegate<global::Module.Delegates.Action___IntPtr>(0, 2);
        ___OnAppInitializedDelegate(__Instance);
    }
    ...
    public override void OnAppInitialized()
    {
        var ___OnAppInitializedDelegate = __VTables.GetMethodDelegate<global::Module.Delegates.Action___IntPtr>(0, -3);
        ___OnAppInitializedDelegate(__Instance);
    }
    ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions