Skip to content

Switch to AnyCPU for libraries, migrate to slnx - #187

Merged
Chris Anderson (codemonkeychris) merged 6 commits into
microsoft:mainfrom
devkanro:feature/anycpu-185
May 8, 2026
Merged

Chris Anderson (codemonkeychris) merged 6 commits into
microsoft:mainfrom
devkanro:feature/anycpu-185

Conversation

@devkanro

@devkanro Kanro (devkanro) commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Switch to per-project platform declarations: library and WPF projects default to AnyCPU,
WinUI application projects explicitly declare x64;ARM64. Migrate from .sln to .slnx.
Remove shared Platform fallback logic from Directory.Build.props.

Linked issue

Fixes #185

Key changes

Build system

  • Directory.Build.props: Remove Platform fallback logic — only shared config (SDK version) remains
  • Library projects (Reactor, Reactor.Interop.WinForms, Chat.UI, Chat.Model, PerfBench.Shared, StressPerf.Shared, CmdPerf.Shared): no <Platforms> tag, MSBuild defaults to AnyCPU
  • WPF projects (StressPerf.Wpf, CmdPerf.Wpf): no <Platforms> tag — WPF has no native Windows App SDK dependency
  • SelfTests: set WindowsAppSDKSelfContained=false — pure MSTest runner, no WinUI dependency
  • App/test/sample projects: explicit <Platforms>x64;ARM64</Platforms> for WindowsAppSDKSelfContained native assets

Solution migration

  • Reactor.sln → Reactor.slnx: cleaner XML format, solution platforms reduced to x64 and ARM64
  • slnx platform mappings removed for AnyCPU-only projects

CI workflows

  • ci.yml: pass explicit -p:Platform=x64 for standalone project builds
  • coverage.yml: pass explicit -p:Platform=x64; replace hardcoded bin/x64 path with dynamic file lookup
  • release.yml: remove -p:Platform=x64 from solution build/pack (slnx provides it); keep --runtime for publish

Code fixes

  • Update FindHostExe() repo-root lookups in SelfTestBatch, TestSession, WinFormsTestSession, and CompileCommand to search for Reactor.slnx instead of Reactor.sln

Docs

  • Update AGENTS.md, CONTRIBUTING.md, README.md, SKILL.md, PR template, devtools skill

Design

Each project declares its own platform requirements — no shared magic:

Project type Platforms Why
Library (Reactor, Interop, shared libs) AnyCPU (default) IL is always architecture-neutral; no native assets
WPF (StressPerf.Wpf, CmdPerf.Wpf) AnyCPU (default) No Windows App SDK dependency
Analyzer/Generator (netstandard2.0) AnyCPU (inherent) netstandard2.0
SelfTests (MSTest runner) AnyCPU (default) Pure test runner, launches AppTests.Host as subprocess
WinUI App/Test/Sample x64;ARM64 WindowsAppSDKSelfContained needs concrete arch for native DLLs

Solution builds get Platform from the .slnx configuration. Standalone project builds
(e.g. dotnet test tests/Reactor.Tests) require explicit -p:Platform=x64.

Packaging verification

NuGet package — architecture-neutral, same structure as before:

Microsoft.UI.Reactor.nupkg
├── analyzers/dotnet/cs/
│   ├── Reactor.Analyzers.dll              (44.5KB)
│   └── Reactor.Localization.Generator.dll (16KB)
├── lib/net10.0-windows10.0.22621/
│   ├── Reactor.dll                        (2500KB, AnyCPU)
│   ├── Reactor.pri / Reactor.xml
│   └── Reactor/Hosting/ReactorApplication.xaml
└── LICENSE

CLI skill kit — RID-specific layout unchanged:

reactor-skill-kit-<version>.zip
└── reactor/
    ├── SKILL.md, skills/, install-skill-kit.ps1
    ├── bin/x64/    ← mur.exe (158.5KB) + 21 managed DLLs
    └── bin/arm64/  ← mur.exe (136.5KB) + 21 managed DLLs

Test plan

  • dotnet build Reactor.slnx — 0 errors
  • dotnet test tests/Reactor.Tests -p:Platform=x64 — 6819 passed, 46 skipped
  • dotnet test tests/Reactor.SelfTests -p:Platform=x64 — 670 passed
  • dotnet build Reactor.slnx -c Release — succeeds
  • dotnet pack src/Reactor/Reactor.csproj — correct nupkg structure
  • dotnet publish --runtime win-x64 / win-arm64 — both produce valid mur.exe
  • bin/x64/mur.exe mirror layout still works

Risk / breaking changes

  • Developers who used dotnet build/test <project> without -p:Platform for app projects will now need to either build via the solution or pass -p:Platform=x64 explicitly.
  • The .sln file is removed; VS / Rider users need to open Reactor.slnx instead.

Replace the Platform-based architecture selection (x64/ARM64) with
RuntimeIdentifier-based selection. All projects now default to AnyCPU;
the correct native Windows App SDK DLLs are resolved via RuntimeIdentifier
(win-x64/win-arm64) set automatically in Directory.Build.targets based on
machine architecture.

Changes:
- Directory.Build.props: Remove Platform override that forced AnyCPU to
  x64/ARM64
- Directory.Build.targets: Add RuntimeIdentifier default for Windows TFM
  projects (net8.0+) when Platform is AnyCPU
- All ~100 .csproj files: Remove <Platforms>x64;ARM64</Platforms>
- Reactor.Cli: Update MirrorBinForSelfhost to resolve arch from
  RuntimeIdentifier (keeps bin/x64 and bin/arm64 layout)
- Solution file: Update Any CPU/x86 project mappings to use Any CPU
  (instead of remapping to x64)
- release.yml: Remove -p:Platform=x64 from build/pack (keep --runtime
  for publish)
- coverage.yml: Replace hardcoded bin/x64 path with dynamic file lookup
- Update AGENTS.md, CONTRIBUTING.md, README.md, PR template, devtools
  skill doc

The release workflow still produces RID-specific CLI binaries (win-x64 +
win-arm64) for the skill kit. The NuGet package is now architecture-neutral.

Fixes #185

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Kanro (devkanro) and others added 2 commits May 7, 2026 14:30
Revise the AnyCPU approach based on feedback:

- Libraries (Reactor, Reactor.Interop.WinForms) explicitly set
  Platform=AnyCPU and Platforms=AnyCPU — they produce architecture-
  neutral IL.
- Application/test projects keep the existing x64/ARM64 platform
  selection via Directory.Build.props (defaults to machine arch).
- WindowsAppSDKSelfContained apps need a concrete architecture for
  native asset resolution; this is supplied by Platform (x64/ARM64).

Also migrates from Reactor.sln to Reactor.slnx:
- Cleaner XML format, no per-project platform mapping boilerplate
- Solution platforms reduced to x64 and ARM64 (removed Any CPU/x86)
- Library projects have no platform mappings (always AnyCPU)

Remove Directory.Build.targets RuntimeIdentifier logic — no longer
needed since apps use Platform directly for native assets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Each project declares its own platform requirements:

- Application/test/sample projects: <Platforms>x64;ARM64</Platforms>
  (need concrete arch for WindowsAppSDKSelfContained native assets)
- Library projects (Reactor, Reactor.Interop.WinForms): no Platforms
  (MSBuild defaults to AnyCPU; IL is always architecture-neutral)
- Analyzers/generators (netstandard2.0): inherently AnyCPU

Directory.Build.props no longer contains Platform fallback logic.
When building a single app project directly, pass -p:Platform=x64
(or ARM64). Solution builds get Platform from the .slnx config.

CI workflows now pass explicit -p:Platform=x64 for standalone
project builds.

Fix SelfTests: pure MSTest runner, no Windows App SDK dependency —
set WindowsAppSDKSelfContained=false and remove Platforms.

Fix .sln → .slnx migration: update FindHostExe() repo-root lookups
in SelfTestBatch, TestSession, WinFormsTestSession, and CompileCommand
to search for Reactor.slnx instead of Reactor.sln.

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

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="microsoft"

@devkanro Kanro (devkanro) changed the title Switch to AnyCPU platform with RuntimeIdentifier for native assets Switch to AnyCPU for libraries, migrate to slnx May 7, 2026
Kanro (devkanro) and others added 2 commits May 7, 2026 15:12
StressPerf.Wpf and CmdPerf.Wpf target net10.0-windows (no WinAppSDK),
so they don't need WindowsAppSDKSelfContained and can be AnyCPU.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PerfBench.Shared, StressPerf.Shared, StressPerf.Wpf, CmdPerf.Wpf,
Chat.UI, and Reactor.SelfTests no longer declare x64/ARM64 Platforms,
so their slnx entries must not map to those configurations.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please check the nuget packaging - i think i ended up with x64/arm64 branches in there for the deployment of mur.exe (CLI devtool)... just check that the package generated correctly. Morten Nielsen (@dotMorten) has been dogfooding the nuget package from the builds, so I don't want to break him.

@devkanro

Copy link
Copy Markdown
Contributor Author

Verified locally — packaging is unchanged.

NuGet package (framework):

Microsoft.UI.Reactor.nupkg
├── analyzers/dotnet/cs/
│   ├── Reactor.Analyzers.dll              (44.5KB)
│   └── Reactor.Localization.Generator.dll (16KB)
├── lib/net10.0-windows10.0.22621/
│   ├── Reactor.dll                        (2500KB, AnyCPU)
│   ├── Reactor.pri                        (1.6KB)
│   ├── Reactor.xml                        (924KB)
│   └── Reactor/Hosting/ReactorApplication.xaml
└── LICENSE

No x64/ARM64 branches — Reactor.dll is architecture-neutral (ProcessorArchitecture: None). Same structure as before this PR.

CLI skill kit (mur.exe): release.yml still publishes with --runtime win-x64 and --runtime win-arm64 separately. Both produce a valid mur.exe + all managed DLLs:

reactor-skill-kit-<version>.zip
└── reactor/
    ├── SKILL.md
    ├── skills/
    ├── install-skill-kit.ps1
    ├── bin/x64/          ← mur.exe (158.5KB, native apphost) + 21 DLLs
    └── bin/arm64/        ← mur.exe (136.5KB, native apphost) + 21 DLLs

mur.dll (196KB) and all other managed DLLs are identical between the two; only mur.exe (the native apphost) differs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@codemonkeychris
Chris Anderson (codemonkeychris) merged commit 1aa6e02 into microsoft:main May 8, 2026
6 checks passed
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 26, 2026
…Core; explicit using in RangeSourceStateTests

Copilot round-7 review (1211fb3):
- ReactorApp.cs (3478564671): OpenWindowCore created the ReactorWindow, then
  invoked configure?.Invoke(window.Host) OUTSIDE any cleanup scope — a throwing
  configure (or a throwing RegisterWindow) leaked the window (never disposed,
  never returned). The #187 trace-removal rewrite of this method surfaced it (the
  original logged + rethrew without disposing either). Wrap configure + register +
  mount in one try; on any failure dispose the window, and unregister only if
  RegisterWindow completed (the 'registered' flag) — mirrors the OpenTrayIcon
  cleanup pattern just below. Happy path and the existing mount-failure path are
  behaviorally unchanged; only the previously-leaking error paths now clean up.
- RangeSourceStateTests.cs: add an explicit using System.Collections.Generic;.
  Redundant under this project's ImplicitUsings=enable (csproj L8) — the file has
  compiled since it was added (commit a0b3392) and a forced non-incremental
  rebuild + full dotnet test are green — so this is explicit-import hygiene to
  settle a recurring reviewer flag, NOT a compile fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 30, 2026
…omics (#660)

Remove per-frame delegate/closure allocations and full-barrier atomics from the
render-loop hosts (ReactorHost + ReactorHostControl), which run at render/data-tick
frequency on the data-grid stress workload:

  #178 QueryCache.DispatcherPost: pass action.Invoke, drop the () => action() trampoline
  #179 cache _rerenderAction instead of () => RequestRender() every render
  #180 cache _renderLoopHandler (DispatcherQueueHandler) for TryEnqueue
  #181 cache _requestRenderAction (RequestRender method group) for BeginRender + Reconcile
  #182 HotReloadService.ConsumeUpdatePending: Volatile.Read fast-path, atomic only when pending
  #183 AnimationAmbient.HasAny sentinel gates the per-setState AsyncLocal walk
  #185 _lastRenderMs: Volatile.Write (single writer) instead of Interlocked.Exchange
  #186 report gate: integer ElapsedMilliseconds compare instead of Elapsed.TotalSeconds
  #187 remove unconditional [embed:trace] Console.Error writes at window open

Behavior preserved: identical render cadence, delegate semantics, and re-render
coalescing; HasAny is a one-way sentinel so any app that opens an Animations.Animate
transaction keeps the full AsyncLocal path. New AnimationAmbient.HasAny tests.

Deferred (flagged to coordinator): theme resolution cache (#85/#86) — #85's per-element
theme-name cache needs generation invalidation on localized RequestedTheme application
which lives in Reconciler.cs (sibling-owned), so it's a cross-boundary change; and theme
resolution can't be measured headlessly. #184 charting dirty-gate (chart-specific, secondary).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jun 30, 2026
…rame atomics, cache theme-brush resolution (#660) (#751)

* perf(render-loop): cache per-frame host delegates + drop per-frame atomics (#660)

Remove per-frame delegate/closure allocations and full-barrier atomics from the
render-loop hosts (ReactorHost + ReactorHostControl), which run at render/data-tick
frequency on the data-grid stress workload:

  #178 QueryCache.DispatcherPost: pass action.Invoke, drop the () => action() trampoline
  #179 cache _rerenderAction instead of () => RequestRender() every render
  #180 cache _renderLoopHandler (DispatcherQueueHandler) for TryEnqueue
  #181 cache _requestRenderAction (RequestRender method group) for BeginRender + Reconcile
  #182 HotReloadService.ConsumeUpdatePending: Volatile.Read fast-path, atomic only when pending
  #183 AnimationAmbient.HasAny sentinel gates the per-setState AsyncLocal walk
  #185 _lastRenderMs: Volatile.Write (single writer) instead of Interlocked.Exchange
  #186 report gate: integer ElapsedMilliseconds compare instead of Elapsed.TotalSeconds
  #187 remove unconditional [embed:trace] Console.Error writes at window open

Behavior preserved: identical render cadence, delegate semantics, and re-render
coalescing; HasAny is a one-way sentinel so any app that opens an Animations.Animate
transaction keeps the full AsyncLocal path. New AnimationAmbient.HasAny tests.

Deferred (flagged to coordinator): theme resolution cache (#85/#86) — #85's per-element
theme-name cache needs generation invalidation on localized RequestedTheme application
which lives in Reconciler.cs (sibling-owned), so it's a cross-boundary change; and theme
resolution can't be measured headlessly. #184 charting dirty-gate (chart-specific, secondary).

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

* perf(theme): cache (key,theme) -> Brush resolution, cleared on theme change (#660 #86)

ThemeRef.Resolve recursed Application.Resources.MergedDictionaries (XamlControlsResources
and its nested dictionaries) on every resolve — per cell x per color token x per render on
the data-grid workload. Cache the deterministic (resourceKey, themeName) -> Brush result in
a process-wide ConcurrentDictionary and clear it from the hosts' theme-change handlers
(ActualThemeChanged + UISettings.ColorValuesChanged). Transient-null Application.Resources
(early startup) is not cached, so no poisoned null entry. Cached value mirrors the uncached
return exactly (including null for unknown keys); ThemeDictionary brushes are shared
instances, so returning the cached reference is identical behavior.

Self-contained in Theme.cs (no BrushHelper/ThemeBinding/Reconciler coupling). The per-element
theme-NAME cache (#85) is intentionally NOT here — it needs a generation bump where a localized
RequestedTheme is applied (Reconciler.cs, sibling-owned), which is a cross-ownership change
flagged to the coordinator.

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

* fix(theme): complete #86 brush-cache invalidation per #751 review

Two correctness hardenings on the (key,theme)->Brush cache:

1. Wire ReactorHostControl to UISettings.ColorValuesChanged (high-contrast /
   accent / palette) -> InvalidateResolutionCache, mirroring ReactorHost. Before,
   the embedded host only invalidated on ActualThemeChanged (Light/Dark), so an
   app using ReactorHostControl without a ReactorApp would keep stale brushes on a
   same-theme accent/high-contrast change. Subscribe on theme-listener attach,
   unsubscribe in Dispose.

2. Cache ONLY successful (non-null) resolutions. A cached null for an unknown key
   would go stale if a ResourceDictionary defining that key is merged in after the
   first resolve (a dictionary add raises no theme-change event). Unknown keys are
   rare; re-walking them is the same cost as pre-cache and always correct.

Invalidation now covers: Light<->Dark (ActualThemeChanged, both hosts — AND the
cache key includes the theme name so a toggle auto-misses) + accent/palette/
high-contrast (ColorValuesChanged, both hosts). Existing theme selftests pass with
the cache active, incl. StructuralSkip_ThemeRangeParity
(ThemeRange_ForegroundReresolvedOnToggle: resolve brush -> toggle theme -> assert
re-resolved) and Issue522_CacheClear_StyleClearedDespiteCacheClear. Full headless
suite 9915/0; build 0/0.

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

* test(theme): regression coverage for #86 brush-cache invalidation (H1/H2)

Selftest fixtures pinning the two converged review findings (the code fixes
landed in 3fd38c4):

- Theme_BrushCacheNullMissNotCached (H2): resolve an unknown key → null (NOT
  cached) → merge a ResourceDictionary defining it → resolves to the brush. Guards
  against the cached-null poisoning a later-merged key (XamlIslandBootstrap /
  docking-embed late XamlControlsResources binding).
- Theme_BrushCacheInvalidationReResolves (H1 mechanism): resolve key→brushA
  (cached) → swap to brushB for the same (key,theme) → still brushA (stale) →
  ThemeRef.InvalidateResolutionCache() (what the hosts call on
  ColorValuesChanged/ActualThemeChanged) → re-resolves to brushB.

Both green. Validates the invalidation path the ReactorHostControl
ColorValuesChanged wiring (3fd38c4) depends on.

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

[Bug] Switch to AnyCPU if possible

2 participants