Skip to content

[net11.0] Expose toolbar drawer-toggle visibility on IToolbar - #37863

Merged
kubaflo merged 7 commits into
net11.0from
redth-supreme-fortnight
Aug 28, 2026
Merged

kubaflo merged 7 commits into
net11.0from
redth-supreme-fortnight

Conversation

@Redth

@Redth Redth commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

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 of Change

External platform backends implement toolbar handlers against Microsoft.Maui.IToolbar. That contract exposed BackButtonVisible, IsVisible and Title, but nothing about the drawer (flyout / "hamburger") toggle — so a backend could not render or update the drawer affordance without forking the state into a private side table.

There were two gaps:

  1. No read contract. DrawerToggleVisible only existed on the Controls-level Microsoft.Maui.Controls.Toolbar type, not on the contract handlers are handed.
  2. No change notification. ShellToolbar and NavigationPageToolbar assign the _drawerToggleVisible backing field directly, so neither PropertyChanged nor Handler.UpdateValue ever fired. Built-in platforms only refreshed the drawer icon as a side effect of a BackButtonVisible change, so a drawer-only transition was silently dropped.

Gap 2 is a latent framework bug, not just an extensibility problem. Cases that did not update before this PR:

  • Shell.FlyoutBehavior toggling between Flyout and Disabled/Locked with the navigation stack unchanged.
  • FlyoutPage.FlyoutLayoutBehavior changing between Split and Popover on a tablet.
  • Tizen's ShellView assigning Toolbar.DrawerToggleVisible — the setter called Handler.UpdateValue("DrawerToggleVisible") against a mapper with no such key.

API: optional capability interface

/// Provides the visibility of the drawer (flyout) toggle affordance for an IToolbar.
public interface IToolbarDrawerToggleVisible
{
    bool DrawerToggleVisible { get; }
}

Microsoft.Maui.Controls.Toolbar implements it. External backends consume it by pattern matching:

bool drawerToggleVisible = toolbar is IToolbarDrawerToggleVisible { DrawerToggleVisible: true };

Why not a member on IToolbar. An earlier revision of this PR added DrawerToggleVisible to IToolbar as a default interface member. That is a source break on netstandard2.0, where DIMs are unsupported and the member is therefore abstract — every existing external IToolbar implementer fails with CS0535. A capability interface is purely additive on every TFM instead. This mirrors ISwipeItemMenuItemIconColor, whose doc comment cites exactly this rationale.

The interface is intentionally not marked [EditorBrowsable(Never)] (unlike ISwipeItemMenuItemIconColor, which is a stopgap): external backend authors are the intended consumer and need to discover it.

It is read-only because the value is computed and owned by the cross-platform layer. Controls.Toolbar keeps its shipped settable property, but the framework owns the value for the Shell and NavigationPage toolbars.

External-implementer compile matrix

A type implementing only the pre-existing IToolbar members, compiled against Microsoft.Maui:

Design netstandard2.0 net11.0
Previous (DIM on IToolbar) ❌ CS0535: 'LegacyExternalToolbar' does not implement interface member 'IToolbar.DrawerToggleVisible' ✅ builds
This PR (capability interface) ✅ builds ✅ builds

Reproduced locally by building src/Core/src/Core.csproj for each TFM and compiling a standalone library that references the resulting Microsoft.Maui.dll and declares:

public class LegacyExternalToolbar : IToolbar
{
    public bool BackButtonVisible { get; set; }
    public bool IsVisible { get; set; }
    public string Title => string.Empty;
    public IElement Parent => null;
    public IElementHandler Handler { get; set; }
}

IToolbar's member set is unchanged on every TFM, so there is nothing left to break; the PublicAPI diff contains no Microsoft.Maui.IToolbar.* additions.

Reliable notification

  • New private protected Toolbar.NotifyPropertyChanged(string) helper (SetProperty routes through it).
  • ShellToolbar.ApplyChanges and NavigationPageToolbar.UpdateBackButton compute the drawer value into a local, still assign the backing field before BackButtonVisible notifies, and raise the DrawerToggleVisible notification after it. This preserves the existing ordering contract that Android's animated back/drawer handling depends on.
  • Suppressed when unchanged, so the common push/pop path does no extra platform work.

Back button precedence — not mutual exclusion

An earlier revision of this PR claimed the two are mutually exclusive. That was wrong and has been removed from the docs and tests. On Windows ShellToolbar derives the drawer toggle purely from FlyoutBehavior while BackButtonVisible is independent, so both can be true at once.

What the framework guarantees is precedence (they share one navigation slot, back wins at render time) and ordering (the drawer value is settled before BackButtonVisible notifies). The test is renamed DrawerToggleValueIsCurrentWhenBackButtonMapperRuns to state the real invariant.

Ownership fix — Tizen

ShellView.UpdateDrawerToggleVisible() did:

Element!.Toolbar.DrawerToggleVisible = Element!.Toolbar.DrawerToggleVisible && Element.FlyoutBehavior == FlyoutBehavior.Flyout;

A platform backend writing a framework-computed value, contradicting the documented ownership. It was also:

  • redundant — ShellToolbar already folds FlyoutBehavior into the value;
  • latching — X = X && cond can never restore true;
  • subtly wrong — it compared the raw Shell.FlyoutBehavior bindable property rather than the effective behavior ShellToolbar uses.

The write is removed; the method is renamed RefreshNavigationSlot() and now only re-renders. The manual _toolbar?.UpdateBackButton(...) refresh is deliberately retained, because _toolbar is injected via SetToolbar(MauiToolbar) and I could not verify locally that it is the same instance the ToolbarHandler drives.

Ordering fix — Android

ShellToolbarTracker.ApplyToolbarChanges forwarded DrawerToggleVisible before BackButtonVisible. That was inert before this PR (no mapping existed), but with a drawer mapping registered it would map the shared navigation slot against a stale back-button value. Reordered so BackButtonVisible is assigned first.

Built-in platform consumption

Platform Consumes it? Where
Android Yes ToolbarExtensions.UpdateBackButton picks a DrawerArrowDrawable (Progress = 0) when back is hidden and the drawer toggle is visible. Shell additionally drives an ActionBarDrawerToggle from ShellToolbarTracker.
Tizen Yes ToolbarExtensions.UpdateBackButton installs a menu button; UpdateTitleIcon avoids clearing the icon while it is visible.
Windows No Flyout toggle is rendered by NavigationView.
iOS / MacCatalyst No Flyout toggle is owned by the flyout/navigation controller.

The mapping is registered for Android and Tizen only. Both it and the BackButtonVisible mapping call UpdateBackButton, so a change flipping both runs it twice — intentional and idempotent.

Tests

src/Controls/tests/Core.UnitTests/ToolbarDrawerToggleTests.cs (11 tests):

  • External fake backend — ExternalToolbarBackendHandler : ElementHandler<IToolbar, object>, written against IToolbar only, never referencing Controls.Toolbar. It reads drawer state solely through the capability-interface pattern match, so anything it can do an external assembly can do.
  • LegacyExternalToolbar — implements only the pre-existing IToolbar members, deliberately not the capability interface: compiles and reports no drawer toggle.
  • CapableExternalToolbar — opts in and reports its value.
  • Shell FlyoutBehavior transitions notify; Disabled → Locked does not (no spurious updates).
  • Back-vs-drawer precedence across push/pop, and drawer value already settled when the back-button mapper runs.
  • NavigationPage inside FlyoutPage: push/pop plus FlyoutLayoutBehavior.Split → Popover.
  • Multi-window: two Shells keep independent state and notifications.

Four tests fail without the notification fix, verified by reverting ShellToolbar.cs + NavigationPageToolbar.cs:

DrawerToggleStateIsTrackedPerWindow [FAIL]
ExternalBackendIsNotifiedForNavigationPageInsideFlyoutPage [FAIL]
DrawerToggleValueIsCurrentWhenBackButtonMapperRuns [FAIL]
ExternalBackendIsNotifiedWhenFlyoutBehaviorChanges [FAIL]

Validation

  • Controls.Core.UnitTests: 6218 passed / 0 failed / 30 skipped.
  • Core.csproj builds clean for netstandard2.0 and net11.0; Controls.Core.csproj builds clean for net11.0-android37.0 (mapper + PublicAPI analyzers).
  • External-implementer compile matrix above.
  • ⚠️ Not verified locally: the Tizen TFM (NETSDK1139 — workload not installed on this machine). The Tizen edits are a method rename with all three references updated plus removal of one assignment, and the Toolbar.Tizen.cs mapper mirrors the Android one that does compile — but CI must confirm the Tizen leg.

Docs

docs/design/ToolbarDrawerToggle.md — why a separate interface, ownership table, precedence-not-exclusion, the ordering guarantee (including the ApplyToolbarChanges assignment-order requirement), a copy-pasteable external handler, and the built-in consumption table.

Issues Fixed

Unblocks external MAUI platform backends that currently need a private ConditionalWeakTable adapter to track drawer toggle state.

External platform backends implement toolbar handlers against
`Microsoft.Maui.IToolbar`, which exposed `BackButtonVisible`, `IsVisible`
and `Title` but not the drawer (flyout / "hamburger") toggle state. That
made it impossible to render or update the drawer affordance without
forking the state into a private side table.

There were two gaps:

1. No read contract. `DrawerToggleVisible` only existed on the
   Controls-level `Microsoft.Maui.Controls.Toolbar` type, not on the
   `IToolbar` contract handlers receive.
2. No change notification. `ShellToolbar` and `NavigationPageToolbar`
   assigned the `_drawerToggleVisible` backing field directly, so neither
   `PropertyChanged` nor `Handler.UpdateValue` ever fired. Built-in
   platforms only refreshed the drawer icon as a side effect of a
   `BackButtonVisible` change, so a drawer-only transition (for example a
   `Shell.FlyoutBehavior` or `FlyoutPage.FlyoutLayoutBehavior` change) was
   silently dropped.

Changes:

- Add `bool IToolbar.DrawerToggleVisible { get; }` as a default interface
  member returning `false`, keeping existing implementations source and
  binary compatible. `Toolbar` already declares a public virtual
  get/set property, so it implements the new member implicitly with no
  binary change. netstandard2.0 declares it without a default, matching
  the existing `IRefreshView.IsRefreshEnabled` pattern.
- Raise the missing notification from `ShellToolbar` and
  `NavigationPageToolbar` via a new `Toolbar.NotifyPropertyChanged`
  helper. The backing field is still assigned before `BackButtonVisible`
  notifies and the drawer notification is raised after it, so back-button
  precedence in the shared navigation slot is preserved and backends never
  observe an inconsistent intermediate state.
