Skip to content

test: expand coverage; fix(FlexPanel): CSS block-level sizing + Collapsed support - #48

Merged
Chris Anderson (codemonkeychris) merged 6 commits into
mainfrom
test-and-flexpanel-css-compliance
Apr 19, 2026
Merged

Chris Anderson (codemonkeychris) merged 6 commits into
mainfrom
test-and-flexpanel-css-compliance

Conversation

@codemonkeychris

Copy link
Copy Markdown
Collaborator

Summary

Two bundled chunks of work, landed in separate commits so the FlexPanel fix can be reviewed independently of the coverage push.

1. Testing improvements (≈82.5% → ≈84.3% merged coverage of Reactor.dll)

  • Unit tests — 13 new *CoverageTests.cs files under tests/Reactor.Tests/ targeting previously-uncovered pure-logic paths: ElementExtensions fluent modifiers, every Theme token, Yoga LayoutResults/Value helpers, NavigationDiagnostics, ReactorEventSource (via EventListener), AccessibilityScanner (TabIndex gap + container arms), IntlAccessor per-locale joiners and format branches, Voronoi/Delaunay small-N cases, Element record constructors, plus a swath of Devtools types (NodeRegistry, WindowRegistry, McpDispatcher, McpToolRegistry, DevtoolsLogger, WaitForPredicate, SelectorParser, StdioMcpLoop, Sankey/Stratify, MarkdownBuilder, MaskEngine). Extensions to existing PropertyGridArrayTests (array-clone paths) and LockfileRegistryTests (Write skip-rewrite, EnumerateAll, IsLive stdio).
  • Selftest — new DslExt_BrushAndFontModifiers fixture covering the extension overloads that allocate WinUI types (SolidColorBrush/FontFamily/FontWeight, implicit transitions, Resources lightweight styling) — only reachable inside an Application host.
  • Net result: 4961 unit tests, 0 failures, 46 skipped. Full selftest green.

2. FlexPanel CSS block-level sizing fix

Uncovered during a parallel parity investigation. Two symptoms traced to the same root axis inversion:

  • ScrollViewer → FlexColumn → RichTextBlock perf regression (historically mitigated with a two-pass hack in MeasureOverride).
  • FlexColumn inside an auto-sized slot reporting ActualHeight = parent-height instead of sum-of-children.

Fix: unify MeasureOverride to match CSS block-level sizing (inline axis fills the containing block, block axis content-sizes) independent of flex-direction. The two-pass hack is gone — CSS's rule makes the RichTextBlock case a natural single pass. HorizontalAlignment != Stretch opts into CSS width: fit-content as an escape hatch.

Secondary fix: Visibility=Collapsed now maps to Yoga Display.None, so collapsed children contribute neither size nor a gap slot — matching CSS display: none and StackPanel.

Artifacts shipped with the fix

  • docs/research/FlexPanel-vs-StackPanel.md — CSS vs StackPanel agreement/divergence matrix; cites StackPanel.cpp from microsoft-ui-xaml-lift; explains why CSS semantics beats StackPanel parity for this project.
  • Fixtures/FlexPanelCssBehaviorFixtures.cs — 14 fixtures in two sections:
    • Section A (CssStack_*, 8): StackPanel and FlexPanel both asserted against the CSS-computed expected value. Drop-in-replacement safety zone.
    • Section B (CssDiverge_*, 6): CSS-only features with no StackPanel analog (flex-grow, justify-content: center/space-between, flex-wrap, align-self, explicit Height honor). FlexPanel asserted against CSS-computed expected; StackPanel excluded with inline justification.
  • WebViewCssMeasurement.cs — scaffolded for live CSS-truth comparison via WebView2 getBoundingClientRect(). The current selftest harness doesn't initialize CoreWebView2 (a pre-existing limitation, confirmed by instrumenting MarkdownHtmlFixtures.HtmlInWebView2 — same silent null). Kept in-tree as the plug-in point for a future harness upgrade; fixtures use hand-computed CSS values (documented inline) in the meantime.

Commits

# Commit Scope
1 chore: gitignore local coverage outputs infra
2 test(unit): expand coverage across Reactor core and hosting surfaces coverage push
3 test(selftest): add brush and font modifier fixture coverage push
4 fix(FlexPanel): align measure with CSS block-level semantics production fix
5 test(selftest): add FlexPanel CSS behavior fixtures fix validation
6 docs(research): add FlexPanel vs StackPanel reference doc

Test plan

  • dotnet test tests/Reactor.Tests — 4961 passed, 0 failed, 46 skipped.
  • dotnet test tests/Reactor.SelfTests — full selftest green, 0 failures across all fixtures (existing + 15 new).
  • Merged coverage (unit + selftest): 30,729 / 36,474 = 84.25% line-rate (from 82.5% baseline).
  • CI signoff.
  • Visual spot-check of FlexPanel parity fixtures in a real window.

🤖 Generated with Claude Code

Cobertura reports under coverage/ are regenerated per-session and have
no value as checked-in artifacts — see CONTRIBUTING.md § Code coverage
for the regen recipe.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds targeted xUnit suites for previously-uncovered pure-logic paths.
These lift merged unit+selftest coverage of Reactor.dll from ~82.5% to
~84.3% without touching production code. Many tests also document the
intended contract of rarely-used APIs (e.g. LayoutResults equality rules,
IntlAccessor per-locale list-joiners, AccessibilityScanner's TabIndex
gap detection).

New suites:
- ElementExtensionsCoverageTests — every non-WinUI-allocating fluent
  modifier on ElementExtensions, including A11y tiers and transitions.
- ThemeTokenCoverageTests — every Theme.* token + Ref() + Resolve().
- ElementRecordCoverageTests — constructors for the many Element record
  types (IconData hierarchy, AppBar/MenuFlyout data, container Setters).
- YogaLayoutResultsTests — CachedMeasurement.Equals, LayoutResults
  Reset/EqualTo per-axis.
- YogaValueExtensionsTests — ResolveValue, IsMaxContent/FitContent/Stretch.
- NavigationDiagnosticsCoverageTests — each OnX entry point fires its
  event with the expected payload.
- ReactorEventSourceCoverageTests — every Event method emits via a
  CapturingListener, including null-string coalescing.
- AccessibilityScannerCoverageTests — TabIndex gap (A11Y_007), the
  less-common container switch arms, and ExportJson's mkdir branch.
- AttachedExtensionsCoverageTests — RelativePanelExtensions and
  FlexExtensions input validation.
- IntlAccessorCoverageTests — FormatList joiners for 15 locales,
  FormatNumber digit-clamp branches, FormatDate styles, Asset() cache
  hit, RichMessage pseudo-localization.
- VoronoiCoverageTests — Delaunay.From small-N branches, Voronoi cell
  clipping, Contains, circumcenter fallback.
- MoreCoverageTests + MoreCoverageTests2 — NodeRegistry, WindowRegistry,
  McpDispatcher/McpToolRegistry, DevtoolsLogger, WaitForPredicate,
  SelectorParser, MaskEngine, MarkdownBuilder, Sankey, Stratify, and
  a pile of Element record-type constructors.

Extensions to existing suites:
- PropertyGridArrayTests — array-clone branches on ArrayOperations
  (Add/RemoveAt/MoveUp/MoveDown) plus the error and unsupported paths.
- D3/CurveTests — CurveBasisClosed 1/2/3-point paths, CurveMonotoneX
  coincident-point and zero-slope edges, Cardinal/CatmullRom tension
  variants.
- Devtools/LockfileRegistryTests — Write skip-rewrite, TryRead bad
  JSON, EnumerateAll with real files, IsLive stdio path, Directory
  and PathFor coverage.

Full suite: 4961 passed, 0 failed, 46 skipped.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Covers the fluent extension overloads that allocate WinUI types
(SolidColorBrush, FontFamily, FontWeight, ScalarTransition,
ContentThemeTransition) and therefore only run inside an Application
host — not reachable from the xUnit unit suite. Exercises Bold/
FontFamily(string|object)/FontWeight/Background(string|brush)/Foreground/
WithBorder/Path().StrokeDashArray/Fill/Stroke, every implicit transition
(Opacity/Rotation/Scale/Translation/Background on Grid and Stack),
WithTransitions, ItemContainerTransitions, and Resources() lightweight
styling. Adds the corresponding registry entry.

Paired with the unit-test coverage push; together they move
merged Reactor.dll coverage from ~82.5% to ~84.3%.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Previous MeasureOverride had two branches: a single-pass path when the
main axis was definite (which made the Yoga root fill that axis), and
a content-size fallback (which caused the known RichTextBlock perf
regression — infinite-width measurement followed by a reflow pass
inside Yoga). Both were symptoms of the same bug: we were treating the
main axis as the "definite" one per flex-direction, but CSS actually
resolves the INLINE axis (width, in horizontal writing mode) against
the containing block and content-sizes the BLOCK axis — independent of
flex-direction.

