Skip to content

Razor C# features answer nothing when the project's SDK is newer than the sidecar's Roslyn #399

Open

Description

@MelbourneDeveloper

Problem

A Razor file's C# projection comes from the Razor source generator of the SDK that resolves for its project. With no global.json, that is the newest installed SDK. If that SDK's generator was built against a newer Roslyn than the one the sidecar bundles, Roslyn refuses to load it. The Razor file then gets no projection:

  • hover, definition, completion and diagnostics answer nothing inside its C#;
  • .cs files that use its generated components report CS0246.

The sidecar bundles Roslyn 5.6. SDK 10.0.303's Razor generator references Roslyn 5.5, and SDK 10.0.4xx's references a newer one.

How it showed up

CI runners carry SDK 10.0.401 alongside the repository's 10.0.303 pin. The Razor end-to-end suites (Rust and VS Code) copy their fixture to a temp folder that has no global.json. On both Linux and Windows, every hover in a Razor file was null and Program.cs reported CS0246 for the generated App component. Keeping the repository's pin in those copies (#398) makes the tests deterministic, but users with a newer SDK are still affected.

Expected

Razor C# features work whichever SDK the project resolves, or the server says why they cannot.

Options

  • Load the Razor generator from the copy the sidecar bundles, which matches its Roslyn, whatever SDK the project uses.
  • Resolve design-time builds to the SDK whose Roslyn the sidecar matched, when no global.json says otherwise.
  • At least log it and show a warning that names the SDK and Roslyn versions.

Refs #397

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions