Skip to content

Commit

Permalink
Check for null destructor in PInvokeGenerator.VisitDecl.cs
Browse files Browse the repository at this point in the history
* Add a diagnostic if the destructor property is null despite other
  bool properties suggesting the precense of a destructor.
  • Loading branch information
ceresgalax committed Feb 5, 2024
1 parent df0ab63 commit d8ab030
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ private void VisitFunctionDecl(FunctionDecl functionDecl)
{
outputBuilder.Write("Base");
}

outputBuilder.Write('.');
outputBuilder.Write(name);
outputBuilder.Write('(');
Expand Down Expand Up @@ -1817,7 +1817,11 @@ private void VisitRecordDecl(RecordDecl recordDecl)
{
var cxxDestructorDecl = cxxRecordDecl.Destructor;

if (!cxxDestructorDecl.IsVirtual && !IsExcluded(cxxDestructorDecl))
if (cxxDestructorDecl == null)
{
AddDiagnostic(DiagnosticLevel.Warning, "Record has user declared destructor, but Destructor property was null. Generated bindings may be incomplete.", cxxRecordDecl);
}
else if (!cxxDestructorDecl.IsVirtual && !IsExcluded(cxxDestructorDecl))
{
Visit(cxxDestructorDecl);
_outputBuilder.WriteDivider();
Expand Down

0 comments on commit d8ab030

Please sign in to comment.