Skip to content

System.Reflection.Metadata: BlobBuilder.LinkSuffix loses pre-linked content when destination is empty #127243

Closed

Description

@jkoritzinsky

Note

This issue body was drafted with assistance from GitHub Copilot.

Description

BlobBuilder.LinkSuffix appears to drop previously linked content when the destination builder is empty and the suffix builder already has a linked suffix.

Minimal repro

using System;
using System.Reflection.Metadata;

static string Hex(byte[] bytes) => BitConverter.ToString(bytes);

var emptyPrefix = new BlobBuilder(16);
var element = new BlobBuilder(16);
var tail = new BlobBuilder(16);

element.WriteByte(0x11);
tail.WriteByte(0x22);

// Pre-link element + tail
element.LinkSuffix(tail);

// Then link into empty destination
emptyPrefix.LinkSuffix(element);

Console.WriteLine(Hex(emptyPrefix.ToArray()));

Actual behavior

Output:

22-00

Expected behavior

Output should preserve both bytes in order:

11-22

Notes

A control case with a non-empty destination (prefix.WriteByte(0xAA) before linking) behaves as expected. The issue reproduces specifically when the destination BlobBuilder is empty.

Observed in local repro project targeting net11.0 in this repository.

Activity

  1. added
    untriaged
    on Apr 21, 2026
  2. dotnet-policy-service commented on Apr 21, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-reflection-metadata
    See info in area-owners.md if you want to be subscribed.

  3. removed
    untriaged
    on Apr 24, 2026
  4. locked and limited conversation to collaborators on May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions