From 88aa8ab824ffab393fb7fad768e62a93af76241f Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Wed, 30 Jun 2021 19:23:38 -0700 Subject: [PATCH] Ensure the translation unit is kept alive --- sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs index 8d2ab126..1e8f4e4b 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs @@ -320,6 +320,8 @@ public void GenerateBindings(TranslationUnit translationUnit, string filePath, s var diagnostic = new Diagnostic(DiagnosticLevel.Error, e.ToString()); _diagnostics.Add(diagnostic); } + + GC.KeepAlive(translationUnit); } private void AddDiagnostic(DiagnosticLevel level, string message)