microsoft / microsoft/microsoft-ui-reactor

Explore collection-initializer API (Option A') as alternative to fluent modifiers

Open
#9 0 comments 0 reactions 1 assignee View on GitHub

@codemonkeychris is already working on this.

Since Apr 17, 2026.

design proposal
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.