## Executive Summary

At .NET Conf 2026, Alex from the Windows team presented **Microsoft.UI.Reactor**, an experimental open-source framework (MIT) that brings the **Model-View-Update (MVU)** functional reactive paradigm directly to native Windows development in **pure, idiomatic C#**. 

For decades, Windows desktop development has relied heavily on declarative XAML markup paired with code-behind and MVVM (`INotifyPropertyChanged`, commands, two-way data bindings). **UI Reactor** completely removes the need for XAML files, `.xaml.cs` code-behind, and view models. Entire native Windows applications can now be written as a **single C# file** and executed directly via `dotnet run`.

Crucially, **Reactor is not a new UI platform, not a new renderer, and not a fork of WinUI**. When developers declare a button, title bar, or grid in Reactor, it creates and reconciles **real WinUI 3 controls** backed by GPU acceleration, native Mica/Acrylic material backdrops, system dark/light mode syncing, and full Windows Narrator accessibility. 

The session demonstrated Reactor's reactive architecture (`UseState` and `UseReducer`), numbered state slot reconciliation, compile-time Roslyn analyzers enforcing the "Rules of Hooks", bi-directional interoperability with existing XAML and WinForms apps, state-preserving Hot Reload (`winapp run --watch`), and structured CLI DevTools (`winapp devtools inspect`) designed for autonomous AI coding agents.

---

## 1. What is UI Reactor? The Three Pillars

![Title: No XAML Required: Native Windows Apps in Pure C#](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/01_title_no_xaml_pure_csharp.webp)

![What is Reactor? MVU Pillars](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/02_what_is_reactor_mvu_pillars.webp)

Microsoft.UI.Reactor is defined by three core principles:
1. **Model-View-Update (MVU):** The user interface is a pure function of state: `UI = f(State)`. Developers familiar with React, SwiftUI, or Jetpack Compose will immediately recognize this functional reactive architecture. It provides an alternative to MVVM with different trade-offs on the same platform.
2. **Real Native WinUI 3 Underneath:** There is no intermediate canvas or custom graphics renderer. Calling `Button()` in Reactor instantiates an authentic `Microsoft.UI.Xaml.Controls.Button`. The application inherits full system accessibility, native touch/mouse/pen input, and DirectX hardware composition.
3. **Open-Source Experimentation:** Built openly on GitHub under the MIT license, Reactor serves as an incubation playground for new desktop patterns and controls that can eventually graduate into official WinUI releases.

```mermaid
flowchart TD
    subgraph ReactiveCode["Declarative C# Application"]
        State["State (UseState / UseReducer)"]
        Render["Render() Method (Pure C# Description)"]
        Action["User Dispatches Action"]
    end

    subgraph ReactorCore["Microsoft.UI.Reactor Engine"]
        Slots["Numbered Slots (Call-order State Tracking)"]
        Reconciler["Keyed Diff Reconciler (Minimal Mutation Path)"]
        Analyzers["62+ Roslyn Compile-Time Analyzers"]
    end

    subgraph NativeWinUI["Native Windows Platform"]
        WinUIControls["Real WinUI 3 Controls (Buttons, Grids, Mica)"]
        Accessibility["Windows Accessibility & Narrator"]
        DirectX["DirectX Hardware Composition"]
    end

    State --> Render
    Render --> Reconciler
    Reconciler -->|"Patches Only Diffs"| WinUIControls
    WinUIControls --> Action
    Action --> Slots
    Slots --> State
    WinUIControls --> Accessibility
    WinUIControls --> DirectX
```

---

## 2. The Single-File C# Native Desktop Application

![Single-File C# Application](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/03_single_file_csharp_app.webp)

Using .NET file-based application directives, a complete native Windows desktop application can be stored in a single `.cs` file without a `.csproj` or XAML file:

```csharp
// counter.cs
#:package Microsoft.UI.Reactor@preview
#:property UseWinUI=true

using Microsoft.UI.Reactor;

ReactorApp.Run<CounterApp>();

public class CounterApp : Component
{
    public override VisualNode Render()
    {
        var (count, setCount) = UseState(0);

        return Window(
            TitleBar("Pure C# WinUI Counter"),
            Column(
                Heading($"Count: {count}"),
                Row(
                    Button("-").OnClick(() => setCount(count - 1)),
                    Button("+").Accent().OnClick(() => setCount(count + 1))
                )
            ).Mica()
        );
    }
}
```

Running `dotnet run counter.cs` compiles and launches an authentic, packaged WinUI 3 window with full Mica backdrop styling and accent buttons:

![Running Pure C# Counter App](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/04_running_pure_csharp_counter.webp)

---

## 3. Project Scaffolding & the Reactor Gallery

![WinApp New Reactor Templates](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/05_winapp_new_reactor_templates.webp)

For multi-file production applications, the **WinApp CLI** (`winget install winapp`) provides five experimental Reactor project templates:
```bash
# Interactive project generator with Reactor templates
winapp new
```

Templates include Blank App, Navigation View App, Class Library, Unit Test App, and complete Application Shells.

![Reactor WinUI Gallery](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/06_reactor_winui_gallery.webp)

The team published the **Reactor WinUI Gallery** featuring over 93 live pages showcasing controls, docking panes, media players, and a native Reactor high-density **DataGrid** with grouping, column sorting, and instant dark/light theme switching.

---

## 4. State Architecture: Numbered Slots & `UseReducer`

![State Management: UseState & Numbered Slots](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/07_state_management_usestate_slots.webp)

### Where Does State Live Without ViewModels?
State is preserved within the component instance across render passes using **numbered slots**:
- `var (count, setCount) = UseState(0);`
- `count` is a simple C# `int` primitive—not an `ObservableProperty` or `INotifyPropertyChanged` wrapper.
- Invoking `setCount(newVal)` updates slot #0 and schedules a render pass.
- When `Render()` executes, Reactor diffs the new visual tree description against the live WinUI controls and updates **only the specific text property that changed**.

### Scaling State with `UseReducer`

![UseReducer Minesweeper Architecture](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/08_use_reducer_minesweeper_architecture.webp)

For complex screens with interdependent state transitions, Reactor provides `UseReducer`:

```csharp
// State and Action modeled as immutable C# records
public record MinesweeperState(Cell[,] Board, GameStatus Status, int FlagsRemaining);

public abstract record Action;
public record RevealCell(int Row, int Col) : Action;
public record ToggleFlag(int Row, int Col) : Action;
public record ResetGame : Action;

// Pure Reducer Function: (State, Action) => NextState
public static MinesweeperState Reducer(MinesweeperState state, Action action) => action switch
{
    RevealCell(var r, var c) => state.Reveal(r, c),
    ToggleFlag(var r, var c) => state.ToggleFlag(r, c),
    ResetGame => MinesweeperState.NewGame(),
    _ => state
};
```

**Key Benefit:** Because the reducer is a pure C# function completely decoupled from UI dispatchers and Windows controls, the entire game engine and every state transition can be **100% unit tested in headless CLI test runners** without initializing a Window.

---

## 5. The "Rules of Hooks" & Roslyn Analyzers

![Rules of Hooks: Slot Ordering](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/09_rules_of_hooks_slot_ordering.webp)

Because state is mapped to numbered slots by **invocation call order**, developers must adhere to the **Rules of Hooks**:
- **Never call hooks (`UseState`, `UseReducer`, `UseEffect`) conditionally.**
- Do not place hooks inside `if` statements, inside `for`/`foreach` loops, or after early `return` statements.
- **Rule:** Always execute the hook unconditionally and branch on the resulting values.

![62+ Roslyn Analyzers for Reactor](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/11_roslyn_analyzers_live_squiggles.webp)

To prevent runtime slot mismatches, Reactor ships with **62+ Roslyn Analyzers** providing instant red squiggles as developers type:
- Flags hooks called inside loops or conditionals.
- Warns when collections are mapped without a stable `.WithKey()`.
- Detects hardcoded colors that fail contrast checks in dark mode.
- Warns on icon-only buttons missing screen-reader accessibility labels.
- Detects background thread UI mutations before they trigger marshaling crashes.
- Includes a *"Did you mean?"* fixer (e.g., catching typos in control names).

---

## 6. Lists, Keys, and Reconciliation Performance

![Lists, Keys & Reconciliation Algorithm](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/10_lists_keys_reconciliation_algorithm.webp)

In a 16x16 Minesweeper grid (256 interactive cells), clicking a blank space can flip 200 cells in a single action. Without keys, reconcilers compare elements strictly by index position, causing full layout churn and lost focus.

By attaching `.WithKey($"{r}_{c}")`, Reactor tracks items by **stable identity**:
- Inserting a new row at index 0 of a 1,000-item list creates **1 control** and moves **0 existing controls**.
- Screen readers receive structured automation names (`$"Row {r}, Column {c}"`).

---

## 7. Bi-Directional Interoperability with XAML & WinForms

![Bi-directional XAML & WinForms Interop](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/12_bidirectional_xaml_winforms_interop.webp)

Reactor is designed for gradual, risk-free adoption without full application rewrites:

### Hosting Reactor inside XAML
```xml
<!-- In existing MainWindow.xaml -->
<Page xmlns:reactor="using:Microsoft.UI.Reactor">
    <Grid>
        <!-- Embeds pure C# Reactor component directly inside XAML layout -->
        <reactor:ReactorHost Component="MyPureCSharpDashboard" />
    </Grid>
</Page>
```

### Hosting XAML inside Reactor
```csharp
// In Reactor Render() method
Window(
    Column(
        Heading("Pure C# Header"),
        // Embed legacy XAML UserControl or 3rd-party control
        XamlHost<LegacyCustomerControl>()
    )
)
```

An interop package is also provided for **Windows Forms**, allowing developers to modernize legacy enterprise desktop apps one panel at a time.

---

## 8. Hot Reload & Agentic DevTools Protocol

![DevTools Hot Reload Watch](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/13_dev_tools_hot_reload_watch.webp)

Running `winapp run --watch` provides live Hot Reload:
- Modifying font scales or layout padding updates the UI in real time while **preserving the active game board state, flagged cells, and timer**.

![Agent Tools: Inspect, Get-State, Set-State](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/14_agent_tools_inspect_get_set_state.webp)

### Agent-Ready Headless CLI Protocol
Reactor exposes its internal component and hook registry to autonomous AI coding agents via `winapp devtools`:
- `winapp devtools inspect`: Outputs the component hierarchy annotated with **exact C# file paths and line numbers**, allowing agents to precisely locate source code.
- `winapp devtools get-state`: Dumps hook names, types, and values (with passwords automatically redacted).
- `winapp devtools set-state`: Allows agents to programmatically inject state for UI testing.

---

## 9. Production Ecosystem & Cross-Platform Reach

![Production Ecosystem: OpenClaw, Uno Platform, and Rust](/dotnetconf2026/archive/29-native-windows-pure-csharp/screenshots/15_ecosystem_openclaw_uno_rust.webp)

Reactor has expanded beyond Microsoft research into production applications:
- **OpenClaw:** The open-source Windows companion app ships Reactor in production for its real-time chat interface.
- **Uno Platform Port:** Experimental Uno port runs identical Reactor C# components across **macOS, Linux, WebAssembly, Android, and iOS** without changing a single line of UI code.
- **Rust Port:** Experimental implementation in the `windows-reactor` repository demonstrating the same MVU architecture in native Rust.

---

## Key Takeaways

| Feature | Microsoft.UI.Reactor Capability |
|---|---|
| **Architecture** | Functional Reactive MVU (`UI = f(State)`); zero XAML, zero INotifyPropertyChanged. |
| **Native Controls** | Emits real WinUI 3 controls; DirectX composition, Mica backdrops, system accessibility. |
| **Single-File Apps** | Full desktop apps in a single `.cs` file runnable with `dotnet run`. |
| **State Primitives** | `UseState` for local slots; `UseReducer` for complex, headlessly unit-testable state machines. |
| **Safety Guardrails** | 62+ Roslyn analyzers catch conditional hooks, missing keys, and dark mode issues at compile time. |
| **List Performance** | Keyed diff reconciler minimizes DOM/visual tree churn on large collection mutations. |
| **Bi-directional Interop** | Host Reactor inside XAML; host XAML/WinForms controls inside Reactor. |
| **Agentic Tooling** | `winapp devtools inspect` returns component trees with exact C# file and line mappings. |
| **Cross-Platform** | Uno Platform port enables execution on macOS, Linux, WebAssembly, iOS, and Android. |
