Repository navigation
fix: re-instantiate the active route's view model on hot reload - #3146
Merged
Merged
Conversation
rajamatt
force-pushed
the
dev/mara/fix-routes-hr
branch
from
August 20, 2026 16:44
465148d to
7b53165
Compare
…Q pipeline - replaces the foreach + inline null-check in CollectUpdatedViewModels with Select/OfType/ToHashSet, per code-quality review - behavior unchanged; IL2072 suppression kept around the resolver lookup Co-Authored-By: Claude Fable 5 <[email protected]>
- the LINQ refactor moved the FindByViewModel call into a lambda, shifting the trim-analyzer diagnostic from IL2072 to IL2067; the carried-over suppression no longer matched and browserwasm failed with warnings-as-errors - verified locally on net9.0-browserwasm: IL2067 reproduces on the previous commit and is clean with this one Co-Authored-By: Claude Fable 5 <[email protected]>
rajamatt
force-pushed
the
dev/mara/fix-routes-hr
branch
from
August 20, 2026 17:17
2147277 to
b6c8774
Compare
Contributor
|
|
…eload - CollectUpdatedViewModels was the first caller to pass view types to FindByViewModel; on a miss, RouteResolverDefault's convention fallback derives the view's own route path from the type name and REPLACES the registered mapping with one whose ViewModel is the view type — corrupting the route table on every XAML delta (the Given_TabBar_HotReload CI regression) and refreshing pages with a page instance as DataContext - filter FrameworkElement-derived types out before the lookup; the pre-existing HasRouteRegisteredType was safe only because its FindByView call short-circuits first - red/fix/green: new unit test on RouteResolverDefault pins the empty result AND the intact route table; the view-only-delta integration test now also asserts the registered mapping survives the walk Co-Authored-By: Claude Fable 5 <[email protected]>
kazo0
approved these changes
Aug 24, 2026
pull Bot
pushed a commit
to ehtick/uno.extensions
that referenced
this pull request
Aug 25, 2026
Layer 1/4 of the MSAL authentication work (unoplatform#3139): the device lanes, without any MSAL code. Build stages publish each head as a pipeline artifact; test stages boot an emulator / simulator / headless browser, run the engine with a namespace filter and harvest NUnit results. Ported from Studio Live's setup. - Four lanes (stage-runtime-tests-{desktop,wasm,android,ios}.yml) fed by stage-build-runtimetests-mobile.yml; scripts under build/test-scripts with bounded waits, inline emulator logs and a results validator that fails on an empty or all-skipped run - Runtime-test head: MobileRuntimeTestsAutostart drives UnitTestsControl and writes the NUnit document on Android/iOS (the engine's own runner throws PlatformNotSupportedException in a sandboxed app); WebAssemblyRuntimeShim supplies the __WASM__ symbol and InvokeJS the source-shipped engine needs; MainActivity uses GetExternalFilesDir for the results path; the iOS head carries the keychain entitlement MSAL's cache accessor demands - src/Directory.Build.targets exempts AndroidApplication heads from the library-only Private=false rule: .NET Android rewrites an app head's OutputType to Library, which emptied ReferenceCopyLocalPaths and shipped APKs without their ProjectReference closure - src/Directory.Build.props turns the trim/AOT analyzers off for test and sample projects; they only turned "this test calls the API it exists to test" into IL2026 errors on the WebAssembly heads - Given_NavigationRouteUpdateHandler (unoplatform#3146, merged under this branch) becomes partial: the Android/iOS native-ctor generator emits a partial for it, and main never compiles the Navigation UI tests for a device TFM, so these lanes are the first build to see CS0260 - RuntimeTestsFilter is Storage.UI.Tests: green on every lane today. The MSAL namespace joins it in the next layer; '!_HotReload' waits on 15 rotted cases in the wider suite AGENTS.md records the new Window() rule (mobile rejects secondary windows); specs/lessons.md the CI lessons. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EqfQh5ovrPEvFGcERLiLhH
Contributor
|
@Mergifyio backport release/stable/7.3 |
✅ Backports have been createdDetails
|
kazo0
added a commit
that referenced
this pull request
Aug 26, 2026
….3/pr-3146 fix: re-instantiate the active route's view model on hot reload (backport #3146)
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
GitHub Issue (If applicable): closes #3142
PR Type
What kind of change does this PR introduce?
What is the current behavior?
A C# hot-reload delta that updates the view model of the currently displayed route never
re-instantiates that view model, so edits that only run at construction time (constructor bodies,
property initializers) stay invisible until a full rebuild — the one page guaranteed not to
refresh is the page the user is looking at.
Every existing HR path declines to handle it:
NavigationRouteUpdateHandler.UpdateApplicationrebuilds the route table and correctlyclassifies the delta as navigation-relevant, but
CascadeNewDefaultsFromRootsuppresses thewalk because the region is already on that route (the suppression itself is correct — it
preserves the user's selection).
FrameNavigator.RehookCurrentViewAfterHotReloadonly reacts when the frame's content elementwas replaced; a metadata-only edit to a plain C# view-model class replaces no element.
RetryPendingFailedRequestsFromRootonly re-issues failed requests.Re-issuing the same route is also a no-op end to end:
FrameNavigator.NavigateForwardAsynccomputes 0 forward segments for the route it is already on, and its HR bypass only fires when
SourcePageTypediffers from the mapping'sRenderView— which it doesn't for an in-place(EnC) update.
What is the new behavior?
When a hot-reload delta updates the view model mapped to a region's active route, that view
model is re-created in place and rebound — no navigation is issued, so the user's selection
cannot move.
Implementation (two orthogonal walks instead of entangling
updatedTypesinto the cascade'sconflict check —
CascadeNewDefaultsFromRootis unchanged):NavigationRouteUpdateHandler.ScheduleCascadenow receivesupdatedTypes.CollectUpdatedViewModelsmaps each updated type to the view-model type the just-rebuilt routetable associates with it, resolved through
RouteResolver.FindByViewModelso the MVUX caseworks (
MappedRouteResolvertranslates a model type — what the delta contains — to itsgenerated bindable view model — what
RouteInfo.ViewModelholds).RefreshUpdatedActiveRoutesFromRootwalks the live region tree; every region whose navigator'sactive
Route.Baseresolves to a mapping whoseViewModelis in that set gets the newControlNavigator.RefreshActiveRouteViewModelAsync(), which re-runs the standardInitializeCurrentView(refresh: true)pipeline (CreateViewModel+InjectServicesAndSetDataContextAsync) for the route the navigator is already on.element-update walk (plus the frame-content re-hook), and rebuilding view models on a view-only
delta would discard un-persisted view-model state on every page edit — the behavior
Given_FrameContentRehook.When_XamlOnlyDelta_Then_CopiedViewModelIsPreservedpins.updatedTypes == null(unknown delta) refreshes nothing — conservative, mirrors the existingx:Uid-revert guard on the cascade.
Known limitation (documented in
specs/009-hr-active-route-vm-refresh/spec.md): a view modelreplaced via
CreateNewOnMetadataUpdate(rude edit / some partial-class deltas) resolves to theold type in the rebuilt route table and is not matched — same pre-existing limitation as the
route table itself (#3072). The in-place EnC case (type identity preserved) is fully covered.
Other information
Tests added (red/fix/green — the repro tests fail on
main):Given_ActiveRouteVmRefresh(UI test, no HR harness — same technique asGiven_FrameContentRehook): drives the internal HR entry point with a synthetic delta againsta live navigation tree. Asserts the VM is rebuilt in place (view instance untouched) for a
VM delta, and preserved for a view-only delta. Verified red before the fix (timeout — nothing
re-instantiates the VM) and green after, on Skia desktop.
Given_HotReload.When_ActiveRouteViewModelUpdated_Then_ActiveRegionVmReinstantiated(runtimetest, real HR delta, secondary app): edits a constructor-seeded property initializer on the
active route's own VM file while sitting on a non-default visibility-region route; asserts
the VM is re-instantiated with the post-HR seed AND the selection is not yanked back to the
IsDefaultroute. Runs in the hot-reload runtime-test CI stage.Given_NavigationRouteUpdateHandler: 5 unit tests forCollectUpdatedViewModels(null / unregistered / registered VM / registered view-only / MVUX mapped-model).
Given_FrameContentRehook(state preservationunchanged),
Given_NavigationRouteUpdateHandler, neighboring navigation suites.Also validated end-to-end in a downstream consumer: with this assembly, editing a chart series
property initializer on the displayed page's model (
ColumnSeries<double>→LineSeries<double>) renders live on the active page in one hot-reload pass — previously itrequired breaking hot reload badly enough to force a full rebuild.
Design doc:
specs/009-hr-active-route-vm-refresh/spec.md(+ scenario entry insrc/Uno.Extensions.Navigation.UI.Tests/HotReload.Spec.md).Internal Issue (If applicable):