- Register a `DrawerToggleVisible` mapping for Android and Tizen, the two
  built-in platforms that render the drawer icon in the navigation slot.

Adds `ToolbarDrawerToggleTests` covering a fake external backend that only
consumes `IToolbar`, Shell and NavigationPage/FlyoutPage visibility
transitions, back-vs-drawer precedence, no-op suppression, and per-window
isolation. Four of the new tests fail without the notification fix.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 26, 2026 23:42
@Redth
Redth temporarily deployed to copilot-pat-pool August 26, 2026 23:42 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37863

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37863"

@Redth
Redth temporarily deployed to copilot-pat-pool August 26, 2026 23:42 — with GitHub Actions Inactive
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the core Microsoft.Maui.IToolbar contract to expose drawer/flyout toggle visibility (DrawerToggleVisible) for external platform backends, and updates Controls toolbars to reliably notify handler mappers when the computed drawer-toggle state changes (e.g., flyout behavior/layout transitions that previously didn’t trigger updates).

Changes:

  • Added IToolbar.DrawerToggleVisible (with a DIM fallback for non-NETSTANDARD2_0) and updated Core PublicAPI baselines accordingly.
  • Ensured ShellToolbar and NavigationPageToolbar notify DrawerToggleVisible changes (via a new Toolbar.NotifyPropertyChanged helper to preserve ordering).
  • Added unit tests covering external-backend mapping/ordering semantics, plus a design doc describing ownership and notification guarantees.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Core/src/Core/IToolbar.cs Adds DrawerToggleVisible to the handler contract (DIM where supported).
src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt Public API baseline update for the new IToolbar.DrawerToggleVisible getter.
src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt Public API baseline update for the new IToolbar.DrawerToggleVisible getter.
src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt Public API baseline update for the new IToolbar.DrawerToggleVisible getter.
src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt Public API baseline update for the new IToolbar.DrawerToggleVisible getter.
src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt Public API baseline update for the new IToolbar.DrawerToggleVisible getter.
src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt Public API baseline update for the new IToolbar.DrawerToggleVisible getter.
src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt Public API baseline update for the new IToolbar.DrawerToggleVisible getter.
src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt Public API baseline update for the new IToolbar.DrawerToggleVisible getter.
src/Controls/src/Core/Toolbar/Toolbar.cs Adds NotifyPropertyChanged helper so derived toolbars can preserve update ordering while still notifying handler/subscribers.
src/Controls/src/Core/ShellToolbar.cs Computes drawer-toggle visibility and explicitly notifies DrawerToggleVisible when it changes.
src/Controls/src/Core/NavigationPage/NavigationPageToolbar.cs Computes drawer-toggle visibility and explicitly notifies DrawerToggleVisible when it changes.
src/Controls/src/Core/Toolbar/Toolbar.Mapper.cs Registers a mapper entry for IToolbar.DrawerToggleVisible (Android/Tizen) to re-evaluate the shared navigation slot.
src/Controls/src/Core/Toolbar/Toolbar.Android.cs Adds MapDrawerToggleVisible mapping to UpdateBackButton on Android.
src/Controls/src/Core/Toolbar/Toolbar.Tizen.cs Adds MapDrawerToggleVisible mapping to UpdateBackButton on Tizen.
src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt Public API baseline update for the new Android Toolbar.MapDrawerToggleVisible methods.
src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt Public API baseline update for the new Tizen Toolbar.MapDrawerToggleVisible methods.
src/Controls/tests/Core.UnitTests/ToolbarDrawerToggleTests.cs Adds unit tests validating contract exposure + external-backend notifications and ordering invariants.
docs/design/ToolbarDrawerToggle.md Documents ownership, precedence, and notification behavior for DrawerToggleVisible.

Comment thread src/Core/src/Core/IToolbar.cs Outdated
Comment on lines +28 to +31
/// <para>Changes to this value raise a handler update for the <c>DrawerToggleVisible</c> property name, so
/// platform backends can map it just like any other toolbar property.</para>
/// <para>The default implementation returns <see langword="false"/> so that existing
/// <see cref="IToolbar"/> implementations remain source and binary compatible.</para>
Addresses review feedback on the previous commit.

The previous approach added `DrawerToggleVisible` to `IToolbar` as a
default interface member. That is a source break on netstandard2.0, where
default interface members are unsupported and the member is therefore
abstract, so any existing external `IToolbar` implementer fails with
CS0535. The `IRefreshView.IsRefreshEnabled` precedent does not justify
introducing a new break.

Replaced with `Microsoft.Maui.IToolbarDrawerToggleVisible`, an optional
read-only capability interface implemented by `Microsoft.Maui.Controls.Toolbar`
and consumed via pattern matching:

    toolbar is IToolbarDrawerToggleVisible { DrawerToggleVisible: true }

`IToolbar` gains no members on any target framework, so the change is
purely additive everywhere. This mirrors `ISwipeItemMenuItemIconColor`,
which was added alongside `ISwipeItemMenuItem` for the same reason.

Verified with an external-implementer compile matrix. A type implementing
only the pre-existing `IToolbar` members compiles against the new Core on
both netstandard2.0 and net11.0, and fails with CS0535 on netstandard2.0
against the previous design.

Also fixes three contract issues found in review:

- Removed the platform-backend write in Tizen's `ShellView`, which did
  `DrawerToggleVisible = DrawerToggleVisible && FlyoutBehavior == Flyout`.
  That contradicted the documented framework ownership, was redundant
  because `ShellToolbar` already folds `FlyoutBehavior` into the value,
  latched to false since it could never restore true, and compared against
  the raw bindable property rather than the effective flyout behavior. The
  method now only re-renders the navigation slot.
- Reordered `ShellToolbarTracker.ApplyToolbarChanges` to assign
  `BackButtonVisible` before `DrawerToggleVisible`. With a drawer mapping
  now registered on Android, forwarding the drawer value first would map
  the shared navigation slot against a stale back-button value.
- Dropped the incorrect mutual-exclusivity claim from the docs and tests.
  On Windows `ShellToolbar` derives the drawer toggle purely from
  `FlyoutBehavior`, so both values can be true simultaneously; the back
  button merely takes precedence when rendering. The guarantee the
  framework actually provides is ordering, and the test is renamed to
  `DrawerToggleValueIsCurrentWhenBackButtonMapperRuns` to say so.

Docs now record actual built-in consumption: Android and Tizen read the
value from `ToolbarExtensions.UpdateBackButton`; Windows, iOS and
MacCatalyst render the flyout toggle from the flyout/navigation view and
never read it, which is why the mapping is registered only for the first
two.

Tests add an external implementer that omits the capability interface
(compiles, reports no drawer toggle) and one that opts into it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 27, 2026 00:19
@Redth

Redth commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

Pushed 24ae20ff — full redesign in response to review. Requesting fresh review.

Blocker confirmed and fixed. The previous head added DrawerToggleVisible to IToolbar as a default interface member. On netstandard2.0 DIMs are unsupported, so the member was abstract and broke existing external implementers. Verified rather than assumed:

error CS0535: 'LegacyExternalToolbar' does not implement interface member 'IToolbar.DrawerToggleVisible'

Replaced with an optional read-only capability interface, Microsoft.Maui.IToolbarDrawerToggleVisible, implemented by Controls.Toolbar and consumed via toolbar is IToolbarDrawerToggleVisible { DrawerToggleVisible: true }. IToolbar now gains no members on any TFM, so the change is purely additive. Same shape as ISwipeItemMenuItemIconColor, whose doc comment cites this exact rationale.

Compile matrix, legacy implementer vs Microsoft.Maui.dll:

Design netstandard2.0 net11.0
Previous (DIM) ❌ CS0535 ✅
This head ✅ ✅

Contract issues, all fixed:

  • False mutual-exclusivity claim removed. Windows can expose both values simultaneously; back merely takes precedence at render. Docs corrected and the test renamed to DrawerToggleValueIsCurrentWhenBackButtonMapperRuns, which is the guarantee that actually holds (ordering).
  • Tizen backend write removed. ShellView did DrawerToggleVisible = DrawerToggleVisible && FlyoutBehavior == Flyout — a backend writing a framework-owned value. It was also redundant, latching (X = X && cond never restores true), and compared the raw bindable property instead of the effective flyout behavior. Method renamed RefreshNavigationSlot() and now only re-renders.
  • Android forwarding reordered. ShellToolbarTracker.ApplyToolbarChanges set DrawerToggleVisible before BackButtonVisible; inert previously, but stale-mapping once a drawer mapping exists.
  • Actual platform consumption documented — Android and Tizen read it from UpdateBackButton; Windows, iOS and MacCatalyst render the flyout toggle from the flyout/navigation view and never read it, which is why the mapping is Android/Tizen only.

Validation: Controls.Core.UnitTests 6218 passed / 0 failed / 30 skipped. Core.csproj clean on netstandard2.0 + net11.0, Controls.Core.csproj clean on net11.0-android37.0. New tests cover an implementer that omits the capability interface and one that opts in; four tests still fail if the notification fix is reverted.

⚠️ One gap I want called out rather than buried: the Tizen TFM is not compile-verified locally (NETSDK1139, workload not installed). The Tizen changes are a rename with all references updated plus one deletion, and the Tizen mapper mirrors the Android one that does compile — but please confirm the Tizen leg in CI before merging.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

src/Controls/tests/Core.UnitTests/ToolbarDrawerToggleTests.cs:290

  • LegacyExternalToolbar implements IElement.Parent/IElement.Handler as non-nullable, but both members are nullable on IElement and this stub returns null / is unset. This can produce nullable-mismatch warnings and makes the test double’s contract misleading. Align the annotations with IElement (IElement? / IElementHandler?).

This issue also appears on line 302 of the same file.

			public string Title => string.Empty;

			public IElement Parent => null;

			public IElementHandler Handler { get; set; }

src/Controls/tests/Core.UnitTests/ToolbarDrawerToggleTests.cs:306

  • CapableExternalToolbar implements IElement.Parent/IElement.Handler as non-nullable, but IElement declares both as nullable and this test double returns null / leaves Handler unset. Align the nullability to avoid interface implementation warnings and to accurately model external implementations.
			public string Title => string.Empty;

			public IElement Parent => null;

			public IElementHandler Handler { get; set; }

