Skip to content

fix(databinding): reject bindable metadata resolved across ALC boundaries (backport #24096) - #26272

Merged
agneszitte merged 2 commits into
release/stable/6.7from
dev/agzi/backport-24096-6.7
Nov 9, 2026
Merged

agneszitte merged 2 commits into
release/stable/6.7from
dev/agzi/backport-24096-6.7

Conversation

@agneszitte

Copy link
Copy Markdown
Member

GitHub Issue: related to #24095 and https://github.com/unoplatform/studio.live/issues/5628

PR Type:

🐞 Bugfix

What changed? 🚀

Backport of #24096 to release/stable/6.7: its 2 commits, cherry-picked with -x (3257675, 2c4a2ed). No conflicts.

Studio 3.3 ships on the 6.7 stables. There, Gallery samples that show their data in a FeedView render blank pages (https://github.com/unoplatform/studio.live/issues/5628): Studio and the previewed app each load their own Uno.Extensions.Reactive.UI, so the app's FeedViewState resolves to Studio's generated binding metadata, whose getters then fail with InvalidCastException. With #24096, the binder only uses metadata built for the exact requested type, and falls back to reflection otherwise.

  • Apps with a single load context are unaffected: the generated metadata is always built for the same type the binder asks for, so the new check never rejects it.
  • BindingPropertyHelper.cs, BindablePropertyDescriptor.cs and TypeActivator.cs end up identical to servicing/6.8, which has had fix(databinding): reject bindable metadata resolved across ALC boundaries #24096 since August.
  • Left out: ae2201c, a test fix made on the 7.0 branch, where DataContext is on FrameworkElement only. Like servicing/6.8, which doesn't have it either, 6.7 doesn't need it.

Validation: Derek built Uno.UI from the 6.7.359 tag with these commits and ran Studio 3.3 (desktop) on the FitApp repro: no more cast failures, and the data shows (results). WASM is still to be checked, with a 6.7 build that has this PR. The Given_Binder.MetadataProviderIdentity unit tests come with it.

PR Checklist ✅

🤖 Generated with Claude Code

…ries

Generated bindable metadata providers match types by full name, so when
the same assembly is loaded in a second AssemblyLoadContext (a host
application previewing a secondary app), a lookup for the secondary
context's type returns the host context's IBindableType. Its typed
getters then throw InvalidCastException and controls binding such types
(e.g. FeedView's FeedViewState) silently render blank.

Validate the provider result against the requested type identity:
IBindableType already carries its Type, so a mismatch now falls back to
the reflection path instead of returning foreign metadata.

(cherry picked from commit 3257675)
RunWithProvider swaps the static BindingPropertyHelper.BindableMetadataProvider
and clears the binder caches, so concurrent execution with other tests touching
that shared state could flake. [DoNotParallelize] pins the historical serial
behavior explicitly instead of relying on it.

(cherry picked from commit 2c4a2ed)
@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @agneszitte's task in 3m 8s —— View job


Code Review — fix(databinding): reject bindable metadata resolved across ALC boundaries (backport #24096)

Verdict: ship — 1 nit inline, 1 out-of-scope gap to track.


Summary

The fix is correct and complete for the main data-binding pipeline. GetValidatedBindableType enforces reference-equality between the requested Type and the IBindableType.Type returned by the generated metadata provider, preventing cross-ALC full-name matches from producing poisoned getters. All five hot-path call sites that previously called BindableMetadataProvider.GetBindableTypeByType directly have been updated (InternalGetValueGetter indexer path, InternalGetValueSetter indexer path, both BindablePropertyDescriptor lookups via GetPropertByBindableMetadataProvider, and TypeActivator.CreateInstance). The three unit tests provide red/fix/green coverage — matching type, mismatched type (miss), and end-to-end reflection fallback.

Findings

Severity Location Finding
Nit Given_Binder.MetadataProviderIdentity.cs:21 Missing [GitHubWorkItem("https://github.com/unoplatform/uno/issues/24095")] per unit-tests convention (inline comment)
Info (out of scope) src/Uno.UI/DirectUI/PropertyAccess.cs:240 The HAS_UNO path still calls BindableMetadataProvider.GetBindableTypeByType directly — same cross-ALC risk, different code path (custom-property / x:Bind, not standard {Binding}). Likely not exercised by the FeedView repro but worth a follow-up. This file isn't in the PR diff so it was equally unfixed in the original #24096.

Positive notes

  • [DoNotParallelize] is correctly applied to protect the global BindableMetadataProvider state during test runs.
  • The StubMetadataProvider returning a constant _result regardless of the requested Type correctly simulates the generated provider's by-full-name resolution behaviour.
  • Commit titles follow Conventional Commits (fix(databinding):, test(databinding):).
  • internal static GetValidatedBindableType is appropriately scoped and reachable from unit tests via the existing InternalsVisibleTo declaration in AssemblyInfo.cs.

Code review assessment (by diff inspection). No local build or runtime execution performed.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@agneszitte
agneszitte merged commit d9efbee into release/stable/6.7 Nov 9, 2026
32 of 46 checks passed
@agneszitte
agneszitte deleted the dev/agzi/backport-24096-6.7 branch November 9, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants