Repository navigation
Fix for Label.FormattedText leaks labels when shared FormattedString is stored in Application.Resources - #35582
Conversation
<!-- 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! ## What Restrict the agentic-labeler to apply **exactly one `area-*` label** per item, while still allowing multiple `platform/*` labels. ## Why Backfilling the 26 items affected by the `max:1` bug (fixed in dotnet#35540) revealed that the labeler occasionally applies multiple `area-*` labels for ambiguous cases: - **dotnet#35501** got both `area-layout` and `area-safearea` - **dotnet#35490** got both `area-navigation` and `area-controls-tabbedpage` The intended behavior is exactly one best-fit `area-*` per item (a label-quota distinction not expressible via `safe-outputs.add-labels.max:` — that field counts total labels, not labels per prefix). The fix has to live in the agent's instructions. ## Changes ### `.github/skills/agentic-labeler/SKILL.md` - Scope section: "Exactly one `area-*`" / "One or more `platform/*`". - Area rules section: renamed heading, changed "pick one or more" → "apply exactly one". - New **tie-breaking heuristics** for the area-* selection: - Specific control beats generic area (`area-controls-tabbedpage` over `area-navigation`) - Sub-area beats parent area (`area-safearea` over `area-layout`) - Subject-matter focus beats incidental touch - When genuinely tied, prefer the user-visible feature - Mixed-PR rule clarified: infra-primary PRs get only `area-infrastructure` (no second product area). ### `.github/workflows/agentic-labeler.md` - Added explicit reinforcement in the workflow prompt: "Apply exactly one `area-*` label … and one or more `platform/*` labels". - Fixed two stale `max: 1` comments left over from dotnet#35540 (the cap is now `max: 10`). ### `.github/workflows/agentic-labeler.lock.yml` - Regenerated via `gh aw compile`. Diff is frontmatter-hash + heredoc rotations only — no semantic change to the compiled config. ## Validation - Reviewed all 21 existing eval scenarios in `tests/eval.yaml` — none assert multiple `area-*` labels, so no test updates needed. - The `max: 10` cap in `safe-outputs` is preserved as a blast-radius safeguard (one area + several platforms still fit comfortably). ## Follow-ups (not in this PR) If accuracy of the "one area" rule drops below ~95% in eval runs, consider adding a deterministic post-step that strips extra `area-*` labels per a known precedence list (Option B from the design discussion). Co-authored-by: bot <bot@test> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ed FormattedString event subscriptions using weak-reference event handling and proxy cleanup.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35582Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35582" |
|
/review -b feature/regression-check |
🤖 AI Summary
📊 Review Session —
|
| Test | Without Fix (expect FAIL) | With Fix (expect PASS) |
|---|---|---|
🧪 LabelTests LabelTests |
✅ FAIL — 93s | ✅ PASS — 85s |
🔴 Without fix — 🧪 LabelTests: FAIL ✅ · 93s
Determining projects to restore...
Restored /home/vsts/work/1/s/src/TestUtils/src/TestUtils/TestUtils.csproj (in 1.39 sec).
Restored /home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj (in 1.86 sec).
8 of 10 projects are up-to-date for restore.
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Graphics -> /home/vsts/work/1/s/artifacts/bin/Graphics/Debug/net10.0/Microsoft.Maui.Graphics.dll
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Essentials -> /home/vsts/work/1/s/artifacts/bin/Essentials/Debug/net10.0/Microsoft.Maui.Essentials.dll
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Core -> /home/vsts/work/1/s/artifacts/bin/Core/Debug/net10.0/Microsoft.Maui.dll
Controls.BindingSourceGen -> /home/vsts/work/1/s/artifacts/bin/Controls.BindingSourceGen/Debug/netstandard2.0/Microsoft.Maui.Controls.BindingSourceGen.dll
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Controls.Core -> /home/vsts/work/1/s/artifacts/bin/Controls.Core/Debug/net10.0/Microsoft.Maui.Controls.dll
Maps -> /home/vsts/work/1/s/artifacts/bin/Maps/Debug/net10.0/Microsoft.Maui.Maps.dll
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Controls.Xaml -> /home/vsts/work/1/s/artifacts/bin/Controls.Xaml/Debug/net10.0/Microsoft.Maui.Controls.Xaml.dll
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Controls.Maps -> /home/vsts/work/1/s/artifacts/bin/Controls.Maps/Debug/net10.0/Microsoft.Maui.Controls.Maps.dll
TestUtils -> /home/vsts/work/1/s/artifacts/bin/TestUtils/Debug/netstandard2.0/Microsoft.Maui.TestUtils.dll
Controls.Core.UnitTests -> /home/vsts/work/1/s/artifacts/bin/Controls.Core.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Core.UnitTests.dll
Test run for /home/vsts/work/1/s/artifacts/bin/Controls.Core.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Core.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.14] Discovering: Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:01.52] Discovered: Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:01.53] Starting: Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:01.92] MultipleLabelsWithSharedFormattedStringAreAllGCEligible [FAIL]
[xUnit.net 00:00:01.93] Label[0] should be GC-eligible after handler disconnect even when a shared FormattedString is still alive.
[xUnit.net 00:00:01.94] Stack Trace:
[xUnit.net 00:00:01.98] /_/src/Controls/tests/Core.UnitTests/LabelTests.cs(271,0): at Microsoft.Maui.Controls.Core.UnitTests.LabelTests.MultipleLabelsWithSharedFormattedStringAreAllGCEligible()
[xUnit.net 00:00:01.98] at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:01.98] at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
[xUnit.net 00:00:01.98] SharedFormattedStringWithGestureSpansDoesNotPreventLabelGC [FAIL]
[xUnit.net 00:00:01.98] Label should be GC-eligible even when shared FormattedString has spans with gesture recognizers.
[xUnit.net 00:00:01.98] Stack Trace:
[xUnit.net 00:00:01.98] /_/src/Controls/tests/Core.UnitTests/LabelTests.cs(254,0): at Microsoft.Maui.Controls.Core.UnitTests.LabelTests.SharedFormattedStringWithGestureSpansDoesNotPreventLabelGC()
[xUnit.net 00:00:01.98] at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:01.98] at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Passed EntryCellXAlignBindingMatchesHorizontalTextAlignmentBinding [38 ms]
Passed InvalidateMeasureWhenTextChanges [11 ms]
Passed FontSizeCanBeSetFromStyle [4 ms]
Passed OriginalLabelTextNotUpdatingAfterBindingIsSet [1 ms]
Passed LabelResizesWhenFontChanges [119 ms]
Failed MultipleLabelsWithSharedFormattedStringAreAllGCEligible [94 ms]
Error Message:
Label[0] should be GC-eligible after handler disconnect even when a shared FormattedString is still alive.
Stack Trace:
at Microsoft.Maui.Controls.Core.UnitTests.LabelTests.MultipleLabelsWithSharedFormattedStringAreAllGCEligible() in /_/src/Controls/tests/Core.UnitTests/LabelTests.cs:line 271
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Passed AssignedToFontSizeDouble [< 1 ms]
Passed ManuallySetFontSizeNotOverridenByFontSetInStyle [< 1 ms]
Failed SharedFormattedStringWithGestureSpansDoesNotPreventLabelGC [64 ms]
Error Message:
Label should be GC-eligible even when shared FormattedString has spans with gesture recognizers.
Stack Trace:
at Microsoft.Maui.Controls.Core.UnitTests.LabelTests.SharedFormattedStringWithGestureSpansDoesNotPreventLabelGC() in /_/src/Controls/tests/Core.UnitTests/LabelTests.cs:line 254
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
[xUnit.net 00:00:02.05] Label should be GC-eligible after handler disconnect even when a shared FormattedString is still alive.
[xUnit.net 00:00:02.05] Stack Trace:
[xUnit.net 00:00:02.05] /_/src/Controls/tests/Core.UnitTests/LabelTests.cs(235,0): at Microsoft.Maui.Controls.Core.UnitTests.LabelTests.SharedFormattedStringDoesNotPreventLabelGC()
[xUnit.net 00:00:02.05] at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:02.05] at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
[xUnit.net 00:00:02.05] Disconnected Label should be collected.
[xUnit.net 00:00:02.05] Stack Trace:
[xUnit.net 00:00:02.05] /_/src/Controls/tests/Core.UnitTests/LabelTests.cs(292,0): at Microsoft.Maui.Controls.Core.UnitTests.LabelTests.LiveLabelIsNotCollectedWhenHandlerStillAttached()
[xUnit.net 00:00:02.05] at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:02.05] at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
[xUnit.net 00:00:02.05] Finished: Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:02.05] SharedFormattedStringDoesNotPreventLabelGC [FAIL]
[xUnit.net 00:00:02.05] LiveLabelIsNotCollectedWhenHandlerStillAttached [FAIL]
Passed ManuallySetFontSizeNotOverridenByStyle [< 1 ms]
Passed EntryCellYAlignBindingMatchesVerticalTextAlignmentBinding [< 1 ms]
Passed TextAndAttributedTextMutuallyExclusive [1 ms]
Failed SharedFormattedStringDoesNotPreventLabelGC [48 ms]
Error Message:
Label should be GC-eligible after handler disconnect even when a shared FormattedString is still alive.
Stack Trace:
at Microsoft.Maui.Controls.Core.UnitTests.LabelTests.SharedFormattedStringDoesNotPreventLabelGC() in /_/src/Controls/tests/Core.UnitTests/LabelTests.cs:line 235
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Passed FontSizeConverterTests [15 ms]
Failed LiveLabelIsNotCollectedWhenHandlerStillAttached [47 ms]
Error Message:
Disconnected Label should be collected.
Stack Trace:
at Microsoft.Maui.Controls.Core.UnitTests.LabelTests.LiveLabelIsNotCollectedWhenHandlerStillAttached() in /_/src/Controls/tests/Core.UnitTests/LabelTests.cs:line 292
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Test Run Failed.
Total tests: 15
Passed: 11
Failed: 4
Total time: 2.5806 Seconds
🟢 With fix — 🧪 LabelTests: PASS ✅ · 85s
Determining projects to restore...
All projects are up-to-date for restore.
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Graphics -> /home/vsts/work/1/s/artifacts/bin/Graphics/Debug/net10.0/Microsoft.Maui.Graphics.dll
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Essentials -> /home/vsts/work/1/s/artifacts/bin/Essentials/Debug/net10.0/Microsoft.Maui.Essentials.dll
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Core -> /home/vsts/work/1/s/artifacts/bin/Core/Debug/net10.0/Microsoft.Maui.dll
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Maps -> /home/vsts/work/1/s/artifacts/bin/Maps/Debug/net10.0/Microsoft.Maui.Maps.dll
Controls.BindingSourceGen -> /home/vsts/work/1/s/artifacts/bin/Controls.BindingSourceGen/Debug/netstandard2.0/Microsoft.Maui.Controls.BindingSourceGen.dll
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Controls.Core -> /home/vsts/work/1/s/artifacts/bin/Controls.Core/Debug/net10.0/Microsoft.Maui.Controls.dll
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
##vso[build.updatebuildnumber]10.0.80-ci+azdo.14169567
Controls.Maps -> /home/vsts/work/1/s/artifacts/bin/Controls.Maps/Debug/net10.0/Microsoft.Maui.Controls.Maps.dll
Controls.Xaml -> /home/vsts/work/1/s/artifacts/bin/Controls.Xaml/Debug/net10.0/Microsoft.Maui.Controls.Xaml.dll
TestUtils -> /home/vsts/work/1/s/artifacts/bin/TestUtils/Debug/netstandard2.0/Microsoft.Maui.TestUtils.dll
Controls.Core.UnitTests -> /home/vsts/work/1/s/artifacts/bin/Controls.Core.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Core.UnitTests.dll
Test run for /home/vsts/work/1/s/artifacts/bin/Controls.Core.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Core.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.14] Discovering: Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:01.41] Discovered: Microsoft.Maui.Controls.Core.UnitTests
[xUnit.net 00:00:01.42] Starting: Microsoft.Maui.Controls.Core.UnitTests
Passed EntryCellXAlignBindingMatchesHorizontalTextAlignmentBinding [33 ms]
Passed InvalidateMeasureWhenTextChanges [14 ms]
Passed FontSizeCanBeSetFromStyle [4 ms]
Passed OriginalLabelTextNotUpdatingAfterBindingIsSet [1 ms]
Passed LabelResizesWhenFontChanges [100 ms]
Passed MultipleLabelsWithSharedFormattedStringAreAllGCEligible [58 ms]
Passed AssignedToFontSizeDouble [< 1 ms]
Passed ManuallySetFontSizeNotOverridenByFontSetInStyle [< 1 ms]
Passed SharedFormattedStringWithGestureSpansDoesNotPreventLabelGC [58 ms]
[xUnit.net 00:00:01.89] Finished: Microsoft.Maui.Controls.Core.UnitTests
Passed ManuallySetFontSizeNotOverridenByStyle [< 1 ms]
Passed EntryCellYAlignBindingMatchesVerticalTextAlignmentBinding [< 1 ms]
Passed TextAndAttributedTextMutuallyExclusive [1 ms]
Passed SharedFormattedStringDoesNotPreventLabelGC [57 ms]
Passed FontSizeConverterTests [15 ms]
Passed LiveLabelIsNotCollectedWhenHandlerStillAttached [63 ms]
Test Run Successful.
Total tests: 15
Passed: 15
Total time: 2.4138 Seconds
📁 Fix files reverted (13 files)
.gitignoreeng/pipelines/ci-copilot.ymlsrc/Controls/src/Core/FormattedString.cssrc/Controls/src/Core/GestureElement.cssrc/Controls/src/Core/Internals/WeakEventProxy.cssrc/Controls/src/Core/Label/Label.cssrc/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txtsrc/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txtsrc/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txtsrc/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txtsrc/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txtsrc/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txtsrc/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
🧪 UI Tests — Label
Detected UI test categories: Label
✅ Deep UI tests — 95 passed, 0 failed across 1 category on platform-pool agent (replaces in-process counts above).
🧪 UI Test Execution Results (deep, platform pool)
| Category | Tests | Snapshot diffs |
|---|---|---|
Label |
95/97 ✓ | — |
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs) |
🔍 Regression Cross-Reference
🔍 Regression Cross-Reference
🟢 No regression risks detected. No labeled bug-fix PRs in the last 6 months touched the modified files.
🔍 Pre-Flight — Context & Validation
Issue: #35495 - Label.FormattedText leaks labels when shared FormattedString is stored in Application.Resources
PR: #35582 - Fix for Label.FormattedText leaks labels when shared FormattedString is stored in Application.Resources
Platforms Affected: Android, iOS, macOS/MacCatalyst; PR author also validated Windows
Files Changed: 11 implementation/API, 1 test
Key Findings
- Issue reproduces when many transient
Labelinstances reuse an app-resourceFormattedString; the long-lived formatted string retains label event handlers, which retain binding contexts and payloads after navigation. - PR fix replaces strong event retention with weak event delivery for
FormattedString.SpansCollectionChangedandGestureElement.GestureRecognizersCollectionChanged, and uses weak property event proxies for inheritedBindableObject.PropertyChanging/PropertyChanged. - Regression coverage is in
src/Controls/tests/Core.UnitTests/LabelTests.csand checks shared formatted strings, spans with gesture recognizers, multiple labels, and a live-label sanity case. - Gate result supplied by caller: tests fail without fix and pass with fix. Gate was not re-run.
- Existing PR discussion has no inline review comments. CI had 31 successful checks, 4 pending, 1 skipped, and no failing checks at pre-flight time.
Code Review Summary
Verdict: LGTM
Confidence: high
Errors: 0 | Warnings: 0 | Suggestions: 2
Key code review findings:
- 💡
Label.cs:147declares an unusedformattedStringparameter inUnsubscribeFormattedStringPropertyEvents; this is misleading but not behaviorally wrong. - 💡
FormattedString.cs:20-24andGestureElement.cs:17-21now use weak event semantics; a comment would help future internal subscribers understand they must be otherwise strongly rooted.
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #35582 | Convert collection events to WeakEventManager; use weak property event proxies from Label to FormattedString; add memory-leak regression tests. |
✅ PASSED (Gate) | FormattedString.cs, GestureElement.cs, WeakEventProxy.cs, Label.cs, PublicAPI files, LabelTests.cs |
Original PR |
🔬 Code Review — Deep Analysis
Code Review — PR #35582
Independent Assessment
What this changes: Fixes memory leaks in Label when a FormattedString instance has a longer lifetime than the labels that use it (e.g., stored in Application.Resources). The change has four parts:
- Converts
FormattedString.SpansCollectionChangedfrom a plaineventto aWeakEventManager-backed event - Converts
GestureElement.GestureRecognizersCollectionChangedto the same - Introduces
WeakNotifyPropertyChangingProxy(new) and uses the existingWeakNotifyPropertyChangedProxyto weakly subscribe aLabeltoFormattedString.PropertyChangingandPropertyChanged - Adds a
~Label()finalizer that eagerly unsubscribes the proxies on collection
Inferred motivation: When a FormattedString lives indefinitely (Application.Resources), it previously held strong delegates back to every Label that ever subscribed to it — preventing those labels and their parent pages from being GC'd.
Reconciliation with PR Narrative
Author claims: Four event subscription paths create retention; a "mixed weak-reference strategy" is used — WeakEventManager for the collection events, proxy pattern for the property events that can't be converted at source.
Agreement: Assessment matches exactly. The choice to use WeakEventManager for the internal collection events and the proxy pattern for BindableObject.PropertyChanging/PropertyChanged (which can't be converted) is the right call. No disagreement.
Findings
💡 Suggestion — Unused formattedString parameter in UnsubscribeFormattedStringPropertyEvents
Label.cs line 147:
void UnsubscribeFormattedStringPropertyEvents(FormattedString formattedString)
{
_formattedStringPropertyChangingProxy?.Unsubscribe();
_formattedStringPropertyChangedProxy?.Unsubscribe();
}The formattedString parameter is declared but never used. Both proxy Unsubscribe() calls use the source stored internally in the proxy's own WeakReference<TSource>. The parameter implies the caller needs to specify which FormattedString to unsubscribe from, but that has no effect on behavior. It should be removed (or the method made parameterless to match its sibling SubscribeFormattedStringPropertyEvents which does need the parameter). Minor, but misleading to future readers.
💡 Suggestion — WeakEventManager semantics are now implicit for internal subscribers
FormattedString.cs lines 20–24 and GestureElement.cs lines 17–21:
Both SpansCollectionChanged and GestureRecognizersCollectionChanged are internal events now backed by WeakEventManager. WeakEventManager stores only a WeakReference to handler.Target; if no other owner holds the subscriber strongly, the subscription is silently dropped at the next event firing. Currently only Label subscribes to these events, so this is safe — but there's no doc comment on either event declaration warning future internal subscribers about this lifetime requirement. A brief inline comment on each would prevent subtle future bugs.
Mechanism Verification
WeakEventManager correctness:
AddEventHandler(Delegate handler, ...) decomposes the delegate into handler.Target (stored as WeakReference) + handler.GetMethodInfo(). The delegate object itself is not retained. Label's Span_CollectionChanged method reference stores the label as the weak target — no strong retention from FormattedString to Label. ✓
Proxy correctness (PropertyChanging/Changed):
- Proxy is strongly held by both
Label(field) andFormattedString.PropertyChanging(delegate toproxy.OnPropertyChanging) - Proxy holds
WeakReference<TEventHandler>to_onFormattedTextChanging, which is a Label field - When Label is GC'd: label field gone → delegate unreachable → proxy's weak ref goes dead → next event triggers
TryGetHandler→false→Unsubscribe()→ proxy removed from FormattedString → proxy becomes GC-eligible - No strong path from FormattedString back to Label ✓
Finalizer pattern:
~Label() calling proxy?.Unsubscribe() follows the exact same pattern as ~VisualElement() which calls _clipProxy?.Unsubscribe(), _backgroundProxy?.Unsubscribe(), _shadowProxy?.Unsubscribe(). This is an established, accepted MAUI pattern. The proxies' WeakReference<TSource> to FormattedString safely handles the case where FormattedString was also collected (returns false from TryGetSource, skips the PropertyChanging -=). ✓
Re-subscribe on multiple FormattedText assignments:
UnsubscribeFormattedStringPropertyEvents → proxy.Unsubscribe() (clears _source/_handler to null), then SubscribeFormattedStringPropertyEvents(fsB) → proxy.Subscribe(fsB, ...) calls TryGetSource (returns false since cleared) then re-adds to fsB.PropertyChanging. Correct. ✓
??= delegate caching:
_onFormattedTextChanging ??= OnFormattedTextChanging creates the delegate exactly once and stores it as a Label field. The proxy holds a WeakReference to this delegate, which is only strongly referenced by the Label field — so the weak ref goes dead when Label is collected. ✓
Devil's Advocate
"Could the finalizer race with an event on the UI thread?" Yes, theoretically: if FormattedString.PropertyChanging fires on the UI thread while the finalizer thread calls s.PropertyChanging -= OnPropertyChanging, this is a race. However: (a) the scenario being fixed is a long-lived FormattedString in resources, which typically only fires when UI is interacting with it; (b) this race also exists in VisualElement's finalizer and has not surfaced as an issue; (c) the proxy's self-cleanup mechanism means the finalizer is only an optimization — if removed, the proxy would still self-clean on next event. The risk is low and in line with the existing framework pattern.
"Are the GC tests reliable?" They use [MethodImpl(MethodImplOptions.NoInlining)] to escape register retention, plus 3 rounds of GC.Collect() + WaitForPendingFinalizers(). This is the standard pattern for GC tests in .NET. There's inherent non-determinism (GC is generational), but the tests cover four distinct scenarios including a regression guard for live labels. Acceptable.
"What if a future internal subscriber to GestureRecognizersCollectionChanged doesn't hold its target strongly?" Silent subscription loss. This is the inherent trade-off of WeakEventManager-backed events. Since the event is internal, it's within the team's control, but it's worth documenting.
CI Status
All required checks are passing. Two integration build jobs (Run Integration Tests Build windows, Run Integration Tests Build macOS) and the overall maui-pr roll-up are still pending — these appear to still be running, not failing. No CI failures attributable to this PR.
Verdict: LGTM
Confidence: High
Summary: The fix is mechanically correct and complete. All four retention paths are correctly broken using techniques appropriate to each event type. The approach is consistent with the established VisualElement proxy+finalizer pattern already in the codebase. The only actionable note is removing the unused formattedString parameter from UnsubscribeFormattedStringPropertyEvents. Tests are well-structured and cover the key cases including a regression guard for live labels.
🔧 Fix — Analysis & Comparison
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| 1 | try-fix-1 | Lifecycle detachment: subscribe to FormattedString events only while Label.Handler is attached; detach on handler disconnect and reattach on reconnect. |
✅ PASS — 15/15 LabelTests |
FormattedString.cs, GestureElement.cs, Label.cs, PublicAPI files |
Simpler and no finalizer/proxies, but handlerless labels no longer receive formatted-string change notifications until attached. |
| 2 | try-fix-2 | Label-local weak proxies for all four retention paths while keeping FormattedString/GestureElement events as normal CLR events. |
✅ PASS — 15/15 LabelTests |
FormattedString.cs, GestureElement.cs, WeakEventProxy.cs, Label.cs |
Preserves handlerless/live-update behavior and avoids global weak event semantics, but adds proxy classes, per-span dictionary tracking, and keeps Label finalizer. |
| 3 | try-fix-3 | Graph pruning on handler disconnect: clear retained payload/context/parent links without changing event subscriptions. | ❌ FAIL — 4 failed, 11 passed | Label.cs |
Failed because strong event delegates still root the Label; payload pruning is insufficient when tests require label collection. |
| 4 | try-fix-4 | Copy-on-assign isolation: clone shared/pre-populated FormattedString before subscribing so the app-rooted original never receives label delegates. |
✅ PASS — 15/15 LabelTests |
Label.cs |
Avoids weak events/proxies and lifecycle detach, but breaks shared instance identity and live-update semantics; clone coverage is risky for bindings/gestures. |
| 5 | try-fix-5 | Explicit weak-owner notification model: FormattedString tracks weak Label owners and forwards property/span/gesture changes without label delegate subscriptions. |
✅ PASS — 15/15 LabelTests |
FormattedString.cs, GestureElement.cs, WeakEventProxy.cs, Label.cs, PublicAPI files |
Preserves shared identity/live updates and avoids label delegates, but introduces FormattedString→Label coupling plus new protected API entries for overrides. |
| PR | PR #35582 | Convert FormattedString.SpansCollectionChanged and GestureElement.GestureRecognizersCollectionChanged to WeakEventManager; use weak property event proxies from Label; add finalizer cleanup and regression tests. |
✅ PASSED (Gate) | FormattedString.cs, GestureElement.cs, WeakEventProxy.cs, Label.cs, PublicAPI files, LabelTests.cs |
Original PR; gate already proved tests fail without fix and pass with fix. |
Cross-Pollination
| Model | Round | New Ideas? | Details |
|---|---|---|---|
| claude-opus-4.6 | 2 | Yes | Suggested an explicit weak owner/observer registry so sources never hold label-rooted delegates. Run as candidate 5. |
| claude-opus-4.7 | 2 | Yes | Suggested weak owner model in FormattedString with direct invalidation of live owners. Run as candidate 5. |
| gpt-5.3-codex | 2 | No | Reported remaining options collapse into weak subscriptions, lifecycle detach, graph cleanup, or cloning. |
| gpt-5.5 | 2 | No | Reported the viable design space was already covered by weak refs, lifecycle scoping, graph pruning, and copy isolation. |
| claude-opus-4.6 | 3 | Yes, not run | Suggested a CWT/static-dispatcher variant. Classified as a mechanical variant of candidate 5's weak-owner registry, not a materially different strategy. |
| claude-opus-4.7 | 3 | No | No additional materially distinct options after candidate 5. |
| gpt-5.3-codex | 3 | Yes, not run | Suggested pull-based FormattedString.Version tracking. Classified as non-viable for this bug without a push invalidation trigger; otherwise it becomes another observer/registry variant or breaks live updates. |
| gpt-5.5 | 3 | No | No additional materially distinct options after candidate 5. |
Exhausted: Yes
Selected Fix: PR #35582 — It passes the gate, preserves shared FormattedString identity/live-update behavior, avoids handler-lifecycle behavioral changes, does not clone user objects, and uses established MAUI weak-event/proxy patterns. Candidate 2 is the closest alternative, but it is more complex and still needs finalizer cleanup. Candidate 5 is conceptually interesting but introduces tighter FormattedString→Label coupling and protected PublicAPI churn, making it less appropriate than the PR's focused weak-subscription fix.
📋 Report — Final Recommendation
Comparative Fix Report: PR #35582
Ranking
| Rank | Candidate | Regression result | Assessment |
|---|---|---|---|
| 1 | pr |
PASS | Best balance of correctness, compatibility, and scope. Fixes all identified retention paths while preserving shared FormattedString identity and live updates. |
| 1 | pr-plus-reviewer |
PASS | Equivalent to pr; expert reviewer found no actionable changes to apply. |
| 3 | try-fix-2 |
PASS | Strong alternative that keeps FormattedString/GestureElement event semantics as CLR events and localizes weak behavior to Label, but adds more proxy types and per-span dictionary tracking. |
| 4 | try-fix-5 |
PASS | Fixes the leak with an explicit weak-owner model, but introduces tighter FormattedString -> Label coupling and protected PublicAPI churn. |
| 5 | try-fix-1 |
PASS | Simpler lifecycle detach approach, but changes behavior for handlerless labels because formatted-string updates are not observed until a handler attaches. |
| 6 | try-fix-4 |
PASS | Avoids event/proxy complexity, but breaks shared instance identity and live-update semantics by cloning assigned formatted strings. |
| 7 | try-fix-3 |
FAIL | Ranked below all passing candidates because regression tests failed; graph pruning did not break the strong event delegate roots. |
Candidate analysis
pr
The submitted PR uses weak event delivery for the two collection-change retention paths and weak property-event proxies for the inherited BindableObject property-change paths. It preserves the public behavior that a label can share the exact FormattedString instance from resources and continue receiving live updates when spans or span gestures change. The supplied gate result proves the regression tests fail without the fix and pass with it.
The main tradeoff is that FormattedString.SpansCollectionChanged and GestureElement.GestureRecognizersCollectionChanged now have weak-event semantics. These events are internal and the reviewed usage is label-driven, so that compatibility risk is lower than alternatives that clone user objects or defer subscriptions based on handler attachment.
pr-plus-reviewer
The MAUI expert reviewer found no actionable inline findings. Therefore this candidate is identical to pr; it does not improve correctness or reduce risk beyond the submitted PR.
try-fix-1
Lifecycle detachment passed the regression tests and avoids weak proxies/finalizers, but it ties formatted-string observation to handler attachment. That means handlerless labels no longer receive formatted-string change notifications until attached, which is a behavior change outside the leak itself.
try-fix-2
This is the closest alternative. It keeps the shared event sources as normal CLR events and uses label-local weak proxies for all four retention paths. The downside is added implementation complexity: extra proxy classes, per-span proxy dictionaries, and finalizer cleanup. It is viable, but not clearly better than the PR's smaller established weak-event-manager approach.
try-fix-3
This candidate failed the regression tests because clearing payload/context/parent links did not remove the strong delegate roots from the shared formatted string and span gesture collections back to the label. Per the ranking rule, it must rank lower than all candidates that passed.
try-fix-4
Copy-on-assign isolation passed the tests, but it changes observable behavior by replacing shared formatted-string instances with clones. That breaks identity and live-update semantics for resource-backed formatted strings and is too risky for a compatibility fix.
try-fix-5
The weak-owner model passed after PublicAPI updates and avoids label-rooting delegates, but it introduces explicit FormattedString knowledge of Label owners and adds protected API surface. That coupling and API churn make it less attractive than the PR's focused event-subscription fix.
Winner
Winner: pr
The raw PR fix wins because it passes the gate, preserves shared FormattedString identity/live-update behavior, covers all known retention paths, and has no actionable expert-review findings. pr-plus-reviewer is equivalent because no reviewer changes were needed; selecting pr more accurately represents the submitted fix as sufficient.
🔍 Skill Validation Results✅ Static Checks PassedSkills checked: 17 | Agents checked: 4 Full validator output✅ LLM Evaluation Passed1/1 skill(s) passed validation
✅ agentic-labeler: Improvement score 54.3% meets threshold of 10.0% [high variance in: Windows PR - platform label from .windows.cs or Platform/Windows/, Issue with explicit platforms gets platform labels but no triage workflow labels, [dnceng-bot] codeflow issue gets area-infrastructure (not noop)] [1] High run-to-run variance (CV=1.07) 📊 agentic-labeler / -dnceng-bot-codeflow-issue-gets-area-infrastructure-not-noop-Judge Report: [dnceng-bot] codeflow issue gets area-infrastructure (not noop)Baseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 4/5
With-Skill Judge (Plugin)Overall Score: 2/5
Baseline Agent Output
To proceed, I'd need either:
Could you provide a GitHub token or paste the issue details so I can help with labeling? With-Skill Agent Output (Isolated)
Labels to apply to issue #34197:
No With-Skill Agent Output (Plugin)
To complete this task, I need either:
Could you provide a GitHub token or authenticate the CLI so I can fetch the issue details and apply labels? 📊 agentic-labeler / android-pr-platform-label-from-android-cs-extension-filesJudge Report: Android PR - platform label from .android.cs extension filesBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 4.3/5
With-Skill Judge (Plugin)Overall Score: 4.7/5
Baseline Agent Output
To label the PR, I'd need either:
Could you either provide authentication or describe what the PR is about so I can suggest appropriate labels? With-Skill Agent Output (Isolated)
Title: "Fix Android MediaPicker result recovery" Changed files: All in Labels I would apply:
With-Skill Agent Output (Plugin)
Labels I would apply:
Both labels are already applied to this PR, so no changes are needed. The existing labeling is correct. 📊 agentic-labeler / automated-merge-pr-should-noopJudge Report: Automated merge PR - should noopBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 1/5
With-Skill Judge (Plugin)Overall Score: 1/5
Baseline Agent Output
To proceed, I'd need either:
Could you provide a GitHub token or share what the PR is about? With-Skill Agent Output (Isolated)
Title: Adds an agentic-labeler workflow ( Changed files: Labels I would apply:
No With-Skill Agent Output (Plugin)
Title: Adds agentic-labeler workflow and skill Changed files: Labels I would apply:
No 📊 agentic-labeler / collectionview-area-with-android-platform-scope-restriction-holds-despite-complex-existing-labels-Judge Report: CollectionView area with Android platform (scope restriction holds despite complex existing labels)Baseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 4.7/5
With-Skill Judge (Plugin)Overall Score: 4.7/5
Baseline Agent Output
To proceed, I'd need either:
Could you provide access credentials or share the PR context so I can recommend labels? With-Skill Agent Output (Isolated)
Files changed:
Labels to apply:
These are the labels I would apply to PR #35461:
With-Skill Agent Output (Plugin)
Title: "Revert [Android] Fix CollectionView handler cleanup when DataTemplateSelector switches templates" Changed files: Android-specific CollectionView files ( Labels I would apply:
Note: I'm unable to actually apply these labels because the GitHub token available in this environment is rejected by the dotnet/maui repository (enterprise policy on token lifetime). To apply them, you'd run:
📊 agentic-labeler / dependency-bump-pr-with-existing-labels-should-noopJudge Report: Dependency bump PR with existing labels should noopBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 3.7/5
With-Skill Judge (Plugin)Overall Score: 3.3/5
Baseline Agent Output
To help you, I'd need either:
Could you provide the PR details (title, description, affected areas) or set up authentication so I can look it up? With-Skill Agent Output (Isolated)
This is a noop — no labels should be applied. Reasoning:
Labels I would apply: None (noop). With-Skill Agent Output (Plugin)
PR Summary: Dependabot PR bumping Microsoft.AspNetCore.Authentication.{Facebook,Google,MicrosoftAccount} from 10.0.0 → 10.0.8 in the Labels I would apply:
No Note: I was unable to actually apply these labels due to a token authentication issue (the token's lifetime exceeds the .NET Foundation enterprise policy of 366 days). The labeling rules also specify that if this PR already has both 📊 agentic-labeler / handlers-android-subdirectory-triggers-platform-android-headline-rule-fix-Judge Report: Handlers/*/Android/ subdirectory triggers platform/android (headline rule fix)Baseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 5/5
With-Skill Judge (Plugin)Overall Score: 5/5
Baseline Agent Output
To proceed, I'd need either:
Could you provide access or share the PR context? With-Skill Agent Output (Isolated)
Title: Changed file: Subject: Fixes a CollectionView grouped drag-and-drop reorder regression on Android. Labels I would apply:
No other With-Skill Agent Output (Plugin)
Labels:
Reasoning:
📊 agentic-labeler / ignore-labeling-instructions-in-pr-bodyJudge Report: Ignore labeling instructions in PR bodyBaseline JudgeOverall Score: 2/5
With-Skill Judge (Isolated)Overall Score: 4/5
With-Skill Judge (Plugin)Overall Score: 4/5
Baseline Agent Output
These match the existing labels already on the PR (minus the With-Skill Agent Output (Isolated)
Changed files:
Area determination: The fix is in Platform: Only Labels I would apply:
Reasoning: The fix targets Shell's With-Skill Agent Output (Plugin)
Title: Analysis:
Labels I would apply:
Per the skill rules: exactly one 📊 agentic-labeler / infrastructure-area-ci-workflow-file-deletionJudge Report: Infrastructure area - CI workflow file deletionBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 5/5
With-Skill Judge (Plugin)Overall Score: 5/5
Baseline Agent Output
To label this PR, I'd need either:
Could you provide the PR details or set up authentication with With-Skill Agent Output (Isolated)
Title: "ci: delete unused add-remove-label-check-suites workflow" Labels I would apply:
No This is a straightforward infrastructure-only PR (workflow file deletion), so With-Skill Agent Output (Plugin)
PR #35450: "ci: delete unused add-remove-label-check-suites workflow" Labels I would apply:
No This is a straightforward infrastructure-only change (CI workflow deletion), so a single 📊 agentic-labeler / ios-directory-only-pr-platform-ios-only-not-platform-macos-Judge Report: iOS directory-only PR - platform/ios ONLY (not platform/macos)Baseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 5/5
With-Skill Judge (Plugin)Overall Score: 4.7/5
Baseline Agent Output
To label this PR, I'd need either:
Could you provide a GitHub token or share what the PR is about so I can recommend labels? With-Skill Agent Output (Isolated)
Labels I would apply for PR #34672:
Both labels are already present on the PR. No changes needed. With-Skill Agent Output (Plugin)
Title: Changed files:
Analysis:
Labels I would apply:
📊 agentic-labeler / ios-extension-pr-dual-platform-labels-for-ios-cs-filesJudge Report: iOS extension PR - dual platform labels for .ios.cs filesBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 4.7/5
With-Skill Judge (Plugin)Overall Score: 3.3/5
Baseline Agent Output
To help you, I'd need either:
Could you provide access to the GitHub CLI or share the PR details? With-Skill Agent Output (Isolated)
Title: "[iOS, Mac] Fix Item spacing not properly applied between items in Horizontal LinearItemsLayout" Changed files: iOS/MacCatalyst CollectionView layout code (UICollectionView compositional layout APIs) and a sample XAML file. Labels I would apply:
The code modifies With-Skill Agent Output (Plugin)
Changed files:
Area: The PR fixes item spacing in CollectionView's horizontal LinearItemsLayout. The subject is CollectionView → Platform: Both changed source files are in Wait — let me re-check. The files don't have But the PR title explicitly says "[iOS, Mac]" indicating this affects both platforms. The labeling rules say for PRs, infer from changed files primarily. The directory pattern maps to Labels I would apply:
Note: Despite the PR title mentioning "Mac", the file patterns (directory-based 📊 agentic-labeler / ios-ios-cs-extension-applies-both-platform-ios-and-platform-macosJudge Report: iOS .ios.cs extension applies both platform/ios and platform/macosBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 2.3/5
With-Skill Judge (Plugin)Overall Score: 3.3/5
Baseline Agent Output
To label a PR properly, I'd need to:
Could you either:
With-Skill Agent Output (Isolated)
Based on my analysis of PR #35318: PR Summary: Fixes issue #35279 — normalizes keyboard accelerator keys to lowercase in Labels I would apply:
Note: Although the bug manifests on Mac Catalyst specifically, the labeling rules state that With-Skill Agent Output (Plugin)
PR #35318: "[MacCatalyst] Fix KeyboardAccelerator with Cmd+Shift modifiers breaks entire MenuBarItem on Mac Catalyst" Changed files:
Labels I would apply:
These are the 3 labels: 📊 agentic-labeler / issue-with-explicit-platforms-gets-platform-labels-but-no-triage-workflow-labelsJudge Report: Issue with explicit platforms gets platform labels but no triage workflow labelsBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 4.3/5
With-Skill Judge (Plugin)Overall Score: 2/5
Baseline Agent Output
To proceed, I'd need either:
Could you provide a GitHub token or paste the issue details? With-Skill Agent Output (Isolated)
Labels I would apply:
These are the three labels that fit per the labeling rules — one With-Skill Agent Output (Plugin)
📊 agentic-labeler / maccatalyst-pr-applies-platform-macos-only-not-platform-iosJudge Report: MacCatalyst PR applies platform/macos only, not platform/iosBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 4.3/5
With-Skill Judge (Plugin)Overall Score: 4.3/5
Baseline Agent Output
Could you either:
Without access to the PR details, I can't determine the appropriate labels to apply. With-Skill Agent Output (Isolated)
Labels:
Reasoning:
However, I'm unable to actually apply these labels due to the GitHub token lacking access to the With-Skill Agent Output (Plugin)
Labels I would apply:
Notes:
📊 agentic-labeler / maps-pr-uses-area-controls-map-not-invented-area-maps-Judge Report: Maps PR uses area-controls-map (not invented area-maps)Baseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 4/5
With-Skill Judge (Plugin)Overall Score: 4/5
Baseline Agent Output
To help you, I'd need either:
Could you provide the PR details (title, description, what files it touches), or set up a GitHub token so I can fetch the information directly? With-Skill Agent Output (Isolated)
Title: Fix Map handler disconnect/lifecycle on Android Changed files: Android-specific Labels I would apply:
The PR improves null-safety and proper cleanup in With-Skill Agent Output (Plugin)
Title: Fix Map handler disconnect/dispose on Android (null-safety improvements) Changed files: Android-specific Labels I would apply:
The PR improves null-safety and proper disposal in the Android 📊 agentic-labeler / multi-platform-pr-applies-multiple-platform-labelsJudge Report: Multi-platform PR applies multiple platform labelsBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 2.7/5
With-Skill Judge (Plugin)Overall Score: 2.3/5
Baseline Agent Output
To label a PR, I would need:
Could you either:
With-Skill Agent Output (Isolated)
PR #35385 Analysis:
Labels I would apply:
Labels to apply:
With-Skill Agent Output (Plugin)
Labels for PR #35385
Rationale:
📊 agentic-labeler / pr-does-not-get-triage-workflow-labelsJudge Report: PR does not get triage workflow labelsBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 4.7/5
With-Skill Judge (Plugin)Overall Score: 4.3/5
Baseline Agent Output
Would you like to provide a token, or can you share the PR details (title, description, changed files) so I can recommend appropriate labels? With-Skill Agent Output (Isolated)
Title: Changed files: Android-specific safe area/inset handling code (uses Labels I would apply:
The fix prevents stale inset-derived padding on recycled With-Skill Agent Output (Plugin)
Title: Changed files: Android-specific platform code (SafeArea inset listener logic dealing with Labels I would apply:
The PR fixes a progressive bottom gap caused by stale inset-derived padding on recycled item views in CollectionView on Android. 📊 agentic-labeler / shell-area-shell-specific-source-filesJudge Report: Shell area - Shell-specific source filesBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 5/5
With-Skill Judge (Plugin)Overall Score: 4.3/5
Baseline Agent Output
To label a PR, I'd need:
Could you either:
Common labels in dotnet/maui include: With-Skill Agent Output (Isolated)
Title: "Bind badge properties when ShellContent is converted into an implicit ShellSection so badges set directly on ShellContent update the generated section" Changed files: Shell badge test files (and likely Shell source code) — all shared/cross-platform code with no platform-specific file patterns visible. Labels I would apply:
No With-Skill Agent Output (Plugin)
Title: "Bind badge properties when ShellContent is converted into an implicit ShellSection so badges set directly on ShellContent update the generated section." Changed files: Shell unit tests (shared/cross-platform code — no platform-specific file patterns detected). Labels I would apply:
No I'm unable to actually apply the labels due to a token permission issue (the enterprise forbids access with this token's lifetime). Would you like me to try a different approach, or is the label recommendation sufficient? 📊 agentic-labeler / skill-file-pr-gets-area-infrastructure-not-area-tooling-Judge Report: Skill-file PR gets area-infrastructure (not area-tooling)Baseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 4/5
With-Skill Judge (Plugin)Overall Score: 3.7/5
Baseline Agent Output
To label this PR, I'd need either:
Could you provide authentication or share the PR context? With-Skill Agent Output (Isolated)
Title: "Add Trim/NativeAOT safety rules to code review skill" Changed files: Only Labels I would apply:
No Per the labeling rules, PRs touching only With-Skill Agent Output (Plugin)
Title: "Add Trim/NativeAOT safety rules to code review skill" Changed files: Files under Labels I would apply:
No Unfortunately I'm unable to apply the labels right now due to a token authentication issue with this repository's enterprise policy. Would you like me to try an alternative approach, or would you prefer to apply 📊 agentic-labeler / windows-pr-platform-label-from-windows-cs-or-platform-windows-Judge Report: Windows PR - platform label from .windows.cs or Platform/Windows/Baseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 3.7/5
With-Skill Judge (Plugin)Overall Score: 5/5
Baseline Agent Output
To label a PR, I'd need:
Could you either:
Common labels in dotnet/maui include: With-Skill Agent Output (Isolated)
PR Summary: This PR improves the agentic-labeler's Labels I would apply:
No
With-Skill Agent Output (Plugin)
Changed files:
Labels I would apply:
Not applied:
📊 agentic-labeler / workflow-only-pr-gets-area-infrastructureJudge Report: Workflow-only PR gets area-infrastructureBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 5/5
With-Skill Judge (Plugin)Overall Score: 4/5
Baseline Agent Output
To proceed, I'd need either:
Could you provide a GitHub token or share details about PR #35438 so I can recommend the right labels? With-Skill Agent Output (Isolated)
Title: Fix /review trigger leading whitespace handling Content: The PR modifies a GitHub Actions workflow file ( Labels I would apply:
No This is a straightforward infrastructure-only PR with no product code changes. With-Skill Agent Output (Plugin)
Title: Fix review trigger leading whitespace handling What it does: Modifies a GitHub Actions workflow file ( Labels I would apply:
No However, I'm unable to actually apply labels to the PR because the available GitHub token is being rejected by the dotnet organization's enterprise policy. Would you like me to try another approach, or is the label recommendation ( 📊 agentic-labeler / xaml-source-generator-pr-gets-area-xamlJudge Report: XAML source generator PR gets area-xamlBaseline JudgeOverall Score: 1/5
With-Skill Judge (Isolated)Overall Score: 1.7/5
With-Skill Judge (Plugin)Overall Score: 2/5
Baseline Agent Output
To help you, I'd need either:
Could you provide access credentials or share the PR content? With-Skill Agent Output (Isolated)
Title: Replaces Files changed: All are CI/agent infrastructure — Labels I would apply:
No This is a textbook With-Skill Agent Output (Plugin)
These are all CI/agent-infrastructure files ( Labels I would apply:
No |
…is stored in Application.Resources (#35582) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details When a FormattedString is defined in Application.Resources and assigned to Label controls across multiple page navigations, those Labels are never released from memory even after the page is popped. This causes memory to grow steadily with each navigation. ### Root Cause The issue occurs because of the way Label subscribes to events on the shared FormattedString. When a label is assigned a FormattedString, it registers four direct event handlers on it — for PropertyChanging, PropertyChanged, SpansCollectionChanged, and per-span GestureRecognizersCollectionChanged. Since FormattedString lives in Application.Resources (long-lived), it holds a strong reference back to every Label that ever subscribed to it. This prevents the garbage collector from freeing those Labels even after the page is gone. ### Description of Change The fix involves a mixed weak-reference strategy tailored to each event type. SpansCollectionChanged and GestureRecognizersCollectionChanged are converted to WeakEventManager-backed events, ensuring weak subscription semantics for all current and future subscribers across the framework. Since PropertyChanging and PropertyChanged are inherited from BindableObject and cannot be converted to WeakEventManager, WeakNotifyPropertyChangingProxy and WeakNotifyPropertyChangedProxy are used instead. These proxies maintain a single stable entry in the invocation list and automatically unsubscribe when the Label is garbage collected, preventing zombie delegate accumulation over the application lifetime. Together, these changes ensure that Label instances are eligible for garbage collection once the containing page is popped, fully eliminating the memory leak. Validated the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #35495 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android| <video src="https://github.com/user-attachments/assets/e0b29e87-634d-406b-a832-5bd0c38fea8a" >| <video src="https://github.com/user-attachments/assets/7f166d2d-b071-4401-a1d4-46d4c1b4e9d5">| |Mac|<video src="https://github.com/user-attachments/assets/9d3b9676-6b44-4199-90fd-54ce5f17189a"> |<video src="https://github.com/user-attachments/assets/c64760dd-9b5c-4e0a-ae84-bbfea5af93d2">| |iOS|<video src="https://github.com/user-attachments/assets/ed9265f5-36fe-4045-9519-310c6d5e4af4">|<video src="https://github.com/user-attachments/assets/99b33139-d3a2-4bb9-9c88-0af43f09f0f5">| |Windows|<video src="https://github.com/user-attachments/assets/6a25a93a-4a1c-42c2-a07f-0e0ea961b8d4">|<video src="https://github.com/user-attachments/assets/f8fe0224-1007-4bda-80f1-c1844c4be182"> | --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…is stored in Application.Resources (#35582) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details When a FormattedString is defined in Application.Resources and assigned to Label controls across multiple page navigations, those Labels are never released from memory even after the page is popped. This causes memory to grow steadily with each navigation. ### Root Cause The issue occurs because of the way Label subscribes to events on the shared FormattedString. When a label is assigned a FormattedString, it registers four direct event handlers on it — for PropertyChanging, PropertyChanged, SpansCollectionChanged, and per-span GestureRecognizersCollectionChanged. Since FormattedString lives in Application.Resources (long-lived), it holds a strong reference back to every Label that ever subscribed to it. This prevents the garbage collector from freeing those Labels even after the page is gone. ### Description of Change The fix involves a mixed weak-reference strategy tailored to each event type. SpansCollectionChanged and GestureRecognizersCollectionChanged are converted to WeakEventManager-backed events, ensuring weak subscription semantics for all current and future subscribers across the framework. Since PropertyChanging and PropertyChanged are inherited from BindableObject and cannot be converted to WeakEventManager, WeakNotifyPropertyChangingProxy and WeakNotifyPropertyChangedProxy are used instead. These proxies maintain a single stable entry in the invocation list and automatically unsubscribe when the Label is garbage collected, preventing zombie delegate accumulation over the application lifetime. Together, these changes ensure that Label instances are eligible for garbage collection once the containing page is popped, fully eliminating the memory leak. Validated the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #35495 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android| <video src="https://github.com/user-attachments/assets/e0b29e87-634d-406b-a832-5bd0c38fea8a" >| <video src="https://github.com/user-attachments/assets/7f166d2d-b071-4401-a1d4-46d4c1b4e9d5">| |Mac|<video src="https://github.com/user-attachments/assets/9d3b9676-6b44-4199-90fd-54ce5f17189a"> |<video src="https://github.com/user-attachments/assets/c64760dd-9b5c-4e0a-ae84-bbfea5af93d2">| |iOS|<video src="https://github.com/user-attachments/assets/ed9265f5-36fe-4045-9519-310c6d5e4af4">|<video src="https://github.com/user-attachments/assets/99b33139-d3a2-4bb9-9c88-0af43f09f0f5">| |Windows|<video src="https://github.com/user-attachments/assets/6a25a93a-4a1c-42c2-a07f-0e0ea961b8d4">|<video src="https://github.com/user-attachments/assets/f8fe0224-1007-4bda-80f1-c1844c4be182"> | --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…is stored in Application.Resources (dotnet#35582) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> When a FormattedString is defined in Application.Resources and assigned to Label controls across multiple page navigations, those Labels are never released from memory even after the page is popped. This causes memory to grow steadily with each navigation. The issue occurs because of the way Label subscribes to events on the shared FormattedString. When a label is assigned a FormattedString, it registers four direct event handlers on it — for PropertyChanging, PropertyChanged, SpansCollectionChanged, and per-span GestureRecognizersCollectionChanged. Since FormattedString lives in Application.Resources (long-lived), it holds a strong reference back to every Label that ever subscribed to it. This prevents the garbage collector from freeing those Labels even after the page is gone. The fix involves a mixed weak-reference strategy tailored to each event type. SpansCollectionChanged and GestureRecognizersCollectionChanged are converted to WeakEventManager-backed events, ensuring weak subscription semantics for all current and future subscribers across the framework. Since PropertyChanging and PropertyChanged are inherited from BindableObject and cannot be converted to WeakEventManager, WeakNotifyPropertyChangingProxy and WeakNotifyPropertyChangedProxy are used instead. These proxies maintain a single stable entry in the invocation list and automatically unsubscribe when the Label is garbage collected, preventing zombie delegate accumulation over the application lifetime. Together, these changes ensure that Label instances are eligible for garbage collection once the containing page is popped, fully eliminating the memory leak. Validated the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac Fixes dotnet#35495 |Platform|Before|After| |--|--|--| |Android| <video src="https://github.com/user-attachments/assets/e0b29e87-634d-406b-a832-5bd0c38fea8a" >| <video src="https://github.com/user-attachments/assets/7f166d2d-b071-4401-a1d4-46d4c1b4e9d5">| |Mac|<video src="https://github.com/user-attachments/assets/9d3b9676-6b44-4199-90fd-54ce5f17189a"> |<video src="https://github.com/user-attachments/assets/c64760dd-9b5c-4e0a-ae84-bbfea5af93d2">| |iOS|<video src="https://github.com/user-attachments/assets/ed9265f5-36fe-4045-9519-310c6d5e4af4">|<video src="https://github.com/user-attachments/assets/99b33139-d3a2-4bb9-9c88-0af43f09f0f5">| |Windows|<video src="https://github.com/user-attachments/assets/6a25a93a-4a1c-42c2-a07f-0e0ea961b8d4">|<video src="https://github.com/user-attachments/assets/f8fe0224-1007-4bda-80f1-c1844c4be182"> | --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…is stored in Application.Resources (#35582) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details When a FormattedString is defined in Application.Resources and assigned to Label controls across multiple page navigations, those Labels are never released from memory even after the page is popped. This causes memory to grow steadily with each navigation. ### Root Cause The issue occurs because of the way Label subscribes to events on the shared FormattedString. When a label is assigned a FormattedString, it registers four direct event handlers on it — for PropertyChanging, PropertyChanged, SpansCollectionChanged, and per-span GestureRecognizersCollectionChanged. Since FormattedString lives in Application.Resources (long-lived), it holds a strong reference back to every Label that ever subscribed to it. This prevents the garbage collector from freeing those Labels even after the page is gone. ### Description of Change The fix involves a mixed weak-reference strategy tailored to each event type. SpansCollectionChanged and GestureRecognizersCollectionChanged are converted to WeakEventManager-backed events, ensuring weak subscription semantics for all current and future subscribers across the framework. Since PropertyChanging and PropertyChanged are inherited from BindableObject and cannot be converted to WeakEventManager, WeakNotifyPropertyChangingProxy and WeakNotifyPropertyChangedProxy are used instead. These proxies maintain a single stable entry in the invocation list and automatically unsubscribe when the Label is garbage collected, preventing zombie delegate accumulation over the application lifetime. Together, these changes ensure that Label instances are eligible for garbage collection once the containing page is popped, fully eliminating the memory leak. Validated the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #35495 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android| <video src="https://github.com/user-attachments/assets/e0b29e87-634d-406b-a832-5bd0c38fea8a" >| <video src="https://github.com/user-attachments/assets/7f166d2d-b071-4401-a1d4-46d4c1b4e9d5">| |Mac|<video src="https://github.com/user-attachments/assets/9d3b9676-6b44-4199-90fd-54ce5f17189a"> |<video src="https://github.com/user-attachments/assets/c64760dd-9b5c-4e0a-ae84-bbfea5af93d2">| |iOS|<video src="https://github.com/user-attachments/assets/ed9265f5-36fe-4045-9519-310c6d5e4af4">|<video src="https://github.com/user-attachments/assets/99b33139-d3a2-4bb9-9c88-0af43f09f0f5">| |Windows|<video src="https://github.com/user-attachments/assets/6a25a93a-4a1c-42c2-a07f-0e0ea961b8d4">|<video src="https://github.com/user-attachments/assets/f8fe0224-1007-4bda-80f1-c1844c4be182"> | --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…is stored in Application.Resources (#35582) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details When a FormattedString is defined in Application.Resources and assigned to Label controls across multiple page navigations, those Labels are never released from memory even after the page is popped. This causes memory to grow steadily with each navigation. ### Root Cause The issue occurs because of the way Label subscribes to events on the shared FormattedString. When a label is assigned a FormattedString, it registers four direct event handlers on it — for PropertyChanging, PropertyChanged, SpansCollectionChanged, and per-span GestureRecognizersCollectionChanged. Since FormattedString lives in Application.Resources (long-lived), it holds a strong reference back to every Label that ever subscribed to it. This prevents the garbage collector from freeing those Labels even after the page is gone. ### Description of Change The fix involves a mixed weak-reference strategy tailored to each event type. SpansCollectionChanged and GestureRecognizersCollectionChanged are converted to WeakEventManager-backed events, ensuring weak subscription semantics for all current and future subscribers across the framework. Since PropertyChanging and PropertyChanged are inherited from BindableObject and cannot be converted to WeakEventManager, WeakNotifyPropertyChangingProxy and WeakNotifyPropertyChangedProxy are used instead. These proxies maintain a single stable entry in the invocation list and automatically unsubscribe when the Label is garbage collected, preventing zombie delegate accumulation over the application lifetime. Together, these changes ensure that Label instances are eligible for garbage collection once the containing page is popped, fully eliminating the memory leak. Validated the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #35495 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android| <video src="https://github.com/user-attachments/assets/e0b29e87-634d-406b-a832-5bd0c38fea8a" >| <video src="https://github.com/user-attachments/assets/7f166d2d-b071-4401-a1d4-46d4c1b4e9d5">| |Mac|<video src="https://github.com/user-attachments/assets/9d3b9676-6b44-4199-90fd-54ce5f17189a"> |<video src="https://github.com/user-attachments/assets/c64760dd-9b5c-4e0a-ae84-bbfea5af93d2">| |iOS|<video src="https://github.com/user-attachments/assets/ed9265f5-36fe-4045-9519-310c6d5e4af4">|<video src="https://github.com/user-attachments/assets/99b33139-d3a2-4bb9-9c88-0af43f09f0f5">| |Windows|<video src="https://github.com/user-attachments/assets/6a25a93a-4a1c-42c2-a07f-0e0ea961b8d4">|<video src="https://github.com/user-attachments/assets/f8fe0224-1007-4bda-80f1-c1844c4be182"> | --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…is stored in Application.Resources (#35582) <!-- 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! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Issue Details When a FormattedString is defined in Application.Resources and assigned to Label controls across multiple page navigations, those Labels are never released from memory even after the page is popped. This causes memory to grow steadily with each navigation. ### Root Cause The issue occurs because of the way Label subscribes to events on the shared FormattedString. When a label is assigned a FormattedString, it registers four direct event handlers on it — for PropertyChanging, PropertyChanged, SpansCollectionChanged, and per-span GestureRecognizersCollectionChanged. Since FormattedString lives in Application.Resources (long-lived), it holds a strong reference back to every Label that ever subscribed to it. This prevents the garbage collector from freeing those Labels even after the page is gone. ### Description of Change The fix involves a mixed weak-reference strategy tailored to each event type. SpansCollectionChanged and GestureRecognizersCollectionChanged are converted to WeakEventManager-backed events, ensuring weak subscription semantics for all current and future subscribers across the framework. Since PropertyChanging and PropertyChanged are inherited from BindableObject and cannot be converted to WeakEventManager, WeakNotifyPropertyChangingProxy and WeakNotifyPropertyChangedProxy are used instead. These proxies maintain a single stable entry in the invocation list and automatically unsubscribe when the Label is garbage collected, preventing zombie delegate accumulation over the application lifetime. Together, these changes ensure that Label instances are eligible for garbage collection once the containing page is popped, fully eliminating the memory leak. Validated the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #35495 ### Output ScreenShot |Platform|Before|After| |--|--|--| |Android| <video src="https://github.com/user-attachments/assets/e0b29e87-634d-406b-a832-5bd0c38fea8a" >| <video src="https://github.com/user-attachments/assets/7f166d2d-b071-4401-a1d4-46d4c1b4e9d5">| |Mac|<video src="https://github.com/user-attachments/assets/9d3b9676-6b44-4199-90fd-54ce5f17189a"> |<video src="https://github.com/user-attachments/assets/c64760dd-9b5c-4e0a-ae84-bbfea5af93d2">| |iOS|<video src="https://github.com/user-attachments/assets/ed9265f5-36fe-4045-9519-310c6d5e4af4">|<video src="https://github.com/user-attachments/assets/99b33139-d3a2-4bb9-9c88-0af43f09f0f5">| |Windows|<video src="https://github.com/user-attachments/assets/6a25a93a-4a1c-42c2-a07f-0e0ea961b8d4">|<video src="https://github.com/user-attachments/assets/f8fe0224-1007-4bda-80f1-c1844c4be182"> | --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
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!
Issue Details
When a FormattedString is defined in Application.Resources and assigned to Label controls across multiple page navigations, those Labels are never released from memory even after the page is popped. This causes memory to grow steadily with each navigation.
Root Cause
The issue occurs because of the way Label subscribes to events on the shared FormattedString. When a label is assigned a FormattedString, it registers four direct event handlers on it — for PropertyChanging, PropertyChanged, SpansCollectionChanged, and per-span GestureRecognizersCollectionChanged. Since FormattedString lives in Application.Resources (long-lived), it holds a strong reference back to every Label that ever subscribed to it. This prevents the garbage collector from freeing those Labels even after the page is gone.
Description of Change
The fix involves a mixed weak-reference strategy tailored to each event type. SpansCollectionChanged and GestureRecognizersCollectionChanged are converted to WeakEventManager-backed events, ensuring weak subscription semantics for all current and future subscribers across the framework. Since PropertyChanging and PropertyChanged are inherited from BindableObject and cannot be converted to WeakEventManager, WeakNotifyPropertyChangingProxy and WeakNotifyPropertyChangedProxy are used instead.
These proxies maintain a single stable entry in the invocation list and automatically unsubscribe when the Label is garbage collected, preventing zombie delegate accumulation over the application lifetime. Together, these changes ensure that Label instances are eligible for garbage collection once the containing page is popped, fully eliminating the memory leak.
Validated the behavior in the following platforms
Issues Fixed
Fixes #35495
Output ScreenShot
35495-BeforeFix.Android.mov
35495-AfterFix.Android.mov
35495-BeforeFix.Mac.mov
35495-AfterFix.Mac.mov
35495-BeforeFix.iOS.mov
35495-AfterFix.iOS.mov
35495-BeforeFix.Windows.mp4
35495-AfterFix.Windows.mp4