0020: Static .NET discovery, SDK selection from disk, csharp-ls, TRX results
- Status: Proposed (implemented in Phase 2, task 013)
- Date: 2026-12-05
Context
C# is the second complete slice. Its project system is MSBuild, which runs code (tasks, targets, imported props) whenever it evaluates a project. Its files are XML, which can carry external entities. The SDK in use depends on global.json and its rollForward policy. Microsoft's own C# language server ships inside a proprietary VS Code extension, and its standalone build uses a custom solution-loading protocol. Test results are only structured in log files.
Decision
- Static discovery, XML without DTDs.
.slnis read as text,.slnxand.csprojwithroxmltreeand DTDs refused, so no entity is resolved. Targets get kind (executable, library, test), target frameworks and project references. Anything that would need MSBuild evaluation (conditions,$(...),Directory.Build.props) is reported as unresolved. - One project per solution folder. It matches the Cargo workspace rule, so the language server is rooted at the solution and documents of all its projects share one server.
- SDK selection without running
dotnet. The SDK folder beside thedotnethost is listed (the same data asdotnet --list-sdks), the nearestglobal.jsonis read, and itsrollForwardpolicy is applied as documented. The highestnetX.Ytarget framework must be satisfiable by the picked SDK. Provider tasks are refused with guidance when the toolchain is missing. - csharp-ls as the C# server. It is MIT, Roslyn-based, installs with
dotnet tool install, speaks standard LSP over stdio and loads the solution in its root. Real completion, hover, diagnostics and definition were verified against it. dotnettasks as typed argv. Build, run, test and restore name only files discovery found, plus--frameworkfor multi-targeted projects. MSBuild's classic logger is forced (MSBUILDTERMINALLOGGER=off) and telemetry is off. Diagnostics come from MSBuild'sfile(line,col): error CODE: messagelines (deduplicated); assemblies from itsName -> pathlines.- Tests from TRX.
dotnet test --logger trxwrites into a fresh folder under the system temporary folder. The parser reads at most 64 files of at most 16 MiB each, as XML without DTDs, and then removes the folder. - netcoredbg for debug plans. MIT, implements DAP, works with modern .NET on Linux, macOS and Windows. The plan uses an assembly MSBuild reported. The DAP client is task 015.
Alternatives considered
- Roslyn's language server (
Microsoft.CodeAnalysis.LanguageServer). MIT, and now published on nuget.org as a prerelease per platform. It needs a customsolution/opennotification and has no stable standalone release or install path; it can replace csharp-ls later behind the same semantic provider. - The C# Dev Kit server. Its licence ties it to Visual Studio Code; not usable.
- OmniSharp. MIT and mature, but in maintenance mode and heavier to install.
dotnet msbuild -getPropertyfor exact project data. Exact, but it evaluates MSBuild, so it is code execution and needs trust. A trusted, explicit refresh can add it later.- Parse
dotnet testconsole output. Formats differ between test frameworks and versions. TRX is structured.
Consequences
- New dependencies:
tree-sitter-c-sharp(MIT) androxmltree(MIT or Apache-2.0, already in the tree through fonts). - The LSP client now always sends
"jsonrpc": "2.0"; csharp-ls refused messages without it, which earlier servers accepted. - Facts MSBuild computes (conditional frameworks, output types set in props files) are shown as unresolved rather than known.