Repository navigation
Classify pool-reset ClearValue calls per property, not per owner - #1099
Conversation
PoolResetSetConsistencyTests split the ClearValue calls in ElementPool.CleanElement's FE-common block into instance vs. attached buckets by owner name. Owner-level membership cannot express a *mixed* owner: Grid owns instance DPs (Padding, CornerRadius) and genuine attached DPs (Row, Column, RowSpan, ColumnSpan) at the same time. Since "Grid" was in InstancePropertyOwners, every Grid.* reset was routed to the instance bucket, so a genuinely attached Grid.* reset never reached Every_Reset_Attached_Property_Is_Classified -- no failure, no triage moment. PanelAttachedHooks.ApplyGridAttached already clears all four attached Grid DPs for pooled reuse just outside the scanned region, so this is a plausible edit, not a hypothetical one. Both scans now share one ClearValue regex and split on one predicate, so instance union attached is every recognized clear by construction. The predicate asks the same question PoolResetSetAnalyzer asks: does the owner declare the static Owner.SetPROP(DependencyObject, value) setter? Grid.SetRow exists, so Grid.Row is attached; there is no Grid.SetPadding, so Grid.Padding stays instance. A future mixed owner needs no edit. Reflection is metadata-only (no WinUI object is constructed), following ModifierTableIntegrityTests, with owner types hand-listed as typeof literals to stay IL2057/IL2072-clean. Unresolvable cases resolve to *attached* on purpose: that direction fails loudly, while the toward-instance direction is silent -- the bug. A dead probe would silently restore the old owner-keyed behaviour with everything green, so a 12-row theory pins both directions on the same owner, and a second test asserts each map key equals its OwnerType.Name so a copy-paste typo cannot pass. Validated by mutating the Grid arm of CleanElement: ARM0 baseline green (67 passed, was 54) ARM1 ClearValue(Grid.RowProperty) RED <- was green before ARM2 ClearValue(Canvas.LeftProperty) red (unchanged control) ARM3 ClearValue(Grid.BorderThickness) green (no false positive) ARM4 probe forced to return false red on the probe theory Full Reactor.Tests: 13289 passed, 0 failed. Test-only behaviour change plus a comment update to ModifierTable.DeliberatelyExcludedAttached; no product behaviour, no new diagnostic id, no docs or API regeneration. Fixes #1067 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
📦 Build metricsArtifact sizes for Packages (compressed .nupkg)
Assemblies in Microsoft.UI.Reactor
Assemblies in Microsoft.UI.Reactor.Advanced
Assemblies in Microsoft.UI.Reactor.Devtools
No size change beyond the noise floor. ✅ ✅ smaller / |
🧪 Merged coverageCoverage for
No coverage change beyond the noise floor. ✅ ✅ higher / |
The probe filtered inside a foreach with two `continue` guards, which code-quality flagged as implicit filtering. The question it answers is existential, not iterative, so `.Any(...)` states it directly and the setter name is computed once instead of per candidate method. Behaviour is identical, and ARM4 re-run against the new form still reddens exactly the five attached-expecting probe rows, so the control still proves the probe is live. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
ModifierTableIntegrityTests already reflects over public static two-arg methods on a WinUI owner, so a reader meeting DeclaresAttachedSetter reasonably asks why there are now two probes. They answer different questions. HasStaticTwoArgMethod omits FlattenHierarchy and checks neither the void return nor that the first parameter is a DependencyObject -- sufficient for the pure attached-property holders it runs against (AutomationProperties, ToolTipService, TitleBar, FlexPanel), where no instance member can collide. This probe discriminates on mixed owners such as Grid, where a loose match is precisely the silent misclassification #1067 is about, so the extra constraints carry the weight. Reusing the looser helper would reintroduce the bug by another route; unifying them would tighten a predicate for callers that do not need it. Comment only -- no behaviour change. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a blind spot in PoolResetSetConsistencyTests by classifying ElementPool.CleanElement ClearValue(Owner.PropProperty) resets as instance vs. attached per property, not per owner (so mixed owners like Grid are handled correctly). It also updates the related explanation comment in ModifierTable.DeliberatelyExcludedAttached.
Changes:
- Replace owner-keyed reset partitioning with a single
ClearValuePatternplusIsAttachedReset(owner, property)predicate to correctly handle mixed owners (e.g.,Grid). - Add positive-control tests to ensure the attached-setter probe is live and keyed correctly.
- Update
ModifierTabledocumentation to reflect the new per-property classification approach.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/Reactor.Tests/AnalyzerTests/PoolResetSetConsistencyTests.cs | Reworks reset scanning to split instance vs. attached by per-property probe; adds probe validation tests and improves failure messaging for mixed owners. |
| src/Reactor.Analyzers/ModifierTable.cs | Updates commentary around DeliberatelyExcludedAttached to align with the revised classification model and hazards. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Two review points on the probe and its comment. The probe re-materialized the owner's full public static method list on every call -- once per ClearValue match per scan, times every test that rescans, plus each theory row. Hoist it: AttachedSetterProbe now takes the reflection pass once per owner when the map initializes, keeps the qualifying setter names in an ordinal set, and returns a closure that is a set lookup. Classifying a match now costs no reflection. This is a refactor of the predicate the whole classification rests on, so it gets the mutation control rather than an assumption that behaviour was preserved: forcing the lookup name unmatchable still reddens exactly the five attached-expecting rows of the probe theory (Grid.Row/Column/ RowSpan/ColumnSpan and Control.IsTemplateFocusTarget), and the restored form is back to 67/67 with the full suite at 13289/0. Separately, the DeliberatelyExcludedAttached remarks said 'The scan now classifies per property', which in a file that *is* the analyzer's table reads as though the analyzer does it. Name the test. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
tests/Reactor.Tests/AnalyzerTests/PoolResetSetConsistencyTests.cs:633
- InstancePropertyOwnerProbes repeats the owner type expression twice per entry (OwnerType and AttachedSetterProbe(typeof(...))). That creates a real foot-gun: a future edit can accidentally mismatch the probe type from the OwnerType (e.g., OwnerType=Grid but probe built from StackPanel), and the existing Every_Instance_Owner_Key_Names_Its_Own_Type test would not catch it because it only validates the key→OwnerType pairing. Consider factoring entry construction so the probe is always derived from the exact OwnerType used in the tuple.
["FrameworkElement"] = (
typeof(Microsoft.UI.Xaml.FrameworkElement),
AttachedSetterProbe(typeof(Microsoft.UI.Xaml.FrameworkElement))),
["UIElement"] = (
typeof(Microsoft.UI.Xaml.UIElement),
Each map entry named its owner twice -- once for OwnerType, once inside AttachedSetterProbe(typeof(...)) -- and nothing tied the two together. Every_Instance_Owner_Key_Names_Its_Own_Type pins the key to OwnerType and never looks at what the probe actually reads, so a drifted pair would classify against the wrong type. That is #1067 restored by a different route: a probe built from a type without the owner's static setters answers 'instance' for every attached property on it. Measured rather than assumed. Building the UIElement entry's probe from TextBlock leaves all 67 tests green, so the hole is real. It is only partly covered elsewhere -- Grid and Control have attached-expecting rows in the probe theory (ARM4 showed those exact five redden when the probe cannot match), but the remaining six owners carry none, so for them the mistake is silent. ProbeFor(Type) takes the type once and returns both halves, which makes the mismatch inexpressible rather than merely tested for. Full suite 13289/0. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Picking up the suppressed comment from the last Copilot pass (no inline thread to reply on) — it was right, and it found a hole the visible comments didn't.
Confirmed by measurement rather than taken on the description. Building the So the drift really is silent. It is partly covered elsewhere, which is worth stating precisely: Fixed in 571dca3 by removing the second mention rather than testing for its absence: private static (Type OwnerType, Func<string, bool> DeclaresAttachedSetter) ProbeFor(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type type)
=> (type, AttachedSetterProbe(type));["Grid"] = ProbeFor(typeof(Microsoft.UI.Xaml.Controls.Grid)),The type is named once and both halves derive from it, so the mismatch is inexpressible instead of merely tested for. I deliberately did not also derive the key from Full suite 13289/0. |
Audits every PR merged since v0.1.0-preview.13 (56 commits) for changelog
coverage, then cuts the release section per docs/contributing/release-runbook.md.
Only 9 of those PRs updated CHANGELOG.md. Nine user-facing changes were missing
an entry and are added here:
Added - declarative window icon: icon: on ReactorApp.Run plus
Run(WindowSpec, ...) overloads (#1145, issue #1143)
Changed - dotnet new reactorapp resolves the latest Windows App SDK (#1096)
Fixed - connected animations never played across a replaced subtree (#1124)
- a controlled SelectedIndex WinUI cannot honor stranded an echo
token and ate the next real selection (issue #1090, #1091, #1097)
- legacy text-node TreeView rendered empty under NativeAOT (#1108)
- devtools DP lookups found nothing, since CsWinRT projects
DependencyProperty statics as properties (issue #1109)
- the exe-icon fallback was dead code, and WindowIcon.FromResource
silently applied a default icon in packaged apps (issue #1143)
- an installed mur was frozen at first bootstrap, and mur check
shipped without Roslyn (#1130)
- mur loc/docs help printed the non-existent "duct" command (#1129)
- a scaffolded project would not launch in Visual Studio 26 (#1084)
The three behaviour fixes were checked against v0.1.0-preview.13 rather than
assumed: the AOT skip for ControlUpdate_Collections, the
_pendingConnectedAnimationStarts list, and the drift-only SelectedIndex gates
all exist at the tag, so each shipped broken and none qualifies for the
introduced-and-fixed-in-window exemption.
Deliberately omitted: dependency bumps, docs-only and CI/test-infra work, and
#1099/#1102, whose product code was already correct (the defect was in a test
classifier and a text matcher respectively).
Bumps ReactorPublicVersion to 0.1.0-preview.14 and recompiles the guide, which
substitutes {{reactorVersion}} across 8 pages, satisfying the docs freshness gate.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fixes #1067.
The defect
PoolResetSetConsistencyTestspartitioned theClearValuecalls inElementPool.CleanElement's FE-common block into instance vs. attached buckets by owner name:Owner-level membership cannot express a mixed owner.
Gridis inInstancePropertyOwnersbecauseGrid.Padding/Grid.CornerRadiusare ordinary instance DPs — butGrid.Row,Grid.Column,Grid.RowSpan,Grid.ColumnSpanare genuinely attached. So everyGrid.*reset was routed to the instance bucket and never reachedEvery_Reset_Attached_Property_Is_Classified. No failure, no triage moment.This is not hypothetical:
PanelAttachedHooks.ApplyGridAttachedalready clears all four attachedGridDPs for pooled reuse, just outside the scanned region. Moving or duplicating one of those lines intoCleanElementis exactly the plausible change that would have landed silently.Product code (
ElementPool,ModifierTable, the analyzer) was correct; the defect was in the test's classifier.The fix
One regex, one predicate, two complementary halves. Both
ReadResetPropertiesandReadResetAttachedPropertiesnow scan with the sameClearValuePatternand split on a singleIsAttachedReset(owner, property), so instance ∪ attached = every recognized clear by construction.InstanceClearValuePattern(the owner alternation) is gone — two views of one owner list is precisely the arrangement that cannot express a mixed owner.The predicate asks the same question the analyzer asks. A clear is attached when its owner is outside the probe table or the owner type declares the static
Owner.SetPROP(DependencyObject, value)setter — literally the call shapePoolResetSetAnalyzermatches inside a.Set(...)lambda.Grid.SetRowexists →Grid.Rowis attached. There is noGrid.SetPadding→Grid.Paddingstays instance. A future mixed owner needs no edit here.Reflection is metadata-only — no WinUI object is constructed — following the pattern already proven in
ModifierTableIntegrityTests. Owner types are hand-listed astypeof(...)literals to stay IL2057/IL2072-clean (Release build: 0 warnings).The bias is deliberate and fail-safe. Calling an instance property attached fails loudly and someone triages it; calling an attached property instance is silent — the whole bug. So anything unresolvable resolves to attached: an owner absent from the probe table is attached by default.
The instrument has a positive control. A dead probe (wrong
BindingFlags, a projection change) would silently revert to today's owner-keyed behaviour with everything green — a no-match is not a measurement. A 12-row theory pins both directions on the same owner (Grid.Row/Column/RowSpan/ColumnSpan→ attached;Grid.Padding,Control.IsEnabled,FrameworkElement.Margin→ instance), asserting the owner is in the probe table first so no row can pass vacuously through the unknown-owner short-circuit. A second test asserts each map key equals itsOwnerType.Name, so["Grid"] = … typeof(StackPanel) …cannot pass.Validation
Mutations inserted into the
Gridarm ofCleanElement, run with--no-build(this class readsElementPool.csas data at runtime):resetGrid.ClearValue(WinUI.Grid.RowProperty);Every_Reset_Attached_Property_Is_Classified— was green before this PRresetGrid.ClearValue(WinUI.Canvas.LeftProperty);resetGrid.ClearValue(WinUI.Grid.BorderThicknessProperty);return falseARM1's failure message names the mixed-owner situation explicitly, so the next person reads why
Gridis in the probe table and that it is not a reason to reclassify.Reactor.Tests: 13289 passed, 0 failed (Release, x64).src/Reactor.AnalyzersRelease: 0 warnings, 0 errors.NU1301restore errors on untouched VS-extension /Reactor.Compile.Analyzer.Testsprojects are an offline-environment artifact — reproduced on a stashed (clean) tree as a positive control, so they are not from this change. CI has network.Scope
Test-only behavioural change plus a comment update to
ModifierTable.DeliberatelyExcludedAttached(which argued only the exclusion-list hazard, not the owner-list hazard it introduced). No product behaviour, no new diagnostic id, noAnalyzerReleases.Unshipped.mdrow, nomur checkmirror, no docs or API regeneration.Rejected alternative: the issue's option 2, a test-only
KnownAttachedOnGridLikeOwnersdeny-list. Smaller, but hand-maintained, silent when the next mixed owner appears, and it leaves both scans owner-keyed — the same shape that produced this bug.Known probe limitation (documented in the helper's remarks rather than papered over): an attached DP with no static setter — the
AutomationProperties.DescribedBycollection shape — would still read as instance. No such property exists on the eight listed owners, and it is exactly the shape theOwner.SetPROP(x, v)rule cannot match anyway.Adjacent, out of scope: #1066 and #1048 are the same family and touch the same two files; expect textual conflicts if they land first.