Skip to content

🦨 [HR] Workspace selects analyzer flavors for the SDK compiler, not its embedded Roslyn β€” generators silently missingΒ #23860

Closed

Description

@dr1rrb

Current behavior

The dev-server's hot-reload workspace loads projects with the machine's SDK but compiles
them with the NuGet-pinned Microsoft.CodeAnalysis embedded in the dev-server (4.13 on the
net9 host flavor, 4.14 on net10). Analyzer packages that multi-target Roslyn
(analyzers/dotnet/roslyn{X.Y}/…) get their flavor selected by the SDK compiler's
CompilerApiVersion (the .NET 10 SDK's csc is Roslyn 5.6) β€” not by the Roslyn that
actually runs the generators.

Concretely, with CommunityToolkit.Mvvm 8.4.2 on a .NET 10 SDK machine, the design-time
build selects analyzers/dotnet/roslyn5.0/cs/CommunityToolkit.Mvvm.SourceGenerators.dll,
which cannot type-load against CodeAnalysis 4.14 (ReflectionTypeLoadException, 48 loader
exceptions). AnalyzerFileReference.GetGenerators("C#") silently returns 0 generators
β€” no exception, no CS8784/CS8785 β€” so every workspace compile of a project using
[ObservableProperty]/[RelayCommand] is missing its generated members (measured: 229
phantom errors on a single library β€” orphaned CS0759 partial methods, CS0103/CS1061
on the generated properties). Any pipeline step that compiles such a project then fails a
hot reload that actually applied (see #23861).

Generators shipping only ≀ roslyn4.x flavors (Uno.UI.SourceGenerators, PolySharp,
Microsoft.Extensions.*) load fine, which makes the failure look package-specific and very
hard to diagnose β€” nothing is logged anywhere.

Expected behavior

  1. The workspace pins the analyzer flavor selection to its embedded Roslyn: pass
    CompilerApiVersion = roslyn{Major}.{Minor} (computed at runtime from
    typeof(Compilation).Assembly) as an MSBuild global property in
    CompilationWorkspaceProvider. Verified empirically: the selected flavor flips to
    roslyn4.12, 7 generators load, and the 229-error library compiles clean.
  2. The embedded Roslyn is bumped per host flavor to match the served SDK line: net9 β†’
    latest 4.x (4.14.0), net10 β†’ latest 5.x (5.6.0) β€” also brings C# 14 parsing for
    net10+ apps.
  3. When an analyzer still fails to load, the workspace logs one warning per (project,
    analyzer)
    stating which project is impacted and that hot reload will NOT work for
    it β€” instead of today's silence followed by a multi-thousand-line error dump.

Environment

Dev-server host net10.0 flavor (SDK 10.0.x, csc Roslyn 5.6), Microsoft.CodeAnalysis
4.14 embedded, CommunityToolkit.Mvvm 8.4.2. Applies to any analyzer package shipping a
roslyn5.x flavor.

Activity

  1. changed the title [-][HR] Workspace selects analyzer flavors for the SDK compiler, not its embedded Roslyn β€” generators silently missing[/-] [+]🦨 [HR] Workspace selects analyzer flavors for the SDK compiler, not its embedded Roslyn β€” generators silently missing[/+] on Jul 31, 2026
  2. added theissue type on Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions