docs(examples): show default and Unsafe view hosts after #4505 by glennawatson · Pull Request #4507 · reactiveui/ReactiveUI · GitHub
Skip to content

docs(examples): show default and Unsafe view hosts after #4505 - #4507

Merged
glennawatson merged 2 commits into
mainfrom
docs/examples-after-4505
Sep 26, 2026
Merged

glennawatson merged 2 commits into
mainfrom
docs/examples-after-4505

Conversation

@glennawatson

Copy link
Copy Markdown
Contributor

Summary

The documentation examples show the default view hosts finding generated and Map views, and use each ...Unsafe twin only for a view registered in the service locator alone.

  • WinUI: the maintenance panel uses the default hosts. SensorMaintenanceView is added with Map, and RoutedViewHost and ViewModelViewHost now show it.
  • WinUI: a radar panel shows the case the twins exist for. RadarImageView is registered only with the service locator and is hosted by RoutedViewHostUnsafe and ViewModelViewHostUnsafe. WinUIStartupExamples.MapAViewFromTheServiceLocator shows the AOT-safe alternative, CreateMappingBuilder().MapFromServiceLocator<TViewModel, IViewFor<TViewModel>>().
  • WPF: a notice board hosts a service-locator-only view through RoutedViewHostUnsafe and ViewModelViewHostUnsafe, and WpfBuilderExtensionsExamples.AddTheUnsafeTemplateHook registers AutoDataTemplateBindingHookUnsafe.
  • WinForms and MAUI: new ServiceLocatorViewExamples. Each shows its two twins against a service-locator-only view, and MapFromServiceLocator letting the default host find the same view.
  • MAUI: the Wide contract view carries [ViewContract("Wide")]. The contract examples registered it only with the service locator, which the default host does not ask.
  • Android: FirstLessonPeekHost derives from ReactiveViewHostUnsafe<LessonViewModel> to show auto-wireup on a host with a view model, next to LessonCountBadgeHost on LayoutViewHostUnsafe.

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.

  • The WinUI maintenance panel used the Unsafe twins only because the default hosts missed Map views.
  • Two MAUI contract examples failed their output check, because the default ViewModelViewHost no 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.

  • The WPF, WinForms and WinUI projects were built and run with --smoke on a real Windows machine; the Android example ran on an emulator.

Notes for the reviewer

Start with platform-winui/MainWindow.cs and the three ServiceLocatorViewExamples/notice-board additions; the rest is new view and view model types.

  • The service-locator-only views carry [ExcludeFromViewRegistration] to stand in for a view from a library built without the source generator.
  • The WinForms --smoke run stops at the loan confirmation with an ObjectDisposedException: RoutedControlHost disposes the catalog view, which disposes the BookCards labels 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

  • 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

- 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.
@sonarqubecloud

Copy link
Copy Markdown

@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 93.62%. Comparing base (6def5a6) to head (3de14e9).

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.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@glennawatson
glennawatson merged commit bbe16fa into main Sep 26, 2026
13 of 15 checks passed
@glennawatson
glennawatson deleted the docs/examples-after-4505 branch September 26, 2026 11:23
@github-actions

Copy link
Copy Markdown

@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