Skip to content

Fix #264: enforce init-only contract on immutable records#274

Merged
codemonkeychris merged 1 commit into
mainfrom
fix/264-immutable-record-contract
May 15, 2026
Merged

Fix #264: enforce init-only contract on immutable records#274
codemonkeychris merged 1 commit into
mainfrom
fix/264-immutable-record-contract

Conversation

@sundaramramaswamy
Copy link
Copy Markdown
Collaborator

@sundaramramaswamy sundaramramaswamy commented May 14, 2026

Summary

The source code was already correct — TrayIconSpec, WindowSpec, Command, and Command<T> all use init-only properties. The external API review tool likely rendered init as set because at the IL level init is a set method with modreq(IsExternalInit).

Changes

  1. New test: tests/Reactor.Tests/ImmutableRecordContractTests.cs — reflection-based regression test that verifies all public settable properties on the four record types carry the IsExternalInit modifier (i.e., are truly init-only). Prevents future regressions.

  2. Doc comment updates: Changed "Immutable" to "Immutable (init-only)" in XML summary tags on all four types, making the contract unambiguous even to tools that cannot distinguish init from set.

Test results

All 8 new theory cases pass (4 types × 2 assertions each).

Closes #264.

Add reflection-based regression test verifying TrayIconSpec,
WindowSpec, Command, and Command<T> properties use init (not
set). Update doc comments to say 'init-only' explicitly so
tools that render init as set won't mislead reviewers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codemonkeychris codemonkeychris merged commit d187cf6 into main May 15, 2026
7 checks passed
@codemonkeychris codemonkeychris deleted the fix/264-immutable-record-contract branch May 15, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API consistency: docs call records "immutable" but properties are mutable

2 participants