Revert ToolbarItem Badge feature (#34669) and follow-up (#34963)#34984
Revert ToolbarItem Badge feature (#34669) and follow-up (#34963)#34984jfversluis wants to merge 3 commits intonet11.0from
Conversation
This reverts commit 4e6b863.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34984Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34984" |
There was a problem hiding this comment.
Pull request overview
Reverts the previously added ToolbarItem badge feature (and its follow-up) to restore net11.0 UI test stability by removing the related public API, platform implementations, samples, and tests.
Changes:
- Removes
ToolbarItembadge API surface and related platform implementations (Android/iOS/Windows). - Deletes the badge sample page + issue UI tests/unit tests and associated screenshot baselines.
- Adjusts a few iOS device test helper implementations (nullability/guards).
Reviewed changes
Copilot reviewed 20 out of 29 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/TestUtils/src/DeviceTests/UINSWindow.iOS.cs | Updates NSWindow lookup logic used by iOS device tests. |
| src/TestUtils/src/DeviceTests/AssertionExtensions.iOS.cs | Updates iOS bitmap capture helper used by device tests. |
| src/TestUtils/src/DeviceTests.Runners/HeadlessRunner/iOS/MauiTestApplicationDelegate.cs | Tweaks exception marshaling event handler signatures in the headless iOS runner. |
| src/Core/maps/src/PublicAPI/net/PublicAPI.Unshipped.txt | Updates Maps public API baseline entries. |
| src/Controls/src/Core/Toolbar/ToolbarItem.cs | Removes ToolbarItem badge-related bindable properties and docs. |
| src/Controls/src/Core/Toolbar/Toolbar.Windows.cs | Removes Windows toolbar badge rendering and related property change handling. |
| src/Controls/src/Core/Platform/Android/Extensions/ToolbarExtensions.cs | Removes Android badge drawable implementation and cleanup logic. |
| src/Controls/src/Core/Compatibility/iOS/Extensions/ToolbarItemExtensions.cs | Removes iOS/macOS badge update logic from primary toolbar items. |
| src/Controls/tests/Core.UnitTests/ToolbarItemBadgeTests.cs | Deletes unit tests covering the removed badge properties. |
| src/Controls/tests/TestCases.HostApp/Issues/Issue8305_Toolbar.cs | Deletes HostApp repro page for ToolbarItem badges. |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue8305_Toolbar.cs | Deletes UI tests validating ToolbarItem badges. |
| src/Controls/tests/TestCases.Android.Tests/snapshots/android/ToolbarItemBadgesDisplay.png | Removes/updates Android screenshot baseline for the deleted UI tests. |
| src/Controls/tests/TestCases.Android.Tests/snapshots/android/ToolbarItemBadgesClear.png | Removes/updates Android screenshot baseline for the deleted UI tests. |
| src/Controls/tests/TestCases.Android.Tests/snapshots/android/ToolbarItemBadgeColorChanges.png | Removes/updates Android screenshot baseline for the deleted UI tests. |
| src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ToolbarItemBadgesDisplay.png | Removes/updates iOS screenshot baseline for the deleted UI tests. |
| src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ToolbarItemBadgesClear.png | Removes/updates iOS screenshot baseline for the deleted UI tests. |
| src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ToolbarItemBadgeColorChanges.png | Removes/updates iOS screenshot baseline for the deleted UI tests. |
| src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/ToolbarItemBadgesDisplay.png | Removes/updates Windows screenshot baseline for the deleted UI tests. |
| src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/ToolbarItemBadgesClear.png | Removes/updates Windows screenshot baseline for the deleted UI tests. |
| src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/ToolbarItemBadgeColorChanges.png | Removes/updates Windows screenshot baseline for the deleted UI tests. |
| src/Controls/samples/Controls.Sample/ViewModels/CoreViewModel.cs | Removes the Toolbar badge sample entry from the gallery list. |
| src/Controls/samples/Controls.Sample/Pages/Core/ToolbarBadgePage.cs | Deletes the Toolbar badge sample page implementation. |
| src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt | Removes ToolbarItem badge-related API entries from Controls baseline. |
| src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt | Removes ToolbarItem badge-related API entries from Controls baseline. |
| src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt | Removes ToolbarItem badge-related API entries from Controls baseline. |
| src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt | Removes ToolbarItem badge-related API entries from Controls baseline. |
| src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | Removes ToolbarItem badge-related API entries from Controls baseline. |
| src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt | Removes ToolbarItem badge-related API entries from Controls baseline. |
| src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt | Removes ToolbarItem badge-related API entries from Controls baseline. |
| var sharedApp = nsapp.PerformSelector(SharedApplicationSelector); | ||
| if (sharedApp is null) | ||
| return null; | ||
|
|
||
| var windows = sharedApp.PerformSelector(WindowsSelector) as NSArray; | ||
| if (windows is null) | ||
| return null; | ||
|
|
||
| for (nuint i = 0; i < windows.Count; i++) | ||
| for (nuint i = 0; i < windows!.Count; i++) |
There was a problem hiding this comment.
The previous null-guards around Objective-C selector results were removed. sharedApp (from PerformSelector) can be null, and windows can be null; the current code immediately calls into sharedApp and then dereferences windows!. If either is null this will throw and can break iOS device tests. Consider restoring the early-return checks (or using pattern matching) before looping.
| var uiwindows = nswin.PerformSelector(UIWindowsSelector) as NSArray; | ||
|
|
||
| for (nuint j = 0; j < uiwindows.Count; j++) | ||
| for (nuint j = 0; j < uiwindows!.Count; j++) | ||
| { |
There was a problem hiding this comment.
nswin.PerformSelector(UIWindowsSelector) as NSArray can yield null, but the code uses uiwindows! in the loop condition. If uiwindows is null this will throw. Consider restoring the previous is not NSArray uiwindows guard (or an equivalent null check) before entering the inner loop.
| var context = UIGraphics.GetCurrentContext(); | ||
| if (context is not null) | ||
| view.Layer.RenderInContext(context); | ||
| view.Layer.RenderInContext(context); | ||
| var image = UIGraphics.GetImageFromCurrentImageContext(); | ||
| UIGraphics.EndImageContext(); | ||
| #pragma warning restore CA1416 // Validate platform compatibility |
There was a problem hiding this comment.
UIGraphics.GetCurrentContext() and UIGraphics.GetImageFromCurrentImageContext() are nullable APIs; the updated code now unconditionally calls view.Layer.RenderInContext(context) and then uses the resulting image without checking. If either returns null this will throw in test infrastructure. Consider restoring the null guards and/or throwing a clearer exception when the context/image cannot be created.
| var uiwin = uiwindows.GetItem<UIWindow>(j); | ||
|
|
||
| if (uiwin is not null && uiwin.Handle == uiWindow.Handle) | ||
| if (uiwin.Handle == uiWindow.Handle) |
There was a problem hiding this comment.
uiwindows.GetItem<UIWindow>(j) can return null; the updated code removed the uiwin is not null guard and now directly accesses uiwin.Handle. Please add the null check back to avoid a potential NullReferenceException when enumerating the NSArray.
| if (uiwin.Handle == uiWindow.Handle) | |
| if (uiwin is not null && uiwin.Handle == uiWindow.Handle) |
🧪 PR Test EvaluationOverall Verdict: This is a revert PR — deleting tests alongside the reverted feature code is expected and appropriate. However, the second revert commit reintroduces potential null-dereference regressions in shared iOS test infrastructure (
📊 Expand Full EvaluationPR Test Evaluation ReportPR: #34984 — Revert "Add BadgeText, BadgeColor, and BadgeTextColor support to ToolbarItem (#34669)"
Overall VerdictTest deletion alongside the reverted feature is correct. The concern is the second commit (Revert "Fix CS8602 nullable dereference in ToolbarBadgePage") which also reverts null safety improvements from shared iOS test infrastructure, reintroducing potential null dereferences in 1. Fix Coverage — ✅This is a revert — removing tests for the removed feature is the correct behavior. The deleted tests covered the feature comprehensively:
No new tests are expected or needed for a pure revert. 2. Edge Cases & Gaps — ✅ (N/A for revert)The deleted unit tests covered the key edge cases for the reverted feature:
No gaps are applicable since the feature is being removed. 3. Test Type Appropriateness — ✅ (N/A for revert)For reference, the deleted tests used appropriate types:
4. Convention Compliance — ✅ (N/A for revert)The deleted test files followed conventions correctly:
5. Flakiness Risk —
|
|
/azp run maui-pr-uitests, maui-pr-devicetests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
The revert of ToolbarItem badges (#34669) also removed BaseShellItem badge entries from PublicAPI.Unshipped.txt, but the BaseShellItem badge code (from Shell badges PR #34659) was not reverted. This caused RS0016 build errors on all platforms. Restore only the BaseShellItem and ShellItemRenderer badge entries; ToolbarItem entries remain removed as intended by the revert. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run maui-pr-uitests, maui-pr-devicetests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
Superseded by #34991 |
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!
Description
Reverts PR #34669 ("Add BadgeText, BadgeColor, and BadgeTextColor support to ToolbarItem") and its follow-up PR #34963 ("Fix CS8602 nullable dereference in ToolbarBadgePage").
Reason
PR #34669 introduced a runtime crash in the TestCases.HostApp that causes 100% UITest failure on the
net11.0branch since April 9th. The app crashes on startup across all platforms (Windows and Android confirmed, iOS/macCatalyst blocked by separate actool infra issue).Evidence
c43df61(before #34669)53be2cd(after #34669)NoSuchWindowException: Currently selected window has been app window dies during startupclosedThe app was expected to be running app crashes before any test runsstillnet11.0UITest builds since April 9 show the same failure patternPlan
The badge feature (BadgeText, BadgeColor, BadgeTextColor on ToolbarItem) can be re-landed after the crash is root-caused and fixed. This revert restores UITest CI health on
net11.0./cc @PureWeen