{{ message }}
Repository navigation
docs(examples): show default and Unsafe view hosts after #4505 - #4507
Merged
Merged
Conversation
- WinUI: the maintenance panel shows its Map-ed view through the default RoutedViewHost and ViewModelViewHost. - WinUI: a radar view registered only in the service locator shows the Unsafe twins; MapFromServiceLocator shows the AOT-safe alternative. - WPF: a notice board hosts a service-locator-only view through RoutedViewHostUnsafe and ViewModelViewHostUnsafe, and the builder examples register AutoDataTemplateBindingHookUnsafe. - WinForms and MAUI: examples for each new Unsafe twin and for MapFromServiceLocator with the default host. - MAUI: the Wide contract view carries [ViewContract], since the default hosts do not read service-locator contract registrations. - Android: FirstLessonPeekHost shows ReactiveViewHostUnsafe<TViewModel> auto-wireup.
…odels - BookListViewModel exposed Label controls and LoanFormViewModel exposed Button controls, and each disposed them. RoutedControlHost disposes a view when it navigates, which disposed those controls with the panel that held them, so the next catalog view bound disposed labels and the --smoke run hung at the loan confirmation step. - BookListViewModel now exposes the card text as IReadOnlyList<string>, and LoanFormViewModel exposes Members. - BookListView and LoanFormView build their own labels and buttons and bind them into the panel and table with WhenAnyValue, Select and BindTo, so each view owns and disposes its controls.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4507 +/- ##
=======================================
Coverage 93.62% 93.62%
=======================================
Files 175 175
Lines 6227 6227
Branches 743 743
=======================================
Hits 5830 5830
Misses 396 396
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
The documentation examples show the default view hosts finding generated and
Mapviews, and use each...Unsafetwin only for a view registered in the service locator alone.SensorMaintenanceViewis added withMap, andRoutedViewHostandViewModelViewHostnow show it.RadarImageViewis registered only with the service locator and is hosted byRoutedViewHostUnsafeandViewModelViewHostUnsafe.WinUIStartupExamples.MapAViewFromTheServiceLocatorshows the AOT-safe alternative,CreateMappingBuilder().MapFromServiceLocator<TViewModel, IViewFor<TViewModel>>().RoutedViewHostUnsafeandViewModelViewHostUnsafe, andWpfBuilderExtensionsExamples.AddTheUnsafeTemplateHookregistersAutoDataTemplateBindingHookUnsafe.ServiceLocatorViewExamples. Each shows its two twins against a service-locator-only view, andMapFromServiceLocatorletting the default host find the same view.Widecontract view carries[ViewContract("Wide")]. The contract examples registered it only with the service locator, which the default host does not ask.FirstLessonPeekHostderives fromReactiveViewHostUnsafe<LessonViewModel>to show auto-wireup on a host with a view model, next toLessonCountBadgeHostonLayoutViewHostUnsafe.Why
#4505 made every default view host AOT safe, so the examples that worked around #4502 and the examples that registered views only in the service locator needed updating.
Mapviews.ViewModelViewHostno longer asks the service locator.Breaking changes
None. Examples only.
How this was verified
Every page project builds in Release with warnings as errors, and the output checks pass.
--smokeon a real Windows machine; the Android example ran on an emulator.Notes for the reviewer
Start with
platform-winui/MainWindow.csand the threeServiceLocatorViewExamples/notice-board additions; the rest is new view and view model types.[ExcludeFromViewRegistration]to stand in for a view from a library built without the source generator.--smokerun stops at the loan confirmation with anObjectDisposedException:RoutedControlHostdisposes the catalog view, which disposes theBookCardslabels its view model owns, and the next catalog view binds those disposed labels. It fails the same way on the commit before fix!: make every default view host AOT safe on Binding 8.1.0 #4505, so it is not caused by this change and is left out of scope.Checklist