Skip to content

Deduplicate the two flyout-placement helpers - #967

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 9 commits into
mainfrom
azchohfi-dedupe-flyout-placement-helpers
Jul 31, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 9 commits into
mainfrom
azchohfi-dedupe-flyout-placement-helpers

Conversation

@azchohfi

Copy link
Copy Markdown
Collaborator

Fixes #953.

What #953 asked for

One dependency property — FlyoutBase.Placement — was owned by two behaviourally-identical internal helpers:

Helper Served
FlyoutPlacement.Apply Flyout, ContentFlyout, MenuFlyout
Reconciler.ApplyFlyoutPlacement all 3 CommandBarFlyout sites

The behavioural divergence was already fixed in #939; what remained was the duplication itself. No user-visible behaviour changes. The reason it's worth doing is that the two helpers already diverged once, silently, because each was written by a different change with no single owner.

The change

  1. Routed the three CommandBarFlyout sites (OverlayLifecycle.cs ~422, ~471, ~482) through FlyoutPlacement.Apply and deleted Reconciler.ApplyFlyoutPlacement. internal, so no public-API impact — reactor.api.txt and its plugin copy are untouched.

  2. Fixed the doc comments that described the split as a live state of affairs. FlyoutPlacement's remarks said folding CBF in was "a mechanical follow-up"; CommandBarFlyoutElement.Placement claimed the helpers "differ only on an update back to Auto" — already false after Never write FlyoutPlacementMode.Auto to a WinUI FlyoutBase (fixes the Flyout default-placement process kill) #939. The history worth keeping is preserved: CommandBarFlyout is affected by the same crash and only appeared safe because the flyout was installed as AttachedFlyout metadata nothing ever called ShowAttachedFlyout on.

  3. Tightened the structural guard to one choke point — the load-bearing half. FlyoutPlacementGuardTests previously encoded the split: an ApplyFlyoutPlacement allow-entry plus a Mount/UpdateCommandBarFlyout carve-out that made the CBF sites invisible to the "no bypass" assertion. Retiring the second helper without retiring those carve-outs would have left the drift hole wide open. Both allow-lists are gone entirely rather than surviving as empty escape valves, so a future second helper must be a deliberate, visible widening of the guard.

Why this matters

FlyoutPlacementMode.Auto is enum value 13. WinUI's FlyoutBase::ShowAtCore → ValidateAndSetParameters accepts only 0..12; anything else is E_INVALIDARG → stowed ArgumentException → process termination when the flyout is shown. Reactor element records default Placement to Auto, so Auto must never reach the DP. "No opinion" is expressed by clearing the DP (whose own default is Top), not by writing Auto and not by skipping the write — skipping would strand the last explicit value as a local DP value outranking Style setters.

Found along the way

  • A real coverage hole. The fresh-flyout arm of UpdateCommandBarFlyout had no placement assertion in any tier — deleting its Apply call left the entire suite green. Added CmdBarFlyout_FreshPlacementBottom to the OverlayCommandBarFlyoutUpdate selftest fixture; all three CBF arms now have an assertion that fails on deletion.
  • Two fail-open holes in the guard itself, from the pr-review pass (see the third commit). The routing test matched by containment, so a new site calling Apply without a list entry was invisible to both halves of the invariant — now set equality. And TypeLeafName had no NullableTypeSyntax arm, so WinUI.MenuFlyout? f = new() { ... } produced "WinUI.MenuFlyout?", which is non-null and so bypassed the fail-closed arm that exists precisely for unresolvable types.

Testing

  • 12,936 unit tests pass (13,000 total, 64 skipped); FlyoutPlacement guard is 25/25.
  • Selftests green, including FlyoutPlacement_Update_AutoResetsToPlatformDefault, CbfReset_AutoRestoresDefaultPlacement, CbfAuto_OpenedWithoutFailFast, and the new CmdBarFlyout_FreshPlacementBottom.
  • dotnet build src/Reactor clean under the trim/AOT-as-error gate.
  • Mutation-checked at both tiers. Deleting OverlayLifecycle.cs:471's Apply call fails CmdBarFlyout_FreshPlacementBottom and only that check. Deleting the NullableTypeSyntax arm fails exactly Scanner_Flags_A_Target_Typed_Flyout_Initializer; dropping one PlacementApplyingMethods entry fails exactly Every_Flyout_Site_Routes_Through_The_Choke_Point — 2 failures, no others.

Per the repo field notes ("Copilot review does not catch vacuous assertions"), this branch ran the .github/skills/pr-review/ multi-model dimension against a different model family; all findings were confirmed and are addressed in the third commit.

Known limits, and the follow-up

The guard is a purely syntactic Roslyn scan, deliberately with no semantic model so it needs no compilation. That leaves resolvable-only gaps it cannot close: DP aliasing (var dp = FlyoutBase.PlacementProperty), using FB = ...FlyoutBase, and a same-named FlyoutPlacement type in another namespace. Each is documented in the test file. #964 proposes an internal Roslyn analyzer as the better long-term mechanism — explicitly out of scope here.

The routing test is method-granular by construction — a syntactic scan cannot tell which branch of a multi-branch method a call sits in. Verified empirically: removing the Apply call from only the reuse arm of UpdateCommandBarFlyout left all unit tests green but failed selftest CbfReset_AutoRestoresDefaultPlacement. Per-branch coverage is the selftests' job, and the failure message says so.

Unrelated and out of scope: #952, the same defect class (ClearValue vs. a local value) in Reconciler.ApplyModifiers.

One dependency property, FlyoutBase.Placement, was owned by two
behaviourally-identical internal helpers: FlyoutPlacement.Apply (Flyout,
ContentFlyout, MenuFlyout) and Reconciler.ApplyFlyoutPlacement (the three
CommandBarFlyout sites). They converged in #939; the duplication remained,
and it had already let them drift apart once, silently, because each was
written by a different change with no single owner of the property.

Retire Reconciler.ApplyFlyoutPlacement and point its call sites at
FlyoutPlacement.Apply. No behaviour change — the two bodies were equivalent.

The load-bearing half is the structural guard, which encoded the split:
FlyoutPlacementGuardTests carried an ApplyFlyoutPlacement helper entry plus a
MountCommandBarFlyout/UpdateCommandBarFlyout carve-out that hid those sites
from the "no bypass" assertion. Both allow-lists are gone, so the bypass test
now covers the CommandBarFlyout sites for real, and two assertions replace
them:

  * FlyoutPlacement_Is_The_Only_File_That_Writes_The_Dp — the set of files
    under src/Reactor containing a placement write is exactly
    ["FlyoutPlacement.cs"], making the class's own "single choke point"
    description literally true. Equality, so an empty scan fails too.
  * CommandBarFlyout_Sites_Route_Through_The_Choke_Point — the positive half
    the bypass test cannot see: a site that stopped applying placement
    entirely writes nothing and would pass "no direct write" vacuously.

Both were mutation-checked: reintroducing a direct write in
MountCommandBarFlyout fails all three structural tests. The routing test is
method-granular by construction, so a mutation confined to one branch of
UpdateCommandBarFlyout was checked against the tier that does catch it — the
selftest CbfReset_AutoRestoresDefaultPlacement fails on it — and that split
is stated in the test's comment rather than left implied.

Also updates the XML docs on FlyoutPlacement and CommandBarFlyoutElement.
Placement, which described the split as a live state of affairs; the latter
still claimed the helpers "differ only on an update back to Auto", false
since #939. The AttachedFlyout/ShowAttachedFlyout history is kept — it
explains why CommandBarFlyout is affected by the same crash and only looked
safe. Fixes two dangling see crefs in the rewritten comments
(NonFlyoutPlacementWriteFiles, AutoTolerantFlyoutMethods) that named members
which no longer exist.

Verified: 12,935 unit tests pass; FlyoutPlacement* and CmdBarFlyout*
selftests pass against real WinUI flyouts, including the ones that actually
open a default-placement flyout.

Refs #953

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7b1568e7-b095-4016-96c2-56ae56b92cf9
Three findings from the multi-model cross-check on 0fa5dda, in descending
order of how much they mattered.

1. The routing guard only listed the two CommandBarFlyout methods, so the
   four other sites that call FlyoutPlacement.Apply — UpdateFlyoutInPlace,
   CreateFlyoutFromElement, MountFlyout, UpdateFlyoutElement — could stop
   applying placement entirely and nothing would fail. A missing write is not
   a bypass, so the bypass test cannot see it either. Renamed to
   Every_Flyout_Site_Routes_Through_The_Choke_Point and listed all six.

2. UpdateCommandBarFlyout's fresh-flyout arm had no placement assertion in
   any tier. The unit guard is method-granular by construction, and the
   selftest that drives the arm (CoreRRC_OverlayCommandBarFlyoutUpdate)
   checked only command counts and labels — so deleting the arm's
   FlyoutPlacement.Apply call passed the whole suite. Added
   CmdBarFlyout_FreshPlacementBottom, mutation-checked: deleting the call
   fails that check and only that check. The comment in the routing test
   claimed selftests covered every branch; now they actually do.

3. The write scanner only understood `new WinUI.Flyout { Placement = ... }`,
   so a target-typed `WinUI.CommandBarFlyout f = new() { Placement = ... }`
   was invisible to it. Handles ImplicitObjectCreationExpressionSyntax now,
   resolving the type from the declaration, return type, or cast that
   supplies it, and failing closed when none does. Resolving return types is
   load-bearing rather than thorough: every DSL flyout factory is
   `=> new(content) { Placement = placement }` on an element record, and a
   naive fail-closed rule flags all of them.

Also folded the redundant FlyoutPlacement_Is_The_Only_File_That_Writes_The_Dp
into the bypass test as an Assert.NotEmpty anti-vacuity guard — it was
asserting the same invariant from the other side — and switched the
canonical-file check from a bare file name to a path suffix, so a second
FlyoutPlacement.cs dropped elsewhere under src/Reactor reads as a bypass
rather than granting itself the exemption.

Doc on FlyoutPlacement now points at FlyoutPlacementGuardTests rather than
naming individual test methods that rename out from under it.

Verified: 12,936 unit tests pass; selftests CmdBarFlyout*, FlyoutPlacement*
and CoreRRC_OverlayCommandBarFlyoutUpdate all green; src/Reactor builds with
0 warnings under the trim/AOT-as-error gate.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7b1568e7-b095-4016-96c2-56ae56b92cf9
Three findings from a full pr-review pass over this branch, all confirmed by a
cross-family model check. Two of them are holes in the guard itself, which is
the load-bearing half of this change — a guard that fails open is worse than no
guard, because it reports green.

M1 — the routing test matched by containment, so a *new* flyout site that called
FlyoutPlacement.Apply without being added to PlacementApplyingMethods was
silently unguarded: it wrote no DP directly, so the bypass test saw nothing, and
it was absent from the list, so the routing test saw nothing either. Assert set
equality instead, with a separate message per direction — "listed but no longer
routed" and "routed but unlisted" need different fixes, and the second one tells
the author to add a selftest per branch, since this test is method-granular.

M2 — TypeLeafName had no NullableTypeSyntax arm, so `WinUI.MenuFlyout? f = new()
{ ... }` fell through to type.ToString() and yielded "WinUI.MenuFlyout?". That is
non-null, so it bypassed the fail-closed arm that exists precisely for types the
scanner cannot resolve, and then failed EndsWith("Flyout"). A nullable-annotated
local declaring a target-typed flyout initializer was therefore invisible to a
scanner whose entire contract is to fail closed. Unwrap to the element type, and
extend the target-typed fixture with a nullable case so the arm is covered
(2 -> 3 expected hits, with the three predicates made mutually exclusive so each
pins a distinct shape rather than overlapping).

L1 — CommandBarFlyoutElement.Placement documented internal machinery, naming
FlyoutPlacement.Apply and "the single choke point" in text that surfaces in
IntelliSense; its sibling flyout records describe the same behaviour without
either. Use the siblings' wording verbatim: the behaviour is now literally
identical across all four records, which is the point of this change, so the
docs should be too.

Mutation-checked: deleting the NullableTypeSyntax arm fails exactly
Scanner_Flags_A_Target_Typed_Flyout_Initializer, and dropping one entry from
PlacementApplyingMethods fails exactly
Every_Flyout_Site_Routes_Through_The_Choke_Point — 2 failures, no others.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7b1568e7-b095-4016-96c2-56ae56b92cf9

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 deduplicates the internal logic that applies FlyoutBase.Placement by routing the three CommandBarFlyout call sites through the single choke point (FlyoutPlacement.Apply) and removing Reconciler.ApplyFlyoutPlacement, while updating the associated guard tests and documentation to reflect the unified ownership.

Changes:

  • Route CommandBarFlyout mount/update placement through FlyoutPlacement.Apply and delete Reconciler.ApplyFlyoutPlacement.
  • Tighten the syntactic guard tests to enforce a single write choke point and require all flyout placement application methods to call it.
  • Add a selftest assertion covering the “fresh CommandBarFlyout” arm’s placement application, and update related doc comments.

Reviewed changes

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

Show a summary per file
File Description
tests/Reactor.Tests/FlyoutPlacementGuardTests.cs Removes old exemption lists; adds choke-point path matching + positive routing invariant and new scanner cases.
tests/Reactor.AppTests.Host/SelfTest/Fixtures/CoreReconcilerRenderCoverageFixtures.cs Adds a non-vacuous placement assertion for the fresh CommandBarFlyout arm.
src/Reactor/Core/V1Protocol/OverlayLifecycle.cs Routes all three CommandBarFlyout placement sites through FlyoutPlacement.Apply.
src/Reactor/Core/Reconciler.cs Deletes the now-redundant ApplyFlyoutPlacement helper.
src/Reactor/Core/FlyoutPlacement.cs Updates remarks to reflect the unified helper and strengthened guard.
src/Reactor/Core/Element.cs Updates CommandBarFlyoutElement.Placement docs to match the unified “clear DP on Auto” behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build metrics

Artifact sizes for 799a724 vs the base branch (33dafd0).

Packages (compressed .nupkg)

Artifact base PR Δ
Microsoft.UI.Reactor.nupkg 1.60 MB 1.60 MB -113 B (-0.01%) ≈
Microsoft.UI.Reactor.Advanced.nupkg 475.5 KB 475.5 KB -2 B (0.00%) ≈
Microsoft.UI.Reactor.Devtools.nupkg 278.2 KB 278.2 KB +7 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor

Artifact base PR Δ
Reactor.Analyzers.dll 354.5 KB 354.5 KB +0 B (0.00%) ≈
Reactor.dll 2.38 MB 2.38 MB +0 B (0.00%) ≈
Reactor.Localization.Generator.dll 16.0 KB 16.0 KB +0 B (0.00%) ≈
Reactor.Wrappers.Abstractions.dll 10.5 KB 10.5 KB +0 B (0.00%) ≈
Reactor.Wrappers.Generator.dll 99.5 KB 99.5 KB +0 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor.Advanced

Artifact base PR Δ
Reactor.Advanced.dll 1014.0 KB 1014.0 KB +0 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor.Devtools

Artifact base PR Δ
Microsoft.UI.Reactor.Devtools.dll 777.5 KB 777.5 KB +0 B (0.00%) ≈

No size change beyond the noise floor. ✅

✅ smaller / ⚠️ larger / ≈ within noise. Sizes come from a Release dotnet pack on the CI runner: packages are the compressed .nupkg download size, assemblies the uncompressed DLL inside it.
workflow run.

@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🧪 Merged coverage

Coverage for 799a724 vs the base branch (33dafd0) — unit + selftest merged.

Metric base PR Δ
Line 85.71% 85.72% +0.01 pp ≈
Branch 77.10% (899/1166) 77.10% (899/1166) 0.00 pp ≈

No coverage change beyond the noise floor. ✅

✅ higher / ⚠️ lower / ≈ within noise. Δ is in percentage points; coverage is unit + selftest merged (Debug x64) on the CI runner. Cobertura reports attached to the workflow run as artifacts.

Copilot review — the choke-point exemption was matched by the suffix
`/Core/FlyoutPlacement.cs`, which the doc comment described as "repo-relative"
but which is not: a second FlyoutPlacement.cs under any other Core/ folder
inside the scan root would have exempted itself from the bypass test. That is
the same fail-open shape as the allow-lists this PR removed, reintroduced by the
mechanism meant to replace them. Anchor the suffix at the scan root
(src/Reactor/Core/FlyoutPlacement.cs) and add
Choke_Point_Exemption_Is_Pinned_To_The_One_Real_File, which asserts both
directions: the real file is still recognised, and three decoys — a nested
Core/, a Core/ subfolder, and the project root — are not. Mutation-checked:
restoring the loose suffix fails exactly that test, naming the decoy.

Code quality — Path.Combine(a, b) carries rooted-path reset semantics that could
silently drop earlier segments. Every argument here is a compile-time constant so
it cannot fire, but the suffix is built from four literals and string.Join over
the separator says what is meant without the caveat.

