Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the destructor to be remapped so it doesn't force conflict with a method named Dispose #588

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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('('))
{
Expand Down Expand Up @@ -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))
Expand Down
Loading