Preserve document custom debug information #981

Open
sbomer wants to merge 1 commit from sbomer/cecil-sourcelink-fix-jbevain into master
sbomer commented 2026-07-24 11:41:42 -05:00 (Migrated from github.com)

Fixes dotnet/runtime#115145.

This ports dotnet/cecil#495 to the upstream repository.

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 -f net8.0 --filter FullyQualifiedName~PortablePdbTests (36 passed)

Note

This content was created with assistance from AI.

Fixes dotnet/runtime#115145. This ports dotnet/cecil#495 to the upstream repository. 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 -f net8.0 --filter FullyQualifiedName~PortablePdbTests` (36 passed) > [!NOTE] > *This content was created with assistance from AI.*
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'sbomer/cecil-sourcelink-fix-jbevain:sbomer/cecil-sourcelink-fix-jbevain'
git switch 'sbomer/cecil-sourcelink-fix-jbevain'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'master'
git merge --no-ff 'sbomer/cecil-sourcelink-fix-jbevain'
git switch 'sbomer/cecil-sourcelink-fix-jbevain'
git rebase 'master'
git switch 'master'
git merge --ff-only 'sbomer/cecil-sourcelink-fix-jbevain'
git switch 'sbomer/cecil-sourcelink-fix-jbevain'
git rebase 'master'
git switch 'master'
git merge --no-ff 'sbomer/cecil-sourcelink-fix-jbevain'
git switch 'master'
git merge --squash 'sbomer/cecil-sourcelink-fix-jbevain'
git switch 'master'
git merge --ff-only 'sbomer/cecil-sourcelink-fix-jbevain'
git switch 'master'
git merge 'sbomer/cecil-sourcelink-fix-jbevain'
git push origin 'master'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-jbevain/cecil!981
No description provided.