Code quality — FindChokePointCalls filtered inside the loop body with two
`continue`s. The body never uses `owner`, which is bound only by the predicate,
so the filter lifts cleanly into .Where over a named IsChokePointCall with no
duplicate pattern match. Equivalence is already pinned by the existing tests:
Every_Flyout_Site_Routes_Through_The_Choke_Point asserts set equality, so a
filter broken open fails on `unlisted` and one broken closed fails on `missing`,
and Scanner_Finds_Choke_Point_Calls_Regardless_Of_Qualification still covers both
qualification forms.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7b1568e7-b095-4016-96c2-56ae56b92cf9
Copilot AI review requested due to automatic review settings July 31, 2026 06:20

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

Suppressed comments (2)

tests/Reactor.Tests/FlyoutPlacementGuardTests.cs:399

  • This comment still refers to CommandBarFlyout_Sites_Route_Through_The_Choke_Point, but the positive-routing test is now Every_Flyout_Site_Routes_Through_The_Choke_Point. Updating the reference will keep the anti-vacuity intent clear.
        // Anti-vacuity for CommandBarFlyout_Sites_Route_Through_The_Choke_Point: a call
        // matcher that missed the shape actually used in src/Reactor would turn that test
        // into a permanent failure rather than a silent pass, but a matcher that is too
        // loose is the real risk — prove it ignores same-named Apply calls on other owners.

tests/Reactor.Tests/FlyoutPlacementGuardTests.cs:369

  • The comment references CommandBarFlyout_Sites_Route_Through_The_Choke_Point, but that test no longer exists (it was replaced by Every_Flyout_Site_Routes_Through_The_Choke_Point). This makes the documentation misleading for future maintainers and reviewers tracing why EnclosingMethodName is load-bearing.

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

        // Both the bypass failure message and
        // CommandBarFlyout_Sites_Route_Through_The_Choke_Point key off the enclosing method
        // name, so prove two identical writes in one file are attributed to the method they
        // actually sit in — not to the file, and not to "<none>".

Round-two review flagged two comments still naming
CommandBarFlyout_Sites_Route_Through_The_Choke_Point, a test this branch renamed
to Every_Flyout_Site_Routes_Through_The_Choke_Point. Both were stale, and both
are the same defect class as the two dangling crefs the first commit already
fixed — an internal reference that rots silently because nothing checks it.

Correcting the strings would leave the mechanism intact, so route the reference
through nameof() in the assertion messages instead, where the compiler validates
it and where it is more useful anyway: the pointer now appears in the failure
output that a future contributor actually reads. Both Assert.Equal(2, ...) calls
become Assert.True with a message naming the test that goes vacuous if the
scanner regresses, and listing what the scanner actually found.

The prose comments keep the explanation but drop the bare identifier, so there
is nothing left in this file to go stale on the next rename.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7b1568e7-b095-4016-96c2-56ae56b92cf9
Copilot AI review requested due to automatic review settings July 31, 2026 06:30
@azchohfi

Copy link
Copy Markdown
Collaborator Author

Picked up both suppressed comments from the round-two review — they were correct. Two body comments still named CommandBarFlyout_Sites_Route_Through_The_Choke_Point, which this branch renamed to Every_Flyout_Site_Routes_Through_The_Choke_Point.

Same defect class as the two dangling <see cref="..."/>s the first commit fixed: an internal reference that rots silently because nothing checks it. So rather than just correcting the strings, 94b3e9d routes the reference through nameof(...) in the assertion messages, where the compiler validates it — and where it is more useful anyway, since the pointer now lands in the failure output a contributor actually reads. Both Assert.Equal(2, ...) calls became Assert.True with a message naming the test that goes vacuous if the scanner regresses, plus what the scanner actually found.

The prose keeps the explanation but drops the bare identifier, so nothing in the file can go stale on the next rename. Verified there are no remaining references to any renamed/deleted member (CommandBarFlyout_Sites*, Scanner_Scopes_The_Exemption*, PlacementHelperMethods, MethodsOwnedElsewhere, AutoTolerantFlyoutMethods); the one surviving mention of ApplyFlyoutPlacement is deliberate history in prose, not a cref.

26/26 guard tests and 12,937 unit tests green.

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

Suppressed comments (1)

