System.Reflection.Metadata: preserve pre-linked suffix chain when linking into empty BlobBuilder#127246
Open
System.Reflection.Metadata: preserve pre-linked suffix chain when linking into empty BlobBuilder#127246
Conversation
…e-linked Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/31683964-9cee-4d89-b561-87c8f1509e4b Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix BlobBuilder.LinkSuffix dropping content when destination is empty
System.Reflection.Metadata: preserve pre-linked suffix chain when linking into empty BlobBuilder
Apr 21, 2026
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-reflection-metadata |
jkoritzinsky
approved these changes
Apr 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes BlobBuilder.LinkSuffix to correctly preserve an incoming suffix’s existing linked-suffix chain when linking into an empty destination builder, ensuring previously-linked content isn’t dropped and byte order/content are retained.
Changes:
- Update
BlobBuilder.LinkSuffixto adopt the suffix chain tail (_nextOrPrevious) when the destination builder is empty. - Add a regression test covering “empty destination + suffix already linked” to verify byte sequence and counts.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobBuilder.cs | Adjusts empty-destination LinkSuffix relinking to preserve an already-linked suffix chain. |
| src/libraries/System.Reflection.Metadata/tests/Metadata/BlobTests.cs | Adds regression coverage for linking a pre-linked suffix into an empty destination. |
This was referenced Apr 22, 2026
Open
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.
BlobBuilder.LinkSuffixcould drop already-linked content when the destination builder was empty and the incoming suffix had its own linked suffix chain. This change preserves the full chain so byte order and total content are retained (11-22, not22-00).Behavior fix (
BlobBuilder.LinkSuffix)_nextOrPrevious) instead of leaving chain links in a state that loses prior suffix content.Regression coverage (
BlobTests)LinkSuffix_EmptyDestination_SuffixAlreadyLinked.elementcontains0x11tailcontains0x22element.LinkSuffix(tail)emptyPrefix.LinkSuffix(element){ 0x11, 0x22 }and counts remain consistent across builders.