Skip to content

[net11.0] Add public Shell flyout item template contract for external backends - #37862

Merged
kubaflo merged 5 commits into
net11.0from
redth-shell-flyout-template-api
Aug 27, 2026
Merged

kubaflo merged 5 commits into
net11.0from
redth-shell-flyout-template-api

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

Out-of-tree Shell backends need to decide whether a flyout item uses an application-supplied DataTemplate or the backend's own platform-native presentation. That decision requires resolving the object that actually carries the template, which is not always the flyout item itself:

  • A MenuItem added to Shell.Items is wrapped in the internal MenuShellItem. When Shell.MenuItemTemplate is set on the MenuItem, the wrapper never has the property set — the template lives on MenuShellItem.MenuItem.
  • A MenuItem in ShellContent.MenuItems appears in the flyout grouping directly, while the template may be set on its parent ShellContent.

Both branches lived in the internal Shell.GetBindableObjectWithFlyoutItemTemplate. An external backend can only inspect the flyout item it is handed, so it concludes no template is set and incorrectly falls back to its platform default. This is a concrete blocker for the Tizen backend now maintained out-of-tree (Redth/Maui.Tizen, Wave C).

New API

One result-oriented, nullable-annotated method:

public static DataTemplate? ResolveFlyoutItemTemplate(Shell? shell, BindableObject flyoutItem)

Returns the final application-defined template, or null meaning use your own platform-native default. MenuShellItem and the paired-object lookup stay internal, and IShellController is unchanged (no breaking interface addition).

Precedence matches the built-in backends exactly: a template set on the item wins over one set on the Shell; MenuItemTemplateProperty is used for menu items and ItemTemplateProperty for everything else.

View CreateFlyoutItemView(Shell shell, BindableObject flyoutItem)
{
    var template = Shell.ResolveFlyoutItemTemplate(shell, flyoutItem);

    if (template is null)
        return CreatePlatformDefaultFlyoutItemView(flyoutItem);

    var view = (View)template.SelectDataTemplate(flyoutItem, shell).CreateContent();
    view.BindingContext = flyoutItem;
    return view;
}

Binding the created content to flyoutItem is what all three built-in backends do — iOS UIContainerCell.BindingContext = context, Android View.BindingContext = value, Windows _content.BindingContext = bo.

Null semantics

An item that explicitly sets the template property wins even when the value is null, so an app can opt a single item out of a Shell-level template. A null or null-bound value is reported as "no template" rather than producing a true + null mismatch or an NRE in platform code.

IShellController.GetFlyoutItemDataTemplate is now ResolveFlyoutItemTemplate(this, bo) ?? BaseShellItem.CreateDefaultFlyoutItemCell(bo), so the in-box path never hands null to platform code. Previously an explicitly-null template returned null here, which produced a blank Windows item and an NRE on Tizen.

Dogfooding

The Windows backend (ShellFlyoutItemView) now goes through the public API and falls back to the default cell. The in-box Tizen adaptor resolves and null-checks in one step. BaseShellItem.CreateDefaultFlyoutItemCell continues to use the internal helper for its style-class source.

Important

Intentional Windows behavior change. When a flyout item explicitly sets its template property to null (e.g. Shell.SetItemTemplate(item, null) to opt one item out of a Shell-level template), Windows previously rendered a blank flyout item — GetFlyoutItemDataTemplate returned null and ShellFlyoutItemView skipped content creation entirely. It now renders the default flyout item cell, matching Android and iOS. This is a deliberate consistency fix, not a regression.

Changes since the first revision

Addressing review feedback, the original three methods (GetFlyoutItemTemplateProperty, GetFlyoutItemTemplateSource, IsFlyoutItemTemplateSet) were removed in favor of the single method above, because:

  1. Get* on Shell reads as an attached-property accessor, which these were not.
  2. Exposing the property / source / is-set trio froze the internal lookup levels as public contract.
  3. The documented binding context was wrong — it pointed callers at the template source (the parent ShellContent for ShellContent.MenuItems) instead of the flyout item.

Issues Fixed

Unblocks external Shell backends (Tizen) from replicating in-box flyout item template selection.

Tests

ShellExternalFlyoutBackendTests (27 tests) drives a FakeExternalShellFlyoutBackend restricted to public API only, mirroring an out-of-tree adaptor:

  • Template resolution — no template → null; Shell-level ItemTemplate/MenuItemTemplate; item-level template winning over Shell-level; MenuItemTemplate set on the MenuItem and found through the MenuShellItem wrapper; set on the parent ShellContent and found through the MenuItem; set on the MenuItem itself for ShellContent.MenuItems; and the pre-existing parent-wins precedence when both are set
  • Binding — Text and Command bound through ShellContent.MenuItems, Text/Command bound through Shell-level MenuItemTemplate, Title bound for shell items, and flyout selection actually invoking the MenuItem.Command
  • Null handling — explicit-null item template opting out of the Shell template (item and menu item), null-bound template, and a test asserting the in-box path still yields a non-null template
  • Selector — DataTemplateSelector returned as-is and resolved by the caller
  • Headers/footers — FlyoutHeader, FlyoutFooter, FlyoutHeaderTemplate, FlyoutFooterTemplate, and headers not appearing as flyout items
  • Argument/ownership semantics — omitting the Shell resolves it from the item, unparented items, null argument validation

Results:

Suite Result
Controls.Core.UnitTests 6234 passed, 0 failed (30 skipped)
Controls.Xaml.UnitTests 2115 passed, 0 failed (8 skipped)
Controls.Core net11.0 + netstandard2.0 build clean, PublicAPI analyzer clean

net11.0-windows* and net11.0-tizen* cannot be compiled on this macOS box (MakePri.exe / unrecognized tizen platform identifier), so those two backend edits are review-validated only; CI covers them.

… backends

Out-of-tree Shell backends (for example the Tizen backend that now lives
outside this repository) have to decide whether a flyout item uses an
application supplied `DataTemplate` or the backend's own platform default
view. That decision requires resolving the object that actually carries the
template, which is not always the flyout item itself: menu items are backed
by a pair of objects (the internal `MenuShellItem` wrapper and the public
`MenuItem`) and the template can be set on either one.

The logic lived in the internal `Shell.GetBindableObjectWithFlyoutItemTemplate`,
so external backends could not reproduce it and menu items incorrectly fell
back to the platform default template.

Expose the minimal contract publicly on `Shell`:

* `GetFlyoutItemTemplateProperty` - the `BindableProperty` used for an item.
* `GetFlyoutItemTemplateSource` - the object that carries the template, the
  style class, and the binding context for an item.
* `IsFlyoutItemTemplateSet` - whether `GetFlyoutItemDataTemplate` returns an
  application supplied template or falls back to the default flyout cell.

`MenuShellItem` stays internal. All existing call sites (Shell template
resolution, default flyout cell style classes, and the in-box Tizen flyout
adaptor) now go through the public helpers, so flyout item, menu item, and
header template selection, binding contexts, and commands are unchanged.

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:39
@Redth
Redth temporarily deployed to copilot-pat-pool August 26, 2026 23:39 — 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 -- 37862

Or

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

@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.

@Redth
Redth temporarily deployed to copilot-pat-pool August 26, 2026 23:39 — with GitHub Actions Inactive
@Redth
Redth temporarily deployed to copilot-pat-pool August 26, 2026 23:40 — with GitHub Actions Inactive
@Redth
Redth temporarily deployed to copilot-pat-pool August 26, 2026 23:43 — with GitHub Actions Inactive
@Redth
Redth temporarily deployed to copilot-pat-pool August 26, 2026 23:44 — with GitHub Actions Inactive
@github-actions github-actions Bot added the area-controls-shell Shell Navigation, Routes, Tabs, Flyout label Aug 26, 2026
@Redth
Redth temporarily deployed to copilot-pat-pool August 26, 2026 23:44 — with GitHub Actions Inactive
Redth pushed a commit to Redth/Maui.Tizen that referenced this pull request Aug 26, 2026
…l one

The ShellTemplateResolver expiry test watched for
Shell.GetBindableObjectWithFlyoutItemTemplate becoming public. Upstream is not
planning to publish that name: dotnet/maui#37862 proposes a different shape -
IsFlyoutItemTemplateSet, GetFlyoutItemTemplateSource and
GetFlyoutItemTemplateProperty, used with the already-public
IShellController.GetFlyoutItemDataTemplate.

As written the test could never have fired, so the adapter would have quietly
become permanent - exactly the rot these tests exist to prevent. It now watches
the three proposed members and names the follow-up work when they land.

#37862 is OPEN, so nothing adopts it here. ShellTemplateResolver's
implementation is untouched and stays provisional until the API merges and
ships in a referenced package. Only the detector, the request ledger and the
wave doc change.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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 adds a small set of new public Shell helper APIs that let out-of-tree Shell flyout backends resolve flyout item templates (and their template “source” object) the same way in-box backends do, especially for the MenuItem/MenuShellItem wrapper case.

Changes:

  • Add public static Shell helpers: GetFlyoutItemTemplateProperty, GetFlyoutItemTemplateSource, and IsFlyoutItemTemplateSet.
  • Update in-box call sites (Shell template resolution, default flyout cell style-class sourcing, and Tizen flyout item template selection) to route through the new helpers.
  • Add ShellExternalFlyoutBackendTests to validate the contract from the perspective of an external backend.

Reviewed changes

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

Show a summary per file
File Description
src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs Adds unit tests that simulate an external Shell flyout backend using the new public helper contract.
src/Controls/src/Core/Shell/Shell.cs Introduces the new public helper APIs and switches internal template resolution to use them.
src/Controls/src/Core/Shell/BaseShellItem.cs Uses the new template-source helper to select the style-class source for the default flyout cell.
src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt Records the new public APIs for netstandard PublicAPI validation.
src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt Records the new public APIs for net PublicAPI validation.
src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt Records the new public APIs for net-windows PublicAPI validation.
src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt Records the new public APIs for net-tizen PublicAPI validation.
src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt Records the new public APIs for net-maccatalyst PublicAPI validation.
src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt Records the new public APIs for net-ios PublicAPI validation.
src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt Records the new public APIs for net-android PublicAPI validation.
src/Controls/src/Core/Handlers/Shell/Tizen/ShellFlyoutItemAdaptor.cs Updates Tizen flyout template selection to rely on Shell.IsFlyoutItemTemplateSet.

Comment thread src/Controls/src/Core/Shell/Shell.cs Outdated
Comment on lines +734 to +749
/// <summary>
/// Gets the <see cref="BindableProperty"/> that Shell uses to look up the flyout <see cref="DataTemplate"/>
/// for <paramref name="flyoutItem"/>.
/// </summary>
/// <param name="flyoutItem">A flyout item produced by <see cref="IShellController.GenerateFlyoutGrouping"/>.</param>
/// <returns>
/// <see cref="MenuItemTemplateProperty"/> for menu items, otherwise <see cref="ItemTemplateProperty"/>.
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="flyoutItem"/> is <see langword="null"/>.</exception>
public static BindableProperty GetFlyoutItemTemplateProperty(BindableObject flyoutItem)
{
if (flyoutItem is null)
throw new ArgumentNullException(nameof(flyoutItem));

return flyoutItem is IMenuItemController ? MenuItemTemplateProperty : ItemTemplateProperty;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch on the original revision — that concern is resolved by the redesign in 37f4a9c, which restored the helper rather than removing it.

Shell.GetBindableObjectWithFlyoutItemTemplate still exists with the identical signature, just internal and now documented:

internal static BindableObject GetBindableObjectWithFlyoutItemTemplate(BindableObject bo)

So both shipped binary profiles still resolve it — verified against the artifacts that Microsoft.Maui.Controls.targets actually imports:

$ strings maui.aotprofile    | grep -c GetBindableObjectWithFlyoutItemTemplate
1
$ strings maui-sc.aotprofile | grep -c GetBindableObjectWithFlyoutItemTemplate
1

IShellController.GetFlyoutItemDataTemplate is also unchanged in signature, so its profile entry (maui.aotprofile.txt:2056, maui-sc.aotprofile.txt:2575) stays valid too.

Two notes for the record:

  1. The .txt files are human-readable dumps, not build inputs — Controls.Build.Tasks.csproj packs nuget\** with Exclude="nuget\**\*.aotprofile.txt", and Microsoft.Maui.Controls.targets imports the binary maui.aotprofile / maui-sc.aotprofile. Hand-editing the .txt would have no effect on profiled AOT.
  2. The new ResolveFlyoutItemTemplate is not in the profiles, which is expected: the profiles are regenerated from a recorded run via src/ProfiledAot, not maintained by hand. It's a small non-virtual static on a path that is already only hit while building flyout items.

Redth pushed a commit to Redth/Maui.Tizen that referenced this pull request Aug 26, 2026
…name

The proposed API has changed shape twice while this adapter sat here: the
internal GetBindableObjectWithFlyoutItemTemplate, then a three-method contract,
and now a single resolve-style call. Each time the expiry test named members
explicitly it silently stopped detecting anything - worse than having no test,
because a green build then implies the adapter is still needed.

The detector now matches the concept: any new public Shell member about a
flyout item template. It is covered by table-driven tests proving it fires for
the resolve-style shape, the three-method shape and plausible alternatives,
while ignoring pre-existing members - so it is verified to trigger rather than
merely assumed to.

dotnet/maui#37862 remains OPEN and under design. No shape is adopted;
ShellTemplateResolver's implementation is untouched.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replaces the three algorithm-piece methods with one nullable-annotated,
result-oriented entry point:

    public static DataTemplate? ResolveFlyoutItemTemplate(Shell? shell, BindableObject flyoutItem)

It returns the final application-defined template, or null meaning "use your
own platform-native default". Rationale for the change:

* `Get*` on Shell reads as an attached-property accessor, which these were not.
* Exposing the property/source/is-set trio froze the internal lookup levels as
  public contract.
* The documented binding context was wrong. The built-in Android, iOS, and
  Windows backends all bind created content to the flyout item itself
  (`View.BindingContext = context` / `_content.BindingContext = bo`), not to the
  object that carried the template, which for `ShellContent.MenuItems` is the
  parent `ShellContent`.

`MenuShellItem` and the paired-object lookup stay internal.

Null handling is explicit: an item that sets the template property wins even
when the value is null (so an app can opt one item out of a Shell level
template), and a null or null-bound value is reported as "no template" rather
than producing a true/null mismatch or an NRE in platform code.
`IShellController.GetFlyoutItemDataTemplate` now composes the new method with
the default flyout cell, so the in-box path never hands null to platform code.

The Windows backend is dogfooded through the public API, and the in-box Tizen
adaptor now resolves and null-checks in one step.

Tests grow to 23 and add binding coverage: Text/Command bound through
`ShellContent.MenuItems` and through Shell-level `MenuItemTemplate`, flyout
selection invoking the command, item vs Shell template precedence, explicit
null, null-bound, `DataTemplateSelector`, headers/footers and their templates,
Shell resolution when the argument is omitted, unparented items, and argument
validation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 27, 2026 00:02
Adds the remaining flyout item shape an external backend can be handed: the
bare MenuItem whose template is set on its (internal) MenuShellItem wrapper,
reachable publicly as MenuItem.Parent, plus the no-template fallback for the
same shape.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Redth

Redth commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

Redesigned — ready for a fresh review

The three-step API from the first revision is gone. Head is now 6cc7f668f0. Point-by-point against the review feedback:

Single nullable result-oriented API. One method, algorithm details internal:

public static DataTemplate? ResolveFlyoutItemTemplate(Shell? shell, BindableObject flyoutItem)

null means "use your platform default". MenuShellItem, the template-owner lookup (GetBindableObjectWithFlyoutItemTemplate), and the property selection are all internal.

Public Get*(BindableObject) helpers removed. GetFlyoutItemTemplateProperty, GetFlyoutItemTemplateSource, and IsFlyoutItemTemplateSet are deleted — they collided with Shell's attached-property accessor convention and froze the internal lookup levels as public contract.

Bind to the flyout item, not the template source. Confirmed correct: for ShellContent.MenuItems the owner is the parent ShellContent, so binding there breaks Text/Icon/Command. The docs and example now bind to flyoutItem, matching all three in-box backends — iOS UIContainerCell.BindingContext = context, Android View.BindingContext = value, Windows _content.BindingContext = bo. There are tests that fail if this regresses.

Explicit/bound null is "no application template". An item that sets the property wins even when the value is null (so an app can opt one item out of a Shell-level template), and null or null-bound resolves to null rather than a set/null mismatch. IShellController.GetFlyoutItemDataTemplate is now ResolveFlyoutItemTemplate(this, bo) ?? BaseShellItem.CreateDefaultFlyoutItemCell(bo), so the in-box path can no longer hand null to platform code — previously that blanked the Windows item and threw on Tizen.

No IShellController change, MenuShellItem stays internal, and the style-class source in BaseShellItem.CreateDefaultFlyoutItemCell still uses the internal helper.

Dogfooded on Windows. ShellFlyoutItemView resolves through the public API and falls back to the default cell; binding semantics (_content.BindingContext = bo) unchanged. The in-box Tizen adaptor collapses to a resolve + null-check.

Nullable annotations + PublicAPI. Method is in a #nullable enable region; PublicAPI.Unshipped.txt updated across all 7 TFM folders:

static Microsoft.Maui.Controls.Shell.ResolveFlyoutItemTemplate(Microsoft.Maui.Controls.Shell? shell, Microsoft.Maui.Controls.BindableObject! flyoutItem) -> Microsoft.Maui.Controls.DataTemplate?

Tests — 25, public API only. ShellExternalFlyoutBackendTests drives a FakeExternalShellFlyoutBackend that cannot touch internals: ShellItem; bare MenuItem and the MenuShellItem wrapper (both directions — template on the MenuItem, and on the wrapper via MenuItem.Parent); ShellContent.MenuItems parent template with real Text/Command bindings plus flyout selection invoking the command; explicit null and null-bound; DataTemplateSelector returned and resolved by the caller; shell/item precedence; headers, footers and their templates; and platform-default fallback for every shape.

Suite Result
Controls.Core.UnitTests 6232 passed / 0 failed
Controls.Xaml.UnitTests 2115 passed / 0 failed
Controls.Core net11.0 + netstandard2.0 clean, PublicAPI analyzer clean

net11.0-windows* and net11.0-tizen* can't be compiled on macOS (MakePri.exe is an x86 Windows binary; the SDK doesn't recognize the tizen platform identifier), so those two backend edits rely on CI.

The AOT-profile comment is answered inline — the helper was restored with an identical signature, so the shipped binary profiles still resolve it.

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 12 out of 12 changed files in this pull request and generated 1 comment.

Comment on lines +786 to +788
// An explicitly set template wins even when its value is null, which lets an application opt a single item
// out of a Shell level template. A null value is reported as "no template" so callers fall back safely.
BindableObject templateSource = GetBindableObjectWithFlyoutItemTemplate(flyoutItem);
Copilot AI review requested due to automatic review settings August 27, 2026 00:13
Redth pushed a commit to Redth/Maui.Tizen that referenced this pull request Aug 27, 2026
…tion bug

Introduces ShellFlyoutTemplateResolution.ResolveFlyoutItemTemplate, whose
signature is deliberately identical to the redesigned upstream API in
dotnet/maui#37862 so adoption becomes a one-line body swap. Nothing is bound to
the open PR.

Building the seam surfaced a real bug. The call sites passed a PRE-RESOLVED
template owner to IShellController.GetFlyoutItemDataTemplate, but that method
re-derives the owner itself and picks the BindableProperty from its argument's
own type. Handing it the owner therefore selected ItemTemplateProperty where
MenuItemTemplateProperty was authored, silently dropping MenuItemTemplate for
flyout menu items - and also skipped the internal MenuShellItem branch that only
that method can reach. The raw item is now passed, which is both correct and
what upstream does.

The seam also returns DataTemplate? rather than a template-or-default, because
GetFlyoutItemDataTemplate never returns null; calling it unguarded would have
replaced Tizen's own flyout item view with MAUI's generic cell for every app
that never authored a template.

Records Core's published shapes (163677d) including the TizenNaviPage rename and
the ITizenToolbarContainer push contract, and notes that TizenShellView's
pull-based toolbar wiring must be reworked on rebase since SetToolbar disposes
the toolbar it replaces.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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 12 out of 12 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/Controls/src/Core/Shell/Shell.cs:788

  • ResolveFlyoutItemTemplate checks GetBindableObjectWithFlyoutItemTemplate(flyoutItem) first. For a MenuItem in ShellContent.MenuItems, GetBindableObjectWithFlyoutItemTemplate returns the parent ShellContent when it has MenuItemTemplateProperty set, which means a template explicitly set on the MenuItem itself (including an explicit null to opt out) will be ignored. If the flyout item has the template property set, it should win before consulting the paired-object lookup.
			BindableProperty bp = flyoutItem is IMenuItemController ? MenuItemTemplateProperty : ItemTemplateProperty;

			// An explicitly set template wins even when its value is null, which lets an application opt a single item
			// out of a Shell level template. A null value is reported as "no template" so callers fall back safely.
			BindableObject templateSource = GetBindableObjectWithFlyoutItemTemplate(flyoutItem);

Test-only follow-up; no production API change.

* The two bare MenuItem tests claimed a shape an external backend receives.
  It does not: GenerateFlyoutGrouping hands back the MenuShellItem wrapper for
  items added to Shell.Items, so passing the bare MenuItem exercises the
  resolver's parent lookup directly. Renamed to ResolverFindsTemplateOnThe-
  ParentOfAMenuItem / ResolverReturnsNullForAMenuItemWithNoTemplateAnywhere,
  reframed as direct unit coverage, and dropped the backend assertions.

* Added the genuinely reachable case that was missing: a MenuItem in
  ShellContent.MenuItems with the template set on the MenuItem itself, which
  does appear in the flyout grouping as the bare MenuItem.

* Pinned the pre-existing precedence when both the MenuItem and its parent set
  a template: the parent wins. That is long-standing Shell behavior which the
  public resolver preserves verbatim, so it is now covered rather than implied.

* MenuItemTemplateBindsTextAndCommandForShellLevelMenuItems never asserted
  Command, because the MenuShellItem wrapper mirrors Text/Title but does not
  surface Command. Renamed to ...BindsTextForShellLevelMenuItems, removed the
  unused Command/invoked setup, and documented that selection is what activates
  the command (already covered by MenuItemFlyoutSelectionInvokesTheCommand).

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

Redth commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

Follow-up pushed — 9d6a339bf8 (test-only, production API unchanged)

Run Integration Tests Samples macOS — UNRELATED (infrastructure)

Classified against the exact head. The integration tests passed; the leg failed during environment provisioning.

Build 1569525, job Samples macOS (505762b3-e3fe-5270-ba33-afcaf8cb4afa):

  • Setup task Install iOS 18.5 Simulator (for integration tests) (log 897):
    Downloading iOS 18.5 Universal Simulator (22F77): 99.4% (8.8 GB of 8.86 GB)
    ##[error]The task has timed out.
    
  • Actual test task Run Integration Tests - Samples (log 966):
    Passed!  - Failed:     0, Passed:    10, Skipped:     0, Total:    10
    
  • Fail if any issues occurred (log 969) then reported SucceededWithIssues.

Baseline — Samples macOS green on net11.0 with the same 10/10, and no other occurrence of this timeout across 500 recent maui-pr runs:

Build Queued Result
1569388 2026-08-26 22:18Z ✅ 10/10
1568717 2026-08-26 16:03Z ✅ 10/10
1567064 2026-08-25 15:27Z ✅ 10/10

An 8.86 GB simulator download timing out at 99.4% is not reachable from this PR, which touches no samples, templates, integration tests, or build infrastructure. No fix warranted. Build 1569790 is now running on the new head and re-executes that leg.

Test accuracy cleanup

  • Reframed the two synthetic tests. You were right — GenerateFlyoutGrouping hands a backend the MenuShellItem wrapper for Shell.Items, not the bare MenuItem. Renamed to ResolverFindsTemplateOnTheParentOfAMenuItem / ResolverReturnsNullForAMenuItemWithNoTemplateAnywhere, commented as direct resolver unit coverage, and dropped the backend-round-trip assertions that implied a reachable shape.
  • Added the reachable case: MenuItemTemplateSetOnTheMenuItemIsUsedForShellContentMenuItems — ShellContent.MenuItems does put the bare MenuItem in the grouping, so an item-level template there is real.
  • Pinned the precedence: ParentTemplateWinsOverMenuItemTemplateForShellContentMenuItems. Parent ShellContent wins over the MenuItem — pre-existing Shell behavior the resolver preserves verbatim, now covered rather than implied.
  • Fixed the unasserted Command test: renamed to MenuItemTemplateBindsTextForShellLevelMenuItems and removed the unused Command/invoked setup. The MenuShellItem wrapper mirrors Text/Title but does not surface Command; that is documented in the test, and command activation stays covered by MenuItemFlyoutSelectionInvokesTheCommand.

Windows explicit-null behavior

Now called out in the PR description: an item that explicitly sets its template to null previously rendered a blank flyout item on Windows (GetFlyoutItemDataTemplate returned null, so ShellFlyoutItemView skipped content creation). It now renders the default cell, matching Android and iOS — a deliberate consistency fix.

Validation

Suite Result
Controls.Core.UnitTests 6234 passed / 0 failed (27 in this file)
Controls.Xaml.UnitTests 2115 passed / 0 failed

Diff for this follow-up is one file: ShellExternalFlyoutBackendTests.cs.

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 12 out of 12 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

src/Controls/src/Core/Shell/Shell.cs:741

  • The XML docs say that if the owning Shell cannot be resolved when the shell argument is null, only templates set on the item itself are considered. However, the implementation can still resolve a menu item's template from its paired object/parent (via GetBindableObjectWithFlyoutItemTemplate), even when Shell is not found; what’s actually skipped is the Shell-level template fallback.
		/// <param name="shell">
		/// The <see cref="Shell"/> that owns <paramref name="flyoutItem"/>. When <see langword="null"/>, the owning Shell is
		/// resolved from <paramref name="flyoutItem"/>; if it cannot be resolved, only templates set on the item itself are considered.
		/// </param>

Comment on lines +70 to +75
// Resolve the application supplied template through the same public contract external backends use.
// A null result means the application did not supply one, so fall back to the default flyout item cell.
DataTemplate dataTemplate = null;

if (bo != null && _shell != null)
dataTemplate = Shell.ResolveFlyoutItemTemplate(_shell, bo) ?? BaseShellItem.CreateDefaultFlyoutItemCell(bo);
GetBindableObjectWithFlyoutItemTemplate already returns its argument when that
argument is null, so the guard added while the helper was briefly public was
behaviorally identical. Reverting it removes BaseShellItem.cs from the change
set entirely.

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

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 11 out of 11 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/Controls/src/Core/Handlers/Shell/Windows/ShellFlyoutItemView.cs:75

  • Shell.ResolveFlyoutItemTemplate can legally return a DataTemplateSelector, but this code path later calls CreateContent() directly. That bypasses selector resolution and makes Windows flyout item templating inconsistent with the new public contract and with the Tizen adaptor (which calls SelectDataTemplate first).
			// Resolve the application supplied template through the same public contract external backends use.
			// A null result means the application did not supply one, so fall back to the default flyout item cell.
			DataTemplate dataTemplate = null;

			if (bo != null && _shell != null)
				dataTemplate = Shell.ResolveFlyoutItemTemplate(_shell, bo) ?? BaseShellItem.CreateDefaultFlyoutItemCell(bo);

@kubaflo

kubaflo commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Multi-model merge-safety review at bd154f2514f27b0865953e3149f1b71b8a084612: SAFE TO MERGE with non-blocking documentation follow-up.

All 27 external flyout-template tests passed, the existing 8 tests passed on both HEAD and merge base, net11.0/netstandard2.0 API builds are clean, and all 31 CI checks are green. Resolver precedence, explicit-null fallback, selector pass-through, binding, and the Windows/Tizen integration paths are coherent. No new material defect was found.

Please correct the body claim that the shell-level menu template binds Command; the wrapper binds text while activation remains selection-based. Windows calling CreateContent() directly on a DataTemplateSelector is a real but pre-existing gap, suitable for a separate follow-up.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 27, 2026
@MauiBot

This comment has been minimized.

@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 — 1 findings

See inline comments for details.


return BaseShellItem.CreateDefaultFlyoutItemCell(bo);
}
=> ResolveFlyoutItemTemplate(this, bo) ?? BaseShellItem.CreateDefaultFlyoutItemCell(bo);

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] Backward Compatibility / Regression Prevention — This rewrite changes what IShellController.GetFlyoutItemDataTemplate returns for an explicitly null template, which breaks the reference-equality fallback in the compatibility renderers.

Old behavior: when ItemTemplate/MenuItemTemplate was explicitly set to null (IsSet == true, value null), the method returned null. New behavior: ResolveFlyoutItemTemplate returns null for that case and the ?? here substitutes BaseShellItem.CreateDefaultFlyoutItemCell(bo).

Concrete scenario — Shell.ItemTemplate is explicitly set to null and a third party derives from ShellFlyoutRecyclerAdapter (Android) / ShellTableViewSource (iOS) overriding DefaultItemTemplate:

  • ShellFlyoutRecyclerAdapter.cs:74 / ShellTableViewSource.cs:157 test DefaultItemTemplate != null && Shell.ItemTemplate == dataTemplate. Previously null == null matched and the renderer's DefaultItemTemplate was used; now dataTemplate is a fresh default cell instance, the comparison fails, and the renderer-supplied default is silently ignored (the same applies to DefaultMenuItemTemplate).

ShellExternalFlyoutBackendTests.ExplicitNullTemplateStillProducesDefaultCellForBuiltInBackends locks in the non-null return but does not cover the compat-renderer DefaultItemTemplate path, so this change is untested. If the substitution is intentional, please state it and add a regression test that derives from one of those adaptors with a non-null DefaultItemTemplate and an explicitly null Shell-level template; otherwise preserve the null return for the explicitly-null case and do the default-cell fallback only at the platform call sites (as the Windows and Tizen code in this PR already does).

@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 bd154f2.

Gate Passed Confidence Medium Platform Android


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

Gate Result: ✅ PASSED

Platform: ANDROID · Base: net11.0 · Merge base: 833e3375

✅ 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)
🧪 ShellExternalFlyoutBackendTests ShellExternalFlyoutBackendTests 🛠️ BUILD ERROR ✅ PASS — 82s
🔴 Without fix — 🧪 ShellExternalFlyoutBackendTests: 🛠️ BUILD ERROR · 87s

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

/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(225,22): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(246,32): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(269,38): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(398,22): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(436,22): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(454,22): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(477,56): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(555,42): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(563,22): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(573,32): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(579,60): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(580,60): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(36,11): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(40,26): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
🟢 With fix — 🧪 ShellExternalFlyoutBackendTests: PASS ✅ · 82s

(no coded error found; showing last 1200 chars)

ItemTemplateSetOnTheMenuItemIsUsedForShellContentMenuItems [3 ms]
  Passed MenuItemWithoutTemplateResolvesToNull [< 1 ms]
  Passed ResolverReturnsNullForAMenuItemWithNoTemplateAnywhere [2 ms]
  Passed MenuItemTemplateBindsTextForShellLevelMenuItems [22 ms]
  Passed NullBoundTemplateResolvesToNull [3 ms]
  Passed UnparentedItemWithItemTemplateStillResolves [< 1 ms]
  Passed ItemLevelItemTemplateWinsOverShellLevelItemTemplate [1 ms]
[xUnit.net 00:00:03.50]   Finished:    Microsoft.Maui.Controls.Core.UnitTests
  Passed MenuItemTemplateBindsTextAndCommandForShellContentMenuItems [10 ms]
  Passed DataTemplateSelectorIsReturnedAndResolvedByTheCaller [3 ms]
  Passed ShellItemWithoutTemplateResolvesToNull [< 1 ms]
  Passed ItemTemplateBindsTitleForShellItems [1 ms]
  Passed ParentTemplateWinsOverMenuItemTemplateForShellContentMenuItems [1 ms]
  Passed FlyoutHeaderAndFooterAreAvailableToExternalBackends [1 ms]
  Passed ShellLevelMenuItemTemplateIsUsedForMenuItems [1 ms]
  Passed MenuItemTemplateSetOnMenuItemIsFoundThroughMenuShellItem [1 ms]
  Passed ExplicitNullItemTemplateOnItemOptsOutOfShellTemplate [< 1 ms]
Test Run Successful.
Total tests: 27
     Passed: 27
 Total time: 4.4424 Seconds