tests/Reactor.Tests/FlyoutPlacementGuardTests.cs:496

  • The XML comment for IsChokePointCall mentions “through an alias whose leaf name is still the type name”, but the matcher only recognizes qualifications where the leaf identifier is literally FlyoutPlacement (e.g., Core.FlyoutPlacement.Apply(...)). A C# type alias like using FP = ...FlyoutPlacement; FP.Apply(...) would not match, so the comment is misleading. Consider rewording to clarify this is about namespace qualification/namespace aliases, not arbitrary type aliases.
    /// <summary>
    /// A call to <c>FlyoutPlacement.Apply(...)</c> under any qualification — bare,
    /// namespace-qualified, or through an alias whose leaf name is still the type name.
    /// </summary>

Round-three review flagged the IsChokePointCall summary added two commits ago:
"through an alias whose leaf name is still the type name" reads as though any
alias works. It does not. A namespace alias matches, because the leaf of
Alias.FlyoutPlacement.Apply is still FlyoutPlacement; a type alias
(using FP = ...FlyoutPlacement; then FP.Apply(...)) does not, because the leaf
is FP and resolving it needs the semantic model this scan deliberately omits.

Split the two cases and state the consequence honestly rather than claiming the
gap simply fails safe, which is only half true: a site already in
PlacementApplyingMethods drops out of the routed set and fails loudly as
missing, but a brand-new site introduced through a type alias is invisible to
both halves of the invariant — no direct DP write for the bypass test to catch,
and no matched call for the routing test to miss. That is the same
symbol-resolution class as the DP aliasing and using-alias gaps already noted on
the scanner, and it is what issue #964 exists to close.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7b1568e7-b095-4016-96c2-56ae56b92cf9
Copilot AI review requested due to automatic review settings July 31, 2026 06:40
@azchohfi

Copy link
Copy Markdown
Collaborator Author

Round three had one suppressed comment, and it was right. The IsChokePointCall summary I added said "through an alias whose leaf name is still the type name", which reads as though any alias works.

It does not. A namespace alias matches — the leaf of Alias.FlyoutPlacement.Apply is still FlyoutPlacement. A type alias (using FP = ...FlyoutPlacement; then FP.Apply(...)) does not: the leaf is FP, and resolving it needs the semantic model this scan deliberately omits.

c82673a splits the two cases and states the consequence rather than hand-waving it as fail-safe, which is only half true:

  • a site already in PlacementApplyingMethods drops out of the routed set and fails loudly as missing;
  • a brand-new site introduced through a type alias is invisible to both halves of the invariant — no direct DP write for the bypass test to catch, and no matched call for the routing test to miss.

That is the same symbol-resolution class as the DP-aliasing and using-alias gaps already documented on the scanner, and it is exactly what #964 exists to close. Recorded on the member rather than quietly narrowed, since a guard that overstates its reach is the failure mode this PR is about.

12,937 unit tests green.

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

…citation

Two findings from a fresh pr-review pass over the final commit. The first
review pass ran against 6641a70 and four commits landed after it, so the
multi-model dimension had never seen the tree it was meant to check.

TypeLeafName had a `_ => type.ToString()` fallback, and GenericNameSyntax is
itself a SimpleNameSyntax. So a placement write inside a collection produced a
leaf name that was non-null but wrong:

    WinUI.Flyout[] a = [new() { Placement = ... }]   ->  "WinUI.Flyout[]"
    List<WinUI.Flyout> b = new() { new() { ... } }   ->  "List"

Non-null means it slipped past the fail-closed arm, and neither ends with
"Flyout", so a real DP write on a real flyout went unseen. That is the same
shape as the nullable hole closed in 260446d ("CommandBarFlyout?"), which is
what makes it worth fixing rather than shrugging at: it is a recurring class,
not a one-off.

TypeLeafName now returns string? and peels the wrappers that hide the leaf --
nullable, array, and single-argument generic. Multi-argument generics give up
rather than guess which argument the initializer targets. QualifiedNameSyntax
recurses on .Right instead of taking its identifier directly, so
Some.Namespace.List<WinUI.Flyout> resolves to Flyout. The fallback is null, so
every unknown shape now fails closed. The explicit ObjectCreationExpressionSyntax
arm is fail-closed too, matching the implicit arm it had drifted from.

Peeling rather than blanket-failing-closed is the deliberate part: element
records held in an array or list are an ordinary DSL shape, and a guard that
flagged all of them would be reverted within a week.
Scanner_Flags_A_Target_Typed_Flyout_Inside_A_Collection pins both directions,
and all three mutations produce exactly the predicted hit count -- drop the
array peel and it sees 2, blanket-fail-closed and it sees 4, drop the generic
arms and it sees 1.

