Preserve document custom debug information#495
Merged
Conversation
Load custom debug information for every preserved portable PDB document so embedded sources survive a round trip. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 01ec6ff9-132e-45df-95c2-9cedbce405cb Assisted-by: GitHub Copilot CLI:GPT-5.6-Sol [code-review]
Read missing document custom debug information only when producing a portable PDB, and verify embedded sources survive after their sequence points are trimmed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 01ec6ff9-132e-45df-95c2-9cedbce405cb Assisted-by: GitHub Copilot CLI:GPT-5.6-Sol [code-review]
akoeplinger
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes dotnet/runtime#115145.
Portable PDB documents are preserved even when they are no longer referenced by sequence points, but their custom debug information was only loaded when resolving a referenced document. Consequently, documents left unreferenced after trimming could be written without records such as
EmbeddedSource.Before writing the complete document collection, load custom debug information for documents that have not already been resolved. This keeps read-only PDB usage lazy while ensuring all document records are preserved during a rewrite. Embedded-source content remains lazy and is copied from its original raw blob when written.
The regression test removes the entry point and types containing a document’s sequence points without first accessing their debug information, writes the module, and verifies the output PDB still contains that document’s embedded source.
Testing
dotnet test Test/Mono.Cecil.Tests.csproj --filter FullyQualifiedName~PortablePdbTests(36 passed)dotnet test Test/Mono.Cecil.Tests.csproj(355 passed, 3 skipped)Note
This content was created with assistance from AI.