⚠️ Failure Details

  • 🛠️ ShellExternalFlyoutBackendTests without fix: build failed before tests could run
    • /home/vsts/work/1/s/src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs(78,22): error CS0117: 'Shell' does not contain a definition for 'ResolveFlyoutItemTemplate' [/home/vsts/work/1/...
📁 Fix files reverted (10 files)
  • src/Controls/src/Core/Handlers/Shell/Tizen/ShellFlyoutItemAdaptor.cs
  • src/Controls/src/Core/Handlers/Shell/Windows/ShellFlyoutItemView.cs
  • src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
  • src/Controls/src/Core/Shell/Shell.cs

📋 Pre-Flight — Context & Validation

PR #37862 Pre-Flight

Context

  • Title: [net11.0] Add public Shell flyout item template contract for external backends
  • Base / head: net11.0 / redth-shell-flyout-template-api
  • Remote head: bd154f2514f27b0865953e3149f1b71b8a084612
  • Materialized review commit: b182ba7b7afe1af448a26d113d056cee7bfbab8e
  • Problem: Out-of-tree Shell backends cannot reliably find the application-defined flyout template because menu-item templates can live on an internal MenuShellItem wrapper or a parent ShellContent. This makes an external backend incorrectly choose its native default.
  • Gate: Passed before STEP 5a; do not rerun gate verification.

Existing PR Approach

The PR exposes Shell.ResolveFlyoutItemTemplate(Shell? shell, BindableObject flyoutItem). It resolves the internal paired template source, preserves item-over-Shell precedence (including explicit-null opt-out), and returns null when a backend should use its platform-native default. IShellController.GetFlyoutItemDataTemplate delegates to the resolver and restores the built-in default cell on null. Windows and Tizen are dogfooded through the new contract.

Direct Diff Inspection

Production changes:

  • src/Controls/src/Core/Shell/Shell.cs: adds the public resolver and documentation; simplifies the in-box controller method.
  • src/Controls/src/Core/Handlers/Shell/Windows/ShellFlyoutItemView.cs: resolves through the public API and falls back to the default cell.
  • src/Controls/src/Core/Handlers/Shell/Tizen/ShellFlyoutItemAdaptor.cs: resolves through the public API and falls back to its default template.
  • Seven PublicAPI.Unshipped.txt files: record the nullable static API.

Tests:

  • Adds src/Controls/tests/Core.UnitTests/ShellExternalFlyoutBackendTests.cs with 27 tests covering resolution sources and precedence, binding, selectors, headers/footers, explicit/null-bound templates, ownership, and argument validation.

Bounded Candidate Inputs

  • Primary test: dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --filter "ShellExternalFlyoutBackendTests"
  • Mandatory regression tests after primary passes:
    1. dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --filter "ShellToolbarTests"
    2. pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter "Issue17550"
  • Platform: Android.
  • Candidate boundary: One implementation/test pass and at most one focused correction/retest. A primary-test pass is not a candidate pass until both regression commands pass.
  • Restoration: Each attempt must use only pwsh .github/scripts/EstablishBrokenBaseline.ps1 -Restore.
  • Worktree note: The checkout contains pre-existing CI-script changes and untracked CI helper files. They are outside this PR fix and must remain untouched.
  • Baseline risk: The PR adds a tracked test file. If .github/.baseline-state.json reports any NewFiles, the try-fix skill requires the attempt to be recorded as Blocked before editing.

🔬 Code Review — Deep Analysis

Expert Evaluation — Submitted PR Fix

Verdict: NEEDS_CHANGES

Confidence: medium

Independent Assessment

The submitted change adds a public, nullable Shell.ResolveFlyoutItemTemplate contract that resolves the application-supplied flyout template across the internal MenuItem/MenuShellItem pairing and ShellContent.MenuItems ownership shape. The public resolver correctly preserves item-over-Shell precedence, treats an explicitly null value as an opt-out, and lets external backends choose their own native default. Windows and Tizen consume that contract directly, and the public API entries and focused external-backend coverage match the new surface.

Actionable Finding

⚠️ Compatibility renderer defaults are bypassed for explicitly null templates

src/Controls/src/Core/Shell/Shell.cs:822 changes IShellController.GetFlyoutItemDataTemplate from returning an explicitly set null value to replacing every null resolver result with BaseShellItem.CreateDefaultFlyoutItemCell(bo).

That alters a pre-existing compatibility contract used by:

  • src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRecyclerAdapter.cs:69-75
  • src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellTableViewSource.cs:152-158

Those renderers detect the Shell-level template by reference equality and substitute an overridden DefaultItemTemplate or DefaultMenuItemTemplate. With an explicitly null Shell template, the old null return compared equal to Shell.ItemTemplate/Shell.MenuItemTemplate; the new framework default-cell instance does not, so a third-party renderer override is silently skipped.

The new ExplicitNullTemplateStillProducesDefaultCellForBuiltInBackends test asserts only that the controller returns a non-null template. It does not exercise either compatibility renderer's overridable default-template path and therefore locks in the regression rather than detecting it.

Failure-Mode Probing

  • No application template: the public resolver correctly returns null and external backends can choose their native default.
  • Item-level explicit null over a Shell template: the public resolver correctly stops at the item and returns null.
  • Shell-level explicit null with a compatibility renderer override: the controller now returns a fresh MAUI default cell, reference equality fails, and the renderer-specific default is bypassed.
  • Windows/Tizen explicit null: both submitted call sites already perform their own null fallback, so correcting the compatibility behavior need not restore the former Windows blank item or Tizen null failure.

Reviewer Recommendation

Keep the public resolver and the Windows/Tizen dogfooding. Consolidate default selection at the compatibility renderer call sites so renderer-supplied defaults continue to win when resolution reports null, while retaining a final MAUI default-cell fallback before template selection. Add focused regression coverage for the overridden compatibility default path.

Other Review Areas

  • Public API naming, nullable shape, XML documentation, and all seven PublicAPI.Unshipped.txt entries are consistent.
  • The paired-object resolution is a faithful extraction of the existing internal behavior.
  • No new lifecycle subscriptions, shared state, asynchronous work, or hot-path allocations were introduced.
  • External output contracts and Trim/NativeAOT reachability are not applicable.
  • Trusted Gate: passed (failure without the submitted fix, pass with it); not rerun.

🛠️ Try-Fix — Analysis & Comparison

PR #37862 — STEP 5a Try-Fix Aggregate

Candidate 1 — Containment-Scope Resolution

Model: claude-opus-5
Result: Blocked
findings_count: 0
Candidate narrative: ../try-fix-1/content.md
Attempt artifacts: attempt-1/

Approach

Replace the PR's fixed paired-object alias lookup with an ordered traversal of the flyout item's containment scope: nearest owners below the Shell, the item, the wrapped public MenuItem, then the Shell. The first object on which the applicable template property is explicitly set would win, including an explicit-null opt-out.

Difference from the PR

The PR assumes each flyout item has one hidden alias and resolves that alias through GetBindableObjectWithFlyoutItemTemplate. Candidate 1 instead treats the root cause as a missing scope traversal, making lookup independent of a fixed two-entry alias table and allowing precedence to follow directly from traversal order.

Outcome

No code was applied and the captured diff is empty. EstablishBrokenBaseline.ps1 rejected the repository-wide pre-existing dirty worktree before writing .github/.baseline-state.json; without a RevertedFiles allow-list, the try-fix boundary prohibits edits. The primary ShellExternalFlyoutBackendTests command and both mandatory regression commands were therefore not run. Inline self-review recorded [].

The exact restore command returned Restored: False / No baseline state found, which is the expected no-state result because baseline creation failed before any attempt edit. Pre-existing changes remained untouched and the PR source/test paths remained clean.

Candidate 2 — Eager Grouping-Boundary Template Projection

Model: gpt-5.6-sol
Result: Blocked
findings_count: 0
Candidate narrative: ../try-fix-2/content.md
Attempt artifacts: attempt-2/

Approach

Treat the defect as incomplete lifecycle-time state projection. When GenerateFlyoutGrouping materializes backend-facing items, copy the explicitly set menu template—including explicit null—from the public MenuItem or ShellContent owner onto the emitted object. The public resolver would then need only item-local lookup followed by Shell fallback.

Difference from Earlier Mechanisms

The PR performs a read-time paired-object alias lookup. Candidate 1 proposed a read-time containment-scope traversal. Candidate 2 does neither: it makes the emitted flyout item canonical once at grouping time, so backend-time resolution does not discover aliases or traverse ownership.

Outcome

No code was applied and the captured diff is empty. Candidate 2 independently ran the required baseline step, which again rejected the pre-existing dirty tracked CI/helper files before creating .github/.baseline-state.json. Without a RevertedFiles allow-list, edits were prohibited. The primary ShellExternalFlyoutBackendTests command and both mandatory regression commands were not run. Inline self-review recorded [].

The exact restore command returned Restored: False / No baseline state found, the expected no-state result because no attempt edit occurred. Candidate 1 and all pre-existing worktree changes remained untouched; PR source/test paths remained clean.

Aggregate Result

Two distinct alternatives were bounded and recorded, but neither could be implemented or tested because the baseline safety script requires a clean tracked worktree and the checkout contains unrelated pre-existing tracked changes. Both candidates are honestly classified Blocked, not Pass or Fail.


🏁 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Winner: pr-plus-reviewer

pr-plus-reviewer preserves the submitted public API and backend integration while correcting the expert reviewer's compatibility-renderer regression. It is the only candidate that both contains an implemented fix and passes the primary test plus every mandatory regression validation.

Comparative Ranking

Rank Candidate Implementation Primary validation Regression validation Assessment
1 pr-plus-reviewer PR plus compatibility-default correction and regression tests PASS — 29/29 ShellExternalFlyoutBackendTests PASS — 21/21 ShellToolbarTests; Android Issue17550 passed Best balance of API correctness, backward compatibility, and empirical coverage
2 pr Submitted public resolver, Windows/Tizen dogfooding, and 27 focused tests Trusted Gate PASS Gate regression evidence PASS Strong core fix, but the expert reviewer found an unaddressed compatibility-renderer regression
3 try-fix-1 Containment-scope traversal proposed; no patch produced NOT RUN — BLOCKED NOT RUN — BLOCKED Broader traversal was speculative and never implemented or validated
4 try-fix-2 Grouping-boundary template projection proposed; no patch produced NOT RUN — BLOCKED NOT RUN — BLOCKED Lifecycle projection was speculative and never implemented or validated

No candidate failed a regression test. The two try-fix-* candidates rank below both implemented candidates because their baseline blocker prevented any code or validation.

Why the Raw PR Does Not Win

The raw PR changes IShellController.GetFlyoutItemDataTemplate so every null resolver result becomes a new MAUI default-cell template. Android's ShellFlyoutRecyclerAdapter and iOS's ShellTableViewSource historically use reference equality against the Shell template to substitute protected DefaultItemTemplate/DefaultMenuItemTemplate overrides. For an explicitly null Shell template, the old null value matched; the new default-cell instance does not, silently bypassing renderer-specific defaults.

The raw PR's non-null controller test does not exercise that extensibility path. This is a concrete backward-compatibility regression in public compatibility renderer classes, so the submitted patch should not be approved unchanged.

Why pr-plus-reviewer Wins

The candidate keeps Shell.ResolveFlyoutItemTemplate unchanged for external backends and keeps the controller's non-null guarantee. It centralizes compatibility-renderer selection in an internal helper that:

  • preserves renderer-specific defaults for Shell templates, including explicitly null Shell templates;
  • preserves the previous unset-template behavior;
  • falls back to BaseShellItem.CreateDefaultFlyoutItemCell before platform template selection; and
  • is shared by the Android and iOS compatibility renderers, with focused tests for both the positive explicit-null case and the negative unset case.

Validation Evidence

All commands ran exactly once from /home/vsts/work/_temp/pr-37862-pr-plus-reviewer:

Command Result
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --filter "ShellExternalFlyoutBackendTests" PASS — 29 passed, 0 failed
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --filter "ShellToolbarTests" PASS — 21 passed, 0 failed
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter "Issue17550" PASS

The Android command compiled and ran from the candidate path. The shared helper and unit tests cover the iOS selection logic, but the required validation matrix did not compile or execute an iOS target; that residual platform uncertainty does not outweigh the raw PR's verified logical regression.

Required Change

Apply the pr-plus-reviewer patch represented by pr-plus-reviewer/reviewer.patch to the submitted PR.


🔗 Regression Cross-Reference

🔍 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/Shell/Shell.cs #36673 #36562
src/Controls/src/Core/Shell/Shell.cs #35896 #35249

🧪 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
#35896 UITest Issue17550 Issue17550

🧪 Regression Test Results

✅ PASSED — 2 passed, 0 failed, 0 skipped

Fix PR Test Type Result
#36673 ShellToolbarTests UnitTest ✅ PASSED
#35896 Issue17550 UITest ✅ PASSED

📱 UI Tests — Shell

Detected UI test categories: Shell

✅ Deep UI tests — 327 passed, 0 failed across 1 category on platform-pool agent (replaces in-process counts above).

🧪 UI Test Execution Results (deep, platform pool)

Category Tests Snapshot diffs
Shell 327/327 ✓ —
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs)

🧭 Next Steps — reviewer changes required

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

Why: pr-plus-reviewer fixes the expert-identified compatibility-renderer default-template regression while preserving the submitted public resolver and non-null built-in fallback. It passed the focused resolver tests, Shell toolbar regression tests, and Android Issue17550 validation; both try-fix alternatives were blocked without code or test evidence.

Address the actionable findings in this review before merging.

@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 27, 2026
@kubaflo
kubaflo merged commit 7d172ed into net11.0 Aug 27, 2026
34 checks passed
@kubaflo
kubaflo deleted the redth-shell-flyout-template-api branch August 27, 2026 22:49
@github-actions github-actions Bot added this to the .NET 11.0-preview7 milestone Aug 27, 2026
@kubaflo

kubaflo commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Post-merge compatibility follow-up at bd154f2514f27b0865953e3149f1b71b8a084612; the overall verdict remains SAFE.

A focused causal control found one narrow behavior change worth tracking. With a Shell-level flyout template explicitly set to null, the merge-base allowed an out-of-tree Android/iOS compatibility renderer's overridden DefaultItemTemplate/DefaultMenuItemTemplate to win through the old null == null check. This head creates the built-in fallback template first, so that override is bypassed. The same disposable test passed on the exact base and failed on this head.

This is not a reason to revert the fix: the old null path also caused the in-box NRE/blank-item failures this PR correctly removes, and the compatibility case requires a derived legacy renderer plus an explicitly-null Shell-level template. A targeted compatibility hook or migration note can follow separately.

@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-shell Shell Navigation, Routes, Tabs, Flyout 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