Support C# language versions: parse C# 15 unions, and honour each project's LangVersion across a mixed-version solution
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- csharp, typescript
調査の方向性
Start with the C# spec and the project-loading path that reads MSBuild evaluation and creates Roslyn parse options; the issue does not name implementation files. Then trace how parse options flow into linked documents, target frameworks, Razor, file-based apps, and tree-sitter. Done means the specified mixed-version solution and language features pass against the latest published release, with tests covering each listed scenario.
索引モデルが issue の本文から書いたものです。
説明
Summary
SharpLsp has no concept of a C# language version. It parses every project with the compiler it ships (Roslyn Microsoft.CodeAnalysis.CSharp.Workspaces 5.9.0, plus tree-sitter-c-sharp 0.23 for the syntax tier), whatever the project targets. C# 15 union types therefore don't parse. A valid C# 15 file is covered in bogus errors:
public union ContentBody(Page, Resource, ResourceList, ResourcesForYou, Container);
CS0246 The type or namespace name 'union' could not be found [Ln 9, Col 8]
CS0501 '<invalid-global-code>.ContentBody(Page, Resource, …)' must declare a body because it is not marked abstract, extern, or partial
CS1001 Identifier expected (×5, one per case type)
CS0246 The type or namespace name 'ContentBody' could not be found [Ln 6, Col 65] ← every use of the union fails too
<invalid-global-code> shows the parser has no union declaration at all. The second union in the same file (Selector, line 30) fails the same way. The project builds with the SDK's own compiler; only SharpLsp reports these errors.
What C# says (official sources)
- C# 15 adds union types, declared with the
unionkeyword. Each listed case type is one possible value, and switches over a union are checked for exhaustiveness. Source: What's new in C# 15. The DevBlogs post says the model and syntax may still change: Explore union types in C# 15. - The language version comes from the target framework unless
<LangVersion>overrides it:- Each TFM maps to a default version (.NET 8 → C# 12, .NET 9 → C# 13, .NET 10 → C# 14, .NET 11 → C# 15).
- Using a version newer than the TFM's default is unsupported.
- Source: C# language versioning.
<LangVersion>values aredefault,latest,latestMajor,previewor an explicit number. Settingdefaultis not the same as leaving it out:defaultmeans the newest version the compiler supports, regardless of TFM. Sources: Compiler options – language (LangVersion), Configure the C# language version.
Required behaviour
- Support C# 15 unions. Ship a Roslyn whose parser and binder know C# 15, and a tree-sitter C# grammar that parses
uniondeclarations, so syntax features (outline, folding, selection, semantic tokens) work. Every semantic feature must work on unions: hover, go to definition, references, rename, completion, exhaustiveness diagnostics inswitch, and code fixes. - Honour each project's own language version. A project on an earlier version must get exactly what
dotnet buildgives it: no union parse, and the compiler's own "feature 'union types' is not available in C# 14. Please use language version 15.0 or greater" error (CS8652/CS9058 family), never a newer language silently.- Roslyn has one parser that is gated per compilation by
CSharpParseOptions.LanguageVersion. "The parser for that version" means the newest compiler running with each project'sLanguageVersion, taken from MSBuild evaluation (LangVersion, else the TFM default, sodefault,latest,previewand omission all resolve as the SDK resolves them). - Never fall back to
CSharpParseOptions.Defaultfor a project-owned document.
- Roslyn has one parser that is gated per compilation by
- Several projects with different versions in one solution:
- Each project, and each target framework of a multi-targeted project, keeps its own parse options.
- A file linked into two projects is checked under each project's version. Its diagnostics follow the active target framework ([NETFX-CONTEXT]).
- Cross-project features (references, rename, Fix All in solution) must not reparse one project's syntax under another's version.
- The syntax tier (tree-sitter) has no version gate. It must accept the newest syntax without false syntax errors in older projects; language-version errors come only from the compiler.
- SDK and compiler skew: when the loaded SDK's analyzers or source generators are built against a newer Roslyn than SharpLsp ships (CS9057), report it in plain words and keep the rest of the project working ([REFACTOR-NEVER-SILENT]).
- File-based apps (
dotnet run file.cs) use the same language versiondotnet build file.cswould ([SCRIPTING-FILEBASED-SPEC]).
Spec work
Add a [CSHARP-LANGVERSION] section to the C# spec covering resolution, per-project and per-TFM parse options, the compiler/SDK skew policy and the tree-sitter policy. Cross-reference it from [NETFX-CONTEXT] and the Razor spec, since Razor already carries the project's CSharpParseOptions.LanguageVersion. F# has the same concept (<LangVersion> for FCS); F# goes first per project rules, so open an F# sibling issue.
Tests (when fixing)
Use real projects in one solution:
- A:
net11.0(C# 15) with the union above, matched exhaustively in aswitch. - B:
net10.0(C# 14) containing the same union. - C:
net8.0with<LangVersion>preview</LangVersion>. - D: multi-targeted
net10.0;net11.0.
Assert:
- A has zero diagnostics and hover/definition/references/rename work on
ContentBodyand its cases. - A missing union case is the compiler's exhaustiveness warning.
- B reports exactly the build's language-version error, not CS0246/CS1001 noise.
- C parses unions.
- D's diagnostics switch with the active target framework.
- Outline and folding show the union in every project.
Keep this issue open until the latest published release's own binaries pass this against a real C# 15 project.
- 主要言語
- TypeScript
- スター
- 185
- フォーク
- 12
- 平均マージ
- 7時間 33分
- マージ済み PR(30日)
- 63
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Nimblesite/SharpLsp のほかの issue
-
Fix All + Enforce overwrites unsaved edits to .editorconfig / Directory.Build.props / sharplsp.tomlオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
Nimblesite/SharpLsp#644 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Nimblesite/SharpLsp#641 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Nimblesite/SharpLsp#640 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Nimblesite/SharpLsp#639 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Nimblesite/SharpLsp#510 ·
メンテナーはふだん 1 日以内に返信
Nimblesite/SharpLsp の issue をすべて見る
似ている issue
-
api bug priority:low ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
wondermoney/wondermoney#862 ·
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
rootsiemen/seo-agent-tools#70 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
alvinunreal/oh-my-opencode-slim#1971 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
elecnix/bellwether#467 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信