Skip to content

Commit 7a7785f

Browse files
committed
Allow the destructor to be remapped so it doesn't force conflict with a method named Dispose
1 parent fd868d6 commit 7a7785f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,9 +2805,11 @@ private string GetCursorName(NamedDecl namedDecl)
28052805
Debug.Assert(parent is not null);
28062806
name = GetCursorName(parent);
28072807
}
2808-
else if (namedDecl is CXXDestructorDecl)
2808+
else if (namedDecl is CXXDestructorDecl cxxDestructorDecl)
28092809
{
2810-
name = "Dispose";
2810+
var parent = cxxDestructorDecl.Parent;
2811+
Debug.Assert(parent is not null);
2812+
name = $"~{GetCursorName(parent)}";
28112813
}
28122814
else if (string.IsNullOrWhiteSpace(name) || name.StartsWith('('))
28132815
{
@@ -3160,6 +3162,10 @@ private string GetRemappedCursorName(NamedDecl namedDecl, out string nativeTypeN
31603162
Debug.Assert(parent is not null);
31613163
remappedName = GetRemappedCursorName(parent);
31623164
}
3165+
else if (namedDecl is CXXDestructorDecl)
3166+
{
3167+
remappedName = "Dispose";
3168+
}
31633169
else if (namedDecl is FieldDecl fieldDecl)
31643170
{
31653171
if (name.StartsWith("__AnonymousFieldDecl_", StringComparison.Ordinal))

0 commit comments

Comments
 (0)