Skip to content

Add GitHub Actions CI for unit tests - #7

Merged
Chris Anderson (codemonkeychris) merged 3 commits into
mainfrom
ci/add-unit-test-workflow
Apr 17, 2026
Merged

Chris Anderson (codemonkeychris) merged 3 commits into
mainfrom
ci/add-unit-test-workflow

Conversation

@codemonkeychris

Copy link
Copy Markdown
Collaborator

Summary

  • Adds .github/workflows/ci.yml running dotnet test tests/Reactor.Tests on every PR and push to main
  • Uses windows-latest since the test project targets net9.0-windows10.0.22621.0 (WinUI)
  • Scopes restore/test to the Reactor.Tests.csproj project graph to avoid building WinUI host apps and samples on every PR

Test plan

  • Workflow runs on this PR and passes
  • Workflow runs on subsequent PRs
  • Workflow runs on push to main

Verified locally: 3518 passed, 0 failed, 46 skipped.

Generated with Claude Code

Runs dotnet test against tests/Reactor.Tests on every pull request and
push to main. Uses windows-latest since the test project targets
net9.0-windows10.0.22621.0 (WinUI).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

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

Adds a GitHub Actions workflow to run the repository’s .NET unit tests on CI for pull requests and pushes to main, targeting Windows to support the WinUI-based test project.

Changes:

  • Introduces .github/workflows/ci.yml with a windows-latest job that installs .NET 9, restores, and runs dotnet test for tests/Reactor.Tests/Reactor.Tests.csproj.

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

Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml
Comment on lines +1 to +7
name: CI

on:
pull_request:
push:
branches: [main]

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

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

Consider explicitly setting workflow/job permissions (e.g., contents: read) to avoid relying on the repository default GITHUB_TOKEN permissions, which may be broader than needed for checkout + restore/test.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copilot apply changes based on this feedback

The previous SHAs were invalid: actions/setup-dotnet@c0f7d5c7... does
not exist, and actions/checkout@692973e3... pointed to the old v4.1.7.
Pin both to the current v4.3.1 commits so the workflow resolves.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@codemonkeychris
Chris Anderson (codemonkeychris) merged commit 5375c98 into main Apr 17, 2026
2 checks passed
Chris Anderson (codemonkeychris) added a commit that referenced this pull request Apr 18, 2026
…ames

Addresses the second-round AI-agent field feedback. Build still compiles
and 3708 unit tests pass.

- #2 Stable window id: WindowIdAllocator.Reserve pins the primary
  devtools window to "main" so the handle survives switchComponent
  changing the window title. Windows payload surfaces `currentComponent`.
- #4 Scroll units + readback: description explicitly calls out
  percentage-delta semantics; response now carries `scrollOffsetPx` and
  `scrollableSizePx` dug out of the underlying ScrollViewer, and the
  -1 sentinel is replaced with null when an axis isn't scrollable.
- #5 Accessible names at mount: the reconciler now mirrors visible
  captions into AutomationProperties.Name for Button, HyperlinkButton,
  RepeatButton, ToggleButton, DropDownButton, SplitButton,
  ToggleSplitButton, CheckBox, RadioButton, ToggleSwitch, TextField, and
  TextBlock. Author-supplied .AutomationName(...) still wins; the
  Update path handles label changes via a provenance-aware compare so
  author overrides are preserved.
- #6 includeReactorSource rejection: tree tool returns structured
  not-implemented instead of silently no-opping.
- #7 ComboBox expand/collapse: new `expand` / `collapse` MCP verbs
  wrap IExpandCollapseProvider; `select` auto-expands a closed
  container so the popup items resolve.
- #9 Fire lambda confusion: unknown-event payload lists
  reachableMethods and explains inline lambdas aren't reflectable;
  tool description warns upfront.
- Usability: GET /mcp self-describes (schema, protocolVersion, tools,
  selectorGrammar, events); tools/list adds _selectorGrammar +
  _treeSchemaVersion extensions so POST-based agents get the grammar
  without a second hop; components tool returns ComponentInfo[] with
  isNested/isPublic/namespace; AnnounceReady emits a
  {"event":"devtools-ready", ...} JSON sentinel alongside the human
  banner; full-view tree nodes carry supportedPatterns[] probed from
  the UIA peer.

#8 (state selector scoping) deferred — requires reconciler component
registry. The resolution table previously in the feedback doc is
superseded; the doc itself has been removed from the working tree.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Chris Anderson (codemonkeychris) added a commit that referenced this pull request Apr 18, 2026
…ames

Addresses the second-round AI-agent field feedback. Build still compiles
and 3708 unit tests pass.

- #2 Stable window id: WindowIdAllocator.Reserve pins the primary
  devtools window to "main" so the handle survives switchComponent
  changing the window title. Windows payload surfaces `currentComponent`.
- #4 Scroll units + readback: description explicitly calls out
  percentage-delta semantics; response now carries `scrollOffsetPx` and
  `scrollableSizePx` dug out of the underlying ScrollViewer, and the
  -1 sentinel is replaced with null when an axis isn't scrollable.
- #5 Accessible names at mount: the reconciler now mirrors visible
  captions into AutomationProperties.Name for Button, HyperlinkButton,
  RepeatButton, ToggleButton, DropDownButton, SplitButton,
  ToggleSplitButton, CheckBox, RadioButton, ToggleSwitch, TextField, and
  TextBlock. Author-supplied .AutomationName(...) still wins; the
  Update path handles label changes via a provenance-aware compare so
  author overrides are preserved.
- #6 includeReactorSource rejection: tree tool returns structured
  not-implemented instead of silently no-opping.
- #7 ComboBox expand/collapse: new `expand` / `collapse` MCP verbs
  wrap IExpandCollapseProvider; `select` auto-expands a closed
  container so the popup items resolve.
- #9 Fire lambda confusion: unknown-event payload lists
  reachableMethods and explains inline lambdas aren't reflectable;
  tool description warns upfront.
- Usability: GET /mcp self-describes (schema, protocolVersion, tools,
  selectorGrammar, events); tools/list adds _selectorGrammar +
  _treeSchemaVersion extensions so POST-based agents get the grammar
  without a second hop; components tool returns ComponentInfo[] with
  isNested/isPublic/namespace; AnnounceReady emits a
  {"event":"devtools-ready", ...} JSON sentinel alongside the human
  banner; full-view tree nodes carry supportedPatterns[] probed from
  the UIA peer.

#8 (state selector scoping) deferred — requires reconciler component
registry. The resolution table previously in the feedback doc is
superseded; the doc itself has been removed from the working tree.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Chris Anderson (codemonkeychris) added a commit that referenced this pull request May 1, 2026
* docs(spec): plan response to WinUI/XAML reviewer feedback (#33)

Adds docs/specs/033 covering the actionable items from the external
WinUI/XAML expert review: GridSize for typed grid tracks, scoped
PersistedStateCache, typed ElementRef<T>, four-way component-flavor
guidance with Func soft-deprecated, Expr(...) for inline blocks,
SystemBackdrop modifiers, and an interop-first sample.

Memo/reflection feedback (#7) is documented as already resolved —
audit shows IPropsComparable dispatch in Reconciler.cs and the
reviewer was reading the test-only mirror. Adds explanatory comments
to MemoizationSelfHostTests and MemoizationPropagationTests so future
reviewers don't mistake the harness for product behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(spec): fix ICommand casing in interop-first sample (§7)

Copilot review on PR #100 flagged inconsistent acronym casing:
- FromIcommand → FromICommand (matches .NET convention and the ICommand
  type it wraps)
- IcommandBridge.cs → ICommandBridge.cs

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Chris Anderson (codemonkeychris) added a commit that referenced this pull request May 22, 2026
Resolves the 22 findings from the docking feature-branch review +
two test failures that surfaced while running the full suite.

Behavior fixes (Native docking host):
- Tear-out / FloatOp: open the floating window BEFORE removing the
  pane from the docked tree. Layout mutation + OnContentFloated fire
  only when a real ReactorWindow was produced (review #1 — the
  previous broad catch around Open turned a failed transition into a
  success-shaped event).
- Drop-overlay global Esc handler now detaches on reconciler unmount
  in addition to WinUI Unloaded (review #2).
- Floating-window observer callbacks, BeforeInsertToolWindow strategy
  hook, drag-session SessionChanged broadcast, navigator commit
  callback, and theme/resource lookup catches all surface failures via
  Debug.WriteLine or narrow to the expected exception type instead of
  swallowing everything (reviews #3, #4, #5, #7, #8).
- Splitter OnPointerCaptureLost now calls RestorePairToGrow() before
  the final ResizeDelta to converge with the normal release path
  (review #6).

Persistence:
- DockLayoutSerializer.Load now routes pre-current-schema documents
  through DockLayoutMigrationRegistry: parse to JsonNode, detect
  schema (absent $schema = v1 per §5.4.4), TryUpgrade, then
  deserialize. Adds a Load(json, registry) overload and emits a
  PII-safe schema-newer ETW category for forward-tolerant inputs
  (reviews #9 + #10).
- PreviousContainerTracker.ClearAll now actually clears by swapping
  in a fresh ConditionalWeakTable under a lock (review #11).

Surface honesty:
- DockHostModel.Floating is populated by the host renderer from a
  per-manager floating-window tracker; doc comment makes the
  initial-bounds-only limitation explicit (review #12).
- UseDockPanePersisted uses a canonical persisted-key encoder
  (pane:<typeName>|<keyText>:<userKey> with %/colon/pipe escaping)
  so two panes whose Key.ToString() collide get independent slots
  (review #13).
- docking.dock detects ambiguous Key.ToString() matches and returns
  an explicit ambiguous-pane error (review #18).

Test isolation:
- New DockingGlobalsCollection ([Collection("DockingGlobals")] +
  DisableParallelization=true) covers DockingStringsTests,
  DockA11yTests, and DevtoolsDockingToolsTests — three classes that
  mutate process-global state (review #14). DockA11yTests now
  restores DockingStrings.Resolver in Dispose.
- The known-failing UseEffect cleanup assertion is emitted as TAP
  "# SKIP" via a new Harness.Skip helper, with a back-flip to a real
  Check the moment the §2.25 product gap closes (review #15).
- EffectCounterComponent moved off static counters; the fixture owns
  per-run counters and passes mount/cleanup callbacks via props
  (review #16).
- EventListener category assertions in LayoutSerializerTests use a
  bounded retry helper to tolerate occasional async dispatch
  (review #17).

Documentation:
- docs/_pipeline/apps/docking/{api,overview}.md updated for the P2
  reality (core Microsoft.UI.Reactor ship vehicle,
  DockingNativeInterop.Register, deleted vendored WinUI.Dock link)
  (reviews #19, #22).
- DockingStrings.cs + dock-showcase sample comments updated to
  reflect that no .resw resource ships today; DefaultEnglish + the
  resolver are the localization surface (review #20).
- Reactor.csproj stale "stays on disk for reference" comment about
  src/Reactor.Docking.Xaml/ replaced with current state (review #21).

Tests / fluents:
- Added 22 fluent extensions in ElementExtensions.Events.cs for
  DockManager event callbacks + TabViewElement.OnTabDragStarting /
  OnTabDragCompleted so PublicApiSurfaceGuardTests passes; the
  guard test itself is now scoped to public element records only
  (internal overlay/splitter elements aren't part of the public
  surface contract).
- Two stale Phase-1-wrapper fixture names removed from
  SelfTestFixtureRegistry.AllFixtures (they had no factory case and
  surfaced as MSTest "fixture not found" failures).
- NativeDocking_PerGroupDropTargetVisualDemo: observer-pause delays
  cut from 500ms/step to 50ms/step so the 20-step walk stays well
  inside the 15s fixture timeout under CI load; eliminates the
  cascading NRE in DragSessionConfirmMutatesLayout that was caused
  by the timed-out fixture leaving stale host state.
- Mutations_OffOwnerThread_Throw uses an explicit new Thread()
  instead of Task.Run, so the assert can never observe a thread-id
  match by chance.
- Load_MissingSchemaField_FallsBack renamed to
  Load_MissingSchemaField_TreatedAsV1AndMigrated and rewritten —
  empty {} now migrates as v1 (matches the integrated registry).

Validation:
- dotnet test tests/Reactor.Tests -p:Platform=x64
    → 8720 passed, 46 skipped, 0 failed
- dotnet test tests/Reactor.SelfTests -p:Platform=x64
    → 813 passed, 0 failed

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Chris Anderson (codemonkeychris) added a commit that referenced this pull request May 22, 2026
Resolves the 22 findings from the docking feature-branch review +
two test failures that surfaced while running the full suite.

Behavior fixes (Native docking host):
- Tear-out / FloatOp: open the floating window BEFORE removing the
  pane from the docked tree. Layout mutation + OnContentFloated fire
  only when a real ReactorWindow was produced (review #1 — the
  previous broad catch around Open turned a failed transition into a
  success-shaped event).
- Drop-overlay global Esc handler now detaches on reconciler unmount
  in addition to WinUI Unloaded (review #2).
- Floating-window observer callbacks, BeforeInsertToolWindow strategy
  hook, drag-session SessionChanged broadcast, navigator commit
  callback, and theme/resource lookup catches all surface failures via
  Debug.WriteLine or narrow to the expected exception type instead of
  swallowing everything (reviews #3, #4, #5, #7, #8).
- Splitter OnPointerCaptureLost now calls RestorePairToGrow() before
  the final ResizeDelta to converge with the normal release path
  (review #6).

Persistence:
- DockLayoutSerializer.Load now routes pre-current-schema documents
  through DockLayoutMigrationRegistry: parse to JsonNode, detect
  schema (absent $schema = v1 per §5.4.4), TryUpgrade, then
  deserialize. Adds a Load(json, registry) overload and emits a
  PII-safe schema-newer ETW category for forward-tolerant inputs
  (reviews #9 + #10).
- PreviousContainerTracker.ClearAll now actually clears by swapping
  in a fresh ConditionalWeakTable under a lock (review #11).

Surface honesty:
- DockHostModel.Floating is populated by the host renderer from a
  per-manager floating-window tracker; doc comment makes the
  initial-bounds-only limitation explicit (review #12).
- UseDockPanePersisted uses a canonical persisted-key encoder
  (pane:<typeName>|<keyText>:<userKey> with %/colon/pipe escaping)
  so two panes whose Key.ToString() collide get independent slots
  (review #13).
- docking.dock detects ambiguous Key.ToString() matches and returns
  an explicit ambiguous-pane error (review #18).

Test isolation:
- New DockingGlobalsCollection ([Collection("DockingGlobals")] +
  DisableParallelization=true) covers DockingStringsTests,
  DockA11yTests, and DevtoolsDockingToolsTests — three classes that
  mutate process-global state (review #14). DockA11yTests now
  restores DockingStrings.Resolver in Dispose.
- The known-failing UseEffect cleanup assertion is emitted as TAP
  "# SKIP" via a new Harness.Skip helper, with a back-flip to a real
  Check the moment the §2.25 product gap closes (review #15).
- EffectCounterComponent moved off static counters; the fixture owns
  per-run counters and passes mount/cleanup callbacks via props
  (review #16).
- EventListener category assertions in LayoutSerializerTests use a
  bounded retry helper to tolerate occasional async dispatch
  (review #17).

Documentation:
- docs/_pipeline/apps/docking/{api,overview}.md updated for the P2
  reality (core Microsoft.UI.Reactor ship vehicle,
  DockingNativeInterop.Register, deleted vendored WinUI.Dock link)
  (reviews #19, #22).
- DockingStrings.cs + dock-showcase sample comments updated to
  reflect that no .resw resource ships today; DefaultEnglish + the
  resolver are the localization surface (review #20).
- Reactor.csproj stale "stays on disk for reference" comment about
  src/Reactor.Docking.Xaml/ replaced with current state (review #21).

Tests / fluents:
- Added 22 fluent extensions in ElementExtensions.Events.cs for
  DockManager event callbacks + TabViewElement.OnTabDragStarting /
  OnTabDragCompleted so PublicApiSurfaceGuardTests passes; the
  guard test itself is now scoped to public element records only
  (internal overlay/splitter elements aren't part of the public
  surface contract).
- Two stale Phase-1-wrapper fixture names removed from
  SelfTestFixtureRegistry.AllFixtures (they had no factory case and
  surfaced as MSTest "fixture not found" failures).
- NativeDocking_PerGroupDropTargetVisualDemo: observer-pause delays
  cut from 500ms/step to 50ms/step so the 20-step walk stays well
  inside the 15s fixture timeout under CI load; eliminates the
  cascading NRE in DragSessionConfirmMutatesLayout that was caused
  by the timed-out fixture leaving stale host state.
- Mutations_OffOwnerThread_Throw uses an explicit new Thread()
  instead of Task.Run, so the assert can never observe a thread-id
  match by chance.
- Load_MissingSchemaField_FallsBack renamed to
  Load_MissingSchemaField_TreatedAsV1AndMigrated and rewritten —
  empty {} now migrates as v1 (matches the integrated registry).

Validation:
- dotnet test tests/Reactor.Tests -p:Platform=x64
    → 8720 passed, 46 skipped, 0 failed
- dotnet test tests/Reactor.SelfTests -p:Platform=x64
    → 813 passed, 0 failed

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Chris Anderson (codemonkeychris) added a commit that referenced this pull request May 23, 2026
Resolves the 22 findings from the docking feature-branch review +
two test failures that surfaced while running the full suite.

Behavior fixes (Native docking host):
- Tear-out / FloatOp: open the floating window BEFORE removing the
  pane from the docked tree. Layout mutation + OnContentFloated fire
  only when a real ReactorWindow was produced (review #1 — the
  previous broad catch around Open turned a failed transition into a
  success-shaped event).
- Drop-overlay global Esc handler now detaches on reconciler unmount
  in addition to WinUI Unloaded (review #2).
- Floating-window observer callbacks, BeforeInsertToolWindow strategy
  hook, drag-session SessionChanged broadcast, navigator commit
  callback, and theme/resource lookup catches all surface failures via
  Debug.WriteLine or narrow to the expected exception type instead of
  swallowing everything (reviews #3, #4, #5, #7, #8).
- Splitter OnPointerCaptureLost now calls RestorePairToGrow() before
  the final ResizeDelta to converge with the normal release path
  (review #6).

Persistence:
- DockLayoutSerializer.Load now routes pre-current-schema documents
  through DockLayoutMigrationRegistry: parse to JsonNode, detect
  schema (absent $schema = v1 per §5.4.4), TryUpgrade, then
  deserialize. Adds a Load(json, registry) overload and emits a
  PII-safe schema-newer ETW category for forward-tolerant inputs
  (reviews #9 + #10).
- PreviousContainerTracker.ClearAll now actually clears by swapping
  in a fresh ConditionalWeakTable under a lock (review #11).

Surface honesty:
- DockHostModel.Floating is populated by the host renderer from a
  per-manager floating-window tracker; doc comment makes the
  initial-bounds-only limitation explicit (review #12).
- UseDockPanePersisted uses a canonical persisted-key encoder
  (pane:<typeName>|<keyText>:<userKey> with %/colon/pipe escaping)
  so two panes whose Key.ToString() collide get independent slots
  (review #13).
- docking.dock detects ambiguous Key.ToString() matches and returns
  an explicit ambiguous-pane error (review #18).

Test isolation:
- New DockingGlobalsCollection ([Collection("DockingGlobals")] +
  DisableParallelization=true) covers DockingStringsTests,
  DockA11yTests, and DevtoolsDockingToolsTests — three classes that
  mutate process-global state (review #14). DockA11yTests now
  restores DockingStrings.Resolver in Dispose.
- The known-failing UseEffect cleanup assertion is emitted as TAP
  "# SKIP" via a new Harness.Skip helper, with a back-flip to a real
  Check the moment the §2.25 product gap closes (review #15).
- EffectCounterComponent moved off static counters; the fixture owns
  per-run counters and passes mount/cleanup callbacks via props
  (review #16).
- EventListener category assertions in LayoutSerializerTests use a
  bounded retry helper to tolerate occasional async dispatch
  (review #17).

Documentation:
- docs/_pipeline/apps/docking/{api,overview}.md updated for the P2
  reality (core Microsoft.UI.Reactor ship vehicle,
  DockingNativeInterop.Register, deleted vendored WinUI.Dock link)
  (reviews #19, #22).
- DockingStrings.cs + dock-showcase sample comments updated to
  reflect that no .resw resource ships today; DefaultEnglish + the
  resolver are the localization surface (review #20).
- Reactor.csproj stale "stays on disk for reference" comment about
  src/Reactor.Docking.Xaml/ replaced with current state (review #21).

Tests / fluents:
- Added 22 fluent extensions in ElementExtensions.Events.cs for
  DockManager event callbacks + TabViewElement.OnTabDragStarting /
  OnTabDragCompleted so PublicApiSurfaceGuardTests passes; the
  guard test itself is now scoped to public element records only
  (internal overlay/splitter elements aren't part of the public
  surface contract).
- Two stale Phase-1-wrapper fixture names removed from
  SelfTestFixtureRegistry.AllFixtures (they had no factory case and
  surfaced as MSTest "fixture not found" failures).
- NativeDocking_PerGroupDropTargetVisualDemo: observer-pause delays
  cut from 500ms/step to 50ms/step so the 20-step walk stays well
  inside the 15s fixture timeout under CI load; eliminates the
  cascading NRE in DragSessionConfirmMutatesLayout that was caused
  by the timed-out fixture leaving stale host state.
- Mutations_OffOwnerThread_Throw uses an explicit new Thread()
  instead of Task.Run, so the assert can never observe a thread-id
  match by chance.
- Load_MissingSchemaField_FallsBack renamed to
  Load_MissingSchemaField_TreatedAsV1AndMigrated and rewritten —
  empty {} now migrates as v1 (matches the integrated registry).

Validation:
- dotnet test tests/Reactor.Tests -p:Platform=x64
    → 8720 passed, 46 skipped, 0 failed
- dotnet test tests/Reactor.SelfTests -p:Platform=x64
    → 813 passed, 0 failed

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@codemonkeychris
Chris Anderson (codemonkeychris) deleted the ci/add-unit-test-workflow branch May 28, 2026 19:11
Chris Anderson (codemonkeychris) added a commit that referenced this pull request Jun 2, 2026
Code-review findings (C:\temp\reactor-advanced-win2d-review.md):

  #1 HIGH — initially paused Win2DAnimatedCanvas can never resume
    Win2DAnimatedCanvasHandler.Mount wrote ctrl.Paused = el.IsPaused, but
    Update never writes Paused (intentional: Win2D-on-WinUI-3 game-thread
    park bug). An app mounted with isPaused:true could never unpause.
    Fixed: never touch ctrl.Paused at any stage; IsPaused gates the user's
    OnUpdate delegate via InvokeUpdate. New selftest fixture
    'Win2D_AnimatedCanvas_InitialPausedResumes' locks in the invariant.

  #2 HIGH — unsynchronized Ref<T> across UI/game threads
    Rewrote UseDrawState XML doc to be honest: Ref<T> is a plain
    auto-property, has no memory barriers, does not protect compound
    mutations. New doc lists per-shape synchronization options (volatile,
    Interlocked, lock, producer/consumer queue). Updated win2d-canvas.md.dt
    threading section to match.
    Fixed the actual race in ParticleStorm: Burst is now a
    ConcurrentQueue<(x,y,n)> producer; ParticleField.Step drains the queue
    on the game thread BEFORE iterating the particle array. No more torn
    Particle structs from UI-thread mutation racing the game-thread loop.

  #3 MED — RedrawKey uses reference equality
    Win2DCanvasHandler diff was !ReferenceEquals; boxed ints differ across
    renders, so every parent re-render triggered a redundant Invalidate.
    Switched to !Equals. New selftest fixture
    'Win2D_Canvas_SameRedrawKeyNoExtraDraws' verifies the no-op behavior.

  #4 MED — docs/sample reference nonexistent '.Of(...)' API
    Updated win2d-canvas.md.dt (4 occurrences), cheat-sheet.md.dt (1),
    samples/apps/particle-storm/README.md (1) to match the actual factory
    shape: Win2DCanvas(...) / Win2DAnimatedCanvas(...) / Win2DVirtualCanvas(...)
    via 'using static Microsoft.UI.Reactor.Advanced.Factories;'.
    Recompiled docs/guide/win2d-canvas.md and docs/guide/cheat-sheet.md.

  #5 MED — missing screenshot + placeholder perf
    Removed broken ../../samples/apps/particle-storm/screenshot.png
    reference from the Win2D guide template (this was the mkdocs --strict
    failure on the CI Docs build job). Toned down the 'canonical
    performance proof' claim — Particle Storm is now described as the
    'canonical worked example' and the guide tells readers to capture
    their own FPS numbers on their own hardware.

  #6 MED — skipped placeholder tests
    Selftest coverage gap acknowledged. Added two new fixtures (above) to
    cover the two scenarios most affected by review bugs (#1 and #3).
    The headless xUnit placeholders for handler updates and device-loss
    remain skipped — those genuinely need live WinUI activation, which
    the AppTests.Host selftest tier provides.

  #7 LOW — silent catches in PackLocalCommand
    Replaced catch { /* best effort */ } with explicit Console.Error
    warnings (stale-package cleanup + HTTP-cache-clear paths). Pack-local
    still succeeds when cleanup fails, but the user sees why.

CodeQL inline findings:

  - Win2DCanvasFixtures.WaitForCollectedOrDetached: removed GC.Collect()
    calls. Visual-tree detach check is the observable invariant; weak-ref
    is a secondary signal under normal GC, not a forced collection probe.
  - Win2DVirtualCanvasHandler.Update: replaced double != check with a
    SizesEqual helper using a 0.5 DIP epsilon (below display rounding,
    above float-precision noise from layout/devicescale math).
  - PackLocalCommand / TrimAssertions / threading test Path.Combine
    warnings: not addressed (low priority, all in test/CLI code; intent
    is clear and operands are repo-internal).

CI failures (https://github.com/microsoft/microsoft-ui-reactor/actions/runs/26819092595,
                https://github.com/microsoft/microsoft-ui-reactor/actions/runs/26819092535):

  - Pack (x64 + arm64) — NU5026 'Reactor.Advanced.dll not found': the
    release workflow's 'dotnet build/pack' runs without -p:Platform, so
    MSBuild defaults to AnyCPU. Reactor.Advanced.csproj had
    Platforms='x64;ARM64' only (no AnyCPU). Added AnyCPU to match
    Reactor.csproj. Both Pack steps now resolve.
  - Docs build — mkdocs --strict failed on the broken screenshot link
    (review finding #5 above); removing the reference fixes it.

Verification:

  - dotnet build Reactor.slnx -p:Platform=x64: clean (0/0).
  - dotnet test tests/Reactor.Advanced.Tests -p:Platform=x64: 27 passed.
  - Win2D selftests (JIT): 5 fixtures, 11/11 assertions green
    (added InitialPausedResumes + SameRedrawKeyNoExtraDraws).
  - mur docs compile --topic win2d-canvas/cheat-sheet: clean.

Co-authored-by: Copilot <[email protected]>
Chris Anderson (codemonkeychris) added a commit that referenced this pull request Jun 2, 2026
* spec 053: Reactor.Advanced + Win2D canvas integration

Implements docs/specs/053-reactor-advanced-and-win2d-canvas.md across all
four phases (per the implementation tracker):

Phase 1 — Library + L0/L1
- src/Reactor.Advanced/: new sibling library, ProjectReference-only consumer
  of Reactor core (no InternalsVisibleTo). Three element/handler triples
  (Win2DCanvas / Win2DAnimatedCanvas / Win2DVirtualCanvas) plus modifiers
  (ClearColor, Paused, TargetFps, Set) and three hooks (UseDrawState,
  UseCanvasResources, UseDrawCommand).
- Per-library trim unit: Factories class with single static cctor registers
  all three handlers. Authors consume via 'using static Microsoft.UI.Reactor
  .Advanced.Factories;' alongside the core factories, calling factories by
  their natural name (Win2DCanvas(...) etc.) — matching the in-tree DSL
  pattern. Touching any factory roots all three; touching none strips all
  three (verified by AOT trim probes).
- tests/Reactor.Advanced.Tests/: 27 passing, 4 skipped-covered-by-selftests.
- tests/aot_trim_proof/Reactor.AotHelloWorld.Advanced{,.Positive}{,.TrimAssertions}/:
  negative (zero handlers when no canvas factory called) + positive
  (handlers present when Win2DCanvas(...) is called) trim probes.
- mur pack-local now emits Microsoft.UI.Reactor.Advanced.{version}.nupkg
  alongside the core package.

Phase 1 game-thread isolation fix
- Win2DAnimatedCanvas Update/Draw fire on Win2D's game thread, not the
  WinUI dispatcher. Original Reactor binding path called DependencyProperty
  APIs from the trampoline, producing RPC_E_WRONG_THREAD (0xC000027B with
  WER P7=8001010e) at AOT-published startup. Fixed by subscribing Update/
  Draw directly with a volatile per-control element holder and tracking
  unsubscribe delegates for clean Unmount.

Phase 1 IsPaused workaround
- Writing CanvasAnimatedControl.Paused causes a known Win2D-on-WinUI-3 bug:
  the game thread wakes for exactly one tick after Paused=false and then
  parks permanently. Handler now never writes ctrl.Paused — IsPaused
  instead gates the user's OnUpdate callback (simulation stops) while
  leaving OnDraw active (last frame stays visible). Authors who want true
  game-thread suspension can opt in via Setters.

Phase 2 — Particle Storm sample
- samples/apps/particle-storm/: ~50k-particle Win2D animated canvas demo
  with chase/idle physics modes, cursor-driven gravity, periodic auto-
  burst, speed-modulated palette, real wall-clock fps meter, AOT publish
  gate. Sidebar is a Component<SidebarProps> per Reactor convention.

Phase 3 — Docs + selftests + skill
- docs/_pipeline/apps/win2d-canvas/ + templates/win2d-canvas.md.dt:
  doc-app with 4 snippets + manifest, comprehensive-tier guide page.
- tests/Reactor.AppTests.Host/SelfTest/Fixtures/Win2DCanvasFixtures.cs:
  three fixtures (manual/animated/virtual canvas mount), two-place
  registration in SelfTestFixtureRegistry, all 7 assertions green under
  both JIT and AOT.
- skills/advanced.md + plugins/reactor/skills/reactor-advanced/SKILL.md:
  two-place agent skill install; bundled into the Advanced nupkg under
  agentkit/skills/reactor-advanced.md.

Supporting changes outside spec-053 scope (justified):
- src/Reactor.Analyzers{,.Internal}/, Reactor.Localization.Generator/:
  added TreatAsLocalProperty='PublishTrimmed' + PublishTrimmed=false so
  Roslyn analyzer ProjectReferences don't inherit Reactor.Advanced's
  PublishTrimmed=true (NETSDK1207 isolation).
- src/Reactor.Cli/Pack/PackLocalCommand.cs: added Advanced as a third
  pack target.

Verification gates green:
- dotnet build Reactor.slnx -p:Platform=x64 — 0/0
- dotnet test tests/Reactor.Advanced.Tests -p:Platform=x64 — 27 passed
- Win2D selftests under JIT and AOT — 7/7 assertions each
- mur pack-local — produces 3 nupkgs side-by-side
- AOT trim probes — negative shows handlers stripped; positive shows present
- src/Reactor/ unchanged (per spec section 2 Goal 5)

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

* docs: recompile cheat-sheet, advanced, architecture-overview after spec-053 template edits

Phase 3's full mur docs compile run hung partway, so only docs/guide/win2d-canvas.md was
regenerated in the initial PR commit. The cheat-sheet / advanced / architecture-overview
templates had spec-053 cross-link edits that hadn't been compiled through. Running each
topic individually completed cleanly.

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

* spec 053: address review feedback + fix CI failures

Code-review findings (C:\temp\reactor-advanced-win2d-review.md):

  #1 HIGH — initially paused Win2DAnimatedCanvas can never resume
    Win2DAnimatedCanvasHandler.Mount wrote ctrl.Paused = el.IsPaused, but
    Update never writes Paused (intentional: Win2D-on-WinUI-3 game-thread
    park bug). An app mounted with isPaused:true could never unpause.
    Fixed: never touch ctrl.Paused at any stage; IsPaused gates the user's
    OnUpdate delegate via InvokeUpdate. New selftest fixture
    'Win2D_AnimatedCanvas_InitialPausedResumes' locks in the invariant.

  #2 HIGH — unsynchronized Ref<T> across UI/game threads
    Rewrote UseDrawState XML doc to be honest: Ref<T> is a plain
    auto-property, has no memory barriers, does not protect compound
    mutations. New doc lists per-shape synchronization options (volatile,
    Interlocked, lock, producer/consumer queue). Updated win2d-canvas.md.dt
    threading section to match.
    Fixed the actual race in ParticleStorm: Burst is now a
    ConcurrentQueue<(x,y,n)> producer; ParticleField.Step drains the queue
    on the game thread BEFORE iterating the particle array. No more torn
    Particle structs from UI-thread mutation racing the game-thread loop.

  #3 MED — RedrawKey uses reference equality
    Win2DCanvasHandler diff was !ReferenceEquals; boxed ints differ across
    renders, so every parent re-render triggered a redundant Invalidate.
    Switched to !Equals. New selftest fixture
    'Win2D_Canvas_SameRedrawKeyNoExtraDraws' verifies the no-op behavior.

  #4 MED — docs/sample reference nonexistent '.Of(...)' API
    Updated win2d-canvas.md.dt (4 occurrences), cheat-sheet.md.dt (1),
    samples/apps/particle-storm/README.md (1) to match the actual factory
    shape: Win2DCanvas(...) / Win2DAnimatedCanvas(...) / Win2DVirtualCanvas(...)
    via 'using static Microsoft.UI.Reactor.Advanced.Factories;'.
    Recompiled docs/guide/win2d-canvas.md and docs/guide/cheat-sheet.md.

  #5 MED — missing screenshot + placeholder perf
    Removed broken ../../samples/apps/particle-storm/screenshot.png
    reference from the Win2D guide template (this was the mkdocs --strict
    failure on the CI Docs build job). Toned down the 'canonical
    performance proof' claim — Particle Storm is now described as the
    'canonical worked example' and the guide tells readers to capture
    their own FPS numbers on their own hardware.

  #6 MED — skipped placeholder tests
    Selftest coverage gap acknowledged. Added two new fixtures (above) to
    cover the two scenarios most affected by review bugs (#1 and #3).
    The headless xUnit placeholders for handler updates and device-loss
    remain skipped — those genuinely need live WinUI activation, which
    the AppTests.Host selftest tier provides.

  #7 LOW — silent catches in PackLocalCommand
    Replaced catch { /* best effort */ } with explicit Console.Error
    warnings (stale-package cleanup + HTTP-cache-clear paths). Pack-local
    still succeeds when cleanup fails, but the user sees why.

CodeQL inline findings:

  - Win2DCanvasFixtures.WaitForCollectedOrDetached: removed GC.Collect()
    calls. Visual-tree detach check is the observable invariant; weak-ref
    is a secondary signal under normal GC, not a forced collection probe.
  - Win2DVirtualCanvasHandler.Update: replaced double != check with a
    SizesEqual helper using a 0.5 DIP epsilon (below display rounding,
    above float-precision noise from layout/devicescale math).
  - PackLocalCommand / TrimAssertions / threading test Path.Combine
    warnings: not addressed (low priority, all in test/CLI code; intent
    is clear and operands are repo-internal).

CI failures (https://github.com/microsoft/microsoft-ui-reactor/actions/runs/26819092595,
                https://github.com/microsoft/microsoft-ui-reactor/actions/runs/26819092535):

  - Pack (x64 + arm64) — NU5026 'Reactor.Advanced.dll not found': the
    release workflow's 'dotnet build/pack' runs without -p:Platform, so
    MSBuild defaults to AnyCPU. Reactor.Advanced.csproj had
    Platforms='x64;ARM64' only (no AnyCPU). Added AnyCPU to match
    Reactor.csproj. Both Pack steps now resolve.
  - Docs build — mkdocs --strict failed on the broken screenshot link
    (review finding #5 above); removing the reference fixes it.

Verification:

  - dotnet build Reactor.slnx -p:Platform=x64: clean (0/0).
  - dotnet test tests/Reactor.Advanced.Tests -p:Platform=x64: 27 passed.
  - Win2D selftests (JIT): 5 fixtures, 11/11 assertions green
    (added InitialPausedResumes + SameRedrawKeyNoExtraDraws).
  - mur docs compile --topic win2d-canvas/cheat-sheet: clean.

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

* spec 053: fix release Pack CI + address new CR feedback (round 2)

CI fix — Pack (x64 + arm64) job:

  Local repro on Reactor.slnx Release build:
    src/Reactor/bin/Release/.../Reactor.dll               present (AnyCPU)
    src/Reactor/bin/ARM64/Release/.../Reactor.dll         present (ARM64)
    src/Reactor.Advanced/bin/ARM64/Release/.../*.dll      present (ARM64)
    src/Reactor.Advanced/bin/Release/.../*.dll            MISSING

  Reactor.csproj happens to land at bin/Release/ (AnyCPU) because its
  analyzer ProjectReferences (netstandard2.0 AnyCPU) force an AnyCPU
  sub-build. Reactor.Advanced has no AnyCPU-forcing consumer in the
  slnx, so the no-Platform 'dotnet build Reactor.slnx --configuration
  Release' only builds it for ARM64. The 'dotnet pack --no-build'
  Advanced step then looks at bin/Release/ and fails with NU5026.

  Added explicit 'Build Advanced (AnyCPU)' step before 'Pack Advanced
  NuGet' in .github/workflows/release.yml, mirroring the Templates
  pattern (which also passes -p:Platform=AnyCPU). The Pack step now
  uses -p:Platform=AnyCPU for symmetry.

  Verified locally that the produced nupkg contains
  lib/net10.0-windows10.0.22621/Reactor.Advanced.dll plus .pri, .xml,
  and the bundled agentkit/skills/reactor-advanced.md.

CR feedback (round 2, github-code-quality bot):

  - src/Reactor.Cli/Pack/PackLocalCommand.cs:68 — Path.Combine
    flagged. Switched to Path.Join (preserves segments even if a
    later segment is rooted; relevant defense-in-depth here).
  - src/Reactor.Cli/Pack/PackLocalCommand.cs:159 — generic catch in
    DeleteStaleNupkg. Replaced with specific catches for IOException,
    UnauthorizedAccessException, and System.Security.SecurityException
    (the three real failure modes for File.Delete).
  - src/Reactor.Advanced/Win2D/Hooks/UseCanvasResources.cs:69 —
    generic 'catch when (disposed)' on the create() failure path.
    Replaced with typed catches for OperationCanceledException and
    ObjectDisposedException (the cancellation/teardown races that
    actually happen here); other failures still propagate so real
    create() bugs aren't masked.
  - tests/aot_trim_proof/.../TrimAssertionTests.cs:56 — Path.Combine
    on appDirectoryName. Added an IsPathRooted guard (returns
    string.Empty on invalid input, matching the existing failure
    behavior) and switched to Path.Join for the combine.

Verification:

  - dotnet build Reactor.slnx -p:Platform=x64: clean (0/0).
  - dotnet test tests/Reactor.Advanced.Tests -p:Platform=x64: 27 passed.
  - Standalone pack verified: nupkg contains Reactor.Advanced.dll.

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.

2 participants