Repository navigation
feat!: remove [IViewFor] in favour of ReactiveUI.Binding - #502
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes
[IViewFor]. ReactiveUI.Binding now covers linking views to view models, in its own more restricted way: a view implementsIViewFor<T>itself, and ReactiveUI.Binding's view locator registers it.[IViewFor<T>]and[IViewFor("...")]are gone, along with theViewModelproperty andIViewFor<T>implementation they generated for WPF, WinUI, Uno, WinForms, Avalonia and MAUI views.[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.IViewFor<T>by hand.[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 theIViewFor<T>implementation itself. A view writes it, or derives from one of ReactiveUI's view base classes such asReactiveUserControl<T>. That is the restricted form this PR moves to.Breaking changes
[IViewFor<T>]and[IViewFor("...")]are removed. AddIViewFor<TViewModel>to the view's declaration, with aViewModelproperty and the untypedIViewFor.ViewModel. Alternatively, derive from a ReactiveUI view base class such asReactiveUserControl<T>,ReactiveWindow<T>orReactiveContentPage<T>. The README shows the hand-written form. A WPF, WinUI or Uno view that needs a bindableViewModelshould declare it as a dependency property, as the generated code did.[IViewFor]no longer applies. It read this package's attributes. Views now register because they implementIViewFor<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
GetGenericTypeandInheritsFromFullyQualifiedMetadataNameStartingWith).src/ReactiveUI.SourceGenerators.Executeandsrc/TestApps, and the README's "Moved to ReactiveUI.Binding" section.[IViewFor]row and the whole-corpus figures insrc/benchmarks/README.mdare 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