When using nested types as method parameters, the type is not fully declared leading to syntax errors in the C# code. A reproduction is as follows:
struct A
{
struct Inner {};
};
struct B
{
virtual void Method(A::Inner& inner);
};
USER@PC MINGW64 /c/Develop/prv/
$ ClangSharpPInvokeGenerator.exe --file bug/bug.h --output bug/output -n Bug
Processing 'bug/bug.h'
USER@PC MINGW64 /c/Develop/prv/
$ ClangSharpPInvokeGenerator --version
ClangSharp P/Invoke Binding Generator version 18.1.3
clang version 18.1.3 (https://github.com/llvm/llvm-project c13b7485b87909fcf739f62cfa382b55407433c0)
clangsharp version 18.1.3
leads to
namespace Bug
{
public partial struct A
{
public partial struct Inner
{
}
}
public unsafe partial struct B
{
public void** lpVtbl;
public void Method([NativeTypeName("A::Inner &")] Inner* inner)
{
((delegate* unmanaged[Thiscall]<B*, Inner*, void>)(lpVtbl[0]))((B*)Unsafe.AsPointer(ref this), inner);
}
}
}
where Method should be declared as public void Method([NativeTypeName("A::Inner &")] A.Inner* inner).
A possible workaround is to use --remap A::Inner=AInner and to add an own C# file with the contents global using AInner = Bug.A.AInner;
When using nested types as method parameters, the type is not fully declared leading to syntax errors in the C# code. A reproduction is as follows:
USER@PC MINGW64 /c/Develop/prv/ $ ClangSharpPInvokeGenerator.exe --file bug/bug.h --output bug/output -n Bug Processing 'bug/bug.h' USER@PC MINGW64 /c/Develop/prv/ $ ClangSharpPInvokeGenerator --version ClangSharp P/Invoke Binding Generator version 18.1.3 clang version 18.1.3 (https://github.com/llvm/llvm-project c13b7485b87909fcf739f62cfa382b55407433c0) clangsharp version 18.1.3leads to
where Method should be declared as
public void Method([NativeTypeName("A::Inner &")] A.Inner* inner).A possible workaround is to use
--remap A::Inner=AInnerand to add an own C# file with the contentsglobal using AInner = Bug.A.AInner;