Separately, the comment justifying the guard's method granularity cited
CbfAuto_OpenedWithoutFailFast as the oracle covering the CommandBarFlyout mount
arm. That citation is vacuous: an Auto mount clears the DP and leaves WinUI's
default Top, which is exactly the state you get by deleting the mount Apply call
outright, so the test cannot tell the two apart. Re-cited
CbfReset_ExplicitPlacementApplied, which mounts an explicit Bottom and asserts
after the first render, and said plainly why the Auto test is not the oracle --
the next reader would otherwise make the same mistake.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7b1568e7-b095-4016-96c2-56ae56b92cf9
Copilot AI review requested due to automatic review settings July 31, 2026 07:17

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

The multi-model cross-check caught a regression I introduced one commit ago,
plus a hole neither of us had seen. Both are the same failure mode the guard
exists to prevent: a real write to a real flyout that the scanner does not see.

Peeling a single-argument generic straight to its type argument answers
List<Flyout> correctly and CustomFlyout<Item> backwards -- the latter resolves
to Item, fails the Flyout suffix test, and slips past the fail-closed arm. Every
generic flyout became invisible to the guard the moment I added collection
peeling.

The mistake was the helper's shape. TypeLeafName answered "what is the leaf
name" and left each caller to apply the suffix test, but a single type argument
is genuinely ambiguous between the flyout itself and the collection holding one,
and no answer phrased as one name can carry that. Only a check that sees both
names can decide. So the helper now answers the question the callers actually
ask -- DenotesFlyout, returning bool? with null meaning "cannot tell" -- and
checks the generic's own name before peeling to its argument. Blanket-flagging
every generic would also have closed the hole and is what I would have written
if the test only pinned the flyout direction; Holder<SomeElement> is in the test
precisely so that shortcut fails.

Second hole: new Holder { ContextFlyout = { Placement = ... } }. A nested member
initializer writes a property on an object that already exists, so the
receiver's type appears nowhere in the expression -- the initializer's parent is
the outer assignment, not a creation, and the switch fell through to false. It
is unresolvable by construction and it is a live write, so it now fails closed
like every other unresolvable shape. The one alarming thing about this hole is
how ordinary the syntax is.

Flatten now reports the outer assignment for that shape. The inner one on its
own reads "Placement = n.Placement" and names neither the member nor the type,
which is close to useless in a failure message.

All three mutations produce exactly the predicted counts: peel-first loses both
generic flyouts, dropping the nested arm loses both member-initializer writes,
and blanket-flagging generics is caught twice over -- by the new test at 3 hits
and by the collection test at 4.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7b1568e7-b095-4016-96c2-56ae56b92cf9
Copilot AI review requested due to automatic review settings July 31, 2026 07:31

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

Refresh the branch against main (33dafd0) so CI validates this change
against the current base rather than a 10h-old one.

Clean merge, no conflicts. The only file touched by both sides is
Reconciler.cs, where main's edits (~2174, ~3699-3725) are unrelated to
the ApplyFlyoutPlacement deletion here.

Verified for the two interactions a textual merge cannot see:
- No new calls to the deleted Reconciler.ApplyFlyoutPlacement on main,
  which would have merged cleanly and failed to compile.
- No new FlyoutBase.Placement writes in src/Reactor on main, which the
  structural guard added here scans and would newly have flagged.

Full unit suite green on the merged tree: 12947 passed, 0 failed,
64 skipped (13011 total), including both generated-artifact gates
(SearchIndexGeneratorTests.Index_IsUpToDate,
ApiIndexGeneratorTests.Index_IsUpToDate) and the placement guard
re-scanning the merged src/Reactor. The two reactor.api.txt copies
remain byte-identical (SHA256 C55A02EF..., 287797 bytes).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7b1568e7-b095-4016-96c2-56ae56b92cf9
Copilot AI review requested due to automatic review settings July 31, 2026 18:19

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

@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit 0e876d8 into main Jul 31, 2026
21 checks passed
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) deleted the azchohfi-dedupe-flyout-placement-helpers branch July 31, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deduplicate the two flyout-placement helpers (behaviour converged in #939; the duplication remains)

2 participants