Change: unify into a single path that mirrors the CSS rule.

  CalculateLayout(
      availableSize.Width (if finite) | NaN (fit-content),  // inline: fill or fit
      NaN,                                                  // block: content-size
      LayoutDirection);

Consequences:
- ScrollViewer → FlexColumn → RichTextBlock case: the text child now
  sees a finite cross-axis constraint from the containing block in a
  single pass, same as StackPanel. No infinite-width shape, no reflow.
- FlexColumn inside an auto-sized slot correctly returns
  (parent-width, sum-of-children) rather than filling the whole slot.
- FlexRow behavior is unchanged (its main=width already matched the
  CSS inline-axis rule).
- HorizontalAlignment != Stretch opts into CSS `width: fit-content`:
  cross axis is NaN capped by availableSize.Width. Slower when
  children include text; user-elected shrink-wrap.

Secondary fix in SyncYogaTree: mirror WinUI Visibility=Collapsed onto
Yoga Display=None. Collapsed children previously contributed both
their size AND a gap slot to the main-axis sum (the parity suite
caught a FlexColumn reporting 136 when the CSS/StackPanel answer was
88). XAML Collapsed is the equivalent of CSS display:none — no size,
no gap. Now enforced.

Full selftest suite passes including the new CSS behavior fixtures
added in the follow-up commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Three-way story for the FlexPanel behavior contract:
  - Section A (CssStack_*, 8 fixtures): scenarios where CSS Flexbox
    and WinUI StackPanel agree on the expected layout. Each fixture
    mounts both panels with identical children and compares both
    ActualWidth/Height against the CSS-computed expected value
    (hand-derived from the flexbox algorithm; verified against a
    real browser at design time). These define the "safe to migrate
    StackPanel → FlexPanel" surface.
  - Section B (CssDiverge_*, 6 fixtures): CSS-only features with no
    StackPanel analog — explicit Height honored, justify-content
    (center, space-between), flex-grow distribution, align-self
    per-child override, flex-wrap. Asserts FlexPanel produces the
    CSS-spec result; inline comments document why StackPanel is
    excluded from the comparison.

Also lands WebViewCssMeasurement.cs — a helper for rendering the
equivalent HTML in a live WebView2 and reading getBoundingClientRect()
through ExecuteScriptAsync. The original intent was to use this for
dynamic CSS-truth comparison in every Section A/B fixture, but the
selftest harness's Application.Start configuration doesn't light up a
working CoreWebView2 (confirmed by instrumenting the existing
MarkdownHtmlFixtures.HtmlInWebView2 which has the same silent null).
The helper is kept as the plug-in point for when the harness acquires
a compositor-ready WebView2 runtime — the fixtures fall back to
hand-computed CSS expected values documented inline per scenario.

Full selftest run: 0 failures across the 14 new fixtures plus all
existing flex / layout / reconciler suites.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Captures the agreement/divergence matrix between CSS Flexbox, WinUI
StackPanel, and Reactor's FlexPanel; explains why the project targets
CSS semantics (not StackPanel parity) and where users can safely
migrate StackPanel to FlexPanel.

Includes the ScrollViewer → FlexColumn → RichTextBlock perf story,
citing StackPanel.cpp from microsoft-ui-xaml-lift — the CSS block-level
rule solves the same problem StackPanel's hard-coded directional
asymmetry solves, in a single pass.

Notes the WebView2 limitation encountered while building the dynamic
CSS-truth comparison, and points at WebViewCssMeasurement.cs as the
plug-in point for a future harness upgrade.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@codemonkeychris
Chris Anderson (codemonkeychris) force-pushed the test-and-flexpanel-css-compliance branch from f452d25 to c1cfb36 Compare April 19, 2026 23:48
@codemonkeychris
Chris Anderson (codemonkeychris) merged commit b5056a8 into main Apr 19, 2026
3 checks passed
@codemonkeychris
Chris Anderson (codemonkeychris) deleted the test-and-flexpanel-css-compliance branch April 19, 2026 23:55
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 25, 2026
…sing

Addresses GitHub Copilot review (5 comments, same root cause): the params object[] overloads and the arity-1 AsParamsArrayDep path stored the caller's deps array by reference. A caller that reuses AND mutates the same array instance across renders would alias prev/next, so DepsEqual would see 'unchanged' and wrongly skip the effect / memo recompute -- an observable semantic change the task forbids.

FIX: SnapshotDeps() clones the array when persisting it on the hook slot (UseEffect via ScheduleEffect, UseMemo, UseCallback -- both params and AsParamsArrayDep paths). This runs ONLY on the deps-CHANGED store path; the steady-state (deps-equal) path short-circuits before storing, so there is NO steady-state allocation and the StocksGrid hot-path win is preserved. Effectively reverts the #48 direct-store micro-opt in favor of correctness (it only saved a copy on the changed path). PackDeps arity paths already allocate fresh arrays and are unchanged.

Tests: reused+mutated-array regressions for effect (re-run), memo (recompute), callback (new instance), plus the unchanged-contents cached case.

Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 26, 2026
Every component re-render re-runs every hook, so per-render hook
allocations multiply by cells x hooks on data-grid workloads
(StocksGrid). This eliminates the hot-path allocations in the hooks
bookkeeping layer while preserving the rules of hooks (same call
order/count/types every render) and observable semantics.

RenderContext.cs:
- #42 ValueHookState Lock is now lazy/nullable (allocated only when
  threadSafe:true); saves N rows x M hooks of unused Lock objects.
- #43 UseState setter cached on the hook slot (built once, not a new
  display-class + Action<T> every render).
- #44 UseReducer<T> updater and UseReducer<TState,TAction> dispatch
  delegates cached on the hook; dispatch reads the latest reducer from
  state (matches React semantics).
- #45/#46/#48 UseEffect/UseMemo/UseCallback gain arity 1-3 deps
  overloads that compare deps without boxing and allocate the deps
  array only when deps actually change; params overloads kept as
  fallback and now assign Dependencies directly (no extra ToArray).
  UseCallback no longer allocates a ()=>callback wrapper.
- #50 _hooks list pre-sized to new(8) to avoid mount realloc churn.
- #51 ContextHooks uses a struct enumerator (no heap enumerator per
  render); still implements IEnumerable for existing .ToList() callers.
- #52 UseCommand/UseCommand<T> use an inline memo slot instead of a
  per-render factory closure capturing 7 vars.
- #53 UsePersisted setter cached on the hook slot.
- #56 new internal UseDisposableEffect(IDisposable) mount-once helper
  with a stable teardown (no 2 lambdas per render).

Hooks/:
- #47 UseMemoCells/ByKey/ByIndex early full-reuse: return the prior
  children array and skip snapshot/dict allocation on a full cache hit.
- #59 UseMemoCellsByKey computes each key once per item into a buffer
  instead of invoking the key selector twice.
- #55 UseElementFocus caches the requestFocus closure and DispatcherQueue
  in refs instead of allocating + a COM call every render.
- #57 UseResource uses an Interlocked counter id (not Guid.NewGuid) and
  skips the deps-hash rebuild when deps are unchanged; #56 disposes via
  UseDisposableEffect.
- #56 UseMutation/UseInfiniteResource dispose via UseDisposableEffect.

PanelAttachedHooks.cs:
- #60 ApplyRelativePanelAttachedProps reuses a thread-static name-map
  dictionary (with a reentrancy guard for nested RelativePanels) instead
  of allocating one per reconcile.

Tests: tests/Reactor.Tests/HookAllocationPerfTests.cs (25 tests) cover
cached-delegate identity across renders, deps short-circuit (params +
arity), threadSafe Lock still allocated + correct under concurrent
writes (null when not requested), and UseMemoCells/ByKey/ByIndex
cache-hit returning the same prior children array.

The two committed skills/reactor.api.txt copies are regenerated to add
the new public arity overloads (UseDisposableEffect stays internal).

Closes #659

Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 26, 2026
…sing

Addresses GitHub Copilot review (5 comments, same root cause): the params object[] overloads and the arity-1 AsParamsArrayDep path stored the caller's deps array by reference. A caller that reuses AND mutates the same array instance across renders would alias prev/next, so DepsEqual would see 'unchanged' and wrongly skip the effect / memo recompute -- an observable semantic change the task forbids.

FIX: SnapshotDeps() clones the array when persisting it on the hook slot (UseEffect via ScheduleEffect, UseMemo, UseCallback -- both params and AsParamsArrayDep paths). This runs ONLY on the deps-CHANGED store path; the steady-state (deps-equal) path short-circuits before storing, so there is NO steady-state allocation and the StocksGrid hot-path win is preserved. Effectively reverts the #48 direct-store micro-opt in favor of correctness (it only saved a copy on the changed path). PackDeps arity paths already allocate fresh arrays and are unchanged.

