diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs index d3b9bb84..87ef11c1 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs @@ -2805,9 +2805,11 @@ private string GetCursorName(NamedDecl namedDecl) Debug.Assert(parent is not null); name = GetCursorName(parent); } - else if (namedDecl is CXXDestructorDecl) + else if (namedDecl is CXXDestructorDecl cxxDestructorDecl) { - name = "Dispose"; + var parent = cxxDestructorDecl.Parent; + Debug.Assert(parent is not null); + name = $"~{GetCursorName(parent)}"; } else if (string.IsNullOrWhiteSpace(name) || name.StartsWith('(')) { @@ -3160,6 +3162,10 @@ private string GetRemappedCursorName(NamedDecl namedDecl, out string nativeTypeN Debug.Assert(parent is not null); remappedName = GetRemappedCursorName(parent); } + else if (namedDecl is CXXDestructorDecl) + { + remappedName = "Dispose"; + } else if (namedDecl is FieldDecl fieldDecl) { if (name.StartsWith("__AnonymousFieldDecl_", StringComparison.Ordinal))