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)