Repository navigation
fix(hr): align workspace analyzer flavors and Roslyn with the SDK compiler (spec 053) - #23863
Conversation
|
Claude finished @dr1rrb's task in 3m 26s —— View job Review: spec 053 — Hot-Reload Workspace Analyzer Flavor SkewVerdict: fix-first — 5 findings (0 blocking, 2 medium, 3 low). The spec is well-reasoned and the root-cause diagnosis is solid; the issues are in implementation guidance that, if followed verbatim, would produce subtle bugs.
SummaryThe technical approach is sound: R1 (pin Cross-cutting concerns not mapped to a specific line:
Overall: the spec is implementation-ready after addressing the inline findings. The deduplication gap (line 144) and the optional regression test (line 174) are the most important to resolve before implementation begins. |
There was a problem hiding this comment.
Pull request overview
Adds a new specification (spec 053) describing how to fix Hot Reload workspace analyzer flavor skew by pinning CompilerApiVersion to the embedded Roslyn version, aligning embedded Roslyn versions per host flavor, and logging per-project analyzer load failures.
Changes:
- Introduces spec 053 outlining the root cause, requirements (R1–R3), and a proposed test plan for the Hot Reload workspace analyzer-loading issue.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…with the SDK compiler The dev-server workspace embeds Microsoft.CodeAnalysis 4.13/4.14 while the .NET 10 SDK's csc is Roslyn 5.x: the standard analyzer multi-targeting selects analyzers/dotnet/roslyn5.0 flavors (e.g. CommunityToolkit.Mvvm 8.4.2) that fail to type-load in the workspace, and AnalyzerFileReference.GetGenerators() silently returns zero generators - every compile of the affected projects is missing their generated members (verified: 229 phantom errors on one library, 0 after the fix). Spec covers: CompilerApiVersion pinned to the embedded Roslyn (computed at runtime), per-host-flavor bumps (net9 latest 4.x, net10 latest 5.x), and per-project analyzer load-failure logging.
…piler
The hot-reload workspace compiles with the dev-server's embedded
Microsoft.CodeAnalysis, but analyzer flavor selection
(analyzers/dotnet/roslyn{X.Y}) follows the SDK's csc: an SDK newer than the
embedded Roslyn (SDK 10 = roslyn5.6) selects flavors that fail to type-load,
and AnalyzerFileReference.GetGenerators() silently returns zero generators -
every compile of the affected projects then misses its generated code
(observed with CommunityToolkit.Mvvm 8.4.2: roslyn5.0 flavor selected, 229
phantom errors on a single library).
- Pin the CompilerApiVersion global property to the embedded Roslyn, computed
at runtime (EmbeddedRoslyn.CompilerApiVersion): a global property is
immutable for the evaluation, so the SDK's unconditional assignment is
ignored and the selected flavors are loadable.
- Bump the embedded Roslyn per host flavor: net9 4.13.0 -> 4.14.0 (latest
4.x, SDK 9 compiler line), net10 4.14.0 -> 5.6.0 (latest 5.x, SDK 10 line;
brings C# 14 parsing and native roslyn5.x flavor loading). Companion
compile-time pins in the net10 groups: Microsoft.Build* 18.0.2,
Microsoft.Extensions.Logging* 10.0.1.
- Retarget the WatchHotReloadService reflection shim to
ExternalAccess.UnitTesting.Api.UnitTestingHotReloadService: Roslyn removed
ExternalAccess.Watch from Microsoft.CodeAnalysis.Features between 5.0 and
5.3; the UnitTesting twin is shape-identical from 4.14 to 5.6 (capabilities
at StartSessionAsync, commitUpdates: true == Watch's commit-on-ready).
Validated by emitting a real EnC delta against both 4.14.0 and 5.6.0. The
obsoleted Workspace.WorkspaceFailed event is replaced by
RegisterWorkspaceFailedHandler on the net10 flavor.
- Warn once per (project, unloadable analyzer) at workspace initialization,
naming the impacted project and stating hot reload will NOT work for it:
the load failure is otherwise completely silent and only surfaces as a
missing-generated-code error wall long after startup.
- EmbeddedRoslyn.Version: read the assembly identity once and replace the null-forgiving operator with an explicit, diagnosable throw. - Spec updated to describe the implementation as landed (R1/R3 actual code and algorithm, robust sweep command, PR links for the related specs, test plan status incl. the red/green evidence for the pin).
c7a1e27 to
2bdabab
Compare
|
Claude finished @dr1rrb's task in 5m 49s —— View job Review: spec 053 — Hot-Reload Workspace Analyzer Flavor Skew (Implementation)Verdict: ship — 0 findings. The implementation is correct, well-tested, and addresses every line of the spec. All concerns raised by the previous spec review have been resolved.
SummaryR1 — R2 — Roslyn bumps: net9 → 4.14.0, net10 → 5.6.0 across both csproj files. R3 — Load-failure logging: Tests: Cross-cutting checks (clean):
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23863/wasm-skia-net9/index.html |
|
|
autocarl
left a comment
There was a problem hiding this comment.
Static review plus hosted-check inspection. The implementation itself looks coherent, but the PR currently breaks the repository's unit-test restore through a Roslyn package conflict, so I cannot approve this head.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
src/Uno.HotReload/Utils/RoslynExtensions.AnalyzerReferences.cs:39
- WithCollectibleAnalyzerReferences() creates a new AnalyzerFileReference per project even when multiple projects reference the same analyzer path. This contradicts the method comment about sharing/caching, and can cause redundant generator materialization (and redundant shadow-copy loads) for shared analyzers. Cache AnalyzerFileReference instances by FullPath within the snapshot transform so projects that reference the same analyzer reuse the same AnalyzerFileReference instance.
internal static Solution WithCollectibleAnalyzerReferences(this Solution solution)
{
// One loader (and one set of per-directory contexts) per solution snapshot lineage: every
// project sharing an analyzer path shares its loaded assembly, mirroring Roslyn's caching.
var loader = new CollectibleAnalyzerAssemblyLoader();
foreach (var projectId in solution.ProjectIds)
{
var references = solution.GetProject(projectId)!.AnalyzerReferences;
if (references.OfType<AnalyzerFileReference>().Any())
{
solution = solution.WithProjectAnalyzerReferences(
projectId,
references.Select(r => r is AnalyzerFileReference file ? new AnalyzerFileReference(file.FullPath, loader) : r));
}
src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj:39
- This change disables the MetadataUpdate hot-reload tests (Compile Remove + commented-out Uno.HotReload ProjectReference), which reduces CI coverage for a hot-reload-sensitive area. If the Roslyn 4.14 snapshot pin requires this temporarily, please gate the disabled suite behind an explicit condition (so it can still run on a Roslyn 5.x build configuration), or move these tests into a separate test project that can take the Roslyn 5.x dependency without snapshot drift.
<!-- Disabled until the net10 Roslyn 5.x migration (follow-up PR): these consume Uno.HotReload
(5.x), incompatible with the temporary 4.14.0 pin. -->
<Compile Remove="MetadataUpdateTests\Given_HotReloadService.cs" />
<Compile Remove="MetadataUpdates\HotReloadWorkspaceProvider.cs" />
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23863/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-23863/docs/index.html |
|
|
…elta-added FieldRVA rows (spec 053 R6) With R5 in place, hot reload still died after a handful of updates on the 5.x embed: MetadataUpdater.ApplyUpdate threw "The assembly update failed" on the 4th update of a session whatever was edited, and the poisoned session then failed every later update (the runtime-test CI job ground through per-scenario timeouts to its 60-minute kill). Root cause — a CoreCLR EnC metadata defect, diagnosed by replaying captured deltas standalone and tracing a Checked CoreCLR build (10.0.10), proven both ways: - CMiniMdRW::GenericFindWithHash (md/enc/metamodelrw.cpp) builds a lazy per-table lookup hash once a table exceeds INDEX_ROW_COUNT_THRESHOLD (25) rows and then searches ONLY the hash — no linear fallback — while the EnC delta-apply path (ApplyDelta/ApplyTableDelta) appends rows without maintaining or invalidating that hash. Any row a delta adds after the hash was built is invisible to lookups. - The lookup that dies is GetFieldRVA during EditAndContinueModule::ApplyEditAndContinue: Roslyn 5.x emits one FieldRVA row per generation for method bodies containing array initializers / u8 literals (a fresh <PrivateImplementationDetails> per generation) — a NEW emission enabled by the equally-new AddFieldRva capability. The test app baseline has 22 FieldRVA rows: generation 3 crosses the threshold and builds the hash, generation 4's row is appended invisible, GetFieldRVA returns CLDB_E_RECORD_NOTFOUND and the apply fails. "Dies at the 4th update" is threshold(25) - baseline(22) + 1. - Roslyn 4.x never emitted FieldRVA delta rows (the capability did not exist), which is why this years-old defect never fired before the 5.x embed. - Checked-build trace: FindFieldRVAHelper HASH tk=04000d84 -> rid=0 with 26 rows in the table; invalidating the lookup hash in ApplyTableDelta makes the identical four deltas apply 4/4 — that one-liner is the candidate fix attached to the dotnet/runtime escalation (standalone repro bundle: baseline + deltas + 30-line ApplyUpdate replay). The shim's capability adjustment now WITHDRAWS AddFieldRva alongside the R5 grant: without it, Roslyn falls back to the historical element-wise array-initializer EnC codegen — no FieldRVA rows in any delta, identical semantics (verified through 8+ generations in an emit+apply harness). To be reverted when the runtime fix ships. Also repairs Given_HotReloadResilience.When_HotReload_Succeeds_Then_ReloadCompleted_ReportsSuccess: it edited "Hello" and asserted a TextBlock "tb1" — neither ever existed in HR_Frame_Pages_Page1.xaml, so the server-side replace was a no-op and the assertion could never succeed (the test landed after the last fully-green master run). It now follows the established Frame + ValidateTextOnChildTextBlock pattern (a reloadable-type update replaces the page instance, so elements must be re-resolved from the live tree). Red/green (local Skia desktop runtime tests, full Given_HotReloadWorkspace class): red before — first ApplyUpdate rejection within seconds, 59+ cascade failures, no scenario family survives; green after — 0 rejections, 0 rude edits, 261 metadata updates applied end-to-end across every scenario family (pages, user controls, resource dictionaries, data templates, file add/remove), single remaining failure was the born-broken test above, repaired and re-validated. Uno.HotReload.Tests: 118/118 with the new grant+withdrawal capability tests.
|
Claude finished @dr1rrb's task in 5m 8s —— View job Review: spec 053 — Hot-Reload Workspace Analyzer Flavor Skew (R6 + round 4 sync)Verdict: ship — 2 low-severity findings, 0 blocking. R6 (
What R6 adds
Inline findings (2)
Cross-cutting (no inline)
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/Uno.HotReload/Roslyn/CollectibleAnalyzerAssemblyLoader.cs:150
- LoadUnmanagedDll currently only probes for a Windows-style "*.dll" native dependency (Path.Combine(_directory, unmanagedDllName + ".dll")). On non-Windows targets (Linux/macOS), native analyzer dependencies are typically ".so"/".dylib" or may already include an extension, so this loader will never resolve them.
protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
{
// Deliberate scope boundary: native DLLs are loaded from their original location, NOT
// shadow-copied (so a rebuild while loaded can fail to replace them on Windows).
// Native analyzer dependencies are rare and Roslyn's own loaders share the limitation.
var candidate = Path.Combine(_directory, unmanagedDllName + ".dll");
return File.Exists(candidate) ? LoadUnmanagedDllFromPath(candidate) : IntPtr.Zero;
src/SourceGenerators/Uno.UI.SourceGenerators.Tests/Uno.UI.SourceGenerators.Tests.csproj:39
- This change disables MetadataUpdate hot-reload tests (Compile Remove + commenting out the Uno.HotReload ProjectReference). That reduces CI coverage for the source-generator/metadata-update integration, and there is no in-repo tracking issue/link to ensure these tests get re-enabled promptly once the Roslyn 5.x migration and snapshot regen lands.
<!-- Disabled until the net10 Roslyn 5.x migration (follow-up PR): these consume Uno.HotReload
(5.x), incompatible with the temporary 4.14.0 pin. -->
<Compile Remove="MetadataUpdateTests\Given_HotReloadService.cs" />
<Compile Remove="MetadataUpdates\HotReloadWorkspaceProvider.cs" />
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23863/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-23863/docs/index.html |
autocarl
left a comment
There was a problem hiding this comment.
Follow-up panel review of the changes since the previously approved ea42f022c507a04f3ecaced236ba84617ce9cc38, frozen at afaeda0ce2422d3b14d3bdf511c140fc70def339.
The R5 capability restoration matches both the removed Roslyn Watch host and current dotnet-watch. The R6 AddFieldRva withdrawal is also well-founded: I followed the lookup through CoreCLR 10.0.10 and current runtime sources and confirmed the 25-row threshold, FindFieldRVAHelper -> GenericFindWithHash, and the lack of a linear fallback once the hash exists. The local Uno.HotReload.Tests suite passes 118/118 on the exact head.
The new R4 loader still diverges from Roslyn on two important loader contracts, however. Most importantly, compiler-context unification only considers assemblies already materialized in the host. I reproduced the resulting split identity with a standalone probe: a compiler-context dependency that was resolvable but not loaded was loaded privately into UnoHotReloadAnalyzers(...); the later host resolution produced a different assembly (host_loaded_before_request=False, same_instance=False, exit 42). That can make analyzer/host exchange types incompatible and recreates the silent generator-loss class this PR is intended to fix.
The shadow-copy race is independently actionable: Roslyn explicitly serializes concurrent callers on a per-path Task and makes losers await the winning copy. Here, existence means only that the destination has been created, not that the copy has completed.
Requesting changes for those correctness issues. The version-blind registered-dependency index is also called out inline because it can cross-contaminate multi-project solutions.
autocarl
left a comment
There was a problem hiding this comment.
Post-merge verification — exact merged head afaeda0c
This is a new review record published on 2026-08-03 after re-reading the final merged object and the three “Done” replies posted immediately before merge.
The PR merged at 15:19:06Z, but the merged head is still afaeda0ce2422d3b14d3bdf511c140fc70def339, created on July 31 and already covered by the prior review. No code commit follows that review. The claimed fixes are therefore not present in the merged source:
- compiler-context resolution still enumerates
_compilerContext.Assembliesinstead of invoking_compilerContext.LoadFromAssemblyName(assemblyName); - shadow copying still writes directly to the final DLL/PDB paths and treats
File.Existsas copy completion rather than publishing a completed staging file atomically; - registered dependencies still use
ConcurrentDictionary<string, string>plusTryAdd, so the first same-name candidate wins and later versions are discarded.
The 118/118 local suite result remains valid for the covered scenarios, but those tests do not exercise the three contracts above. The merged code therefore still contains the two high-severity loader correctness issues and the version-selection issue identified in the prior review.
Verdict: changes are still required in the merged code. Because the PR is already merged, this formal review is submitted as COMMENTED; the existing inline threads are refreshed separately with exact merged-line evidence.
…review-round4 fix(hr): harden the collectible analyzer loader (review follow-up of #23863)
GitHub Issue: closes #23860
PR Type:
🐞 Bugfix
What changed? 🚀
Implements
specs/053-hotreload-workspace-analyzer-flavor-skew/spec.md(carried by this PR):CompilerApiVersion=roslyn{X.Y}of its embedded Microsoft.CodeAnalysis as a global property (computed at runtime —EmbeddedRoslyn.CompilerApiVersion), so the standard analyzer multi-targeting (analyzers/dotnet/roslyn{X.Y}folders) selects flavors the workspace can actually load. Without it, an SDK newer than the embedded Roslyn (SDK 10 →roslyn5.6) selects flavors that fail to type-load andAnalyzerFileReference.GetGenerators()silently returns zero generators — every workspace compile of the affected projects then misses its generated code (measured: 229 phantom errors on a single CommunityToolkit.Mvvm 8.4.2 library, CS0759/CS0103/CS1061 walls).4.13.0→4.14.0(latest 4.x, SDK 9 compiler line), net10 flavor4.14.0→5.6.0(latest 5.x, SDK 10 line; brings C# 14 parsing and nativeroslyn5.xflavor loading). Companion compile-time pins in the net10 groups:Microsoft.Build*18.0.2 (ExcludeAssets="runtime"),Microsoft.Extensions.Logging*10.0.1.ExternalAccess.WatchfromMicrosoft.CodeAnalysis.Featuresbetween 5.0 and 5.3; the reflection shim now targets the shape-identicalExternalAccess.UnitTesting.Api.UnitTestingHotReloadService(identical from 4.14 to 5.6 — capabilities move toStartSessionAsync, andcommitUpdates: truereproduces Watch's implicit commit-on-ready, confirmed against the Roslyn sources). The obsoletedWorkspace.WorkspaceFailedevent is replaced byRegisterWorkspaceFailedHandleron the net10 flavor.Validation
Uno.HotReload.Tests: 103/103 pass on the net10/Roslyn 5.6 flavor — including 4 new tests (pin format + package-line guard; per-project load-failure warnings incl. shared-reference attribution; loadable-analyzer negative case).MSBuildWorkspacerepro of the original failure (SDK 10.0.302): with the pin and the 5.6.0 embed, the CommunityToolkit generators load and produce their documents, 0 errors / 0 CS8784-CS8785 on the previously-failing project graph (the same graph failed with ~2,400 phantom errors before).Uno.HotReload,Uno.UI.RemoteControl.Server.ProcessorsandUno.UI.RemoteControl.Hostbuild clean on both flavors.PR Checklist ✅
Screenshots Compare Test Runresults.