From dd25c48da71a84146e9a954e9e7c5a1eb0befbed Mon Sep 17 00:00:00 2001 From: Peter Shrosbree Date: Sun, 18 Oct 2026 21:59:42 -0700 Subject: [PATCH] Fix null CustomDebugInfos in PdbDocument constructors new PdbDocument() and the six-argument constructor left CustomDebugInfos null; only Initialize(SymbolDocument) assigned it. The Portable PDB writer reads CustomDebugInfos.Count for every document, so writing a PDB that contains such a document threw NullReferenceException, and a caller could not add custom debug info to a new document. Create the list in those two constructors. The partial document that PdbState creates to look up an existing document still allocates no list, and documents read from a PDB still get theirs in Initialize(). --- src/DotNet/Pdb/PdbDocument.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DotNet/Pdb/PdbDocument.cs b/src/DotNet/Pdb/PdbDocument.cs index 6f25bbe8c..c05f974ec 100644 --- a/src/DotNet/Pdb/PdbDocument.cs +++ b/src/DotNet/Pdb/PdbDocument.cs @@ -61,8 +61,7 @@ public sealed class PdbDocument : IHasCustomDebugInformation { /// /// Default constructor /// - public PdbDocument() { - } + public PdbDocument() => customDebugInfos = new List(); /// /// Constructor @@ -110,6 +109,7 @@ public PdbDocument(string url, Guid language, Guid languageVendor, Guid document DocumentType = documentType; CheckSumAlgorithmId = checkSumAlgorithmId; CheckSum = checkSum; + customDebugInfos = new List(); } ///