Skip to content

Make LengthPrefixedBlock fields readonly#18

Merged
lukaskabrt merged 2 commits intofeature/block-writingfrom
copilot/sub-pr-16-again
Jan 11, 2026
Merged

Make LengthPrefixedBlock fields readonly#18
lukaskabrt merged 2 commits intofeature/block-writingfrom
copilot/sub-pr-16-again

Conversation

Copy link
Contributor

Copilot AI commented Jan 11, 2026

The LengthPrefixedBlock struct had mutable public fields that could be modified after creation, violating immutability best practices for value types used as tokens.

Changes

  • Converted LengthPrefixedBlock to use primary constructor syntax, making fields readonly by default
  • Updated instantiation site to use constructor instead of object initializer

Before

public record struct LengthPrefixedBlock {
    public int LengthPosition;
    public int ContentPosition;
}

// Usage
return new LengthPrefixedBlock {
    LengthPosition = lengthPosition,
    ContentPosition = contentPosition
};

After

public record struct LengthPrefixedBlock(int LengthPosition, int ContentPosition);

// Usage
return new LengthPrefixedBlock(lengthPosition, contentPosition);

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: lukaskabrt <2894161+lukaskabrt@users.noreply.github.com>
Copilot AI changed the title [WIP] Update serialization methods for nested classes in LengthPrefixedBlock Make LengthPrefixedBlock fields readonly Jan 11, 2026
Copilot AI requested a review from lukaskabrt January 11, 2026 10:43
@lukaskabrt lukaskabrt marked this pull request as ready for review January 11, 2026 10:52
@lukaskabrt lukaskabrt merged commit b718550 into feature/block-writing Jan 11, 2026
@lukaskabrt lukaskabrt deleted the copilot/sub-pr-16-again branch January 11, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants