microsoft / microsoft/microsoft-ui-reactor
Explore collection-initializer API (Option A') as alternative to fluent modifiers
@codemonkeychris is already working on this.
Since Apr 17, 2026.
- Dominant language
- C#
- Stars
- 646
- Forks
- 54
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 84
Description
Spec: [docs/spec/019-collection-initializer-api-exploration.md](https://github.com/microsoft/microsoft-ui-reactor/blob/main/docs/spec/019-collection-initializer-api-exploration.md)
Today's fluent API mixes three syntaxes — `.Method()` chains, `with { }` for record props, and `.Set(x => ...)` as an escape hatch. Spec 019 explores **Option A'**: `new` + object initializers + C# 12 collection expressions (`Children = [..]`). Same result, properties grouped, no `.Set()` escape hatch, spread works natively for dynamic children.
### Example — TodoApp header
**Today (fluent):**
```csharp
Text("todos").FontSize(36)
.Set(t => t.FontWeight = FontWeights.Light)
.Foreground(AccentText)
.HAlign(HorizontalAlignment.Center)
.Margin(0, 16, 0, 8)
```
**Option A' (`new` + initializer):**
```csharp
new Text("todos") {
FontSize = 36,
Weight = FontWeights.Light,
Foreground = AccentText,
HAlign = HorizontalAlignment.Center,
Margin = Thick(0, 16, 0, 8),
}
```
The `FontWeight` no longer needs `.Set()`, all properties sit in one `{ }` block, and dynamic child lists become `Children = [..items.Select(Render)]` instead of `.ToArray()` into `params`.
See the spec for the full analysis across TodoApp, Outlook MessageRow, charts, and the comparison matrix vs. Options A/B/C/E.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.