Skip to content

feat: add Omnisharp Roslyn - #1109

Closed
angelozerr wants to merge 1 commit into
redhat-developer:mainfrom
angelozerr:omnisharp-roslyn
Closed

angelozerr wants to merge 1 commit into
redhat-developer:mainfrom
angelozerr:omnisharp-roslyn

Conversation

@angelozerr

Copy link
Copy Markdown
Contributor

No description provided.

@lagergren

Copy link
Copy Markdown
Collaborator

Superseded by #2229. It keeps this commit as it is, and brings the template up to date with OmniSharp 2.0.0: the release assets for each OS and CPU, dotnet …/OmniSharp.dll --languageserver, a .NET SDK check, *.cs/*.csx mapped to csharp, and tests. The installer and server were tried live on macOS.

@lagergren lagergren closed this Nov 25, 2026
lagergren added a commit that referenced this pull request Nov 25, 2026
…t OmniSharp for each platform and starts it with dotnet (#2229)

Supersedes #1109. Angelo's commit is kept as it was, and this PR brings
it up to date with OmniSharp 2.0.0 and the current installer format. It
also adds an installer option that the template needs, `outputMatches`.
This PR is meant to be **rebase-merged**, so that each commit, the
engine option among them, gets its own release note.

## What

The C# template of #1109 was a copy of the Clojure LSP template:
- it mapped `*.cs` to the `clojure` language id, with `;` as comment;
- its command, `"OmniSharp --languageserver"`, was one quoted argument;
- its check ran that command;
- its installer asked for `omnisharp-osx.zip` and
`omnisharp-linux-x86.zip`, which OmniSharp 2.0.0 (2026-09-18) doesn't
publish;
- two tests that every bundled installer passes failed on it.

## Change

- **Install:** the `omnisharp-<os>-<arch>.zip` asset of the latest
release, for Linux x64/arm64, macOS Intel/Apple Silicon and Windows
x64/x86/arm64, with a fallback `url` pinned to v2.0.0, into
`~/.lsp4ij/lsp/omnisharp-roslyn`.
- **Command:** `dotnet
"$USER_HOME$/.lsp4ij/lsp/omnisharp-roslyn/OmniSharp.dll"
--languageserver` on every OS.
- It's the `dotnet` that the check finds, and the one OmniSharp loads
projects with. The `OmniSharp` apphost finds .NET only in its default
folders, and the zip doesn't keep its executable bit.
- No `-z`, `--hostPID` or `--encoding`: in LSP mode OmniSharp counts
from 0, takes the process id from `initialize`, and reads raw streams.
- **New installer option, `outputMatches`:** an `exec` task can require
its stdout to match a regex (`find`, so `(?m)` for lines). Without the
key, nothing changes, and LSP4IJ 0.30.1 and earlier ignore it. On a
mismatch, the console names the command, the regex and the output. An
invalid regex fails the task without running the command. It's
documented in the installer docs and the installer JSON schema.
- **Check and run:** `dotnet --list-sdks` with `outputMatches`
`(?m)^[1-9]\d+\.\d+\.\d+\s` (in the JSON, each `\` is written `\\`). It
accepts an SDK 10 or later, which carries the runtime that OmniSharp
2.0.0 (`net10.0`) needs, and rejects 8.x, 9.x and 10 previews. Then the
check does a `fileExists` of `OmniSharp.dll`, and the run downloads.
Without such an SDK, the run shows ".NET SDK 10 or later not found" with
a link to the SDK download, and downloads nothing.
- **Mappings:** `*.cs` and `*.csx` → `csharp`, by pattern, since IDEA
has no C# file type. C# comments and statement terminator.
- **Settings:** none. OmniSharp 2.0.0 asks for its `csharp` and
`omnisharp` sections but doesn't apply them, tested live with
`FormattingOptions`. It does apply a project `omnisharp.json` and
options on its command line, and the page says so.
- **Docs:**
  - the template's README;
  - `docs/user-defined-ls/omnisharp-roslyn.md`, with the asset table;
  - an entry in "Default template";
  - new pages for Luau and Smart Data Lake;
- Candor, Luau and Smart Data Lake listed by their page instead of their
source folder.

## Tests

- **`InstallerTaskRegistryFileExistsTest`**, 3 new tests:
  - the .NET check comes first, in both the check and the run;
- a local zip laid out like the release installs `OmniSharp.dll` where
the command starts it, and the check finds it;
- without `dotnet`, the run shows the message (a bounded wait),
downloads nothing and keeps the command.
- **`BundledTemplateCommandsTest`:** OmniSharp starts where its
installer puts it.
- **New `ExecTaskOutputMatchesTest`** (8 tests): a match passes; a
mismatch fails, and the message names the command, the regex and the
output; exit 0 with no output fails; exit 1 with matching output fails;
an invalid regex fails without running the command; without the key,
only the exit code decides; at a timeout, only output that matches
passes; and the factory reads the key.
- **The SDK check, with the real installer and `ExecTask`:** SDKs 8+9, a
10 preview, no SDK, or no `dotnet` → the check fails, and the run shows
the message and downloads nothing. SDK 10, or 9+11 → it installs.
- **Red-green:** with #1109's template, 6 of 62 tests fail; now none do.
- **Platforms:** `installation.*`, `launching.*` and `templates.*` pass
headless on IC 2024.2, 2025.3 and IU 2026.3: 322 tests each, 0 failures,
0 skipped.
- **Live, on macOS arm64** with the .NET SDK 11.0.100:
  - the installer downloaded v2.0.0 (51 MB) and set the command;
- on a `dotnet new console` project, `initialize` answered in about 2.7
s;
  - hover on `Console` gave `class System.Console`;
  - completion after `Console.` gave 53 items, including `WriteLine`.

The harness waited on OmniSharp's own `o#/projectadded` notification, on
`publishDiagnostics` and on the process exit, with no fixed sleeps.
- **Not run** on Linux, Windows or Intel Macs. Their asset names are
checked against the v2.0.0 release and by `BundledTemplateCommandsTest`.

## Behaviour change

| Before | After |
|---|---|
| The OmniSharp template mapped `*.cs` to `clojure`, and its command and
installer couldn't start OmniSharp | It installs the current OmniSharp
for the OS and CPU, maps `*.cs`/`*.csx` to `csharp`, and starts it with
`dotnet`. Without the .NET SDK 10 or later, it says so and downloads
nothing |
| An installer's `exec` task passed on exit code 0 alone | With
`outputMatches`, it also requires its output to match a regex |
| The Luau and Smart Data Lake templates had no docs page, and no link
on their Server tab | They have a page, and their Server tab links it |

---------

Signed-off-by: azerr <[email protected]>
Co-authored-by: azerr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request user-defined LS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants