Skip to content

bug: Repeating section Parse silently truncates at 128 items due to fixed stackalloc buffer #53

@DrBarnabus

Description

@DrBarnabus

Description

The generated Parse and TryParse methods for repeating sections use a fixed-size stack-allocated buffer:

Span<Range> tagsRanges = stackalloc Range[128];

If a key contains more than 128 items in a repeating section, MemoryExtensions.Split will silently truncate the results. This produces an incorrect parse result rather than a clear error.

Reproduction

Visible in the snapshot baseline:
SourceGeneratorSnapshotTests.RepeatingPropertyCompositeKey_SourceOutput#UnitTests.UserTagKey.g.verified.cs (lines ~184-185 for Parse, ~235 for TryParse)

Expected behaviour

The generated code should either:

  • Detect when the buffer is exhausted (i.e. tagsCount == 128) and fall back to a heap allocation or return a clear error
  • Or document the 128-item limit as a known constraint

Discovered via

Snapshot testing added in #48 — this is a pre-existing generator issue, not a regression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions