From 7a7785f35af23c87046a859c804d01e6380a65d5 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 19 Dec 2024 07:20:12 -0800 Subject: [PATCH] Allow the destructor to be remapped so it doesn't force conflict with a method named Dispose --- .../ClangSharp.PInvokeGenerator/PInvokeGenerator.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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))