Skip to content

feat!: remove [IViewFor] in favour of ReactiveUI.Binding - #502

Merged
glennawatson merged 1 commit into
mainfrom
feature/remove-iviewfor
Sep 26, 2026
Merged

glennawatson merged 1 commit into
mainfrom
feature/remove-iviewfor

Conversation

@glennawatson

Copy link
Copy Markdown
Contributor

Summary

Removes [IViewFor]. ReactiveUI.Binding now covers linking views to view models, in its own more restricted way: a view implements IViewFor<T> itself, and ReactiveUI.Binding's view locator registers it.

  • [IViewFor<T>] and [IViewFor("...")] are gone, along with the ViewModel property and IViewFor<T> implementation they generated for WPF, WinUI, Uno, WinForms, Avalonia and MAUI views.
  • The WinForms [RoutedControlHost] and [ViewModelControlHost] stay. ReactiveUI.Binding has no equivalent that hosts views on a control base type you choose. They still resolve views through ReactiveUI's view locator, or ReactiveUI.Binding's when the project's ReactiveUI is built on it.
  • The examples and test apps implement IViewFor<T> by hand.
  • The README's "Moved to ReactiveUI.Binding" section covers [IViewFor], shows the hand-written view, and points to RXUIBIND018 for migrating the old [ObservableAsProperty] forms.

Why

ReactiveUI.Binding 7.11.0 (#142) completed the view registration this package handed over to it in #501, so [IViewFor] is the last piece of view plumbing that overlaps with ReactiveUI.Binding. ReactiveUI.Binding does not generate the IViewFor<T> implementation itself. A view writes it, or derives from one of ReactiveUI's view base classes such as ReactiveUserControl<T>. That is the restricted form this PR moves to.

Breaking changes

  • [IViewFor<T>] and [IViewFor("...")] are removed. Add IViewFor<TViewModel> to the view's declaration, with a ViewModel property and the untyped IViewFor.ViewModel. Alternatively, derive from a ReactiveUI view base class such as ReactiveUserControl<T>, ReactiveWindow<T> or ReactiveContentPage<T>. The README shows the hand-written form. A WPF, WinUI or Uno view that needs a bindable ViewModel should declare it as a dependency property, as the generated code did.
  • ReactiveUI.Binding 7.11's registration of views marked only with [IViewFor] no longer applies. It read this package's attributes. Views now register because they implement IViewFor<T> themselves.

How this was verified

The solution, the examples, all five test apps and the benchmarks build with the views written by hand. The existing tests still cover the WinForms hosts, including which view locator they call under each ReactiveUI.

Notes for the reviewer

  • Mechanical and safe to skim: deleting the generator, its snapshots and tests, the benchmark corpus, and two helpers only it used (GetGenericType and InheritsFromFullyQualifiedMetadataNameStartingWith).
  • Worth a look: the hand-written views in src/ReactiveUI.SourceGenerators.Execute and src/TestApps, and the README's "Moved to ReactiveUI.Binding" section.
  • Benchmark figures: the [IViewFor] row and the whole-corpus figures in src/benchmarks/README.md are the PR feat!: leave [ObservableAsProperty] and view registration to ReactiveUI.Binding, and generate through an indentation-aware writer #501 measurements, which included [IViewFor]. The README now says so, and they were not remeasured.

Checklist

  • I have read the Contribute guide
  • The PR title follows Conventional Commits
  • Tests cover this change, or the summary says why they do not
  • New or changed public API has XML documentation

ReactiveUI.Binding's view locator registers views. Views now implement IViewFor<T>
themselves or derive from a ReactiveUI view base class. The WinForms hosts stay.
@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.94%. Comparing base (b7d7496) to head (f080bd9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #502      +/-   ##
==========================================
- Coverage   97.11%   96.94%   -0.18%     
==========================================
  Files          72       69       -3     
  Lines        4121     3857     -264     
  Branches      537      503      -34     
==========================================
- Hits         4002     3739     -263     
+ Misses        119      118       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@glennawatson
glennawatson merged commit d2e6f72 into main Sep 26, 2026
11 of 12 checks passed
@glennawatson
glennawatson deleted the feature/remove-iviewfor branch September 26, 2026 04:45
@github-actions

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant