Commit e10b0be
[Regression] Fix TypedBinding nested property re-subscription (dotnet#34428) (dotnet#34449)
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
## Description
Cherry-pick of
[`5d6e5a20`](dotnet@5d6e5a2)
from `net11.0`, adapted for `main`.
Fixes dotnet#34428
### Problem
Release 10.0.50 introduced a performance optimization (`_isSubscribed`
flag) in `TypedBinding` that prevented re-subscribing to intermediate
INPC objects when they changed. This caused compiled bindings with
nested property paths (e.g. `{Binding ViewModel.Text}`) to stop updating
when the intermediate object was replaced.
### Fix
Remove the `_isSubscribed` guard and always call `Subscribe()` on every
`Apply`. The `Subscribe()` implementation is already idempotent — it
diffs old vs new subscription targets — so calling it repeatedly is safe
with minimal overhead.
### Tests
Two regression tests added to `TypedBindingUnitTests.cs`:
-
`TypedBinding_NestedProperty_ResubscribesAfterNullIntermediateBecomesNonNull`
- `TypedBinding_NestedProperty_ResubscribesAfterIntermediateReplaced`
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent f6314b5 commit e10b0be
2 files changed
Lines changed: 85 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | 150 | | |
152 | 151 | | |
153 | 152 | | |
| |||
289 | 288 | | |
290 | 289 | | |
291 | 290 | | |
292 | | - | |
293 | 291 | | |
294 | 292 | | |
295 | 293 | | |
| |||
332 | 330 | | |
333 | 331 | | |
334 | 332 | | |
335 | | - | |
336 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
340 | 339 | | |
341 | 340 | | |
342 | 341 | | |
| |||
Lines changed: 81 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1773 | 1773 | | |
1774 | 1774 | | |
1775 | 1775 | | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
1776 | 1857 | | |
1777 | 1858 | | |
1778 | 1859 | | |
| |||
0 commit comments