[release/11.0.1xx-preview7] Avoid null TypedBinding source during ancestor detach - #37095
Merged
kubaflo merged 1 commit intoAug 4, 2026
Merged
Conversation
Relative source bindings can temporarily resolve to null while items are detached or recycled. Do not reuse the cached successful source type check for that transient null source, preventing generated getters from receiving null. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d6abf7-c466-4cff-aaaf-f990c083a7af
PureWeen
temporarily deployed
to
copilot-pat-pool
August 4, 2026 17:50 — with
GitHub Actions
Inactive
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37095Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37095" |
PureWeen
temporarily deployed
to
copilot-pat-pool
August 4, 2026 17:50 — with
GitHub Actions
Inactive
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
PureWeen
temporarily deployed
to
copilot-pat-pool
August 4, 2026 17:51 — with
GitHub Actions
Inactive
jonathanpeppers
approved these changes
Aug 4, 2026
PureWeen
temporarily deployed
to
copilot-pat-pool
August 4, 2026 17:54 — with
GitHub Actions
Inactive
PureWeen
temporarily deployed
to
copilot-pat-pool
August 4, 2026 17:54 — with
GitHub Actions
Inactive
PureWeen
temporarily deployed
to
copilot-pat-pool
August 4, 2026 17:55 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the TypedBinding engine to avoid invoking typed binding getters (and related subscription logic) when a relative-source binding temporarily resolves to a null source during ancestor detach/recycle scenarios. It also adds a unit test to prevent regressions for FindAncestorBindingContext typed bindings.
Changes:
- Update
TypedBinding.ApplyCoreto avoid reusing a cached “isTSource” result when the current source object isnull. - Add a regression unit test ensuring a typed getter is not invoked with a
nullsource when an ancestor binding context becomes temporarily unresolved.
Show a summary per file
| File | Description |
|---|---|
| src/Controls/src/Core/TypedBinding.cs | Prevents cached typed-source checks from being applied when the current resolved source is null, avoiding getter invocation during transient detach states. |
| src/Controls/tests/Core.UnitTests/RelativeSourceBindingTests.cs | Adds a regression test covering FindAncestorBindingContext typed binding behavior during detach to ensure the getter isn’t called with a null source. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
kubaflo
approved these changes
Aug 4, 2026
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.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Root Cause
TypedBinding.ApplyCorecaches a successfulTSourcetype check. Relative source ancestor bindings can temporarily resolve tonullwhen an item is detached or recycled, but the cached result remainedtrue. This caused the generated binding getter to be invoked with a null source, producing a first-chanceNullReferenceExceptionthat was swallowed by the binding engine but surfaced in the debugger.This became visible in Preview 7 after #34408 began compiling
RelativeSource AncestorTypebindings intoTypedBindinginstances.Description of Change
Do not reuse the cached successful source type result when the current source is null. This skips subscriptions and getter invocation during the transient detach state while preserving the cached result when the ancestor is resolved again.
Add a regression test that detaches a
FindAncestorBindingContexttarget and verifies its typed getter is never invoked with a null source.Issues Fixed
Test Coverage
RelativeSourceBindingTests