Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bbc7b5f
Add AOT-first property observation runtime
wieslawsoltes Aug 18, 2026
4c8b27c
Add unit coverage and NativeAOT smoke tests
wieslawsoltes Aug 18, 2026
f66723e
Add MVVM framework integrations and samples
wieslawsoltes Aug 18, 2026
6394371
Add ReactiveUI performance benchmark matrix
wieslawsoltes Aug 18, 2026
2e96fd5
Add release validation workflow
wieslawsoltes Aug 18, 2026
78d6369
Document architecture and performance
wieslawsoltes Aug 18, 2026
ee4585e
Add generated compatibility runtime through arity 12
wieslawsoltes Aug 18, 2026
ac047b4
Expand compatibility and deployment validation
wieslawsoltes Aug 18, 2026
50dbdc4
Benchmark generated and adapter hot paths
wieslawsoltes Aug 18, 2026
be02a5c
Document compatibility architecture and results
wieslawsoltes Aug 18, 2026
9f9ef5a
Add framework expression samples
wieslawsoltes Aug 18, 2026
eaa595e
Specialize three-segment property paths
wieslawsoltes Aug 18, 2026
351546d
Benchmark specialized nested paths
wieslawsoltes Aug 18, 2026
642e544
Document nested path architecture and results
wieslawsoltes Aug 18, 2026
ea0ffba
Add ReactiveUI string and selector compatibility
wieslawsoltes Aug 18, 2026
46b0133
Expand expression compatibility samples
wieslawsoltes Aug 18, 2026
8c169a2
Benchmark string and single-selector paths
wieslawsoltes Aug 18, 2026
bc65392
Document compatibility architecture and results
wieslawsoltes Aug 18, 2026
8a18e6f
Match ReactiveUI multi-selector semantics
wieslawsoltes Aug 18, 2026
297f61f
Optimize constant indexer expression paths
wieslawsoltes Aug 18, 2026
ebe7b3b
Validate both ReactiveUI 24 distributions
wieslawsoltes Aug 18, 2026
2ea172b
Benchmark constant indexer paths
wieslawsoltes Aug 18, 2026
51993f8
Document indexer architecture and results
wieslawsoltes Aug 18, 2026
9af9789
Normalize generated source assertions
wieslawsoltes Aug 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
verify:
name: Verify (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-2025, macos-15]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.201
- run: dotnet build ProMvvm.slnx -c Release
- run: dotnet test tests/ProMvvm.Tests -c Release --no-build
- run: dotnet test tests/ProMvvm.SourceGenerators.Tests -c Release --no-build
- run: dotnet test tests/ProMvvm.IntegrationTests -c Release --no-build
- run: dotnet test tests/ProMvvm.ReactiveUiCoreIntegrationTests -c Release --no-build
- if: runner.os == 'Linux'
run: >-
dotnet test tests/ProMvvm.Tests -c Release --no-build
--collect:"XPlat Code Coverage"
--results-directory artifacts/coverage
- run: dotnet run --project samples/ProMvvm.Sample.ReactiveUI -c Release --no-build
- run: dotnet run --project samples/ProMvvm.Sample.CommunityToolkit -c Release --no-build
- run: dotnet run --project samples/ProMvvm.Sample.ReactiveUI.Expression -c Release --no-build
- run: dotnet run --project samples/ProMvvm.Sample.CommunityToolkit.Expression -c Release --no-build
- run: dotnet run --project benchmarks/ProMvvm.Benchmarks -c Release --no-build -- --list flat
- if: runner.os == 'Linux'
run: dotnet pack src/ProMvvm -c Release --no-build -o artifacts/packages
- if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: coverage
path: artifacts/coverage

trimmed:
name: Full trim (${{ matrix.rid }})
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
rid: linux-x64
executable: ./artifacts/trim/ProMvvm.AotSmoke
- os: windows-2025
rid: win-x64
executable: ./artifacts/trim/ProMvvm.AotSmoke.exe
- os: macos-15
rid: osx-arm64
executable: ./artifacts/trim/ProMvvm.AotSmoke
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.201
- run: >-
dotnet publish tests/ProMvvm.AotSmoke -c Release
-r ${{ matrix.rid }} --self-contained
-p:PublishAot=false -p:PublishTrimmed=true -p:TrimMode=full
-o artifacts/trim
- run: ${{ matrix.executable }}
shell: bash

native-aot:
name: NativeAOT (${{ matrix.rid }})
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
rid: linux-x64
executable: ./artifacts/aot/ProMvvm.AotSmoke
- os: windows-2025
rid: win-x64
executable: ./artifacts/aot/ProMvvm.AotSmoke.exe
- os: macos-15
rid: osx-arm64
executable: ./artifacts/aot/ProMvvm.AotSmoke
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.201
- run: >-
dotnet publish tests/ProMvvm.AotSmoke -c Release
-r ${{ matrix.rid }} --self-contained
-o artifacts/aot
- run: ${{ matrix.executable }}
shell: bash

native-aot-framework-samples:
name: NativeAOT framework samples
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.201
- run: >-
dotnet publish samples/ProMvvm.Sample.ReactiveUI -c Release
-r osx-arm64 --self-contained -p:PublishAot=true
-o artifacts/aot-reactiveui
- run: ./artifacts/aot-reactiveui/ProMvvm.Sample.ReactiveUI
- run: >-
dotnet publish samples/ProMvvm.Sample.CommunityToolkit -c Release
-r osx-arm64 --self-contained -p:PublishAot=true
-o artifacts/aot-toolkit
- run: ./artifacts/aot-toolkit/ProMvvm.Sample.CommunityToolkit
11 changes: 11 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<PropertyGroup>
<LangVersion>14.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<Deterministic>true</Deterministic>
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>
</Project>
19 changes: 19 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0" />
<PackageVersion Include="ReactiveUI.Reactive" Version="24.0.0" />
<PackageVersion Include="ReactiveUI" Version="24.0.0" />
<PackageVersion Include="ReactiveUI.SourceGenerators" Version="3.2.0" />
<PackageVersion Include="System.Reactive" Version="7.0.0" />
<PackageVersion Include="xunit.v3" Version="3.2.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions ProMvvm.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Solution>
<Folder Name="/src/">
<Project Path="src/ProMvvm/ProMvvm.csproj" />
<Project Path="src/ProMvvm.SourceGenerators/ProMvvm.SourceGenerators.csproj" />
</Folder>
<Folder Name="/tests/">
<Project Path="tests/ProMvvm.Tests/ProMvvm.Tests.csproj" />
<Project Path="tests/ProMvvm.IntegrationTests/ProMvvm.IntegrationTests.csproj" />
<Project Path="tests/ProMvvm.ReactiveUiCoreIntegrationTests/ProMvvm.ReactiveUiCoreIntegrationTests.csproj" />
<Project Path="tests/ProMvvm.SourceGenerators.Tests/ProMvvm.SourceGenerators.Tests.csproj" />
<Project Path="tests/ProMvvm.AotSmoke/ProMvvm.AotSmoke.csproj" />
</Folder>
<Folder Name="/samples/">
<Project Path="samples/ProMvvm.Sample.ReactiveUI/ProMvvm.Sample.ReactiveUI.csproj" />
<Project Path="samples/ProMvvm.Sample.ReactiveUI.Expression/ProMvvm.Sample.ReactiveUI.Expression.csproj" />
<Project Path="samples/ProMvvm.Sample.CommunityToolkit/ProMvvm.Sample.CommunityToolkit.csproj" />
<Project Path="samples/ProMvvm.Sample.CommunityToolkit.Expression/ProMvvm.Sample.CommunityToolkit.Expression.csproj" />
</Folder>
<Folder Name="/benchmarks/">
<Project Path="benchmarks/ProMvvm.Benchmarks/ProMvvm.Benchmarks.csproj" />
</Folder>
</Solution>
149 changes: 149 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# ProMvvm

ProMvvm is an experimental, .NET 10-first replacement path for ReactiveUI MVVM functionality. The first implemented slice is `WhenAnyValue`: a cold, dependency-free `IObservable<T>` engine for `INotifyPropertyChanged` models, with an AOT-first typed API and a ReactiveUI-compatible expression migration API.

The runtime package has no dependency on ReactiveUI, CommunityToolkit.Mvvm, or System.Reactive. Its BCL `IObservable<T>` results compose directly with System.Reactive 7, while its notification boundary works with both ReactiveUI 24 generated properties and CommunityToolkit.Mvvm generated properties.

See [the architecture guide](docs/ARCHITECTURE.md) for the runtime state machines, typed and expression execution paths, performance decisions, AOT boundary, and a design-level comparison with both ReactiveUI 24 distributions.

## AOT-first API

For one property, pass an ahead-of-time compiled getter and the notification name:

```csharp
using ProMvvm;
using System.Reactive.Linq;

using var subscription = viewModel
.WhenAnyValue(static model => model.SearchText, nameof(viewModel.SearchText))
.Where(static text => !string.IsNullOrWhiteSpace(text))
.Subscribe(Console.WriteLine);
```

Use `PropertyPath` for reusable and nested paths:

```csharp
var city = PropertyPath
.Create<PersonViewModel, Address?>(nameof(PersonViewModel.Address), static x => x.Address)
.Then(nameof(Address.City), static x => x!.City);

using var subscription = viewModel.WhenAnyValue(city).Subscribe(Console.WriteLine);
```

These overloads use only normal delegates and property-change events. They do not reflect, compile expressions, or require dynamic code.
Single-property plus two- and three-segment typed paths use specialized generic sinks that avoid value boxing and the general watcher graph on their steady-state notification paths.

Annotate a model to generate reusable descriptors for every accessible property:

```csharp
[GeneratePropertyPaths]
public partial class SearchViewModel : ObservableObject
{
[ObservableProperty]
private string _searchText = string.Empty;
}

using var subscription = viewModel
.WhenAnyValue(SearchViewModelPropertyPaths.SearchText)
.Subscribe(Console.WriteLine);
```

The generator recognizes ordinary properties, CommunityToolkit.Mvvm `[ObservableProperty]` fields, and ReactiveUI.SourceGenerators `[Reactive]` fields. The generated call site is terse, reusable, reflection-free, trim-safe, and NativeAOT-safe.

For gradual migration, expression syntax is also available:

```csharp
#pragma warning disable IL2026 // migration compatibility path
using var subscription = viewModel.WhenAnyValue(x => x.Address!.City)
.Subscribe(Console.WriteLine);
#pragma warning restore IL2026
```

Expression overloads are intentionally marked `RequiresUnreferencedCode`. Exact single-property expressions cache their resolved metadata and use a bound getter with the same specialized sink as typed paths, so steady-state notifications do not reflect. Other compatible expression shapes use the general reflected path engine. Use typed paths in trimming or NativeAOT applications.

The migration parser also supports ReactiveUI-compatible constant indexers, including nested paths. `x => x.Items[0]` listens for `Item[]` (or the type's custom `IndexerName`) and rewires like an ordinary property chain. Captured/nonconstant indices and array-element expressions retain ReactiveUI 24's rejection behavior; array `Length` is supported.

ReactiveUI-compatible direct property-name and single-property selector overloads are available for migration code as well. Property-name metadata is cached, and direct selectors use a fused subscription rather than allocating a second observable pipeline:

```csharp
#pragma warning disable IL2026
using var subscription = viewModel.WhenAnyValue<SearchViewModel, int, string>(
x => x.SearchText,
static text => text.Length).Subscribe(Console.WriteLine);

using var byName = viewModel.WhenAnyValue<SearchViewModel, string>(nameof(SearchViewModel.SearchText))
.Subscribe(Console.WriteLine);
#pragma warning restore IL2026
```

## Current semantics

- Emits the current value synchronously for each subscription.
- Produces a cold observable with independent subscriptions.
- Observes nested `INotifyPropertyChanged` chains and rewires when an intermediate object changes.
- Suppresses output while an intermediate object is `null`; a `null` final value remains valid.
- Applies final-value distinctness by default for single and typed paths, including across temporarily invalid nested chains; multi expression/string selectors preserve ReactiveUI's input-only distinctness unless an expression result comparer is supplied.
- Supports custom equality comparers and disabling distinctness.
- Supports a ReactiveUI-compatible single-property selector plus typed, expression, and string-name selector overloads through arity 12.
- Supports typed, expression, and string-name tuple overloads from arity 2 through arity 12.
- Supports constant-argument expression indexers, custom indexer notification names, nested rewiring, and ReactiveUI-compatible array-length/error behavior.
- Accepts explicit notification adapters for custom events or `IObservable<string?>` change streams, including mixed object chains, without global registration.
- Serializes model event handling and observer notification per subscription.
- Detaches all handlers on disposal or terminal getter/selector error.

## Compatibility samples

- [ReactiveUI 24 typed sample](samples/ProMvvm.Sample.ReactiveUI) uses generated ProMvvm descriptors with `ReactiveUI.Reactive` 24.0.0 and `ReactiveUI.SourceGenerators` 3.2.0.
- [CommunityToolkit.Mvvm typed sample](samples/ProMvvm.Sample.CommunityToolkit) uses generated ProMvvm descriptors with `[ObservableProperty]` properties.
- [ReactiveUI 24 expression sample](samples/ProMvvm.Sample.ReactiveUI.Expression) demonstrates direct, nested, fused single-selector, arity-2/3 selector, and tuple expression observations.
- [CommunityToolkit.Mvvm expression sample](samples/ProMvvm.Sample.CommunityToolkit.Expression) demonstrates the same expression migration surface on Toolkit-generated properties.

The typed samples are the trim-safe and NativeAOT-safe examples. The expression samples intentionally target ordinary JIT applications and keep the `RequiresUnreferencedCode` boundary visible at their call sites.

Run them with:

```bash
dotnet run --project samples/ProMvvm.Sample.ReactiveUI -c Release
dotnet run --project samples/ProMvvm.Sample.CommunityToolkit -c Release
dotnet run --project samples/ProMvvm.Sample.ReactiveUI.Expression -c Release
dotnet run --project samples/ProMvvm.Sample.CommunityToolkit.Expression -c Release
```

## Verification

```bash
dotnet build ProMvvm.slnx -c Release
dotnet test tests/ProMvvm.Tests -c Release
dotnet test tests/ProMvvm.SourceGenerators.Tests -c Release
dotnet test tests/ProMvvm.IntegrationTests -c Release
dotnet test tests/ProMvvm.ReactiveUiCoreIntegrationTests -c Release

dotnet publish tests/ProMvvm.AotSmoke -c Release -r osx-arm64 --self-contained
./tests/ProMvvm.AotSmoke/bin/Release/net10.0/osx-arm64/publish/ProMvvm.AotSmoke
```

Release unit tests enforce 100% line coverage, at least 98% branch coverage, and 100% method coverage. Dedicated generator tests validate emitted descriptors and overloads; integration tests compile and execute both source-generator ecosystems.
CI builds and tests on Linux, Windows, and macOS, and full-trim and NativeAOT smoke executables run on all three platforms. Both framework samples are also NativeAOT-published and executed.

## Benchmarks

The BenchmarkDotNet suite compares typed, expression, and direct string-name ProMvvm paths with both ReactiveUI 24 distributions under the same notification models:

1. ProMvvm typed/AOT paths.
2. ProMvvm expression compatibility paths.
3. ReactiveUI 24 core expression paths.
4. ReactiveUI.Reactive 24 expression paths.

It covers cold construction, warmed end-to-end hot start, generated-descriptor hot start, direct and projected string-name calls, fused single selectors, subscribe + initial emission + disposal, leaf emission, burst throughput (1, 100, and 10,000 changes), two- and three-segment hot start, nested leaf emission and rewiring, constant-indexer hot start/emission/rewiring, arity-2 and arity-12 projection, explicit-adapter overhead, and allocation for every case.

```bash
dotnet run --project benchmarks/ProMvvm.Benchmarks -c Release -- --filter '*'
```

See [benchmarks/README.md](benchmarks/README.md) for focused commands and measurement rules.

## Status and next parity work

The current compatibility milestone includes a fused arity-1 selector, generated arity-2-through-12 expression/string APIs and specialized sinks, cached direct string-name observation, generated property descriptors, explicit notification adapters, two- and three-segment specialization, inherited-property and constant-indexer expression fast paths, concurrent stress coverage, and cross-platform trim/NativeAOT matrices. It remains a focused `WhenAnyValue` implementation rather than a complete ReactiveUI replacement; binding, commands, activation, routing, before-change observation, arbitrary dynamic paths, and nonconstant index expressions remain outside the current slice.

The compatibility namespace is `ProMvvm`, so both libraries may be referenced during gradual migration. The explicit getter + property-name overload also avoids extension ambiguity when `ReactiveUI.Reactive` is imported.
7 changes: 7 additions & 0 deletions benchmarks/ProMvvm.Benchmarks/BenchmarkConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using BenchmarkDotNet.Attributes;

namespace ProMvvm.Benchmarks;

[MemoryDiagnoser]
[HideColumns("Error", "StdDev", "Median")]
public abstract class BenchmarkConfig;
Loading
Loading