Tests: reused+mutated-array regressions for effect (re-run), memo (recompute), callback (new instance), plus the unchanged-contents cached case.

Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 29, 2026
…659)

Cache ref-stable hook delegates on the (identity-stable) hook cell and add a
full-reuse early-out to UseMemoCells, eliminating per-render allocations on the
component render hot path. Measured via a headless GC-alloc harness
(tests/Reactor.Tests/HookAllocBench.cs, env-gated REACTOR_ALLOC_BENCH):

  UseState x1/x4        96/384 -> 0    (#43 cached setter)
  UseReducer<T>/<S,A>   96/104 -> 0    (#44 cached updater/dispatch + latest-reducer cell)
  UsePersisted              96 -> 0    (#53 cached setter)
  UseCallback              152 -> 64   (#46 inlined, dropped () => callback wrapper)
  UseMemoCells cache-hit   632 -> 32   (#47 full-reuse early-out; residual is caller params array)

Also: #42 lazy lock (no Lock unless threadSafe), #48 drop redundant deps .ToArray(),
#50 _hooks initial capacity 8, #51 ContextHooks struct enumerator (no per-render heap
iterator on the reconciler's per-component loop).

Hook semantics preserved: call-order stable; cached delegates read live cell value
and the current re-render callback; threadSafe path keeps its lock; two-arg reducer
dispatch honors the latest render's reducer. UseMemoCells full cache-hit returns the
prior children array (no rebuild). New regression tests in HookDelegateCachingTests.

Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 29, 2026
…659)

Cache ref-stable hook delegates on the (identity-stable) hook cell and add a
full-reuse early-out to UseMemoCells, eliminating per-render allocations on the
component render hot path. Measured via a headless GC-alloc harness
(tests/Reactor.Tests/HookAllocBench.cs, env-gated REACTOR_ALLOC_BENCH):

  UseState x1/x4        96/384 -> 0    (#43 cached setter)
  UseReducer<T>/<S,A>   96/104 -> 0    (#44 cached updater/dispatch + latest-reducer cell)
  UsePersisted              96 -> 0    (#53 cached setter)
  UseCallback              152 -> 64   (#46 inlined, dropped () => callback wrapper)
  UseMemoCells cache-hit   632 -> 32   (#47 full-reuse early-out; residual is caller params array)

Also: #42 lazy lock (no Lock unless threadSafe), #48 drop redundant deps .ToArray(),
#50 _hooks initial capacity 8, #51 ContextHooks struct enumerator (no per-render heap
iterator on the reconciler's per-component loop).

Hook semantics preserved: call-order stable; cached delegates read live cell value
and the current re-render callback; threadSafe path keeps its lock; two-arg reducer
dispatch honors the latest render's reducer. UseMemoCells full cache-hit returns the
prior children array (no rebuild). New regression tests in HookDelegateCachingTests.

Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 30, 2026
…659)

Cache ref-stable hook delegates on the (identity-stable) hook cell and add a
full-reuse early-out to UseMemoCells, eliminating per-render allocations on the
component render hot path. Measured via a headless GC-alloc harness
(tests/Reactor.Tests/HookAllocBench.cs, env-gated REACTOR_ALLOC_BENCH):

  UseState x1/x4        96/384 -> 0    (#43 cached setter)
  UseReducer<T>/<S,A>   96/104 -> 0    (#44 cached updater/dispatch + latest-reducer cell)
  UsePersisted              96 -> 0    (#53 cached setter)
  UseCallback              152 -> 64   (#46 inlined, dropped () => callback wrapper)
  UseMemoCells cache-hit   632 -> 32   (#47 full-reuse early-out; residual is caller params array)

Also: #42 lazy lock (no Lock unless threadSafe), #48 drop redundant deps .ToArray(),
#50 _hooks initial capacity 8, #51 ContextHooks struct enumerator (no per-render heap
iterator on the reconciler's per-component loop).

Hook semantics preserved: call-order stable; cached delegates read live cell value
and the current re-render callback; threadSafe path keeps its lock; two-arg reducer
dispatch honors the latest render's reducer. UseMemoCells full cache-hit returns the
prior children array (no rebuild). New regression tests in HookDelegateCachingTests.

Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 30, 2026
…659) (#750)

* perf(hooks): cache hook delegates + drop per-render hook allocations (#659)

Cache ref-stable hook delegates on the (identity-stable) hook cell and add a
full-reuse early-out to UseMemoCells, eliminating per-render allocations on the
component render hot path. Measured via a headless GC-alloc harness
(tests/Reactor.Tests/HookAllocBench.cs, env-gated REACTOR_ALLOC_BENCH):

  UseState x1/x4        96/384 -> 0    (#43 cached setter)
  UseReducer<T>/<S,A>   96/104 -> 0    (#44 cached updater/dispatch + latest-reducer cell)
  UsePersisted              96 -> 0    (#53 cached setter)
  UseCallback              152 -> 64   (#46 inlined, dropped () => callback wrapper)
  UseMemoCells cache-hit   632 -> 32   (#47 full-reuse early-out; residual is caller params array)

Also: #42 lazy lock (no Lock unless threadSafe), #48 drop redundant deps .ToArray(),
#50 _hooks initial capacity 8, #51 ContextHooks struct enumerator (no per-render heap
iterator on the reconciler's per-component loop).

Hook semantics preserved: call-order stable; cached delegates read live cell value
and the current re-render callback; threadSafe path keeps its lock; two-arg reducer
dispatch honors the latest render's reducer. UseMemoCells full cache-hit returns the
prior children array (no rebuild). New regression tests in HookDelegateCachingTests.

Co-authored-by: Copilot <[email protected]>

* fix(hooks): harden UseMemoCells early-out + hook-cache per #659 review

Addresses the dual-review findings on PR #750:

#1 (BLOCKING, confirmed by RED test) theme propagation: the full-cache-hit
early-out returned a reference-equal Children array, which makes the container
ShallowEquals-skip its subtree (Element.cs ~622-699) so theme-sensitive
descendants never re-apply their brush on a theme change. Gate the same-array
early-out on the prior render having NO theme-sensitive cell (tracked as
MemoCellsState.AnyThemeSensitive via ChildDiffHints.IsThemeSensitive). Theme-
sensitive lists fall through to the fresh-array path (container recurses, theme
re-applies); non-theme-sensitive lists keep the 632->32B win. New adjudicating
tests in UseMemoCellsThemeSafetyTests.

#2 (HIGH) predicate consistency: AllItemsEqual now uses object.Equals (exact
match to the per-cell reuse loop) instead of EqualityComparer<T>.Default, so the
early-out can't diverge for IEquatable<T> types. Dropped the UseMemoCellsByKey
early-out entirely (its 'equal items imply identical keys' assumption + reused
KeyToIndex was unsafe for impure key selectors); ByKey still reuses elements.

#3 (MEDIUM) deps snapshot: restored deps.ToArray() on the deps-CHANGED store
path (UseEffect/UseMemo/UseCallback) so an explicit mutable object[] a caller
mutates can't corrupt the stored previous-deps. Runs only on deps-change, never
the steady-state hot path, so the per-render win (call-site array) is unchanged.

LOW delegate-kind guard: ValueHookState.SetterKind discriminates UseState vs
UseReducer vs two-arg dispatch so an invalid same-slot swap producing a
coincidentally same-typed delegate (Action<int>) re-materializes instead of
reusing the wrong one.

Measured (bytes/render): UseState/UseReducer/UsePersisted still 0; UseMemoCells
cache-hit non-theme-sensitive ref still 32; theme-sensitive now 640 (correctly
falls through). Full suite 9929 green; build 0/0.

Co-authored-by: Copilot <[email protected]>

* test(hooks): end-to-end theme-propagation guard for UseMemoCells early-out (#659)

Adds UseMemoCells_BaseReThemeOnAncestorToggle selftest: a base UseMemoCells list of
theme-sensitive cells under an ancestor RequestedTheme toggle, driven through a full
value-equal cache hit, asserts the cell's themed Foreground re-resolves on the toggle
(000000 Light -> FFFFFF Dark).

Empirical result (verified by running this WITH and WITHOUT the AnyThemeSensitive
gate): the themed Foreground re-resolves IDENTICALLY in both cases. A
.Foreground(Theme.X) binding compiles to a {ThemeResource} Style setter that WinUI
re-resolves natively on the cell's effective-theme change, independent of whether
Reactor recurses or the container ShallowEquals-skips it — so the early-out's
container skip does not strand a themed-Foreground descendant. The AnyThemeSensitive
gate (5ead003) is retained as conservative insurance matching ChildDiffHints.IsThemeSensitive.

(A ResourceOverride ThemeRef->concrete-brush does not re-resolve on this toggle, but it
is wrong already at mount — a pre-existing GetEffectiveThemeName-during-reconcile issue
unrelated to this PR — so it is not asserted here.)

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
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.

1 participant