From 0c0182542a93fed8ae5ddcdb6865c5fd1b56dafc Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 12 Nov 2026 07:45:36 -0800 Subject: [PATCH] Prevent orphaned XML documentation includes Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../CSharp/CSharpOutputBuilder.VisitDecl.cs | 5 ++- .../DocIncludeGuardTest.cs | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/DocIncludeGuardTest.cs diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs index 7aa89682..c037e38b 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs @@ -32,7 +32,10 @@ public void EndUnchecked() public void BeginValue(in ValueDesc desc) { - if (_generator.Config.GenerateDocIncludes && !string.IsNullOrWhiteSpace(desc.ParentName)) + if (_generator.Config.GenerateDocIncludes + && desc.Kind != ValueKind.Unknown + && !string.IsNullOrEmpty(desc.ParentName) + && !string.IsNullOrEmpty(desc.EscapedName)) { WriteIndented("///