Comment on lines 102 to +106
Element.Toolbar.PropertyChanged += (s, e) =>
{
if (e.PropertyName == "BackButtonVisible")
{
UpdateDrawerToggleVisible();
RefreshNavigationSlot();
Redth pushed a commit to Redth/Maui.Tizen that referenced this pull request Aug 27, 2026
Upstream settled dotnet/maui#37863 as an additive interface -
IToolbarDrawerToggleVisible with a get-only DrawerToggleVisible; IToolbar is
unchanged - and removed the Tizen write/latch. Wave C's ConditionalWeakTable
faithfully reproduced that latch, so it is now wrong in two ways.

No write, no latch. The value is computed on read, which also removes a real
staleness hazard: a stored flag is only as fresh as the last code path that
remembered to update it.

Back-precedence, not mutual exclusivity. The latch stored
drawerToggle && !backButton, conflating "a drawer toggle is available" with
"a drawer toggle is what we draw". The capability now stays true while a back
button shows; only the renderer applies precedence.

Off-tree wrinkle found while doing this: ShellToolbar is NOT an Element, so
there is no public path from a toolbar to its shell to compute the value from.
Rather than reintroduce a latch, the caller that knows the owner passes it in
and a caller that does not gets false. On adoption every call site collapses to
the pattern match and the owner parameter goes away with the adapter.

Adds the DrawerToggleVisible mapper key (literal, so the parity generator can
extract it; the string is identical to the upstream member name) and nine
executable tests, including one that fails under the old latch. The expiry
detector now watches for the capability interface - watching IToolbar alone
would never have fired, since IToolbar is deliberately unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 27, 2026 11:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/Controls/tests/Core.UnitTests/ToolbarDrawerToggleTests.cs:134

  • Test name reads awkwardly due to the double negative NotNotified. Renaming it will improve readability/searchability without changing behavior.
		[Fact]
		public void ExternalBackendIsNotNotifiedWhenDrawerToggleIsUnchanged()
		{

Comment on lines +588 to +592
// BackButtonVisible must be assigned before DrawerToggleVisible: the two share the toolbar's
// navigation slot and the back button wins, so forwarding the drawer value first would map the
// slot against a stale back-button value.
destination.BackButtonVisible = shellToolbar.BackButtonVisible;
destination.DrawerToggleVisible = shellToolbar.DrawerToggleVisible;
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1ba564b4-93dd-4ce5-9f43-93d2953acfe8
Copilot AI review requested due to automatic review settings August 27, 2026 13:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

src/Controls/src/Core/Platform/Tizen/Extensions/ToolbarExtensions.cs:45

  • UpdateTitleIcon currently throws when toolbar.Handler.MauiContext is null before it checks whether TitleIcon is null/empty. After this PR, UpdateBackButton can call UpdateTitleIcon in the "no back button / no drawer toggle" case even when TitleIcon is null, which means this can now throw in scenarios where the previous code simply cleared the icon without needing MauiContext. Move the MauiContext guard to only run when an image actually needs to be loaded.
		static void UpdateTitleIcon(this MauiToolbar platformToolbar, Toolbar toolbar, int generation)
		{
			_ = toolbar?.Handler?.MauiContext ?? throw new ArgumentNullException(nameof(toolbar.Handler.MauiContext));

			ImageSource source = toolbar.TitleIcon;

Comment on lines +75 to +92
internal void ForwardNavigationIconStateTo(Toolbar destination)
{
if (BackButtonVisible)
{
destination.BackButtonVisible = true;
destination.DrawerToggleVisible = DrawerToggleVisible;
}
else if (DrawerToggleVisible)
{
destination.DrawerToggleVisible = true;
destination.BackButtonVisible = false;
}
else
{
destination.BackButtonVisible = false;
destination.DrawerToggleVisible = false;
}
}
@kubaflo

kubaflo commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Multi-model merge-safety review at 53b9073c7ac6ac84dd6241493f7fde87b4ca1d69: SAFE TO MERGE with documentation follow-up.

All 15 toolbar tests passed, PublicAPI and Android mapper builds succeeded, legacy IToolbar consumers compiled for netstandard2.0/net11.0, and all 31 CI checks are green. No material functional defect was found.

The latest ordering concern was tested directly: current back-to-drawer forwarding preserved a BackButton-to-DrawerToggle slot in 2/2 controls, while the suggested back-first order transiently produced None. The code is preferable, but ToolbarDrawerToggle.md and the test name overclaim that every notification observes a fully settled pair; document the actual rule ("assign the winning affordance first"). The title should name the optional IToolbarDrawerToggleVisible capability, the body omits the last two commits, and the test count is 15 rather than 11. Tizen remains static-review-only.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@github-actions github-actions Bot added s/agent-review-in-progress AI review is currently running for this PR and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated no new comments.

Suppressed comments (1)

docs/design/ToolbarDrawerToggle.md:50

  • The doc claims that forwarding toolbar state between instances must assign BackButtonVisible before DrawerToggleVisible, but Toolbar.ForwardNavigationIconStateTo (used by ShellToolbarTracker.ApplyToolbarChanges) assigns in different orders depending on the transition (e.g., it sets DrawerToggleVisible before clearing BackButtonVisible when switching from back→drawer to avoid transient None/TitleIcon states). As written, this sentence is inaccurate and could mislead external backends or future maintainers.
For the same reason, code that forwards toolbar state between instances must assign `BackButtonVisible`
before `DrawerToggleVisible` (see `ShellToolbarTracker.ApplyToolbarChanges`).

Copilot AI review requested due to automatic review settings August 27, 2026 22:56
@kubaflo

kubaflo commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

/azp run

@kubaflo

This comment has been minimized.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@github-actions github-actions Bot added s/agent-review-in-progress AI review is currently running for this PR and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Suppressed comments (3)

src/Controls/src/Core/Toolbar/Toolbar.cs:86

  • ForwardNavigationIconStateTo currently changes destination.BackButtonVisible/DrawerToggleVisible via the public setters in an order that can notify handlers while the other value is still stale (and the order differs by branch). This undermines the stated ordering guarantee and can cause mappers to render the shared navigation slot against a half-updated pair. Consider batching by updating both backing fields first and then raising notifications in a deterministic order (BackButtonVisible first, then DrawerToggleVisible if changed).
		internal void ForwardNavigationIconStateTo(Toolbar destination)
		{
			if (BackButtonVisible)
			{
				destination.BackButtonVisible = true;
				destination.DrawerToggleVisible = DrawerToggleVisible;
			}
			else if (DrawerToggleVisible)
			{
				destination.DrawerToggleVisible = true;
				destination.BackButtonVisible = false;
			}

docs/design/ToolbarDrawerToggle.md:50

  • This section says forwarding code “must assign BackButtonVisible before DrawerToggleVisible”, but ShellToolbarTracker.ApplyToolbarChanges no longer assigns properties directly; it calls Toolbar.ForwardNavigationIconStateTo, which (as written) may notify in a different order. Please update the wording to reflect the actual requirement (update both values before notifying, and notify BackButtonVisible before DrawerToggleVisible).
For the same reason, code that forwards toolbar state between instances must assign `BackButtonVisible`
before `DrawerToggleVisible` (see `ShellToolbarTracker.ApplyToolbarChanges`).

src/Controls/src/Core/Platform/Tizen/Extensions/ToolbarExtensions.cs:47

  • UpdateTitleIcon currently throws if toolbar.Handler.MauiContext is null, but UpdateBackButton now routes through UpdateTitleIcon for the non-back/non-drawer path. This can crash when UpdateBackButton is invoked from code paths that manipulate a Toolbar without a handler (e.g., ShellView calling these extension methods directly). Consider deferring the MauiContext requirement until after you’ve confirmed there’s a non-empty TitleIcon to load, and treat missing MauiContext as a no-op for loading (clearing the icon should not require a context).
			_ = toolbar?.Handler?.MauiContext ?? throw new ArgumentNullException(nameof(toolbar.Handler.MauiContext));

			ImageSource source = toolbar.TitleIcon;

			if (source == null || source.IsEmpty)

}

[Fact]
public void ExternalBackendIsNotNotifiedWhenDrawerToggleIsUnchanged()
Comment on lines +51 to +52
/// <para>Changes raise a handler update keyed on <c>"DrawerToggleVisible"</c>, so a backend maps it
/// like any other toolbar property.</para>
@kubaflo

kubaflo commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Rechecked at 00405fe19c471ce2170e0e9a176d614f35268b02: SAFE TO MERGE with non-blocking follow-ups.

The two latest commits are pure net11.0 merges: every PR-owned source, test, and design-doc blob is byte-identical to the validated 9dc0b20 head, and the PublicAPI merge is lossless. The toolbar suite passed 15/15, three transition-order controls passed, PublicAPI and Android builds succeeded, and a legacy external IToolbar consumer compiled for netstandard2.0/net11.0.

I also traced the current red checks through raw AzDO and Helix output. They fail unrelated tests (WebView URL encoding on iOS, concurrent Geocoder setup and a TabbedPage badge test on Windows, SafeArea/UI screenshot cases) or infrastructure setup (NuGet feed HTTP 500, missing AVD/ADB setup). The late Mac Catalyst Navigation result timed out in the two Bugzilla59172 back-navigation cases on both attempts and one unrelated Issue2004 case on only the retry. Mac Catalyst does not map DrawerToggleVisible, and Bugzilla59172 uses a plain root NavigationPage, where this PR leaves the drawer state false and never takes the new notification path; Azure history also shows that test passing on the latest net11.0 run. The Toolbar device-test category itself completed without a reported failure.

One Android follow-up deserves an explicit emulator check: on the first push/last pop of a FlyoutPage-hosted NavigationPage, the new drawer notification writes the final DrawerArrowDrawable.Progress before NavController.Navigate runs. That could collapse the AndroidX hamburger/arrow animation which the nearby direct field assignment intentionally avoids; the existing post-Navigate update is not an equivalent timing point. The possible regression is narrow and cosmetic, so I would not block this PR on it, but a mapper regression or quick visual check is worthwhile.

The other reported concerns are not blockers. The in-box Tizen call path installs the handler before exposing the toolbar, although repeated title-icon loads remain worth hardening and Tizen still lacks CI compile coverage. The forwarding test proves the navigation slot never clears but cannot claim every notification sees a fully settled (BackButtonVisible, DrawerToggleVisible) pair. The design doc/title/body should describe the optional capability and actual transition-aware ordering. ReplaceMapping is consistent with the existing mapper contract and is not a defect.

Fresh-review addendum: GPT-5.6 Terra added a discriminating transition probe at this exact head. Both direction changes emitted two handler updates and briefly exposed (BackButtonVisible=true, DrawerToggleVisible=true); a batched control emitted one settled update, and both arms passed 18/18. The intermediate state is observable but deterministic because back-button precedence is the documented rule, and the old path already emitted two writes. This remains an efficiency/test-precision follow-up, not a correctness blocker.

Removing the Android/Tizen DrawerToggleVisible mapper registration still passed the existing 15/15 targeted tests, empirically confirming that the net-only suite does not cover the shipped platform mapping. The exact-head Android DeviceTests APK built, but the attached emulator disappeared before execution, so there is no runtime animation certification. A tightly equivalent unconnected Tizen fallback does throw before its null/empty title-source branch, but no Tizen workload was available and the in-box call path remains statically guarded by installing the toolbar handler/context before _toolbar becomes reachable. Repeated non-empty title-icon loads are real and worth fixing; the generation token prevents stale callbacks from winning but does not avoid the extra loads.

This completed recheck does not change the verdict. The PR has since merged; the useful follow-ups are platform-aware mapper coverage, Tizen title-icon load/disposal hardening, and more precise transition documentation/tests.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 6 findings

See inline comments for details.

// Notified last so that BackButtonVisible (which takes precedence in the navigation slot)
// is already up to date when platform backends react to the drawer toggle change.
if (drawerToggleVisibleChanged)
NotifyPropertyChanged(nameof(DrawerToggleVisible));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Handler Mapper and Property Patterns / Regression Prevention — This notification re-introduces a handler-driven navigation-icon write on exactly the transition that the #if ANDROID branch a few lines above deliberately suppresses. In the !_userChanged path Android assigns _backButtonVisible = GetBackButtonVisible(); directly (no SetProperty, so no Handler.UpdateValue), because ToolbarHandler.Android wires the navigation icon through NavigationUI.SetupWithNavController(...)/AppBarConfiguration.SetOpenableLayout(_drawerLayout) and animates the hamburger↔arrow via the NavController destination change.

Concrete scenario (Android, FlyoutPage whose Detail is a NavigationPage, flyout behavior Flyout): pushing the second page makes anyPagesPushed true, so drawerToggleVisible goes true -> false, drawerToggleVisibleChanged is true, and this line fires Handler.UpdateValue("DrawerToggleVisible"). With the new #if ANDROID || TIZEN mapping in Toolbar.Mapper.cs that reaches Toolbar.MapDrawerToggleVisible -> AToolbar.UpdateBackButton(toolbar), which reads toolbar.BackButtonVisible (already updated to true by the untracked field assignment) and immediately sets iconDrawable.Progress = 1 on the shared DrawerArrowDrawable. That is the same write the Android branch was written to avoid, so the drawer→arrow morph is snapped to its end state instead of being animated by the navigation transition. The reverse pop-to-root case snaps Progress = 0.

Suggest scoping the new notification so Android keeps its animation-owned path — e.g. #if !ANDROID around the notification when the untracked _backButtonVisible assignment was taken, or route the drawer-only change through a mapper that does not touch DrawerArrowDrawable.Progress. Whatever is chosen, please add an Android device/UI regression test for FlyoutPage+NavigationPage push/pop, since no test in this PR covers it.

// toolbar itself, in the same navigation slot as the back button, so a drawer toggle change has
// to re-evaluate that slot. Windows, iOS and MacCatalyst render the flyout toggle from the
// flyout/navigation view instead and never read this property.
ToolbarHandler.Mapper.ReplaceMapping<Toolbar, IToolbarHandler>(nameof(IToolbarDrawerToggleVisible.DrawerToggleVisible), MapDrawerToggleVisible);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Regression Prevention and Test Coverage — This registration is the actual behavioral fix: before it, Handler?.UpdateValue("DrawerToggleVisible") was a no-op because ToolbarHandler.Mapper had no entry for that key (Core's mapper only defines Title). Nothing in the PR exercises it. The line is compiled only under #if ANDROID || TIZEN, while Controls.Core.UnitTests builds net only, so neither MapDrawerToggleVisible nor the registration is reachable from ToolbarDrawerToggleTests. The added tests assert NotifyPropertyChanged fires and that a stub ElementHandler.UpdateValue records the key, which passes with or without this registration.

Also note the semantics differ from the interface doc: because the mapping is Android/Tizen-only, a change does not raise a platform update on iOS/MacCatalyst/Windows. Consider a device test under Controls.DeviceTests (Android) that asserts the platform AToolbar.NavigationIcon/DrawerArrowDrawable.Progress after a drawer-only transition — that is the only level at which this line is currently observable.

else
{
platformToolbar.Icon = null;
platformToolbar.UpdateTitleIcon(toolbar, generation);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Null Safety / Logic and Correctness — The rewritten else branch turns a handler-free assignment into a call that unconditionally dereferences the handler. Previously this branch was else if (toolbar.TitleIcon == null) { platformToolbar.Icon = null; } and never touched toolbar.Handler. UpdateTitleIcon(toolbar, generation) starts with _ = toolbar?.Handler?.MauiContext ?? throw new ArgumentNullException(...), which now runs before the source == null || source.IsEmpty early-out, so UpdateBackButton throws whenever the toolbar has no connected handler/MauiContext.

Concrete scenario: ShellView.RefreshNavigationSlot() (this PR's rename) calls _toolbar?.UpdateBackButton(Element!.Toolbar) from UpdateFlyoutBehavior(...) and from the PropertyChanged listener. Element.Toolbar is the Shell-owned ShellToolbar, whose Handler/MauiContext is not guaranteed to be set at those points (early Shell setup, or after the toolbar handler is disconnected on teardown) — previously that path was safe because the no-icon case never read the handler. Suggest moving the MauiContext guard below the source == null || source.IsEmpty early-out, or guarding the else branch with a toolbar.Handler?.MauiContext is not null check and clearing platformToolbar.Icon otherwise.

}
else if (DrawerToggleVisible)
{
destination.DrawerToggleVisible = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Logic and Correctness — The drawer branch assigns destination.DrawerToggleVisible = true while destination.BackButtonVisible may still be true from the previous state, then clears the back button on the next line. Both go through the public setters -> SetProperty -> Handler?.UpdateValue, and with the new Android/Tizen mapping each one now reaches UpdateBackButton, so the platform slot is rendered twice per forward: first as a back arrow (Progress = 1, back content description) and only then as the drawer toggle (Progress = 0, nav_app_bar_open_drawer_description). This contradicts the ordering invariant stated in the comments added to ShellToolbar/NavigationPageToolbar ("BackButtonVisible ... is already up to date when platform backends react to the drawer toggle change") and in docs/design/ToolbarDrawerToggle.md.

The symmetric else branch (line 88-90) has the same shape in reverse: BackButtonVisible = false is applied while DrawerToggleVisible is still true. The end state converges in every branch, but the intermediate handler write is observable on Android via DrawerArrowDrawable.Progress and the navigation content description. Consider batching the two writes (assign both backing values, then raise a single navigation-slot update) rather than relying on setter ordering.

source.ForwardNavigationIconStateTo(destination);

Assert.NotEmpty(observedKinds);
Assert.DoesNotContain(ToolbarNavigationIconKind.None, observedKinds);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Regression Prevention and Test Coverage — ForwardingNavigationSlotAvoidsInvalidIntermediateState cannot discriminate the ordering it claims to pin. Both toolbars are constructed with a non-null TitleIcon, so NavigationIconKind can never return None (the TitleIcon is not null arm always wins the fallback) — Assert.DoesNotContain(None, ...) is vacuous for this fixture. And for transitionToBackButton == false the source is Drawer=true, the destination starts BackButton=true, so ForwardNavigationIconStateTo takes the else if (DrawerToggleVisible) branch and sets DrawerToggleVisible = true while BackButtonVisible is still true; the observed kind at that notification is BackButton, which satisfies both DoesNotContain assertions. The test therefore passes for exactly the interleaving flagged on Toolbar.cs:84.

To make it discriminating, record (PropertyName, BackButtonVisible, DrawerToggleVisible) tuples and assert that no notification is observed while the two flags disagree with the source's final state, and add a TitleIcon = null variant so the None assertion is actually reachable.

/// on Windows both can be <see langword="true"/> at the same time. They share a single navigation
/// slot and <see cref="IToolbar.BackButtonVisible"/> takes precedence when rendering, so a backend
/// should check the back button first and only fall through to the drawer toggle.</para>
/// <para>Changes raise a handler update keyed on <c>"DrawerToggleVisible"</c>, so a backend maps it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Public API Surface / Cross-Platform Behavioral Consistency — This remark is inaccurate as written on two counts. First, the handler update is only raised on Android and Tizen: the mapping added in Toolbar.Mapper.cs is inside #if ANDROID || TIZEN, and ToolbarHandler.Mapper in Core registers only Title, so on iOS, MacCatalyst and Windows a DrawerToggleVisible change produces UpdateValue against a mapper with no entry for that key — no backend is invoked. Second, an interface cannot guarantee notification behavior for arbitrary external IToolbar implementations; only the framework-owned Controls.Toolbar raises it.

Suggest scoping the sentence to the framework-owned toolbars and naming the platforms that actually map it, so external backend authors on iOS/Windows do not build on an update that never arrives.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review Summary

@Redth — new AI review results are available based on commit 00405fe.

Gate Passed Confidence Unknown Platform Android


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: ANDROID · Base: net11.0 · Merge base: e4b0c0a1

✅ Verified (new API / feature) — this PR adds new API and a test that references it in the same project, so reverting the fix un-compiles the test: there is no valid "fails without the fix" baseline to establish (a compile-coupled baseline). The gate instead verified the fix by a clean build + pass with the fix, so this is a real PASS rather than a non-committal INCONCLUSIVE.

Test Without Fix (expect FAIL) With Fix (expect PASS)
🧪 ToolbarDrawerToggleTests ToolbarDrawerToggleTests 🛠️ BUILD ERROR ✅ PASS — 75s
🔴 Without fix — 🧪 ToolbarDrawerToggleTests: 🛠️ BUILD ERROR · 61s

Error-relevant lines (filtered from the build log):

/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ToolbarDrawerToggleTests.cs(373,44): error CS0246: The type or namespace name 'IToolbarDrawerToggleVisible' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
🟢 With fix — 🧪 ToolbarDrawerToggleTests: PASS ✅ · 75s

(no coded error found; showing last 1200 chars)

ms]
  Passed ForwardingNavigationSlotAvoidsInvalidIntermediateState(transitionToBackButton: True) [16 ms]
  Passed ForwardingNavigationSlotAvoidsInvalidIntermediateState(transitionToBackButton: False) [< 1 ms]
  Passed DrawerToggleTransitionsForNavigationPageInsideFlyoutPage [27 ms]
  Passed DrawerToggleStateIsTrackedPerWindow [18 ms]
  Passed StaleTitleIconLoadIsRejectedAfterNavigationSlotChanges [21 ms]
  Passed BackButtonTakesPrecedenceOverDrawerToggleInShell [33 ms]
  Passed DrawerToggleIsHiddenWhenFlyoutPageIsSplit [2 ms]
  Passed ToolbarWithoutCapabilityInterfaceReportsNoDrawerToggle [< 1 ms]
[xUnit.net 00:00:03.12]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
  Passed ExternalBackendIsNotifiedForNavigationPageInsideFlyoutPage [3 ms]
  Passed DrawerToggleValueIsCurrentWhenBackButtonMapperRuns [3 ms]
  Passed ExternalBackendIsNotNotifiedWhenDrawerToggleIsUnchanged [2 ms]
  Passed ToolbarImplementingCapabilityInterfaceReportsDrawerToggle [< 1 ms]
  Passed TizenNavigationSlotRestoresTitleIconWhenDrawerToggleIsHidden [< 1 ms]
  Passed ExternalBackendIsNotifiedWhenFlyoutBehaviorChanges [2 ms]
Test Run Successful.
Total tests: 15
     Passed: 15
 Total time: 4.0412 Seconds

⚠️ Failure Details

  • 🛠️ ToolbarDrawerToggleTests without fix: build failed before tests could run
    • /home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ToolbarDrawerToggleTests.cs(373,44): error CS0246: The type or namespace name 'IToolbarDrawerToggleVisible' could not be found (are you missing a ...
📁 Fix files reverted (20 files)
  • src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellToolbarTracker.cs
  • src/Controls/src/Core/Handlers/Shell/Tizen/ShellView.cs
  • src/Controls/src/Core/NavigationPage/NavigationPageToolbar.cs
  • src/Controls/src/Core/Platform/Tizen/Extensions/ToolbarExtensions.cs
  • src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/ShellToolbar.cs
  • src/Controls/src/Core/Toolbar/Toolbar.Android.cs
  • src/Controls/src/Core/Toolbar/Toolbar.Mapper.cs
  • src/Controls/src/Core/Toolbar/Toolbar.Tizen.cs
  • src/Controls/src/Core/Toolbar/Toolbar.cs
  • src/Core/src/Core/IToolbar.cs
  • src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
  • src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
  • src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
  • src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
  • src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt
  • src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt
  • src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt
  • src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt

📋 Pre-Flight — Context & Validation

PR #37863 Pre-Flight

Context

  • Title: [net11.0] Expose toolbar drawer-toggle visibility on IToolbar
  • Base / head: net11.0 / redth-supreme-fortnight
  • Materialized review commit: 736bd9f291 over e4b0c0a1fb
  • Platform: Android
  • Gate: Passed previously; do not re-run gate verification.
  • Problem: External toolbar backends receive Microsoft.Maui.IToolbar, but cannot read the Controls toolbar's computed drawer-toggle visibility or receive a property-mapper update when that value changes. Direct backing-field assignments in ShellToolbar and NavigationPageToolbar bypass both PropertyChanged and Handler.UpdateValue, so drawer-only transitions are dropped.

Existing PR Approach

The PR adds the optional public capability interface IToolbarDrawerToggleVisible, implements it on Controls.Toolbar, registers Android/Tizen drawer-toggle mappings, and introduces Toolbar.NotifyPropertyChanged. Derived toolbars assign _drawerToggleVisible before notifying BackButtonVisible, then explicitly notify the drawer property afterward to preserve navigation-slot ordering. It also centralizes navigation-icon precedence/generation state, updates Android/Tizen consumers, adds PublicAPI entries and documentation, and adds ToolbarDrawerToggleTests.

The PR deliberately avoids an earlier default-interface-member design on IToolbar, which source-breaks external IToolbar implementations on netstandard2.0. It also avoids treating back and drawer visibility as mutually exclusive because both may be true on Windows.

Relevant Diff Surface

  • src/Core/src/Core/IToolbar.cs
  • src/Controls/src/Core/Toolbar/Toolbar.cs
  • src/Controls/src/Core/Toolbar/Toolbar.Mapper.cs
  • src/Controls/src/Core/Toolbar/Toolbar.Android.cs
  • src/Controls/src/Core/ShellToolbar.cs
  • src/Controls/src/Core/NavigationPage/NavigationPageToolbar.cs
  • src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellToolbarTracker.cs
  • Android/Tizen PublicAPI and platform counterparts
  • src/Controls/tests/Core.UnitTests/ToolbarDrawerToggleTests.cs

The worktree also contains pre-existing harness changes under .github/ and eng/; attempts must preserve them and use only EstablishBrokenBaseline.ps1 for restoration.

Bounded Validation

Primary test:

dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --filter "ToolbarDrawerToggleTests"

Mandatory regression test, run only after the primary test passes:

dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --filter "ShellToolbarTests"

Each candidate receives one implementation/test pass and at most one focused correction/retest. A primary-test failure is Fail; a regression-test failure after a primary pass is also Fail. Environment inability to execute the validation is recorded honestly as Blocked or Fail according to the try-fix skill.


🔬 Code Review — Deep Analysis

Expert PR Evaluation — dotnet/maui #37863

Title: [net11.0] Expose toolbar drawer-toggle visibility on IToolbar
Author: Redth · Base/head: net11.0 / redth-supreme-fortnight
Reviewed range: e4b0c0a1fb..736bd9f29164049f3e6ff523b6a81f9af2bb9f00 (branch pr-review-37863)
Test platform: Android · Method: code-first (diff read in full before narrative/prior reviews)


1. Independent assessment (code before narrative)

What the diff actually does

22 files, +676/−39. Four distinct mechanisms:

  1. New public capability interface — Microsoft.Maui.IToolbarDrawerToggleVisible with a single bool DrawerToggleVisible { get; } in src/Core/src/Core/IToolbar.cs. Controls.Toolbar now implements it (Toolbar : Maui.IToolbar, Maui.IToolbarDrawerToggleVisible, INotifyPropertyChanged). The property already existed on Controls.Toolbar as public virtual bool DrawerToggleVisible; the interface only lifts it into the Core contract.

  2. Notification plumbing — Toolbar.SetProperty is split so the notify half is reusable: new private protected void NotifyPropertyChanged(string) performs Handler?.UpdateValue(name) + PropertyChanged?.Invoke(...). ShellToolbar.ApplyChanges and NavigationPageToolbar.UpdateBackButton still assign the _drawerToggleVisible backing field directly (to preserve their existing ordering relative to BackButtonVisible), then call NotifyPropertyChanged(nameof(DrawerToggleVisible)) at the end if the value changed.

  3. Mapper registration — Toolbar.Mapper.cs adds, under #if ANDROID || TIZEN, ToolbarHandler.Mapper.ReplaceMapping<Toolbar, IToolbarHandler>(nameof(IToolbarDrawerToggleVisible.DrawerToggleVisible), MapDrawerToggleVisible), with MapDrawerToggleVisible on both platforms delegating to PlatformView.UpdateBackButton(toolbar).

  4. Navigation-slot centralization — new internal enum ToolbarNavigationIconKind { None, TitleIcon, DrawerToggle, BackButton }, an internal ToolbarNavigationIconKind NavigationIconKind precedence expression, an Interlocked-based generation counter (BeginNavigationIconUpdate / IsCurrentTitleIconUpdate) to reject stale async title-icon loads, and internal void ForwardNavigationIconStateTo(Toolbar destination) used by ShellToolbarTracker.ApplyToolbarChanges. Tizen's ToolbarExtensions.UpdateBackButton and ShellView are rewritten on top of these; ShellView.UpdateDrawerToggleVisible (which used to mutate Element.Toolbar.DrawerToggleVisible) becomes RefreshNavigationSlot (render-only).

Plus PublicAPI entries, a 103-line design doc, and 388 lines of new unit tests.

Root-cause read (independent)

The pre-fix defect is real and correctly located: Handler?.UpdateValue("DrawerToggleVisible") was a no-op because ToolbarHandler.Mapper in Core registers only [nameof(IToolbar.Title)], and no platform partial had ever registered a DrawerToggleVisible entry. Additionally ShellToolbar/NavigationPageToolbar assigned the backing field directly, so even PropertyChanged never fired. Both halves had to be fixed; the PR fixes both. Item (3) is the load-bearing change.

The interface-vs-DIM decision is sound: adding a member to the shipped IToolbar is a breaking change for netstandard2.0 implementers (no default interface members), so a separate optional interface consumed by pattern match is the right shape. Read-only on the contract is also right — the value is computed by the cross-platform layer, and the previous Tizen code writing back into Element.Toolbar.DrawerToggleVisible was exactly the layering violation this removes.

Architectural / layering verdict

  • Interface placement in src/Core is correct (Wave-note: Core is where IToolbar lives; nothing new was added to Controls.csproj's core dependency surface).
  • ToolbarNavigationIconKind / NavigationIconKind / the generation counter are internal — no API cost, and they legitimately de-duplicate precedence logic that was previously open-coded and inconsistent between Tizen's UpdateBackButton and UpdateTitleIcon.
  • ShellView.RefreshNavigationSlot no longer computes state — good, that responsibility now sits solely in ShellToolbar.ApplyChanges. I verified ShellToolbar recomputes _drawerToggleVisible from (_shell as IFlyoutView).FlyoutBehavior inside ApplyChanges, so the removed Tizen recomputation is not a lost update path.
  • ReplaceMapping on a key Core does not define behaves as an add. The repo convention prefers ModifyMapping when overriding Core behavior; here there is nothing to override, and the surrounding lines in the same method use ReplaceMapping, so this is consistent. Not flagged.

Public API / TFM compatibility

  • IToolbarDrawerToggleVisible + its getter are added to net, netstandard, netstandard2.0, net-android, net-ios, net-maccatalyst, net-tizen, net-windows PublicAPI.Unshipped.txt. Coverage is complete.
  • Toolbar.MapDrawerToggleVisible overloads (IToolbarHandler and ToolbarHandler) are added to net-android and net-tizen only, matching the #if ANDROID || TIZEN compilation. Correct.
  • Nothing was written to any PublicAPI.Shipped.txt. Correct.
  • Churn note (not filed inline): src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt and netstandard2.0/PublicAPI.Unshipped.txt were fully re-sorted (StatusBarTheme, ISwipeItemMenuItemIconColor, SafeAreaEdges.Container, SearchBarHandler.MapCursorPosition/MapSelectionLength, ShapeViewHandler.MapFlowDirection all moved). That accounts for ~20 of the 22 changed lines in those two files and is unrelated to this fix. It is harmless (the analyzer is order-insensitive) but makes the API delta hard to read and will conflict with concurrent API-adding PRs. Worth reverting the reorder before merge; too low-value to spend an inline slot on.

Handler lifecycle / threading / memory

  • No ConnectHandler/DisconnectHandler changes; no new event subscriptions or listener registrations, so no new leak surface.
  • Interlocked.Increment / Volatile.Read on _navigationIconUpdateGeneration is appropriate for the intended use (invalidating in-flight LoadImage callbacks). int rollover is benign here — a collision requires exactly 2^32 intervening updates.
  • IsCurrentTitleIconUpdate correctly triple-checks generation, ReferenceEquals(source, TitleIcon), and that the slot still wants a title icon. This closes a genuine pre-existing Tizen bug where a slow title-icon load could stomp a back button that was set after the load started.
  • No hot-path concerns: everything added runs on navigation transitions, not measure/arrange/scroll.

Cross-platform consistency

The mapping is Android/Tizen-only. The in-code justification (Windows/iOS/MacCatalyst render the flyout toggle from the flyout/navigation view, not the toolbar's navigation slot) matches what I found: Toolbar.Windows.cs and the iOS toolbar path have no DrawerToggleVisible consumer. So the scoping is right — but the XML doc on the new interface promises the update unconditionally, which is inconsistent with the scoping (filed).


2. Concrete failure-mode probing (Toolbar/Shell are regression-sensitive)

I traced each mutation path end-to-end into the Android platform writes.

Probe A — Android DrawerArrowDrawable.Progress is now written on a transition that deliberately avoided handler updates.
NavigationPageToolbar.UpdateBackButton has an #if ANDROID branch assigning _backButtonVisible = GetBackButtonVisible(); without SetProperty, with an in-code rationale that Android animates the hamburger↔arrow morph and "we don't want to interrupt here". Android's ToolbarHandler confirms it: SetupToolbar() calls NavigationUI.SetupWithNavController(PlatformView, _navController, appbarConfig) with SetOpenableLayout(_drawerLayout), i.e. the NavController owns the drawer arrow. The new line 226 notification fires on precisely the FlyoutPage→NavigationPage push/pop transition (anyPagesPushed flipping drawerToggleVisible), reaches MapDrawerToggleVisible → AToolbar.UpdateBackButton, which sets iconDrawable.Progress = 1 (or 0) immediately. This re-opens the interruption the guard exists to prevent. Filed, major. This is the highest-value finding for the nominated Android platform, and it is the one the PR has no test for at any level.

Probe B — Tizen UpdateBackButton gains a hard MauiContext requirement.
The else branch changed from else if (toolbar.TitleIcon == null) { platformToolbar.Icon = null; } (handler-free) to platformToolbar.UpdateTitleIcon(toolbar, generation), whose first statement throws ArgumentNullException if toolbar?.Handler?.MauiContext is null — before the source == null || source.IsEmpty early-out. ShellView.RefreshNavigationSlot() calls _toolbar?.UpdateBackButton(Element!.Toolbar) from UpdateFlyoutBehavior and from a PropertyChanged listener, where the Shell toolbar's handler is not guaranteed connected. Filed, major.

Probe C — ForwardNavigationIconStateTo intermediate states.
All three branches converge to the correct final state, so there is no persistent corruption. But branch 2 (DrawerToggleVisible = true then BackButtonVisible = false) and branch 3 (BackButtonVisible = false then DrawerToggleVisible = false) each raise a handler update while the other flag is stale, and with the new mapping each update now reaches UpdateBackButton. Result: two platform renders per Shell screen change and one intermediate render that contradicts the ordering invariant the PR itself documents. Not a crash, not a persistent wrong state; observable as a redundant Progress/content-description write. Filed, moderate.

Probe D — missed-notification paths. I checked for early returns between the _drawerToggleVisible write and the notification in both derived toolbars. NavigationPageToolbar.UpdateBackButton has returns only before the assignment (_currentPage/_currentNavigationPage == null, anyPagesPushed == null); ShellToolbar.ApplyChanges has none between the two. No missed-notification defect. Clean.

Probe E — Shell Android tracker. ShellToolbarTracker.ApplyToolbarChanges replacing two assignments with ForwardNavigationIconStateTo preserves the custom-flyout-icon protection in AToolbar.UpdateBackButton (NavigationIcon ??= new DrawerArrowDrawable(context!)), and the final state matches the old code in all four flag combinations. The prior review's concern about "briefly clearing the navigation icon" is addressed by this helper. Clean.

Probe F — Tizen title-icon restoration. With TitleIcon set and the drawer toggle turning off, the old code left the stale back/menu button in place (else if (toolbar.TitleIcon == null) never fired). The new else branch restores the title icon. This is a genuine behavior fix, correctly covered by TizenNavigationSlotRestoresTitleIconWhenDrawerToggleIsHidden. Clean (improvement).

Probe G — external IToolbar implementers. A type implementing only IToolbar is unaffected (new interface is separate). Pattern-match consumption is IToolbarDrawerToggleVisible { DrawerToggleVisible: true } degrades to false. No source or binary break. Clean.


3. Test-coverage assessment

ToolbarDrawerToggleTests (14 tests) covers: interface reachability from IToolbar, legacy-vs-capable toolbar pattern matching, external-backend notification on flyout-behavior change, suppression when unchanged, Tizen title-icon restoration, forwarding intermediate state, stale title-icon rejection, Shell back-button precedence, NavigationPage-in-FlyoutPage transitions, split-mode suppression, and per-window tracking. That is a genuinely broad cross-platform-agnostic suite and the notification half of the fix is well covered.

Two gaps:

  • The mapper registration — the actual fix — is untested. It compiles only under ANDROID || TIZEN; Controls.Core.UnitTests targets net. Every test asserting "the backend was notified" uses a stub ElementHandler whose UpdateValue is recorded directly, which passes with or without the registration. Removing line 35 of Toolbar.Mapper.cs would leave the whole suite green. Filed, major.
  • ForwardingNavigationSlotAvoidsInvalidIntermediateState conflates signals and cannot fail on the ordering it names (both fixtures set TitleIcon, so None is unreachable; the drawer branch's stale-BackButtonVisible notification reports kind BackButton, satisfying both DoesNotContain assertions). Filed, moderate.

No Android device/UI test accompanies an Android-behavior-changing PR touching Toolbar + Shell — both entries on the frequently-regressed list.


4. Narrative and prior-review reconciliation

Pre-flight (pre-flight/content.md). Matches my independent read on every material point: the no-op UpdateValue, the direct backing-field assignments bypassing both channels, the deliberate rejection of a DIM-on-IToolbar design because it source-breaks netstandard2.0 implementers, and the non-mutually-exclusive back/drawer semantics on Windows. No divergence to reconcile.

Prior review surfaces (retrieved anonymously via GitHub REST; gh unauthenticated, which did not block): 9 reviews / 12 review comments across several commits, most against 9dc0b209 (an earlier commit than the reviewed head 736bd9f291).

  • Copilot reviewer raised a netstandard2.0 DIM-accuracy remark and an "interface can't guarantee notification" remark on IToolbar.cs. The first is obsolete — the DIM design is gone at head. The second is still valid at head and I re-derived it independently plus the platform-scoping inaccuracy; consolidated into my IToolbar.cs:51 finding.
  • Copilot reviewer on ShellToolbarTracker ("assigns BackButtonVisible before DrawerToggleVisible, can briefly clear the navigation icon") is resolved at head by ForwardNavigationIconStateTo. Not re-filed.
  • Copilot reviewer on ShellView.cs:106 ("also refresh the slot when DrawerToggleVisible changes") is now a false positive: with the Tizen mapper registered, a DrawerToggleVisible change reaches UpdateBackButton via MapDrawerToggleVisible, so the listener does not need a second key. Deliberately not filed.
  • Copilot reviewer on docs/design/ToolbarDrawerToggle.md:50 (doc prescribes an ordering the helper no longer follows) is valid but doc-only and low-value; not filed.
  • MauiBot AI review (5 findings) independently landed on the same four items I derived from code: Tizen null-handler, the Android #if ANDROID re-interruption, the untested #if ANDROID || TIZEN mapping, and the non-discriminating forwarding test. None of them are fixed at head — I verified each against 736bd9f291 line-by-line. Because they remain live defects in the submitted PR and this is the single review pass of record, I re-file them with head-accurate line numbers and my own corroborating trace rather than suppressing them as duplicates.

Net: my code-first conclusions and the prior surfaces agree; the disagreements are all cases where the prior comment has since been fixed or has become a false positive, and I dropped those.


5. Blast radius

Surface Exposure
Android Shell + NavigationPage/FlyoutPage toolbars High. New platform write path on every drawer-toggle transition; both components are on the frequently-regressed list. Primary risk.
Tizen toolbars High relative to platform usage. UpdateBackButton gains a throwing precondition and a new async image-load on the no-nav-icon path.
iOS / MacCatalyst / Windows Very low. No mapping registered; only the extra PropertyChanged raise, which nothing consumes.
Public API Additive only, all TFMs, no shipped-file edits. Safe.
External IToolbar implementers None — separate optional interface.
Compatibility renderers ShellToolbarTracker.ApplyToolbarChanges only; final state preserved.

Reversibility is good: the fix is four small, independently revertible mechanisms.


6. CI / Gate evidence

  • Gate: trusted result PASSED (tests fail without fix, pass with fix). Not re-run, per instruction. No test suites were executed in this pass.
  • Required checks: not retrieved. The anonymous REST calls returned PR metadata, reviews and comments, but I did not resolve the combined status/check-runs for head 736bd9f291. Recorded as uncertainty, not treated as a blocker. Note the PR's statuses_url points at 00405fe19c47…, a different SHA than the materialized review head, so any status read would have needed care regardless.
  • Regression cross-reference: no regression-check/risks.json present; no REVERT entries to acknowledge. The only deletions of prior logic are the two ShellToolbarTracker assignments (replaced by an equivalent helper) and the ShellView.UpdateDrawerToggleVisible write-back (intentional layering fix).

7. Findings

Six inline findings written to CustomAgentLogsTmp/PRState/37863/PRAgent/inline-findings.json, all on RIGHT-side added lines of the submitted diff.

# Sev Dimension Location
1 major Handler Mapper / Regression Prevention NavigationPageToolbar.cs:226 — notification re-interrupts the Android drawer↔arrow animation the #if ANDROID branch protects
2 major Regression Prevention & Test Coverage Toolbar.Mapper.cs:35 — the load-bearing registration is unreachable from the net-only unit test project; suite stays green if deleted
3 major Null Safety / Logic and Correctness Platform/Tizen/Extensions/ToolbarExtensions.cs:87 — UpdateBackButton now throws when Handler.MauiContext is null, reachable from ShellView.RefreshNavigationSlot
4 moderate Logic and Correctness Toolbar.cs:84 — ForwardNavigationIconStateTo notifies with a stale sibling flag, contradicting the documented ordering invariant; double platform render
5 moderate Regression Prevention & Test Coverage ToolbarDrawerToggleTests.cs:193 — fixture conflates signals; the test cannot fail on the ordering it names
6 moderate Public API Surface / Cross-Platform Consistency IToolbar.cs:51 — doc promises a handler update that only occurs on Android/Tizen and cannot be guaranteed for external implementers

Noted but not filed: PublicAPI.Unshipped.txt re-sort churn on net/netstandard2.0 (harmless, but should be reverted to keep the API delta readable); docs/design/ToolbarDrawerToggle.md:50 ordering prescription now describing behavior the helper does not follow.

Explicitly cleared: no external-output parsing in this diff; no trimming/AOT annotation change (no RequiresDynamicCode, RequiresUnreferencedCode, DynamicallyAccessedMembers, FeatureGuard, UnconditionalSuppressMessage, or IL20xx/IL30xx suppression added); no reflection introduced; no input/path/deserialization surface touched.


8. Verdict

NEEDS_CHANGES · Confidence: high (medium specifically on finding #1's severity — the animation-interruption is derived from the in-code rationale plus the NavigationUI.SetupWithNavController/AppBarConfiguration wiring and a read of UpdateBackButton's direct Progress write, not from an observed Android run).

The design is right and the root cause is correctly and completely diagnosed — both halves of the bug (the missing mapper entry and the bypassed notification) are fixed, the optional-interface shape is the correct choice for netstandard2.0 compatibility, the layering cleanup on Tizen removes a real inversion, and the generation counter fixes a latent stale-async-load bug. This is a well-constructed PR. It is held back by three concrete issues on the nominated Android platform and on Tizen, plus a coverage gap that leaves the load-bearing line unverified.

Is reviewer feedback actionable enough to improve the PR in one consolidated patch? Yes. All six findings are mechanical and mutually independent, and a single patch can address them without redesign:

  1. Scope the NavigationPageToolbar notification so Android's animation-owned path is not re-entered (guard the notification the same way the _backButtonVisible assignment is guarded), or route it to a mapper that does not write DrawerArrowDrawable.Progress.
  2. Move the Tizen MauiContext guard below the source == null || source.IsEmpty early-out.
  3. Batch the two writes in ForwardNavigationIconStateTo so only one navigation-slot update is raised with both flags final.
  4. Tighten ForwardingNavigationSlotAvoidsInvalidIntermediateState to record flag tuples and add a TitleIcon = null case.
  5. Add one Android device test asserting platform navigation-icon state across a drawer-only transition, so the #if ANDROID || TIZEN mapping is actually exercised.
  6. Correct the IToolbar remark to scope the notification guarantee to framework-owned toolbars on Android/Tizen; optionally revert the PublicAPI.Unshipped.txt re-sort and align the design doc.

🛠️ Try-Fix — Analysis & Comparison

PR #37863 Try-Fix Aggregate

Candidate 1 — Claude Opus 5

Result: Blocked

Approach: Transactional toolbar state commit with automatic change diffing

Treat each derived-toolbar ApplyChanges pass as a transaction. A nesting-aware scope on Toolbar would snapshot navigation-slot state, allow existing direct backing-field writes, and diff/notify changed properties only when the outermost scope exits. This differs from the PR's explicit per-site NotifyPropertyChanged calls: detection and back-before-drawer ordering would be structural properties of transaction commit rather than conventions repeated at each mutation site. The optional IToolbarDrawerToggleVisible contract would remain to avoid the rejected netstandard2.0 default-interface-member source break; the design does not assume back/drawer mutual exclusion or let Tizen overwrite framework-owned state.

Outcome

The design was not applied. pwsh .github/scripts/EstablishBrokenBaseline.ps1 failed its clean-tree preflight because the review environment already contains roughly 60 tracked harness changes under .github/ and eng/. A confirming -DryRun failed at the same check, .github/.baseline-state.json was never created, and the try-fix modification allow-list therefore did not exist. The candidate correctly made no tracked edits.

  • Files changed: none
  • Diff: empty
  • Primary test: not run; without a broken baseline it would measure the existing PR fix
  • Mandatory ShellToolbarTests regression: not run because the primary test did not pass
  • Self-review: 0 findings ([]; no diff)
  • Restoration: exact script-only -Restore ran and reported the expected no-state result (Restored False); pre-existing harness changes remain untouched

Failure analysis

The blocker is environmental rather than evidence against the approach. The script offers no force/allow-dirty mode, while discarding or committing the pre-existing harness work is outside the execution contract. Further candidates are expected to encounter the same baseline preflight block, but candidate 2 must still attempt its own distinct design in the requested order.

Full narrative: ../try-fix-1/content.md

Artifacts: attempt-1/

Candidate 2 — GPT-5.6 Sol

Result: Blocked

Approach: Ordered dependent-property invalidation queue

Replace derived direct drawer backing-field writes with a base Toolbar.SetDrawerToggleVisibleBeforeBackButton(bool) transition. It would centrally perform changed-value detection, update drawer state, and queue one pending drawer invalidation. A specialized BackButtonVisible setter would publish/settle back state and then drain the pending drawer notification, including when the back value itself is unchanged. Public direct drawer assignments would retain immediate SetProperty behavior.

This mechanism differs from both the PR's explicit call-site notification and candidate 1's transactional snapshot/scope: derived classes provide the new drawer value but do not compare, notify, snapshot, or manage a transaction. Ordering follows from the drawer property's declared dependency on the subsequent back-state publication. The design would retain the optional capability interface to avoid the rejected netstandard2.0 DIM source break and would not assume mutual exclusion or platform ownership.

Outcome

The design was not applied. The mandatory baseline command encountered the same pre-existing .github/ and eng/ tracked harness changes, did not create .github/.baseline-state.json, and therefore provided no RevertedFiles allow-list. The candidate correctly stopped before editing or testing rather than attributing the PR's existing behavior to its unimplemented design.

  • Files changed: none
  • Diff: empty
  • Primary test: not run; no broken baseline existed
  • Mandatory ShellToolbarTests regression: not run because the primary test did not pass
  • Self-review: 0 findings ([]; no diff)
  • Restoration: exact script-only -Restore ran and reported the expected no-state result (Restored False); pre-existing harness changes remain untouched

Failure analysis

The result is an environmental block, not empirical support for or against the dependent-property queue. Cleaning, committing, stashing, or manually restoring the harness changes would violate the execution contract, while testing current HEAD would only re-measure the already-verified PR implementation.

Full narrative: ../try-fix-2/content.md

Artifacts: attempt-2/

Aggregate Result

Two candidates were generated in the required model order. Both are distinct from the PR and from each other, but neither could be implemented or validated because the baseline script rejects the pre-existing tracked harness modifications before creating a restoration allow-list. There is therefore no passing alternative candidate and no candidate diff to compare in STEP 5b.


📝 PR Finalize — Recommended Title & Description

Assessment: ✏️ Recommend updating — the title inaccurately names IToolbar instead of the optional capability interface, while the description has stale ordering/test-count claims and omits the new navigation-icon generation guard.

Recommended title

[net11.0] Toolbar: Expose drawer-toggle visibility to platform handlers

Recommended description

### Description of Change

External platform backends implement toolbar handlers against `Microsoft.Maui.IToolbar`. That contract exposed `BackButtonVisible`, `IsVisible`, and `Title`, but no way to read the drawer (flyout / "hamburger") toggle, so a backend could not render or update that affordance without keeping duplicate state.

There were two gaps:

1. **No read contract.** `DrawerToggleVisible` existed only on the Controls-level `Microsoft.Maui.Controls.Toolbar`, not on a contract available to handlers.
2. **No change notification.** `ShellToolbar` and `NavigationPageToolbar` assign the `_drawerToggleVisible` backing field directly, bypassing both `PropertyChanged` and `Handler.UpdateValue`. A drawer-only transition could therefore be dropped.

Affected transitions include:

- `Shell.FlyoutBehavior` changing between `Flyout` and `Disabled`/`Locked` without a navigation-stack change.
- `FlyoutPage.FlyoutLayoutBehavior` changing between `Split` and `Popover` on a tablet.
- Tizen `ShellView` updating `Toolbar.DrawerToggleVisible` when no mapper key existed.

### API: optional capability interface

```csharp
/// Provides the visibility of the drawer (flyout) toggle affordance for an IToolbar.
public interface IToolbarDrawerToggleVisible
{
    bool DrawerToggleVisible { get; }
}

Microsoft.Maui.Controls.Toolbar implements this interface. External backends consume it by pattern matching:

bool drawerToggleVisible =
    toolbar is IToolbarDrawerToggleVisible { DrawerToggleVisible: true };

Why not add a member to IToolbar

An earlier design added DrawerToggleVisible to IToolbar as a default interface member. That source-breaks external IToolbar implementations targeting netstandard2.0, where default interface members are unsupported and the member becomes abstract (CS0535).

The separate capability interface is additive on every TFM. This follows the precedent of ISwipeItemMenuItemIconColor, whose documentation cites the same compatibility constraint.

The interface is intentionally discoverable rather than marked [EditorBrowsable(EditorBrowsableState.Never)]: external backend authors are its intended consumers. It is read-only because Shell and NavigationPage own and compute this state. The shipped settable property remains on Controls.Toolbar.

External-implementer compile matrix

Design netstandard2.0 net11.0
Default member on IToolbar ❌ Existing implementations fail with CS0535 ✅ Builds
Optional capability interface ✅ Builds ✅ Builds

The compatibility check used a standalone implementation containing only the pre-existing IToolbar members:

public class LegacyExternalToolbar : IToolbar
{
    public bool BackButtonVisible { get; set; }
    public bool IsVisible { get; set; }
    public string Title => string.Empty;
    public IElement Parent => null;
    public IElementHandler Handler { get; set; }
}

IToolbar itself is unchanged, and the PublicAPI diff adds no Microsoft.Maui.IToolbar.* member.

Notification and navigation-slot state

  • Adds private protected Toolbar.NotifyPropertyChanged(string) and routes SetProperty through it.
  • ShellToolbar.ApplyChanges and NavigationPageToolbar.UpdateBackButton compute the drawer value, assign the backing field before updating BackButtonVisible, and raise a changed-only DrawerToggleVisible notification afterward. Handlers therefore read the final cross-platform back/drawer values when the drawer notification runs.
  • Registers DrawerToggleVisible mappings for Android and Tizen, the built-in platforms that render the drawer affordance from the toolbar navigation slot.
  • Adds ToolbarNavigationIconKind to centralize precedence among back, drawer, title-icon, and empty states.
  • Adds ForwardNavigationIconStateTo for the Android compatibility ShellToolbarTracker rather than open-coding the two flags at that call site.
  • Adds a generation counter around asynchronous title-icon loading so an obsolete image callback cannot overwrite a newer back or drawer icon.

BackButtonVisible and DrawerToggleVisible are not mutually exclusive. On Windows both can be true; because they share a navigation slot, the back button takes precedence when rendering.

Each Android/Tizen property mapping re-evaluates the shared slot. When both properties change, both mapper keys can run against the final toolbar state.

Tizen ownership and title-icon behavior

The previous ShellView.UpdateDrawerToggleVisible() assigned:

Element!.Toolbar.DrawerToggleVisible =
    Element!.Toolbar.DrawerToggleVisible &&
    Element.FlyoutBehavior == FlyoutBehavior.Flyout;

That made a platform backend overwrite framework-owned state, duplicated ShellToolbar's effective-flyout calculation, latched false, and compared the raw bindable property instead of the effective behavior.

The assignment is removed. The method is renamed RefreshNavigationSlot() and only re-renders the current framework-owned state. Tizen navigation-slot rendering also restores the title icon after a back/drawer icon is removed, and stale asynchronous title-icon completions are rejected by the generation check.

Built-in platform consumption

Platform Consumes this toolbar property? Implementation
Android Yes ToolbarExtensions.UpdateBackButton selects a DrawerArrowDrawable with drawer progress when the back button is hidden. Shell also uses ShellToolbarTracker.
Tizen Yes ToolbarExtensions.UpdateBackButton installs the menu button and restores the title icon when appropriate.
Windows No NavigationView owns the flyout toggle.
iOS / MacCatalyst No The flyout/navigation controller owns the toggle.

Tests

src/Controls/tests/Core.UnitTests/ToolbarDrawerToggleTests.cs adds 14 test methods covering:

  • capability access through IToolbar;
  • legacy external implementations that do not opt in;
  • capable external implementations;
  • an external fake backend that reads state only through IToolbarDrawerToggleVisible;
  • Shell FlyoutBehavior notifications and unchanged-value suppression;
  • back-button precedence and notification ordering;
  • NavigationPage inside FlyoutPage, including push/pop and Split to Popover;
  • Tizen title-icon restoration and stale-load rejection;
  • compatibility-toolbar state forwarding;
  • per-window state isolation.

Four tests fail when the Shell/NavigationPage notification fix is removed:

DrawerToggleStateIsTrackedPerWindow
ExternalBackendIsNotifiedForNavigationPageInsideFlyoutPage
DrawerToggleValueIsCurrentWhenBackButtonMapperRuns
ExternalBackendIsNotifiedWhenFlyoutBehaviorChanges

Validation

  • Controls.Core.UnitTests: 6218 passed, 0 failed, 30 skipped.
  • Core.csproj builds for netstandard2.0 and net11.0.
  • Controls.Core.csproj builds for net11.0-android37.0, including mapper and PublicAPI analyzers.
  • The external-implementer compile matrix above passes.
  • Tizen was not verified locally because the workload was unavailable (NETSDK1139); CI must confirm that target.

Docs

Adds docs/design/ToolbarDrawerToggle.md covering the optional-interface rationale, ownership, back-button precedence, update ordering, a copy-pasteable external handler, and built-in platform consumption.

Issues Fixed

Unblocks external MAUI platform backends that currently need a private ConditionalWeakTable adapter to track drawer-toggle state.



</details>

---

<details>
<summary><strong>🏁 Report — Final Recommendation</strong></summary>
<br/>

## ⚠️ Final Recommendation: REQUEST CHANGES

**Winner:** `pr-plus-reviewer`

The submitted design is fundamentally sound, and the trusted Gate passed, but the raw `pr` candidate does not win because the one expert review found three major and three moderate actionable issues. The consolidated `pr-plus-reviewer` candidate addresses those findings and passes both required targeted test groups. Because the winning changes are not in the submitted PR HEAD, the recommendation must remain **REQUEST CHANGES**.

## Candidate comparison

| Rank | Candidate | Implementation | Validation | Expert/review evidence | Decision |
|---:|---|---|---|---|---|
| 1 | `pr-plus-reviewer` | Applied one consolidated patch to the required sandbox. It protects Android's NavController animation without suppressing external notifications, fixes the Tizen handler-free path, batches forwarded state before notifying, corrects the API remark, strengthens unit coverage, and adds Android mapper coverage. | **Pass:** `ToolbarDrawerToggleTests` 17/17; **Pass:** `ShellToolbarTests` 21/21. | Directly addresses all six raw-PR inline findings. Android device coverage was added but not run; Android/Tizen conditional code still needs platform CI. | **Winner.** Best correctness and regression profile among implemented candidates. |
| 2 | `pr` | Adds the optional `IToolbarDrawerToggleVisible` contract, changed-only notifications, Android/Tizen mappings, centralized navigation-slot state, stale-image generation protection, docs, and broad unit tests. | Trusted Gate **passed**: tests fail without the fix and pass with it. | Expert verdict **NEEDS_CHANGES (high confidence)**. Raw PR can snap Android's NavController-owned transition, can throw on Tizen without `MauiContext`, notifies forwarded state with a stale sibling flag, leaves the platform mapper untested, has a non-discriminating forwarding test, and overstates the interface notification contract. | Strong base design, but lower than the refined candidate because concrete review findings remain. |
| 3 | `try-fix-1` | Proposed a transactional, nesting-aware toolbar state scope with commit-time diffing. No implementation or diff was produced. | **Blocked:** primary and regression tests not run because the baseline script rejected pre-existing harness changes. | Distinct structural idea, but there is no empirical or code evidence to compare with either implemented candidate. | Cannot win over passing implemented candidates. |
| 4 | `try-fix-2` | Proposed an ordered dependent-property invalidation queue drained by the back-button setter. No implementation or diff was produced. | **Blocked:** primary and regression tests not run for the same baseline-environment reason. | Distinct from both the PR and candidate 1, but likewise has no implementation or validation evidence. | Cannot win over passing implemented candidates. |

No candidate failed a regression test. The two alternatives were blocked before implementation, while both implemented candidates have passing evidence; the expert-confirmed defects therefore determine the ordering between `pr-plus-reviewer` and `pr`.

## Why `pr-plus-reviewer` wins

The candidate retains the raw PR's best decisions: a separate optional interface avoids the `netstandard2.0` source break, state remains owned by the cross-platform toolbar, and Android/Tizen consume the new key through normal handler mappings. It then removes the concrete regressions identified by the expert without redesigning that contract:

1. Android built-in mapping is skipped only while a changed back state is owned by the NavController transition; drawer-only updates and external mappings remain observable.
2. Tizen requires `MauiContext` only when loading a real title image, not when clearing an empty one.
3. Compatibility forwarding settles both flags before either mapper or subscriber runs, while preserving both property keys for external mapper extensibility.
4. Focused tests now detect stale sibling state, exercise both title-icon cases, and include platform-level Android mapper coverage.
5. XML documentation now distinguishes the framework toolbar's notification from which built-in platforms map it.

## Residual uncertainty

The required `net11.0` unit-test commands do not compile or execute the Android/Tizen conditional paths. The new Android device test was not run under the bounded command contract, and no Tizen workload validation was performed. The candidate's platform fixes are therefore supported by code-path analysis and passing shared regressions, not by a completed device run. This uncertainty does not elevate either blocked try-fix design or the raw PR above the candidate, but platform CI should confirm the winning patch after it is applied to the PR.


</details>

---

<details>
<summary><strong>🔗 Regression Cross-Reference</strong></summary>
<br/>

## 🔍 Regression Cross-Reference

⚠ **Overlaps with prior bug-fix PRs** — same files modified, but no exact line revert detected.

| File | Fix PR | Fixed issue(s) |
|---|---|---|
| `src/Controls/src/Core/ShellToolbar.cs` | #36673 | #36562 |

### 🧪 Regression Tests to Verify

These tests were added by the overlapping fix PRs. Running them to verify no side-effect regressions:

| Fix PR | Type | Test | Filter |
|---|---|---|---|
| #36673 | UnitTest | ShellToolbarTests | `ShellToolbarTests` |


### 🧪 Regression Test Results

✅ **PASSED** — 1 passed, 0 failed, 0 skipped

| Fix PR | Test | Type | Result |
|---|---|---|---|
| #36673 | ShellToolbarTests | UnitTest | ✅ PASSED |


</details>

---

<details>
<summary><strong>📱 UI Tests — Navigation,Shell</strong></summary>
<br/>

**Detected UI test categories:** `Navigation,Shell`

<!-- DEEP_UITESTS_BEGIN -->
✅ **Deep UI tests** — 417 passed, 0 failed, 1 skipped across 2 categories on platform-pool agent (replaces in-process counts above).

### 🧪 UI Test Execution Results (deep, platform pool)

| Category | Tests | Snapshot diffs |
|---|---|---|
| `Navigation` | 90/91 (1 skipped) ✓ | — |
| `Shell` | 327/327 ✓ | — |
📎 [Download `drop-deep-uitests` artifact (TRX + snapshot diffs)](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=15132198&view=artifacts&pathAsName=false&type=publishedArtifacts)

<!-- DEEP_UITESTS_END -->


</details>

</details>
<!-- SESSION:00405fe END -->

---

<details>
<summary><strong>🧭 Next Steps</strong> — reviewer changes required</summary>
<br/>

**The reviewer-enhanced candidate identified changes that are not yet in the submitted PR.**

**Why:** The consolidated reviewer candidate preserves the PR&#39;s additive capability-interface design while fixing the expert-confirmed Android animation, Tizen null-context, state-ordering, test-coverage, and documentation issues. Both required targeted test groups passed, whereas the two try-fix alternatives were blocked before producing code or validation evidence.

Address the actionable findings in this review before merging.

</details>

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Aug 28, 2026
@kubaflo
kubaflo merged commit 533bb4a into net11.0 Aug 28, 2026
139 of 152 checks passed
@kubaflo
kubaflo deleted the redth-supreme-fortnight branch August 28, 2026 18:12
@github-actions github-actions Bot added this to the .NET 11.0-preview7 milestone Aug 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-toolbar ToolBar platform/android s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants