Skip to content

fix(navigation): follow-ups to #3249 — test host without Navigation.WinUI, case-insensitive name match, docs - #3254

Merged
kazo0 merged 11 commits into
mainfrom
dev/sb/3248-test-host
Oct 27, 2026
Merged

kazo0 merged 11 commits into
mainfrom
dev/sb/3248-test-host

Conversation

@kazo0

@kazo0 kazo0 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue (If applicable): related to #3248 (follow-up to #3249)

PR Type

  • Bugfix
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes

What is the current behavior?

Follow-ups from the review of #3249:

  • Uno.Extensions.Navigation.Tests references Uno.Extensions.Navigation.WinUI. To make that load in a plain test host, the csproj reads $(UnoVersion) out of global.json with a regex and disables UNOB0025.
  • RouteResolverDefault compares assembly simple names ordinally when it skips default-context copies of assemblies the resolver's own context already has. The loader compares them case-insensitively.
  • The navigation docs don't say that implicit (by-name) route lookup only searches the resolver's own load context and the default one.
  • The test that loads an assembly into the default context fails if it runs twice in the same process.

Found while reviewing this PR (most predate it):

  • AssemblyExtensions.SafeGetTypes catches everything and excludes the whole assembly when one type fails to load, without logging anything.
  • LoadedTypes and AssemblyExtensions.Excludes are not safe when two first lookups run concurrently.
  • The "Could not resolve type for path" warning doesn't say which load contexts were searched.

What is the new behavior?

  • refactor: the load-context assembly selection and the by-name type index move into the UI-free internal RouteTypeIndex.
    • It has a single entry point, RouteTypeIndex.For(anchor), which both RouteResolverDefault.LoadedTypes and the tests call.
    • The index is built with Dictionary.TryAdd (keep first), not ToDictionaryDistinct.
    • The test project compiles RouteTypeIndex.cs and AssemblyExtensions.cs in directly, as Authentication.MSAL.Tests does. That removes the Navigation.WinUI reference, the global.json regex, the UNOB0025 override, and any extra package reference.
  • fix: simple names are compared with OrdinalIgnoreCase.
  • fix: when some types of an assembly fail to load (ReflectionTypeLoadException), the types that did load are still indexed, and a structured warning is logged.
  • fix: the index is built once, even when first lookups race (LazyInitializer). Reads of and additions to Excludes take a lock.
  • fix: the unresolved-route warning names the searched load contexts and points to ViewMap/RouteMap.
  • docs: HowTo-DefineRoutes.md explains which load contexts implicit lookup searches. It also says the index is built once, at the first lookup, and lists what the lookup skips. AssemblyExtensions gains XML docs.

PR Checklist

  • Tested code with current supported SDKs:
    • Uno.Extensions.Navigation.Tests passes 7/7 in Release with build/tests.runsettings.
    • The desktop runtime-test head passes 13/13 for Given_RouteResolverDefault | Given_NavigationRouteUpdateHandler.
    • Uno.Extensions.Navigation.WinUI builds in Release for net10.0 locally. The android and ios workloads aren't installed on the machine used, and the Windows target needs msbuild, so CI covers those.
  • Docs have been added/updated
  • Unit Tests for the changes have been added
  • Wasm UI Tests: N/A (no UI change)
  • Contains NO breaking changes:
    • RouteTypeIndex is internal.
    • The public AssemblyExtensions moved to its own file in the same assembly and namespace, and its public signatures are unchanged.
    • SafeGetTypes now returns the loadable types of a partly loadable assembly instead of an empty array.
  • Updated the Release Notes
  • Associated with an issue (GitHub or internal)

Other information

  • Given_RouteResolverDefault (Navigation.UI.Tests) is gated to desktop. No CI lane runs Navigation.UI.Tests today: the desktop lane's RuntimeTestsFilter leaves it out, and the skia !_HotReload stage is disabled. It was run locally on the desktop head.
  • Each test was checked by breaking the code on purpose; each break is caught:
    • Removing the simple-name filter fails 2 tests.
    • Scanning every assembly in the process fails 4 unit tests and Given_RouteResolverDefault.
    • Putting the default context first fails the own-wins test.
    • Making the own context always the default context fails 4 tests.
    • Also indexing sibling load contexts fails the sibling-context test.
    • Restoring the old catch-all in SafeGetTypes fails When_SomeTypesFailToLoad_Then_LoadableTypesIndexed.
  • Not covered by a test: the race in the first lookup (it needs two threads to interleave), and the typeof(RouteResolverDefault).Assembly anchor in a host where the resolver lives outside the default context.
  • Not changed here: the index doesn't follow assemblies loaded after the first lookup (now documented).

