diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs index 3af1a765..0d45f9de 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))