Skip to content
Back to search

claude-roslyn-lsp

MarketplaceWorks with Claude CodeGitHub

The claude-roslyn-lsp adapter — Roslyn over LSP plus an MCP refactoring surface — and its C# workflow skill, published from the project's own repository.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 20 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/lahma/claude-roslyn-lsp with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/lahma/claude-roslyn-lsp'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/lahma--claude-roslyn-lsp/badge.svg)](/listings/lahma--claude-roslyn-lsp)

HTML

<a href="/listings/lahma--claude-roslyn-lsp"><img src="/api/listings/lahma--claude-roslyn-lsp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Two channels, one binary. **Claude Code gets the plugin**, which carries both servers and the workflow skill and runs them through `dnx` — no download step, and the SDK is required for C# work anyway. **Every other client gets the Native AOT binary** from GitHub Releases: a file-based client wants an absolute path. Since 0.9.0 `dnx` runs the same Native AOT binary too, so both channels start in a few hundred milliseconds.

Claude Code: the plugin

This repository is its own [plugin marketplace](https://code.claude.com/docs/en/plugin-marketplaces), so one install delivers the LSP server, the MCP server and the skill:

/plugin marketplace add lahma/claude-roslyn-lsp
/plugin install roslyn-adapter@claude-roslyn-lsp

or, without starting a session:

claude plugin marketplace add lahma/claude-roslyn-lsp
claude plugin install roslyn-adapter@claude-roslyn-lsp

The plugin is called `roslyn-adapter`; the marketplace, the binary and the NuGet package are `claude-roslyn-lsp`. Its MCP tools appear as `mcp__plugin_roslyn-adapter_roslyn__<tool>`, which is the name to use in `permissions` rules.

**Upgrading from 0.9.0 or earlier**, where the plugin was itself called `claude-roslyn-lsp`: the old name is gone from the marketplace, so `/plugin update` will not find it. Install the new one and remove the old one, once:

claude plugin marketplace update claude-roslyn-lsp
claude plugin install roslyn-adapter@claude-roslyn-lsp
claude plugin uninstall claude-roslyn-lsp@claude-roslyn-lsp

Plugin options are kept per plugin, so set them again if you had any; rename any `mcp__plugin_claude-roslyn-lsp_roslyn__*` entries in your permission rules; and expect the first session to download Roslyn once more, into the new plugin's data directory.

**Then disable the official C# plugin.** The first plugin registered for an extension wins, and marketplace plugins register before everything else — so with `csharp-lsp@claude-plugins-official` enabled, `.cs` goes to it and this adapter is never launched. The symptom is `Command 'csharp-ls' not found`, or nothing at all.

claude plugin disable csharp-lsp@claude-plugins-official

In a session, `/plugin` → *Manage plugins* → `csharp-lsp` → *Disable* does the same thing.

Enabling asks for an optional solution path, Roslyn version, Roslyn path and log level; every field is optional and each maps to the environment variable of the same name in *Environment variables* below. Leave them blank and nothing is set — a blank plugin option is treated as absent rather than as an empty value, which is not the default behaviour and is the subject of a test.

The **first run downloads about 70 MB** of Roslyn into the plugin's own data directory and verifies it against a checked-in SHA-512. Expect the first session to take a few seconds longer to answer; afterwards there is nothing to download and nothing to check.

The plugin is **pinned to the release it shipped with** rather than floating, so the skill and the binary it describes always move together. `/plugin update` picks up the next release.

Claude Code: without the marketplace

For a locally built binary, or to try a change without publishing anything, point Claude Code at a plugin directory:

claude --plugin-dir /path/to/claude-roslyn-lsp/docs/clients/claude-code-local-plugin

[`docs/clients/claude-code-local-plugin/.claude-plugin/plugin.json`](docs/clients/claude-code-local-plugin/.claude-plugin/plugin.json) is a complete manifest for that: edit the two `command` values to the absolute path of your binary. **Use forward slashes on Windows** (`D:/tools/claude-roslyn-lsp.exe`) or escape the backslashes — the manifest is JSON, and an unescaped `D:\Work\...` makes it fail to load *silently*, with no plugin and no error.

The official plugin still wins the `.cs` extension. To sideline it for one run without touching your settings:

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 17 lines
  1. {
  2. "$schema": "https://json.schemastore.org/claude-code-plugin-marketplace.json",
  3. "name": "claude-roslyn-lsp",
  4. "description": "The claude-roslyn-lsp adapter — Roslyn over LSP plus an MCP refactoring surface — and its C# workflow skill, published from the project's own repository.",
  5. "owner": {
  6. "name": "lahma",
  7. "url": "https://github.com/lahma"
  8. },
  9. "plugins": [
  10. {
  11. "name": "roslyn-adapter",
  12. "source": "./",
  13. "category": "language-support",
  14. "tags": ["csharp", "dotnet", "roslyn", "lsp", "refactoring", "mcp"]
  15. }
  16. ]
  17. }
README.md · README · 1,168 lines
  1. # claude-roslyn-lsp
  2. <!-- mcp-name: io.github.lahma/claude-roslyn-lsp -->
  3. Microsoft's Roslyn language server, mediated so that a coding agent can actually use it — as an
  4. **LSP server** for the agents that speak LSP, and as an **MCP server** for the refactorings LSP
  5. clients have no button for. It contains no compiler. Roslyn runs in a child process this binary
  6. downloads, launches and supervises, which is the whole design: reimplementing C# analysis is not
  7. something one person maintains, and Microsoft now publishes the real engine as a public MIT dotnet
  8. tool. The only part nobody had done is the mediation.
  9. Claude Code's C# story is broken in a specific, fixable way. The official `csharp-lsp` plugin
  10. launches `csharp-ls` from `PATH` and installs nothing, so on most machines the language-server tool
  11. never activates at all. And even when a server does start, Claude Code's LSP client refuses
  12. `client/registerCapability`, answers `workspace/configuration` only when a settings block happens to
  13. be present, never sends Roslyn's `solution/open`, never waits for
  14. `workspace/projectInitializationComplete` — so the first several seconds of every session answer
  15. "no definition found" rather than an error — and consumes only *push* diagnostics, which Roslyn does
  16. not send. The result is an agent that reaches for `grep` and `sed` on a language that has had exact,
  17. semantic answers for twenty years.
  18. This binary supplies each of those: it acquires and launches Roslyn, answers the registrations,
  19. configuration and progress requests on the client's behalf, opens the solution, holds requests until
  20. the workspace has actually loaded, and bridges Roslyn's pull diagnostics onto the push model the
  21. client understands. On top of that, the `mcp` verb exposes the mutating half no LSP client offers a
  22. model — solution-wide semantic rename, code actions, fix-all by diagnostic id, formatting and
  23. diagnostics on demand — addressed **by symbol name** rather than by a line number the model had to
  24. grep for first.
  25. One binary serves all of it: Claude Code (both protocols, as a plugin), GitHub Copilot CLI and
  26. OpenCode over LSP, and Codex CLI, Gemini CLI, Cursor, VS Code and Claude Desktop over MCP. It is
  27. written in C# on .NET 10 and ships as a Native AOT executable per platform. The runtime dependency
  28. tree is three packages, all from Microsoft or the official MCP organisation; there is not one
  29. `Microsoft.CodeAnalysis.*` reference in it, and there never will be. MIT licensed.
  30. ## What it does
  31. ```
  32. claude-roslyn-lsp lsp The LSP server. What an editor or an agent's LSP client launches.
  33. claude-roslyn-lsp mcp The MCP server: ten tools, over stdio.
  34. claude-roslyn-lsp doctor Report everything, then start Roslyn and complete one handshake.
  35. claude-roslyn-lsp install The same, with the download allowed.
  36. ```
  37. There is **no default verb**. Both servers speak a different protocol on the same stdout, so a
  38. client that forgot the subcommand would be connected to the wrong one and simply hang; a bare
  39. invocation exits 2 with the usage text on stderr instead.
  40. - **`lsp`** mediates the session in both directions. It answers `initialize` immediately from its own
  41. authored capability document, opens the discovered solution, holds semantic requests until Roslyn
  42. reports the workspace loaded, answers the requests Roslyn makes that Claude Code refuses, and
  43. forwards everything else with only the JSON-RPC id rewritten — no reserialisation, so a result
  44. crosses byte for byte.
  45. - **`mcp`** is the refactoring surface: `resolveSymbol`, `findReferences`, `getTypeMembers`,
  46. `getDiagnostics`, `getCodeActions`, `applyCodeAction`, `renameSymbol`, `fixDiagnostics`,
  47. `formatCode`, `getWorkspaceStatus`. Four of them write files; all four take `preview`. It runs a
  48. Roslyn of its own — launched, supervised and file-watched exactly as the `lsp` half's is — and it
  49. starts loading the solution as soon as the client finishes the MCP handshake rather than when the
  50. first tool is called, because a client starts its servers when a session starts and may not ask a
  51. C# question for minutes. Until the workspace is loaded every tool answers `status: "loading"`
  52. instead of hanging, and `getWorkspaceStatus` says how far it has got.
  53. - **`doctor`** is the support report and the exit code that means something: 0 only if Roslyn is
  54. runnable right now, established by launching it and completing a real handshake.
  55. **What to expect on a first run.** The first `lsp` session for a machine downloads about 70 MB of
  56. Roslyn and extracts about 140 MB, reporting progress to the client as it goes; every later session
  57. starts from the cache. Then the solution loads, and everything asked during that window is held and
  58. answered afterwards rather than answered empty. Measured through Claude Code on this machine:
  59. | | Quartz.NET, 30 projects | OrchardCore, 239 projects |
  60. |---|---|---|
  61. | Handshake (answered by the adapter, not by Roslyn) | 22-30 ms | 24-63 ms |
  62. | Workspace loaded | 5.9 s | 20 s warm, 46 s colder |
  63. | Go to definition, once loaded | 2 ms warm | 4 ms warm |
  64. | Find references | 11 s (278 hits) | 45 s (272 hits) |
  65. | Roslyn memory, workstation GC (the default) | 0.30-0.34 GB | 0.44-0.47 GB |
  66. | Roslyn memory, `CLAUDE_ROSLYN_LSP_GC=server` | 0.6-0.9 GB | 1.9-2.1 GB |
  67. A repository that has never been restored takes longer, because Roslyn restores it itself before it
  68. can load anything.
  69. **The child runs with the workstation garbage collector by default**, although Roslyn's own
  70. configuration asks for the server one. On OrchardCore that is the difference between about 1.9 GB
  71. and **577 MB**, for roughly eight seconds more on the load — and this adapter exists to be run
  72. beside a model's tool calls on the same machine, so the memory is the side worth taking. Set
  73. `CLAUDE_ROSLYN_LSP_GC=server` to buy the seconds back; an explicit `DOTNET_gcServer` — or the older
  74. `COMPlus_gcServer` spelling — in the environment wins over both and is never overwritten, and
  75. `doctor` prints which of the three is in effect.
  76. **A solution-wide `getDiagnostics` is not a one-second call.** The per-file pass is; the first
  77. solution-wide one compiles every project, which took about a minute on Quartz.NET's 30 and did not
  78. finish inside the 120-second budget on OrchardCore's 239 — where it is refused with a sentence
  79. naming `scope: "project"` rather than answered with an empty list. Use file or project scope after
  80. an edit, and solution scope when you actually want the whole picture.
  81. The 120-second readiness budget (`CLAUDE_ROSLYN_LSP_READY_TIMEOUT_SECONDS`) has roughly 2.5x headroom
  82. on a 239-project solution; raise it if yours is larger or is being loaded for the first time.
  83. ## Prerequisites
  84. **A .NET 10 runtime, and in practice the .NET 10 SDK.** Roslyn is a .NET 10 application and this
  85. adapter does not bundle a runtime for it: it resolves the `dotnet` host itself — `DOTNET_ROOT`, then
  86. every match on `PATH`, then the platform's install locations — and asks it for its runtime list
  87. *before* launching anything, so a missing runtime is a sentence in a report rather than a child
  88. process that dies about a framework nobody was watching for. That check is what `doctor` prints, and
  89. it wants `Microsoft.NETCore.App` 10.x.
  90. The SDK is what you want in practice, for two reasons that are not this adapter's doing: Roslyn
  91. evaluates project files and restores packages server-side, which is MSBuild's job, and `dnx` — the
  92. launch channel the Claude Code plugin uses — is part of the SDK. Anyone doing C# work has it.
  93. The adapter itself is self-contained. The Native AOT binary has no runtime dependency at all — on
  94. Linux it needs **glibc 2.34 or newer** (Ubuntu 22.04, Debian 12, RHEL 9, Fedora 35 and later), and
  95. the release build fails rather than ship one that needs more. `dnx` delivers that same binary on the
  96. five platforms below, and a framework-dependent build everywhere else.
  97. ## Install
  98. Two channels, one binary. **Claude Code gets the plugin**, which carries both servers and the
  99. workflow skill and runs them through `dnx` — no download step, and the SDK is required for C# work
  100. anyway. **Every other client gets the Native AOT binary** from GitHub Releases: a file-based client
  101. wants an absolute path. Since 0.9.0 `dnx` runs the same Native AOT binary too, so both channels start
  102. in a few hundred milliseconds.
  103. ### Claude Code: the plugin
  104. This repository is its own [plugin marketplace](https://code.claude.com/docs/en/plugin-marketplaces),
  105. so one install delivers the LSP server, the MCP server and the skill:
  106. ```
  107. /plugin marketplace add lahma/claude-roslyn-lsp
  108. /plugin install roslyn-adapter@claude-roslyn-lsp
  109. ```
  110. or, without starting a session:
  111. ```bash
  112. claude plugin marketplace add lahma/claude-roslyn-lsp
  113. claude plugin install roslyn-adapter@claude-roslyn-lsp
  114. ```
  115. The plugin is called `roslyn-adapter`; the marketplace, the binary and the NuGet package are
  116. `claude-roslyn-lsp`. Its MCP tools appear as `mcp__plugin_roslyn-adapter_roslyn__<tool>`, which is
  117. the name to use in `permissions` rules.
  118. **Upgrading from 0.9.0 or earlier**, where the plugin was itself called `claude-roslyn-lsp`: the old
  119. name is gone from the marketplace, so `/plugin update` will not find it. Install the new one and
  120. remove the old one, once:
  121. ```bash
  122. claude plugin marketplace update claude-roslyn-lsp
  123. claude plugin install roslyn-adapter@claude-roslyn-lsp
  124. claude plugin uninstall claude-roslyn-lsp@claude-roslyn-lsp
  125. ```
  126. Plugin options are kept per plugin, so set them again if you had any; rename any
  127. `mcp__plugin_claude-roslyn-lsp_roslyn__*` entries in your permission rules; and expect the first
  128. session to download Roslyn once more, into the new plugin's data directory.
  129. **Then disable the official C# plugin.** The first plugin registered for an extension wins, and
  130. marketplace plugins register before everything else — so with `csharp-lsp@claude-plugins-official`
  131. enabled, `.cs` goes to it and this adapter is never launched. The symptom is
  132. `Command 'csharp-ls' not found`, or nothing at all.
  133. ```bash
  134. claude plugin disable csharp-lsp@claude-plugins-official
  135. ```
  136. In a session, `/plugin` → *Manage plugins* → `csharp-lsp` → *Disable* does the same thing.
  137. Enabling asks for an optional solution path, Roslyn version, Roslyn path and log level; every field
  138. is optional and each maps to the environment variable of the same name in *Environment variables*
  139. below. Leave them blank and nothing is set — a blank plugin option is treated as absent rather than
  140. as an empty value, which is not the default behaviour and is the subject of a test.
  141. The **first run downloads about 70 MB** of Roslyn into the plugin's own data directory and verifies
  142. it against a checked-in SHA-512. Expect the first session to take a few seconds longer to answer;
  143. afterwards there is nothing to download and nothing to check.
  144. The plugin is **pinned to the release it shipped with** rather than floating, so the skill and the
  145. binary it describes always move together. `/plugin update` picks up the next release.
  146. ### Claude Code: without the marketplace
  147. For a locally built binary, or to try a change without publishing anything, point Claude Code at a
  148. plugin directory:
  149. ```bash
  150. claude --plugin-dir /path/to/claude-roslyn-lsp/docs/clients/claude-code-local-plugin
  151. ```
  152. [`docs/clients/claude-code-local-plugin/.claude-plugin/plugin.json`](docs/clients/claude-code-local-plugin/.claude-plugin/plugin.json)
  153. is a complete manifest for that: edit the two `command` values to the absolute path of your binary.
  154. **Use forward slashes on Windows** (`D:/tools/claude-roslyn-lsp.exe`) or escape the backslashes — the
  155. manifest is JSON, and an unescaped `D:\Work\...` makes it fail to load *silently*, with no plugin and
  156. no error.
  157. The official plugin still wins the `.cs` extension. To sideline it for one run without touching your
  158. settings:
  159. ```bash
  160. claude --settings '{"enabledPlugins":{"csharp-lsp@claude-plugins-official":false}}'
  161. ```
  162. A local plugin directory cannot carry the skill, because a plugin may not reference files outside its
  163. own root. Install it separately — see [Agent skill](#agent-skill) — or work inside a checkout of this
  164. repository, where `.claude/skills/` is loaded as a project skill automatically.
  165. ### Native AOT binary
  166. Download the archive for your platform from
  167. [GitHub Releases](https://github.com/lahma/claude-roslyn-lsp/releases) and extract it. Each archive
  168. is named `claude-roslyn-lsp-{version}-{rid}` and contains the executable, `LICENSE` and this
  169. `README.md`.
  170. | Platform | RID | Archive |
  171. |---|---|---|
  172. | Windows x64 | `win-x64` | `claude-roslyn-lsp-{version}-win-x64.zip` |
  173. | Windows ARM64 | `win-arm64` | `claude-roslyn-lsp-{version}-win-arm64.zip` |
  174. | Linux x64 | `linux-x64` | `claude-roslyn-lsp-{version}-linux-x64.tar.gz` |
  175. | Linux ARM64 | `linux-arm64` | `claude-roslyn-lsp-{version}-linux-arm64.tar.gz` |
  176. | macOS Apple silicon | `osx-arm64` | `claude-roslyn-lsp-{version}-osx-arm64.tar.gz` |
  177. ```bash
  178. tar -xzf claude-roslyn-lsp-1.0.0-linux-x64.tar.gz
  179. chmod +x claude-roslyn-lsp
  180. ./claude-roslyn-lsp install
  181. ```
  182. Every archive is built *and handshake-tested on its own architecture* before it is uploaded — the
  183. arm64 legs run on arm64 runners rather than being cross-compiled — so no binary ships that has not
  184. answered both protocols on the hardware it targets.
  185. Note the absolute path: that is what every configuration file below needs. The Roslyn server the
  186. binary downloads is a separate matter and covers more platforms than this table does — see
  187. *Acquisition and pinning*.
  188. ### NuGet package (dnx)
  189. The same binary is published to nuget.org as
  190. [`claude-roslyn-lsp`](https://www.nuget.org/packages/claude-roslyn-lsp), a .NET tool package carrying
  191. the `McpServer` package type, and listed in the official
  192. [MCP Registry](https://registry.modelcontextprotocol.io) as `io.github.lahma/claude-roslyn-lsp`. The
  193. package is a pointer: `dnx` — part of the .NET 10 SDK — fetches `claude-roslyn-lsp.<rid>`, the
  194. Native AOT binary for Windows, Linux and macOS on the five platforms in the table above, or the
  195. framework-dependent `claude-roslyn-lsp.any` anywhere else (Alpine, Intel macOS), and runs it in one
  196. step:
  197. ```bash
  198. dnx claude-roslyn-lsp@1.0.0 --yes doctor
  199. ```
  200. `--yes` accepts the download prompt and is consumed by `dnx` itself; everything after it reaches the
  201. adapter. Pin the version rather than floating: a language server is something an agent runs on your
  202. behalf, and a pinned version is one you decided to run.
  203. **Never `dnx claude-roslyn-lsp@1.0.0 --version`.** `dnx` takes `--version` for itself, along with
  204. `-v`, `--verbosity`, `--prerelease`, `--source`, `--interactive`, `-h` and about eight others, and
  205. prints its own usage to stdout on a parse error. Use `doctor`, which reports the version along with
  206. everything else.
  207. Releases are pushed to nuget.org by a workflow only a `v*.*.*` tag can start, using
  208. [trusted publishing](https://learn.microsoft.com/nuget/nuget-org/trusted-publishing): the workflow
  209. exchanges its GitHub OIDC token for an API key that lives minutes. There is no NuGet API key stored
  210. in this repository, so there is none to leak.
  211. ### GitHub Copilot CLI
  212. Copilot CLI reads LSP servers from `~/.copilot/lsp-config.json` (yours, every repository) and
  213. `.github/lsp.json` (the repository's, checked in and shared). The repository-level file wins where
  214. both name the same server.
  215. ```json
  216. {
  217. "lspServers": {
  218. "csharp": {
  219. "command": "/usr/local/bin/claude-roslyn-lsp",
  220. "args": ["lsp"],
  221. "fileExtensions": { ".cs": "csharp" },
  222. "requestTimeoutMs": 180000
  223. }
  224. }
  225. }
  226. ```
  227. `fileExtensions` is a **map** from extension to language id, not a list — a list is the mistake that
  228. produces a server that loads and is never asked anything. `requestTimeoutMs` defaults to 90 s and is
  229. raised here because a first request can be waiting on a solution load. `/lsp test csharp` checks the
  230. entry and `/lsp reload` picks up an edit without restarting the CLI.
  231. Copies of both files are in [`docs/clients/copilot-cli/`](docs/clients/copilot-cli), and
  232. [`.github/lsp.json`](.github/lsp.json) in this repository is the same thing pointed at the published
  233. package — this project uses itself.
  234. For the MCP half, `~/.copilot/mcp-config.json`:
  235. ```json
  236. {
  237. "mcpServers": {
  238. "roslyn": {
  239. "type": "local",
  240. "command": "/usr/local/bin/claude-roslyn-lsp",
  241. "args": ["mcp"],
  242. "tools": ["*"]
  243. }
  244. }
  245. }
  246. ```
  247. `type` is required.
  248. ### OpenCode
  249. `opencode.json` in the project root, or `~/.config/opencode/opencode.json` globally:
  250. ```json
  251. {
  252. "$schema": "https://opencode.ai/config.json",
  253. "lsp": {
  254. "csharp": {
  255. "command": ["/usr/local/bin/claude-roslyn-lsp", "lsp"],
  256. "extensions": [".cs"]
  257. }
  258. }
  259. }
  260. ```
  261. The command is one array, executable and arguments together. Reusing the key `csharp` **replaces**
  262. OpenCode's built-in C# server rather than adding a second one that also claims `.cs`; that is
  263. deliberate. Note that OpenCode v2 parses the `lsp` block for forward compatibility and does not run
  264. language servers at all, so this applies to v1.
  265. ### Neovim, Helix, Zed
  266. All three are standard stdio LSP clients and the adapter is a standard stdio LSP server, so these
  267. should work. They are **untested** — nobody has run them — and are written from each editor's
  268. documentation. Reports welcome.
  269. **Neovim** 0.11+, where `vim.lsp.config` is core and `nvim-lspconfig` is not required:
  270. ```lua
  271. vim.lsp.config('claude_roslyn_lsp', {
  272. cmd = { '/usr/local/bin/claude-roslyn-lsp', 'lsp' },
  273. filetypes = { 'cs' },
  274. root_markers = { '.git' },
  275. })
  276. vim.lsp.enable('claude_roslyn_lsp')
  277. ```
  278. `.git` is the marker on purpose: the adapter does its own solution discovery from the root it is
  279. given, and the repository root is the root it wants.
  280. **Helix**, in `~/.config/helix/languages.toml`:
  281. ```toml
  282. [language-server.claude-roslyn-lsp]
  283. command = "/usr/local/bin/claude-roslyn-lsp"
  284. args = ["lsp"]
  285. [[language]]
  286. name = "c-sharp"
  287. language-servers = ["claude-roslyn-lsp"]
  288. ```
  289. The language is `c-sharp`, hyphenated, and `language-servers` **replaces** Helix's default list
  290. rather than extending it — which is what you want here, but is worth knowing.
  291. **Zed** cannot attach a language server it does not already know about; a new id is rejected by the
  292. settings schema. What it can do is replace the binary behind the C# extension's `roslyn` server, so
  293. install that extension first and then, in `~/.config/zed/settings.json`:
  294. ```json
  295. {
  296. "lsp": {
  297. "roslyn": {
  298. "binary": {
  299. "path": "/usr/local/bin/claude-roslyn-lsp",
  300. "arguments": ["lsp"]
  301. }
  302. }
  303. },
  304. "languages": {
  305. "C#": { "language_servers": ["roslyn", "!omnisharp", "!csharp-ls"] }
  306. }
  307. }
  308. ```
  309. The path must be absolute.
  310. ### MCP-only clients
  311. Codex CLI and Gemini CLI have no way to attach an LSP server at all; Cursor, VS Code and Claude
  312. Desktop have their own C# story and want the refactoring tools rather than the navigation. All of
  313. them launch the `mcp` verb over stdio. Every file below is also in
  314. [`docs/clients/`](docs/clients).
  315. **Codex CLI** — `~/.codex/config.toml`:
  316. ```toml
  317. [mcp_servers.roslyn]
  318. command = "/usr/local/bin/claude-roslyn-lsp"
  319. args = ["mcp"]
  320. startup_timeout_sec = 60
  321. tool_timeout_sec = 180
  322. ```
  323. The table is `mcp_servers`, with an underscore. Both timeouts are raised from their defaults of 10 s
  324. and 60 s, because a first call can be waiting on a solution load for up to two minutes.
  325. **Gemini CLI** — `~/.gemini/settings.json` (or `.gemini/settings.json` in the project):
  326. ```json
  327. {
  328. "mcpServers": {
  329. "roslyn": {
  330. "command": "/usr/local/bin/claude-roslyn-lsp",
  331. "args": ["mcp"]
  332. }
  333. }
  334. }
  335. ```
  336. `mcpServers` stays at the top level; the separate `mcp` object holds policy, not server definitions.
  337. **Cursor** — `.cursor/mcp.json` in the project, or `~/.cursor/mcp.json`:
  338. ```json
  339. {
  340. "mcpServers": {
  341. "roslyn": {
  342. "command": "/usr/local/bin/claude-roslyn-lsp",
  343. "args": ["mcp"]
  344. }
  345. }
  346. }
  347. ```
  348. **VS Code** — `.vscode/mcp.json` in the workspace:
  349. ```json
  350. {
  351. "servers": {
  352. "roslyn": {
  353. "type": "stdio",
  354. "command": "/usr/local/bin/claude-roslyn-lsp",
  355. "args": ["mcp"]
  356. }
  357. }
  358. }
  359. ```
  360. **Claude Desktop** — `claude_desktop_config.json` (`%APPDATA%\Claude\` on Windows,
  361. `~/Library/Application Support/Claude/` on macOS):
  362. ```json
  363. {
  364. "mcpServers": {
  365. "roslyn": {
  366. "command": "/usr/local/bin/claude-roslyn-lsp",
  367. "args": ["mcp"],
  368. "env": {
  369. "CLAUDE_ROSLYN_LSP_SOLUTION": "/home/you/src/YourApp/YourApp.slnx"
  370. }
  371. }
  372. }
  373. }
  374. ```
  375. Claude Desktop is the one client here with no workspace of its own, which has two consequences worth
  376. stating before they are discovered. `CLAUDE_ROSLYN_LSP_SOLUTION` is not optional there, because
  377. there is no working directory to discover a solution from. And the four mutating tools will refuse
  378. to write: what bounds a write is the server's own working directory, and Claude Desktop's is not
  379. your repository. Read-only work is what it is good for.
  380. ## MCP tools
  381. Ten tools. Six answer questions, four change files. They exist because an LSP client's tool surface
  382. is read-only and position-addressed: it needs a file, a line and a character for every call, which a
  383. model does not have until it has searched for one — and searching for one is the grep habit this
  384. project exists to replace.
  385. | Tool | What it does | Annotations |
  386. |---|---|---|
  387. | `getWorkspaceStatus` | Which solution is open, how far it has loaded, load errors, the projects and their target frameworks, the Roslyn build in use, and the language server's process id and working set. The tool every `loading` note points at. | read-only, idempotent |
  388. | `resolveSymbol` | Finds where a symbol is declared, semantically, with its hover signature and a 1-based position you can hand straight to an LSP tool. Ambiguity returns every candidate rather than a guess. | read-only, idempotent |
  389. | `getTypeMembers` | Lists a type's members and their signatures without reading the file — including for a type that comes from a NuGet package rather than the checkout. | read-only, idempotent |
  390. | `findReferences` | Every semantic reference across the solution, the source line beside each one, a per-file summary, de-duplicated across target frameworks, paged. | read-only, idempotent |
  391. | `getDiagnostics` | Compiler errors and warnings — and, on request, IDE and CA analyzer diagnostics — for a file, a project or the whole solution. About a second for a file; the first solution-wide pass compiles every project and costs a minute or more. | read-only, idempotent |
  392. | `getCodeActions` | The quick fixes and refactorings Roslyn offers at a position: the lightbulb list, each with a short stable id, the diagnostic ids it addresses, and the scopes its fix-all accepts. | read-only, idempotent |
  393. | `applyCodeAction` | Applies one of them, optionally across the document, the project or the whole solution. | **destructive**, not idempotent |
  394. | `renameSymbol` | A solution-wide semantic rename: overrides, interface implementations, other projects. Not a search and replace, and not a file rename. | write, **not** destructive, idempotent |
  395. | `fixDiagnostics` | Roslyn's own fix-all for one diagnostic id (`IDE0005`, `CA1822`, …) across a file, a project or the solution. | **destructive**, idempotent |
  396. | `formatCode` | Formats with Roslyn, honouring `.editorconfig`, optionally organising usings. Never shells out to `dotnet format`, and applies `end_of_line` and `insert_final_newline` as it does. | write, **not** destructive, idempotent |
  397. Every tool declares `openWorldHint: false` — nothing here leaves the machine, let alone the
  398. workspace — and returns structured content. `applyCodeAction` and `fixDiagnostics` are marked
  399. destructive because a code action can delete a file and a fix-all rewrites a solution; `renameSymbol`
  400. and `formatCode` deliberately are not, because putting a confirmation prompt in front of the two
  401. operations this product most wants a model to reach for is how a user learns to click through the
  402. prompts that matter. The full annotation table, and the reasoning for each judgement call, is in
  403. [AGENTS.md](AGENTS.md).
  404. Four conventions run through all ten:
  405. - **Lines and columns are 1-based**, in and out, and paths are workspace-relative with forward
  406. slashes. LSP counts from zero; every editor, compiler error and stack trace in the C# world counts
  407. from one. The conversion happens here.
  408. - **Anything taking a `symbol` accepts a name or a position** — `IScheduler.Start`, matched as a
  409. dot-segment suffix, or `src/Core/Calculator.cs:7:15`. The name form is the one that matters: it
  410. survives an edit that moved the declaration, and a model that can write it never greps for a line
  411. number first.
  412. - **The four mutating tools take `preview: true`**, which writes nothing and returns a diff. Calling
  413. the same tool again with `preview: false` applies exactly what was previewed rather than
  414. recomputing it — and if a file moved underneath in between, the plan is dropped and re-resolved
  415. rather than applied to something else.
  416. - **They write to disk immediately, and say so.** Every applied result ends with one fixed sentence
  417. asking you to re-read the changed files, because Claude Code's own `Edit` tool refuses a file that
  418. changed since its last read and its refusal does not explain why.
  419. Until the solution has loaded, every tool answers `status: "loading"` rather than hanging, and
  420. `getWorkspaceStatus` says how far it has got.
  421. ## The LSP tool
  422. Claude Code's built-in `LSP` tool exposes nine read-only operations, and **all nine work** through
  423. this adapter: hover, go to definition, go to type definition, go to implementation, find references,
  424. document symbols, workspace symbols, incoming calls and outgoing calls. Call hierarchy is the one
  425. worth naming, because it is the operation the alternatives most often lack; Roslyn has implemented it
  426. since 5.8 and the pin is 5.12.
  427. Two of those cross into code you do not have open. Go-to-definition on a BCL or NuGet symbol returns
  428. a real `file:` path to decompiled source, which any editor and any agent's file reader can open —
  429. not a custom URI scheme that renders as nothing. And call hierarchy on a multi-targeted project
  430. reports each result once rather than once per target framework.
  431. 0.1.0 also ships the diagnostics bridge: Roslyn answers diagnostics only when *asked* (a pull model)
  432. and Claude Code only listens for diagnostics that are *sent* (a push model), so without the bridge
  433. the client gets none at all, forever, with no error to explain it. With it, editing a file produces
  434. its diagnostics on the next turn.
  435. The adapter advertises more than the nine to its own client — rename with prepare, code actions with
  436. resolve, formatting, range formatting, signature help and completion — for the LSP clients that use
  437. them. It deliberately advertises **no** semantic tokens, code lens or inlay hints: advertising a
  438. capability is a promise to answer the requests it enables, Roslyn offers all three whether or not
  439. anyone asked, and computing them for an agent that will never render them is work thrown away.
  440. ## How it works
  441. The adapter terminates both sessions. It is a *server* to its client and a *client* to Roslyn, with
  442. two independent handshakes and state of its own — not a byte relay with patches. A relay cannot
  443. answer the client's `initialize` before Roslyn has answered its own, cannot answer the ~140
  444. registrations and 80 configuration sections the client refuses, and has nowhere to keep a document
  445. mirror or a queue of held requests.
  446. ### Acquisition and pinning
  447. This binary contains no compiler. It runs Microsoft's `roslyn-language-server` as a child process and
  448. fetches that server itself the first time it is needed — pinned to one exact version,
  449. **5.12.0-1.26426.8**, whose SHA-512 for every published platform is checked into this repository and
  450. regenerated only by a build target, never typed in by a person.
  451. Bundling the server would multiply every release archive by an order of magnitude, and asking the
  452. user to install it would reproduce the exact failure this project exists to fix: a plugin that
  453. launches a binary nobody has. So the first run downloads about 70 MB, verifies it against the pin,
  454. and extracts it into a per-user cache. Afterwards there is nothing to download and nothing to check.
  455. The pin is one constant rather than a floating range because the server is prerelease-only with an
  456. unstable command line: `--clientProcessId`, `--daemon` and `--daemonKeepAlive` exist in 5.12 and do
  457. not exist in the builds a year older, and Roslyn *exits* on an option it does not recognise. A flag
  458. passed to the wrong version is not a degraded feature, it is a child that never starts. A floating
  459. version is a release that breaks on somebody else's schedule.
  460. Where the server comes from, in order of trust — and only the last step spends bandwidth:
  461. 1. **`CLAUDE_ROSLYN_LSP_ROSLYN_PATH`**, if set. Its version is not checked: you asked for it. A value
  462. that does not resolve is an error, not a fall-through to a download — a variable that silently
  463. does nothing is the one configuration bug you cannot diagnose.
  464. 2. **The cache**, if a `.complete` marker there records the hash the pin expects.
  465. 3. **A global `dotnet tool` installation**, but only at exactly the pinned version. One at a
  466. different version is *reported* by `doctor` — present, not used, wrong version — and never used.
  467. 4. **nuget.org**, streamed straight to disk and hashed on the way rather than re-read afterwards,
  468. extracted into a staging directory and promoted with one rename so the cache is never
  469. half-populated. A lock file serialises the two processes Claude Code starts at the same instant,
  470. so a first run downloads once rather than twice.
  471. Eight platforms are published — `win-x64`, `win-arm64`, `linux-x64`, `linux-arm64`,
  472. `linux-musl-x64`, `linux-musl-arm64`, `osx-x64`, `osx-arm64` — which is deliberately more than the
  473. five this repository builds archives for, because the NuGet channel reaches platforms no archive is
  474. built for. On anything else, `doctor` names the platform as unsupported rather than downloading a
  475. payload that cannot run. `CLAUDE_ROSLYN_LSP_OFFLINE=1` turns step 4 into an explanation instead of a
  476. fetch.
  477. Roslyn is launched as `<dotnet> …/Microsoft.CodeAnalysis.LanguageServer.dll`, never through the
  478. apphost beside it: that executable is a thin client that spawns its own daemon per instance, which
  479. gave four processes and no shared workspace. The adapter talks to it over a named pipe by default,
  480. because in pipe mode the protocol is on a channel nothing else holds a handle to — the server writes
  481. a 646-byte banner to its own stdout at startup, which under `--stdio` would be protocol corruption.
  482. `CLAUDE_ROSLYN_LSP_TRANSPORT=stdio` exists for environments with no usable named pipe.
  483. ### Which solution gets opened
  484. `CLAUDE_ROSLYN_LSP_SOLUTION` decides it outright, and a path that is not there is an error rather
  485. than a licence to guess: falling back to a scan would open a *different* solution and then answer
  486. about it with total confidence.
  487. Failing that, `.vscode/settings.json`'s `dotnet.defaultSolution` is honoured — any repository opened
  488. in VS Code with the C# extension has already answered this question and checked the answer in —
  489. including its `disable` sentinel, which means no solution on purpose. That file is parsed as JSONC,
  490. because it has comments and trailing commas in it, and a malformed one is treated as absent rather
  491. than as a startup failure: it is somebody else's file.
  492. Otherwise the adapter looks: three directories deep, skipping `bin`, `obj`, `.git`, `node_modules`,
  493. `.vs`, `artifacts` and `TestResults`, and **scores** what it finds rather than taking the first hit.
  494. A name matching the repository folder is worth 100, `.slnx` over `.sln` is worth 10, and each project
  495. listed is worth one; ties go to the shallower file. With no solution at all it opens every `.csproj`
  496. it can find, up to 500 — test projects included, because an agent asked to fix a failing test needs
  497. the test project loaded, and a symbol that resolves everywhere except in tests is worse than a
  498. slower load. `doctor` prints the candidates and their scores, so a wrong choice is visible rather
  499. than mysterious.
  500. ### The readiness gate
  501. A request issued before Roslyn reports `workspace/projectInitializationComplete` is answered with an
  502. *empty successful result* — never an error. An ungated client therefore reports "no definition found"
  503. for the first several seconds of every session, which is indistinguishable from a correct answer and
  504. teaches an agent that the server is useless. That single behaviour is most of why this project
  505. exists.
  506. So requests queue in arrival order and are released in that order once the workspace is loaded.
  507. `CLAUDE_ROSLYN_LSP_READY_TIMEOUT_SECONDS` (120 s, matching the plugin's own `startupTimeout`, so the
  508. client and the server give up at the same moment) is a floor rather than a promise: after it, held
  509. requests are passed through anyway, because a partially loaded workspace answering some questions
  510. beats a server that has stopped answering. A cancellation for a held request is honoured; a backend
  511. that failed answers with an error naming `doctor`; and a client left waiting is told every ten
  512. seconds through `window/logMessage`, which is the one channel it renders.
  513. The MCP half makes the opposite choice for the same reason. A language client has nowhere else to be,
  514. so it waits; an MCP call is a turn of a conversation, so it answers `status: "loading"` with how far
  515. the load has got. A model told "still loading, 3 of 8 projects" can do something else and come back.
  516. ### The three requests answered on the client's behalf
  517. Roslyn asks its client questions, and Claude Code answers none of them usefully. The adapter answers
  518. all three itself:
  519. - **`client/registerCapability`.** Roslyn registers dynamically — ten diagnostic sources, and 135 to
  520. 149 file watchers for a two-project solution, one request each. Claude Code refuses every one with
  521. `-32601`. The adapter accepts them, tracks them, and collapses the watcher set into something a
  522. client can actually act on.
  523. - **`workspace/configuration`.** Roslyn asks for 80 sections across two batches, and the section
  524. names contain a pipe (`csharp|background_analysis…`) which the client's dotted settings lookup
  525. cannot address at all. It also only answers when a settings block happens to be present. The
  526. adapter answers both batches — the second arrives from the Razor subsystem after its own
  527. registrations, and a client that answers only the first leaves a request outstanding on the
  528. startup path.
  529. - **`window/workDoneProgress/create`.** The solution load reports through a progress stream. Without
  530. a client that creates the token, the progress that says how far the load has got has nowhere to go —
  531. which is the number `getWorkspaceStatus` reports and the readiness gate waits on.
  532. ### Configuration defaults
  533. The answers the adapter gives `workspace/configuration` assume an agent rather than a human with a
  534. screen. Both diagnostic scopes are set to open files only, because a full-solution compiler scope is
  535. what makes a large solution unusable and the opt-in workspace mode raises it deliberately. Automatic
  536. restore is **on**, because Roslyn restores server-side and never asks, and a freshly cloned
  537. repository would otherwise load with no references at all. Decompiled-source navigation is **on**, so
  538. go-to-definition into a BCL symbol reaches real source. Reference-assembly symbol search, every inlay
  539. hint, every code lens and auto-insert are **off**, because the adapter advertises none of them and
  540. the work would be discarded — and the two families are matched by prefix rather than enumerated, so
  541. a Roslyn release that adds a hint kind cannot quietly switch it back on.
  542. `CLAUDE_ROSLYN_LSP_OPTIONS` takes a JSON object that overrides any of this, and a settings block from
  543. the client wins over both.
  544. <!-- WP4: how it works -->
  545. ### Diagnostics, file watching and crash recovery
  546. ### Waiting for the workspace, instead of answering wrongly
  547. A request that reaches Roslyn before the solution has finished loading is answered with an **empty
  548. successful result** — never an error. So an ungated client silently reports "no definition found"
  549. for the first several seconds of every session, which is indistinguishable from a correct answer and
  550. teaches the agent that the language server is useless.
  551. The adapter therefore holds requests in arrival order and releases them, in that order, when
  552. `workspace/projectInitializationComplete` arrives. The client's own handshake is answered
  553. immediately out of a capability document written in this repository, so startup does not wait for
  554. the backend: on Quartz.NET's 30-project solution `initialize` comes back in 22 ms and the workspace
  555. is ready 5.9 s later, with everything asked in between held and then answered. If the load exceeds
  556. `CLAUDE_ROSLYN_LSP_READY_TIMEOUT_SECONDS` the gate opens anyway — a partly loaded workspace answering
  557. some questions beats a server that has stopped answering — and says so. A client holding requests is
  558. told every ten seconds through `window/logMessage`, which is the one channel Claude Code renders.
  559. ### Diagnostics: pulled from Roslyn, pushed at the client
  560. Roslyn reports diagnostics only when asked (`textDocument/diagnostic`). Claude Code only understands
  561. being told (`textDocument/publishDiagnostics`) and has no code path that asks. Pointed at each other
  562. unmediated, the result is a language server that never reports a single error and is silent about it.
  563. The bridge is that translation, and it is as much the reason this project exists as the readiness
  564. gate is.
  565. It pulls on open, on save, 400 ms after the last edit, when Roslyn asks for a refresh, and a second
  566. after a project file changes on disk; one pull is in flight per file at a time with a dirty flag
  567. behind it, and each published set carries the document version it was computed at, so a slow answer
  568. cannot paint diagnostics at positions that have moved.
  569. What is published is deliberately less than what Roslyn reports, because the client renders
  570. diagnostics as a text attachment and cuts it — every entry kept pushes another out:
  571. - **Warnings and errors only** by default. `CLAUDE_ROSLYN_LSP_DIAGNOSTIC_MIN_SEVERITY=information`
  572. (or `hint`) lowers the floor.
  573. - **Anything tagged "unnecessary" that is not an error is dropped.** IDE0005 arrives as a hint at
  574. line 0, column 0, for the whole `using` block; it is the least useful entry available and the one
  575. most likely to read as "something is wrong at the top of this file".
  576. - **Visual Studio's private diagnostic tags are stripped**, because no client outside VS knows what
  577. they mean and several drop a diagnostic that carries one.
  578. - **Sorted by severity, then position, and capped at fifty per file.**
  579. Closing a file publishes an empty set, so a diagnostic the user fixed and then closed does not stay
  580. in the transcript forever. `CLAUDE_ROSLYN_LSP_DIAGNOSTICS=off` turns the whole thing off, which
  581. leaves a navigation-only adapter.
  582. **Files nobody has open** are reachable only through a whole-solution pull, and only with the
  583. compiler analysis scope raised to `fullSolution` — the setting that makes a large solution expensive,
  584. because it puts every project's compilation in memory. So it is opt-in:
  585. `CLAUDE_ROSLYN_LSP_WORKSPACE_DIAGNOSTICS=errors` raises that one scope (and no other), asks after
  586. each save, and publishes **compile errors only, for at most ten files, five each**, with the saved
  587. file's own project first. Build output, project files and the duplicate copy a multi-targeted project
  588. reports per framework are all filtered out, and a file that gets fixed is cleared explicitly.
  589. ### Watching the disk, because nothing else will
  590. Roslyn has no file watcher of its own and no fallback: it registers watchers with its client and
  591. waits to be told. Claude Code refuses every one of those registrations and never sends a watched-file
  592. notification — so without this bridge, a file created by `git checkout` or by a shell command never
  593. joins its project, and every later answer is silently *wrong* rather than missing.
  594. Two things about it are worth knowing:
  595. - **A new `.cs` file is not enough.** Roslyn takes the event and carries on; the new type stays
  596. invisible. What makes it re-evaluate is a *change* to the owning `.csproj`, so every appearance or
  597. disappearance of a source file is accompanied by a synthetic change event for the nearest project
  598. file above it. That single mapping is the difference between "a file created by Bash is found" and
  599. "restart your editor". On the test fixture the new type is findable 1.4 s after the file is
  600. written.
  601. - **`obj/` is excluded, except for `project.assets.json`.** That file *is* the restore result, and it
  602. is load-bearing in a way that is easy to miss: on a freshly cloned repository Roslyn restores the
  603. solution itself and then waits to be told the restore happened. Without that one event the load
  604. never completes at all — three projects reported as loaded, a completed restore, and no readiness
  605. notification for as long as you care to wait.
  606. Registrations rooted outside the workspace are dropped (on Quartz.NET that is 342 of 433, all in the
  607. NuGet package cache), events are batched for 200 ms, and files the client has open are skipped
  608. because it already owns their contents. Past 64 distinct directories the per-directory watchers are
  609. replaced by a single recursive one on the workspace root, which covers all of them for one handle.
  610. `CLAUDE_ROSLYN_LSP_FILE_WATCHER=off` disables it, and then the capability is withdrawn from the
  611. handshake entirely so Roslyn registers nothing — advertising it and then not delivering would look
  612. exactly like a working watcher until an answer turned out to be stale. On Linux, watching costs one
  613. inotify instance per directory (`fs.inotify.max_user_instances`, 128 by default); each directory that
  614. cannot be watched is reported by name with the sysctl to raise.
  615. ### When Roslyn dies
  616. It is absorbed, not forwarded. The client's restart budget restarts *this* process, which throws away
  617. the session, the document mirror, the readiness state and every answer in flight — and Roslyn dying is
  618. not that kind of failure, because everything needed to rebuild the backend is held here.
  619. So the gate closes again, the child is relaunched, every open document is replayed at its latest
  620. text, the solution is re-opened, and requests that arrive in the gap are held exactly as they were at
  621. startup. The client sees a slow answer and a log line, not an error: in the live test, a `kill -9`
  622. mid-session is followed by a correct answer 2.9 s later. Two restarts are allowed per ten minutes —
  623. an accident comes back and works, and a server that dies three times on the same solution is
  624. deterministic, so a fourth attempt would be an infinite loop that also holds every request in it.
  625. After that the session moves to its failure state, where each request is refused with a sentence
  626. naming `claude-roslyn-lsp doctor`.
  627. ### When Roslyn cannot be started at all
  628. Offline, no .NET 10 runtime, a proxy serving HTML where a package should be, a hash that does not
  629. match the pin: all ordinary, and none of them kills the adapter. The process stays up, the handshake
  630. stands, and every request is answered with an error naming `claude-roslyn-lsp doctor`; the client
  631. gets one message it will surface and one it will file. A server that exits during startup leaves its
  632. client with a dead pipe and no channel to be told why, because stdout **is** the channel.
  633. ### What is deliberately not advertised
  634. The capability document the adapter presents is authored and static, and it is answered immediately
  635. rather than derived from Roslyn's — Claude Code holds `initialize` open indefinitely if it is not
  636. answered, and deriving one document from the other would make the client's startup wait on the
  637. backend's. It is also not a copy of Roslyn's, which advertises semantic tokens, code lens, inlay
  638. hints and a Visual Studio auto-insert provider statically whether or not anyone asked for them.
  639. The adapter carries exactly what the mediation carries. It does not declare `workspace/applyEdit`
  640. either: the LSP half of 0.1.0 writes no files at all, and the MCP half applies its own edits — which
  641. makes `Edits/` the single place in this product that writes a source file, with one path guard in
  642. front of it.
  643. ### One Roslyn per solution, shared between the two servers
  644. Claude Code starts this plugin's MCP server when your session starts and its LSP server the first
  645. time you touch a `.cs` file. Both of them want a loaded solution, and a Roslyn holding a solution is
  646. by far the largest thing this product puts on a machine — so they share one.
  647. Whichever process gets there first becomes the **host**: it launches Roslyn, publishes itself in
  648. `<home>/sessions/<hash of the solution path>.json`, and listens on a named pipe. The other one
  649. **attaches** and starts nothing at all. Attaching costs about a tenth of a second, against the
  650. seconds or minutes a solution load costs, so the second server is answering questions as soon as it
  651. is asked one.
  652. The host multiplexes: requests from an attached client are renumbered onto the host's own connection
  653. and held by the same readiness gate, documents are reference-counted so one client closing a file
  654. does not take it away from the other, and the notifications an attached client needs — the log
  655. lines, the "workspace loaded" signal, the "your diagnostics are stale" refresh — are fanned out to
  656. everybody. Registrations, configuration and progress stay with the host, which is the one process
  657. that owes Roslyn an answer to them.
  658. Losing either half is a state, not a failure. If Roslyn dies, the host relaunches it and both halves
  659. see a workspace that went briefly quiet; requests in flight at the time are asked again rather than
  660. refused. If the *host* goes away, the attached process sees its backend disappear, finds the session
  661. file gone, and becomes the host itself — on the fixture solution, about two and a half seconds later.
  662. `getWorkspaceStatus` reports which of the two you are talking to: `engine: "owned"` for a Roslyn this
  663. server launched, `engine: "attached"` with `hostProcessId` for one it is sharing. Every failure in
  664. the rendezvous — an unwritable home directory, a platform that will not give out named pipes, a
  665. session file naming a process that has gone — falls back to launching a private Roslyn, which is
  666. what the first release did in every case. `CLAUDE_ROSLYN_LSP_SHARE=off` turns sharing off
  667. deliberately.
  668. `claude-roslyn-lsp doctor` lists every host on the machine with what its Roslyn holds (see
  669. [Memory](#memory-and-idle-sessions)); `doctor --fix` removes stale session files and, on Windows,
  670. orphaned locks, though a server that becomes a host removes them by itself. Elsewhere an orphaned
  671. lock is an empty file and is left where it is, because removing one safely is not something those
  672. file systems allow. Containers that share one home directory each number their processes their own
  673. way, so on Linux a session file written in another container is never judged stale here — `doctor`
  674. says it belongs to another pid namespace instead of calling its process gone.
  675. ### Memory, and idle sessions
  676. A Roslyn child sits near its load size while a session only reads code. A session that edits,
  677. builds and runs tests grows it two to six times. Some of that is real workspace state — the
  678. compilations a project's first diagnostics build — but most of it is the garbage collector's:
  679. background collections sweep rather than compact, so a day of edits leaves 40-70% of the heap as free
  680. space, and even a compacting collection keeps most of what it frees committed for the next burst.
  681. None of it comes back on its own, because an idle process allocates nothing and so no collection ever
  682. runs. With a dozen sessions open, one per worktree, that was most of a 64 GB machine. The
  683. measurements are C66 in [`docs/roslyn-protocol-facts.md`](docs/roslyn-protocol-facts.md).
  684. So the adapter gives it back, in four ways:
  685. - **It recycles a grown child once the session goes idle.** About a minute after the workspace
  686. loads, the adapter measures the child — private bytes on Windows, where an idle process's working
  687. set is trimmed to a fraction of what it actually holds; the working set elsewhere — and keeps that
  688. as its *baseline*. When nothing has asked it anything for `CLAUDE_ROSLYN_LSP_IDLE_RECYCLE_MINUTES`
  689. (20) and it has grown past the larger of twice the baseline and the baseline plus 512 MB, the child
  690. is shut down cleanly. The **next request relaunches it**: it is held while the solution reloads,
  691. every open document is replayed with its unsaved text, and it is answered from the fresh workspace
  692. under the id the client is still waiting on. The client is told why the answer is slow, and is
  693. never sent an error. If that relaunch itself fails — a pipe that will not connect on a loaded
  694. machine, a cache cleaned while the child was gone — the requests that were waiting for it are
  695. answered with an error that says the next request tries again, and the next one does; only three
  696. failed relaunches in a row fail the session, the way a failed first start does. A recycle never
  697. uses up the crash budget, and a crash afterwards still gets both of its restarts. A child that is still loading, has a request held or in flight, or belongs to
  698. another process (an attached engine) is never recycled; with a shared engine the host decides, and
  699. only when every server using it has been quiet.
  700. - **It asks an idle child to compact first.** Five minutes into a quiet spell the adapter asks the
  701. child's runtime, over .NET's own diagnostics channel, for a full compacting collection. Much of what
  702. a working day adds is fragmentation rather than live data — twelve rounds of edits on Quartz.NET
  703. added 335 MB of private bytes and only 24 MB of live heap — and one collection gave back about
  704. 200 MB with no reload at all. Only what the workspace genuinely still holds is left for the recycle
  705. to judge. A child started with `DOTNET_EnableDiagnostics=0` simply is not asked.
  706. - **It caps how much free space the child's collector keeps.** The child runs with
  707. `DOTNET_GCConserveMemory=7` unless `CLAUDE_ROSLYN_LSP_GC_CONSERVE` says otherwise. That limits how
  708. far the collector lets its heap grow past the live data, and so how much free space it keeps
  709. committed: on the same workload the child ended at 1,236 MB instead of 1,465 MB, and at 1,028 MB
  710. instead of 1,366 MB after the compaction, for no measurable CPU. A fresh child is about 690 MB, so
  711. what is left for a recycle to win back is about 340 MB rather than about 680 MB. An explicit
  712. `DOTNET_GCConserveMemory` — or `COMPlus_GCConserveMemory` — in your environment wins and is passed
  713. through.
  714. - **It can unload an idle child whatever its size.** `CLAUDE_ROSLYN_LSP_IDLE_SHUTDOWN_MINUTES` is
  715. off by default, because every relaunch costs a whole solution load; on a machine running many
  716. sessions, a few hours is a reasonable setting.
  717. `getWorkspaceStatus` reports `recycles`, `baselineMegabytes`, `lastRecycleAt` and `privateMegabytes`
  718. beside the working set, so a model can see why a call after a quiet spell took as long as the first
  719. one did. `claude-roslyn-lsp doctor` lists every host on the machine — the Roslyn process id, its
  720. working set and private bytes as measured by `doctor` itself, whether it is `starting`, `running` or
  721. `dormant`, how long ago it was last used, how often it has been recycled, its baseline and how many
  722. other servers are attached — and a total. Servers running with `CLAUDE_ROSLYN_LSP_SHARE=off` keep a
  723. private Roslyn and do not publish themselves, so they are not in that list.
  724. ## Environment variables
  725. Environment variables only — there is no configuration file and no configuration provider. A client
  726. launches this binary with an environment block and nothing else, and reading configuration **never**
  727. fails startup: a malformed value falls back to its documented default and says so on stderr, because
  728. stdout is the protocol channel and a dead process has nowhere to explain itself. `doctor` prints
  729. what is actually in effect and is the authority when this table and the binary disagree.
  730. | Variable | Default | What it does |
  731. |---|---|---|
  732. | `CLAUDE_ROSLYN_LSP_SOLUTION` | discovered | The `.slnx`, `.sln` or `.csproj` to open. A path that does not exist **fails loudly** rather than falling back to discovery. |
  733. | `CLAUDE_ROSLYN_LSP_ROSLYN_PATH` | — | A directory holding `Microsoft.CodeAnalysis.LanguageServer.dll`, that assembly, or another executable to run instead. First in the resolution chain; its version is not checked. Alias: `_SERVER_PATH`. |
  734. | `CLAUDE_ROSLYN_LSP_ROSLYN_VERSION` | the pin | Fetch a different `roslyn-language-server` version. There is no hash for it, so `doctor` reports it as unverified, and the launcher drops the flags only the pinned build is known to accept. Alias: `_SERVER_VERSION`. |
  735. | `CLAUDE_ROSLYN_LSP_ROSLYN_ARGS` | — | Extra arguments for the Roslyn child, split on whitespace. Development only. |
  736. | `CLAUDE_ROSLYN_LSP_HOME` | platform cache dir | Where downloads, logs and lock files live. Falls back to `CLAUDE_PLUGIN_DATA`, then `%LOCALAPPDATA%`, `~/Library/Caches`, `$XDG_CACHE_HOME` or `~/.cache`. Around 140 MB extracted per Roslyn version per platform, so it is a cache by every definition an operating system has. |
  737. | `CLAUDE_ROSLYN_LSP_CACHE_DIR` | under the home | Moves the downloaded servers only; logs and staged downloads stay under the home. |
  738. | `CLAUDE_ROSLYN_LSP_OFFLINE` | `0` | Never download. A missing server becomes an explained failure instead of a 70 MB fetch. |
  739. | `CLAUDE_ROSLYN_LSP_TRANSPORT` | `pipe` | `pipe` or `stdio`. The pipe keeps the protocol on a channel nothing else can write to. |
  740. | `CLAUDE_ROSLYN_LSP_READY_TIMEOUT_SECONDS` | `120` | How long a request waits for the workspace to load before passing through anyway. 1–3600. |
  741. | `CLAUDE_ROSLYN_LSP_DIAGNOSTICS` | `1` | The pull-to-push diagnostics bridge. `lsp` only — an MCP client asks with `getDiagnostics`. |
  742. | `CLAUDE_ROSLYN_LSP_DIAGNOSTIC_MIN_SEVERITY` | `warning` | The severity floor applied before diagnostics are published to an LSP client. |
  743. | `CLAUDE_ROSLYN_LSP_WORKSPACE_DIAGNOSTICS` | off | Opt-in workspace-wide diagnostics for files that are not open. Needs a full-solution compiler scope, which is the expensive setting. |
  744. | `CLAUDE_ROSLYN_LSP_FILE_WATCHER` | `1` | The file-watch bridge. Without it, a file created by a shell command or by git never joins its project and every later answer is silently stale. `lsp` only: the `mcp` half always watches, because it has no editor telling it what changed and because a repository that needs a restore does not finish loading without it. |
  745. | `CLAUDE_ROSLYN_LSP_SHARE` | `1` | Whether the `lsp` and `mcp` servers share one Roslyn per solution. Off makes each of them launch one of its own, which loads the solution twice and pays for it twice in memory. `getWorkspaceStatus` reports `engine: "owned"` or `"attached"`, so which of the two happened is never a guess. |
  746. | `CLAUDE_ROSLYN_LSP_GC` | `workstation` | Which garbage collector the Roslyn child runs with: `workstation` or `server`. Workstation peaks around 577 MB on a 239-project solution where server peaks around 2 GB, and costs about eight seconds of load time. An explicit `DOTNET_gcServer` or `COMPlus_gcServer` in the environment wins over this and is left alone. |
  747. | `CLAUDE_ROSLYN_LSP_GC_CONSERVE` | `7` | The `DOTNET_GCConserveMemory` level, 0–9, the Roslyn child runs with: it caps how far the child's heap may grow past its live data, so less free space stays committed after a compacting collection. `0` sets nothing. An explicit `DOTNET_GCConserveMemory` or `COMPlus_GCConserveMemory` in the environment wins and is left alone. |
  748. | `CLAUDE_ROSLYN_LSP_IDLE_RECYCLE_MINUTES` | `20` | How long a session has to be idle before a Roslyn child that has grown past its threshold is shut down to give its memory back; the next request relaunches it. 0–10080; `0` is off. See [Memory](#memory-and-idle-sessions). |
  749. | `CLAUDE_ROSLYN_LSP_RECYCLE_GROWTH_FACTOR` | `2` | How far past its post-load baseline the child must have grown: the threshold is the larger of baseline × factor and baseline + 512 MB. A decimal with a `.`, 1.2–20. |
  750. | `CLAUDE_ROSLYN_LSP_IDLE_SHUTDOWN_MINUTES` | `0` (off) | Shut the child down after this many idle minutes whatever its size; the next request relaunches it. 0–10080. |
  751. | `CLAUDE_ROSLYN_LSP_LOG_LEVEL` | `Information` | This adapter's own stderr logger: `Trace`, `Debug`, `Information`, `Warning`, `Error`, `Critical`, `None`. |
  752. | `CLAUDE_ROSLYN_LSP_ROSLYN_LOG_LEVEL` | `Warning` | The level handed to Roslyn. Its `Information` is about twenty lines of narration per start. |
  753. | `CLAUDE_ROSLYN_LSP_OPTIONS` | — | A JSON object merged into the answers given to Roslyn's `workspace/configuration` requests. A syntax error is a logged warning, never a startup failure. |
  754. Booleans accept `1/true/yes/on` and `0/false/no/off`, in any case. A number out of range falls back
  755. to the default rather than failing.
  756. **The plugin-option rule.** Every one of these is also read as `CLAUDE_PLUGIN_OPTION_<NAME>`,
  757. **first**, with a blank value treated as absent. A Claude Code plugin manifest substitutes an
  758. unfilled option as the empty string rather than omitting it, so mapping one straight onto the plain
  759. name would set it to `""` in the child process and shadow whatever your environment already said —
  760. which is a real bug a sibling project shipped and had reported. You never set these by hand; the
  761. plugin launcher does, and `doctor` reports which variable a value actually came from.
  762. `CLAUDE_ROSLYN_LSP_HOME` is the single exception: the manifest sets it directly to
  763. `${CLAUDE_PLUGIN_DATA}`, which is a real directory Claude Code owns and has no blank case to guard
  764. against.
  765. ## doctor
  766. ```sh
  767. claude-roslyn-lsp doctor # report everything, then start Roslyn and complete a handshake
  768. claude-roslyn-lsp install # the same, but download the server if it is missing
  769. claude-roslyn-lsp doctor --json # the same report, machine-readable
  770. ```
  771. `doctor` prints the adapter's version and platform, the `dotnet` host and its runtimes with the .NET
  772. 10 ones marked, the whole Roslyn resolution chain with the winner and whether its bytes were
  773. verified, the cache directory and its free space, which solution would be opened and how it scored
  774. against the other candidates, and whether Claude Code's language-server tool is enabled — plus a
  775. warning if the official `csharp-lsp` plugin is also enabled, because the first plugin registered for
  776. `.cs` wins. Next to the garbage collector it prints the `DOTNET_GCConserveMemory` level the child
  777. will get and where that came from.
  778. Its **Shared engines** section answers "who is using my memory": one line per session file, and for
  779. each live host the Roslyn process id, the working set and private bytes `doctor` measured just now,
  780. the state (`starting`, `running` or `dormant`), how long ago it was last used, how many times it has
  781. been recycled, its baseline and how many other servers are attached; then the number of live hosts
  782. and the memory their Roslyn processes hold together. Stale session files, orphaned locks (on
  783. Windows) and leftover temporary files are counted, and `doctor --fix` removes them; plain `doctor`
  784. never deletes anything, and neither form touches a session file it cannot judge — one whose process
  785. it is not allowed to look at, or one written in another container's pid namespace.
  786. Then it launches the server it just described and completes a real `initialize`/`shutdown`/`exit`,
  787. reporting what the server said and how long each step took. **It exits 0 only if that worked.**
  788. Every static check above it can pass on a machine where Roslyn still does not start, which is why
  789. the exit code means the live thing and not the checklist.
  790. `doctor` never downloads — a diagnostic that quietly spends 70 MB of somebody's tethered connection
  791. is a diagnostic they will not run again. `install` is the same command with the download allowed
  792. (`doctor --fix` is a synonym). Through `dnx`, use `doctor` rather than `--version`; `dnx` takes
  793. `--version` for itself.
  794. ## Agent skill
  795. The workflows are also shipped as an [Agent Skill](https://agentskills.io) — the open `SKILL.md`
  796. format most coding agents now read — at
  797. [`.claude/skills/claude-roslyn-lsp/SKILL.md`](.claude/skills/claude-roslyn-lsp/SKILL.md).
  798. It matters more here than it does in a typical MCP server, because **the behaviour is the product**.
  799. The complaint this project started from is that an agent greps and seds C# instead of refactoring it.
  800. The built-in LSP tool's description is fixed by the client and says nothing about when to prefer it
  801. over a text search; each MCP tool's schema describes one tool and cannot say what to reach for
  802. instead of what. Only a skill can teach *order* and *substitution* — resolve the symbol before
  803. searching for it, rename semantically instead of editing declarations, run a design-time diagnostic
  804. pass instead of a build — and it teaches both tool families at once, including the pairing that makes
  805. them compose: `resolveSymbol` reports the `path:line:col` the built-in LSP tool needs, so the model
  806. never greps for a line number first.
  807. The chosen solution and its score are logged **and** sent to the client once, because "which
  808. solution did it open" is the first question of any report about a repository with more than one.
  809. ### Any other tool
  810. ```bash
  811. npx skills add lahma/claude-roslyn-lsp --skill claude-roslyn-lsp -a codex -y
  812. gh skill install lahma/claude-roslyn-lsp claude-roslyn-lsp --agent codex
  813. ```
  814. Replace `codex` with `claude-code`, `cursor`, `gemini-cli` or `github-copilot`. Or copy the directory
  815. by hand — it is one file. Working inside a checkout of this repository needs none of it:
  816. `.claude/skills/` is loaded as a project skill automatically.
  817. Both the skill and the plugin manifests are checked against the server on every build. One test
  818. cross-references every tool the skill names against the real, reflected tool inventory in both
  819. directions, so the skill can neither name a tool that does not exist nor quietly omit one that does;
  820. another asserts that the plugin's skill path still resolves, that its version is the one in
  821. `CHANGELOG.md`, that both server entries run the same pinned package with only their verb differing,
  822. and that the `.cs` mapping that actually launches the LSP server is still there.
  823. ## Troubleshooting
  824. Start with `claude-roslyn-lsp doctor`. Almost everything below is a line in its report.
  825. **Claude Code never launches it, or says `Command 'csharp-ls' not found`.** The official
  826. `csharp-lsp@claude-plugins-official` plugin has the `.cs` extension. The first plugin registered for
  827. an extension wins and marketplace plugins register first, so this adapter is never asked.
  828. `claude plugin disable csharp-lsp@claude-plugins-official`, or `/plugin` → *Manage plugins* →
  829. *Disable*. `doctor` warns when both are enabled.
  830. **Nothing works and the .NET 10 SDK is missing.** Roslyn is a .NET 10 application. `doctor` lists
  831. every `dotnet` host it found and every runtime each one has, with the .NET 10 ones marked; if none
  832. is marked, that is the whole problem. Install the SDK from
  833. [dot.net](https://dotnet.microsoft.com/download) and run `doctor` again. If a client reports *the
  834. command "dnx" was not found*, the same thing is missing.
  835. **The first answers of a session are empty, or the first tool call says `loading`.** That is the
  836. solution loading, and it is normal: a few seconds on a small repository, up to two minutes on a large
  837. one, once per session. `getWorkspaceStatus` says how many projects are in and what failed. The LSP
  838. half holds requests rather than answering them emptily, so a slow first answer is the gate working.
  839. **Answers are confidently about the wrong code.** A monorepo with several solutions is the usual
  840. cause: discovery scores what it finds and cannot know which one you are working in. `doctor` prints
  841. the candidates and their scores. Fix it for everyone by setting `dotnet.defaultSolution` in
  842. `.vscode/settings.json`, or per client with `CLAUDE_ROSLYN_LSP_SOLUTION` in the environment block
  843. that launches the server. Either way the server has to be restarted; it reads its environment once.
  844. **A symbol that is plainly in the checkout is not found.** Its project is not in the loaded solution,
  845. or it did not restore. `getWorkspaceStatus` lists the loaded projects and the load errors. Roslyn
  846. restores server-side, so the fix is usually to look at the restore error rather than to run
  847. `dotnet restore` again.
  848. **Behind a proxy, or offline.** The only thing the adapter downloads is the Roslyn payload from
  849. nuget.org, through the standard .NET proxy environment. Run `claude-roslyn-lsp install` once on a
  850. machine that can reach nuget.org, copy the resulting home directory, and point
  851. `CLAUDE_ROSLYN_LSP_HOME` at it — or install the server yourself and set
  852. `CLAUDE_ROSLYN_LSP_ROSLYN_PATH`. `CLAUDE_ROSLYN_LSP_OFFLINE=1` then makes a missing payload an
  853. explained failure instead of a doomed fetch.
  854. **The machine is short of memory and there are many sessions open.** `claude-roslyn-lsp doctor`
  855. lists every host with what its Roslyn holds right now, and a total. A child that grew during a
  856. working session is recycled once its session has been quiet for twenty minutes; lower
  857. `CLAUDE_ROSLYN_LSP_IDLE_RECYCLE_MINUTES` to give memory back sooner, or set
  858. `CLAUDE_ROSLYN_LSP_IDLE_SHUTDOWN_MINUTES` to unload idle children whatever their size. Each costs one
  859. solution load on the next request. See [Memory, and idle sessions](#memory-and-idle-sessions).
  860. **A call after a quiet spell is as slow as the first one.** The language server was recycled while
  861. the session was idle, and that call reloaded it. `getWorkspaceStatus` says so: `recycles` counts how
  862. often it has happened and `lastRecycleAt` says when.
  863. **You want to see what it is actually doing.** All logging goes to stderr — stdout is the protocol
  864. channel — and Claude Code shows it with `claude --debug`. `CLAUDE_ROSLYN_LSP_LOG_LEVEL=Debug` for the
  865. adapter's own narration, `CLAUDE_ROSLYN_LSP_ROSLYN_LOG_LEVEL=Information` for Roslyn's, which is
  866. about twenty lines per start.
  867. ## Security
  868. - **The only thing downloaded is Roslyn, from nuget.org, and it is hash-verified.** One pinned
  869. version, one SHA-512 per platform checked into this repository, hashed while streaming to disk
  870. rather than by re-reading the file afterwards, extracted into a staging directory and promoted with
  871. a single rename so a half-extracted cache can never look complete. Every entry in the archive is
  872. checked against the destination root before it is opened — a `..` segment, a rooted path, a drive
  873. qualifier or a backslash separator each reject the whole package. A version override you asked for
  874. has no hash, is verified by TLS alone, and is reported as unverified rather than quietly treated as
  875. equivalent.
  876. - **Edits are written only inside the workspace.** Roslyn hands out URIs outside it as a matter of
  877. course — decompiled sources live in a temporary directory — so every write is checked for a `file:`
  878. scheme and a *resolved* path under the workspace root, compared the way the platform's own file
  879. system compares paths. Writes go through a temporary file beside the target, preserve the byte
  880. order mark and the dominant line ending, and refuse overlapping edits rather than merging them.
  881. - **No telemetry, no analytics, no update check.** The Roslyn child is launched with
  882. `--telemetryLevel off`. Outside a first-run download the adapter talks to nothing.
  883. - **The supply chain is three runtime packages**, all from Microsoft or the official MCP
  884. organisation, centrally pinned with transitive pinning on and the MCP SDK pinned to an exact
  885. version. Adding one requires a recorded decision in [AGENTS.md](AGENTS.md). There is no
  886. `Microsoft.CodeAnalysis.*` reference and no `StreamJsonRpc`: framing, process launch, download,
  887. hashing and named pipes are all plain BCL, which is what keeps the tree small enough for one person
  888. to audit.
  889. ## Prior art
  890. Read for facts, credited here, and not copied from — the code in this repository is its own:
  891. - [SamHurne/roslyn-lsp-adapter](https://github.com/SamHurne/roslyn-lsp-adapter) — an adapter with the
  892. same premise.
  893. - [erinloy/claude-roslyn-lsp](https://github.com/erinloy/claude-roslyn-lsp) — the name collision is
  894. not an accident; it is the same idea, arrived at independently.
  895. - `ClaudeCodeRoslynLspProxy` on nuget.org — a relay in front of the same server.
  896. - [oraios/serena](https://github.com/oraios/serena) — semantic tooling for agents across many
  897. languages, and the clearest statement of why name-addressed beats position-addressed.
  898. - [seblyng/roslyn.nvim](https://github.com/seblyng/roslyn.nvim) — the reference for how
  899. `roslyn-language-server` actually wants to be launched and talked to.
  900. - [razzmatazz/csharp-language-server](https://github.com/razzmatazz/csharp-language-server)
  901. (`csharp-ls`) — the honest baseline this project has to beat, and the server the official plugin
  902. points at.
  903. Microsoft's [`roslyn-language-server`](https://www.nuget.org/packages/roslyn-language-server) is the
  904. engine. It is MIT-licensed, and it is downloaded, never vendored.
  905. ## Building from source
  906. Needs the .NET 10 SDK (the exact version is pinned in `global.json`).
  907. ```bash
  908. git clone https://github.com/lahma/claude-roslyn-lsp.git
  909. cd claude-roslyn-lsp
  910. ./build.sh Test # restore, compile, run the tests
  911. ./build.sh SmokeTest # AOT publish, then four real stdio sessions against the binary
  912. ./build.sh Pack # the pointer and 'any' tool packages, into artifacts/packages
  913. ./build.sh PackRuntime # this platform's Native AOT tool package
  914. CLAUDE_ROSLYN_LSP_LIVE_TESTS=1 ./build.sh Test LiveTest # + the real Roslyn, downloaded
  915. ```
  916. ```powershell
  917. .\build.ps1 Test
  918. .\build.ps1 SmokeTest
  919. .\build.ps1 Pack
  920. ```
  921. `LiveTest` is the only thing here that talks to Microsoft's actual server: it acquires the pinned
  922. build, opens the never-restored fixture solution under `tests/fixtures/`, and waits for the
  923. deliberate compile error in it to arrive as a pushed diagnostic. Everything else speaks to a scripted
  924. backend, which proves the mediation and nothing at all about whether Roslyn still answers what this
  925. adapter believes it answers. Without the variable the target reports *skipped* rather than passing.
  926. The orchestrator is [Fallout](https://fallout.build); `build.ps1` / `build.sh` bootstrap the CLI from
  927. `.config/dotnet-tools.json`, so nothing needs installing globally. `dotnet fallout PublishAot
  928. --runtime linux-arm64` builds one platform; the executable lands in `artifacts/publish/{rid}/` and
  929. the archive in `artifacts/archives/`.
  930. `CHANGELOG.md` is the version authority — the build parses its top section and stamps that version
  931. into the binary and the package. The plugin manifest, `.mcp/server.json` and this repository's own
  932. `.github/lsp.json` restate it, and nothing in the build reads those back, so tests fail when any of
  933. them falls behind. `dotnet fallout UpdateRoslynPin` is the only thing allowed to change the pinned
  934. Roslyn version and its hashes.
  935. `SmokeTest` is the check the unit tests cannot be: it publishes the Native AOT binary and drives two
  936. real LSP sessions and two MCP sessions against it, reading LSP stdout as *frames*, so any byte that
  937. is not part of one fails the build, and sending a mis-cased argument that must be refused rather than
  938. dropped. It needs no Roslyn download — a scripted backend reproducing a real 5.12 startup ships
  939. inside the binary behind a hidden verb, which is what lets every release platform be proven on its
  940. own hardware. `Pack` and `PackRuntime` drive the same sessions against the binaries inside the
  941. tool packages, because those are publishes of their own.
  942. ## Contributing
  943. Read [AGENTS.md](AGENTS.md) first. It records the design decisions with the argument for each one,
  944. the package budget, the wire facts in
  945. [`docs/roslyn-protocol-facts.md`](docs/roslyn-protocol-facts.md) that cost a spike each to find, and
  946. the handful of hard rules that are easy to break by accident: never reference
  947. `Microsoft.CodeAnalysis.*`, never transcribe the prior art, no `Console.*` outside `Cli/`, never
  948. hand-edit the generated workflows, and never weaken a rule-enforcing test to make a change pass.
  949. ## License
  950. MIT. See [LICENSE](LICENSE).

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.