🤖 Generated with Claude Code

https://claude.ai/code/session_01DfEL4A7BqL6zLvko22CdCA
https://claude.ai/code/session_01S4VxjrUrcGVoeBhEjXrmpo
https://claude.ai/code/session_01PZQ75nMpDZr9xNdRwacVQN

@kazo0
kazo0 marked this pull request as ready for review October 16, 2026 15:36
@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 239927 has failed on uno.extensions.

@kazo0

kazo0 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio rebase

@mergify

mergify Bot commented Oct 19, 2026

Copy link
Copy Markdown

rebase

✅ Branch has been successfully rebased

@kazo0
kazo0 force-pushed the dev/sb/3248-test-host branch from 81faf0b to 746cbe8 Compare October 19, 2026 16:36
@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 240175 has failed on uno.extensions.

@kazo0
kazo0 enabled auto-merge October 26, 2026 15:21
@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 241441 has failed on uno.extensions.

@Xiaoy312 Xiaoy312 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The extraction is clean and the case-insensitive fix comes with a test that catches it. The main point is the first inline comment: the resolver's own wiring is no longer covered. The rest are small nits or follow-ups on older behaviour, none of them blocking.

kazo0 and others added 10 commits October 27, 2026 10:16
…ithout Navigation.WinUI

- Move the load-context assembly selection and the by-name type index out of RouteResolverDefault into the UI-free internal RouteTypeIndex; move the public AssemblyExtensions to its own file, unchanged
- Compile RouteTypeIndex.cs and AssemblyExtensions.cs into Uno.Extensions.Navigation.Tests instead of referencing Navigation.WinUI, as Authentication.MSAL.Tests does, so the project no longer needs Uno.WinUI, the $(UnoVersion) read from global.json, or the UNOB0025 override
- Test RouteTypeIndex directly (Given_RouteTypeIndex): other-context isolation, own-context precedence (also proves ToDictionaryDistinct keeps the first entry), and skipping the default copy of an assembly the own context has
- Give the emitted default-context assembly and types unique names per run, since the default context never unloads
- Part of #3248

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DfEL4A7BqL6zLvko22CdCA
- The loader treats assembly simple names case-insensitively, so a default-context assembly whose name differs from an own-context one only in casing is the same assembly and must be skipped like any other default copy
- When_AssemblyAlsoInOwnLoadContextWithOtherCasing_Then_DefaultCopyIgnored fails with the previous ordinal comparison
- Part of #3248

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DfEL4A7BqL6zLvko22CdCA
…ches

- Since #3248, a route without a registered view is resolved by name only from the load context that loaded Uno.Extensions.Navigation and the default one; views in any other AssemblyLoadContext (e.g. Assembly.LoadFile) need an explicit ViewMap/RouteMap

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DfEL4A7BqL6zLvko22CdCA
…-context isolation

- Move the own-context choice (GetLoadContext(anchor) ?? Default) into RouteTypeIndex.OwnContextOf so the tests reach it; every Given_RouteTypeIndex case now builds the index from an anchor assembly, as RouteResolverDefault does
- Add When_TypeOnlyInSiblingLoadContext_Then_NotIndexed: the resolver's own context and another app's context are both alive, and the other's types stay out of the index
- Assert the own copy is still indexed in the casing test
- Returning the default context from OwnContextOf fails 4 tests; also indexing sibling contexts fails the new test
- Part of #3248

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01S4VxjrUrcGVoeBhEjXrmpo
… lookup searches

- The resolver anchors on Uno.Extensions.Navigation.UI (package Uno.Extensions.Navigation.WinUI), not the core Uno.Extensions.Navigation assembly

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01S4VxjrUrcGVoeBhEjXrmpo
…rop ToDictionaryDistinct

- RouteTypeIndex.For(anchor) picks the anchor's load context and builds the index; RouteResolverDefault.LoadedTypes and Given_RouteTypeIndex both call it, so the tests exercise the resolver's own wiring rather than a copy of it
- Build the index with Dictionary.TryAdd instead of ToDictionaryDistinct: the shipped library got that helper from Uno.Core.Extensions 4.1.1 while the tests got it from Uno.Core.Extensions.Collections 5.0.0-dev.34, so the tests proved keep-first on a different binary; both keep the first entry, so behaviour is unchanged
- Drop the Uno.Core.Extensions.Collections reference from Uno.Extensions.Navigation.Tests and warn in the csproj that referencing Navigation.WinUI would define the linked AssemblyExtensions twice (CS0436)
- Trim the production remark to the constraint it guards, and say why both casings can load in the casing test
- Part of #3248

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PZQ75nMpDZr9xNdRwacVQN
- LoadedTypes used an unsynchronised null check, so two concurrent first lookups on a multi-threaded head could both run the full GetTypes() scan; build it with LazyInitializer.EnsureInitialized instead, as specs/lessons.md asks for shared memoisation
- Lock AssemblyExtensions.Excludes while the index reads it and while SafeGetTypes adds to it, so concurrent index builds don't corrupt the list; WASM is single-threaded, so the lock is never contended there
- No deterministic test: the race needs two threads to interleave inside the first lookup
- Part of #3248

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PZQ75nMpDZr9xNdRwacVQN
…artly fail to load

- SafeGetTypes caught everything and excluded the whole assembly for the rest of the process, so one class referencing a missing optional package hid every page and view model in its assembly from implicit routing, with nothing logged
- Catch ReflectionTypeLoadException first and keep the types it did load, without excluding the assembly; any other failure still excludes it as before
- RouteTypeIndex reports each failure, and RouteResolverDefault logs it as a structured warning carrying the exception and its loader exceptions
- The public SafeGetTypes signature is unchanged; the error comes out through an internal overload
- When_SomeTypesFailToLoad_Then_LoadableTypesIndexed fails with the previous catch-all
- Part of #3248

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PZQ75nMpDZr9xNdRwacVQN
…te doesn't resolve

- Since #3249, a view in another AssemblyLoadContext no longer resolves by name, but the warning read the same as a typo, and the scope was only logged at Debug
- The "Could not resolve type for path" warning now says which load contexts were searched and that types elsewhere need an explicit ViewMap/RouteMap
- Add Given_RouteResolverDefault in Navigation.UI.Tests: through the resolver itself, a view model loaded only into another load context does not resolve, one in the resolver's own context does, and the warning names the searched contexts; making the index scan every assembly in the process fails it
- Gated to desktop, like the repo's other emitted-assembly tests; no CI lane runs Navigation.UI.Tests today (the desktop lane's RuntimeTestsFilter leaves it out and the skia !_HotReload stage is disabled), so it was run locally on the desktop head
- Part of #3248

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PZQ75nMpDZr9xNdRwacVQN
… lookup skips

- XML docs for the public AssemblyExtensions, Excludes (including the lock navigation takes on it) and SafeGetTypes
- HowTo-DefineRoutes.md: the type index is built once, at the first lookup; it skips a default-context assembly when the first load context has one with the same name, assemblies whose name starts with `_`, and types that fail to load; any of these needs an explicit ViewMap/RouteMap
- Part of #3248

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PZQ75nMpDZr9xNdRwacVQN
@kazo0
kazo0 force-pushed the dev/sb/3248-test-host branch from 2613bdd to 83deade Compare October 27, 2026 14:37
…use Where'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
@kazo0
kazo0 merged commit 3d9a62a into main Oct 27, 2026
29 of 30 checks passed
@kazo0
kazo0 deleted the dev/sb/3248-test-host branch October 27, 2026 18:34
@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

agneszitte pushed a commit that referenced this pull request Nov 3, 2026
- The docs validation only runs for PRs that touch a .md file. This PR does (HowTo-DefineRoutes.md, from #3254), so it fails on 7.3 files it didn't change
- Same fix as main's ec84019 (from #3153): MD040 in specs/004 and specs/006, "nuspecs" and "unmaterialized" in the dictionary, "recognize" in specs/lessons.md, MD059/MD060 off
- Also adds "rehook" (specs/009), which main got with #3154

(cherry picked from commit ec84019)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
agneszitte added a commit that referenced this pull request Nov 3, 2026
… tests use

- Given_RouteResolverDefault (#3254) logs through CapturingLoggerProvider. main got that helper with #3231, which 7.3 doesn't have
- Copied as is from main: test project only, no product change

Co-Authored-By: Claude Opus 5.5 <[email protected]>
agneszitte added a commit that referenced this pull request Nov 3, 2026
…e whole route (backport #3231)

- Backport of #3231 to servicing/7.4, applied without changes
- Also moves CapturingLoggerProvider to its own file, which the #3254 tests use

Co-Authored-By: Claude Opus 5.5 <[email protected]>
agneszitte added a commit that referenced this pull request Nov 3, 2026
…nUI, case-insensitive name match, docs (backport #3254)

- Backport of #3254 to servicing/7.4, applied without changes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
agneszitte added a commit that referenced this pull request Nov 3, 2026
…6.7-sr3

fix: get servicing/7.4 ready for 6.7 SR3 (backport #3228, #3231, #3235, #3249, #3254, #3259; Uno floor 6.7.65)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants