← 返回 Skills 市场
leafbird

C# LSP

作者 choi sung ki · GitHub ↗ · v1.2.0
linuxdarwinwin32 ⚠ suspicious
306
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install csharp-lsp
功能描述
C# language server providing code intelligence, diagnostics, and navigation for .cs and .csx files. Uses csharp-ls (lightweight Roslyn-based). Requires .sln...
使用说明 (SKILL.md)

C# LSP

C# code intelligence via csharp-ls — a lightweight Roslyn-based language server.

Capabilities

  • Go-to-definition: Jump to symbol definitions across solution
  • Find references: Locate all usages of a symbol
  • Hover info: Type signatures, XML docs, parameter info
  • Diagnostics: Real-time compiler errors and warnings
  • Document symbols: List classes, methods, properties in a file
  • Workspace symbol search: Find symbols across the entire solution

Supported extensions: .cs, .csx

Prerequisites

  • .NET SDK (9.0+): https://dot.net/download
  • Python 3: Required to run the lsp-query daemon
  • .sln or .csproj: Project file is required (loose .cs files give limited results)

Setup

Run the one-time setup script (idempotent — safe to re-run):

bash {baseDir}/scripts/setup.sh           # setup only
bash {baseDir}/scripts/setup.sh --verify  # setup + verification test

What it does:

  1. Checks for .NET SDK
  2. Installs csharp-ls via dotnet tool install --global
  3. Registers ~/.dotnet/tools in PATH
  4. Creates lsp-query symlink
  5. Creates cache directory

Usage

# Set workspace to the directory containing .sln/.csproj
export LSP_WORKSPACE=/path/to/project

# Go to definition
lsp-query definition src/Program.cs 15 8

# Find all references
lsp-query references src/Models/User.cs 42 10

# Type info / hover
lsp-query hover src/Services/AuthService.cs 30 22

# List symbols in a file
lsp-query symbols src/Program.cs

# Search symbols across workspace
lsp-query workspace-symbols "UserService"

# Compiler diagnostics
lsp-query diagnostics src/Program.cs

# Check running servers
lsp-query servers

# Shut down daemon
lsp-query shutdown

Line/column numbers are 1-indexed.

Architecture

lsp-query CLI → Unix Socket → lsp-query daemon (Python)
                                   ↓
                              csharp-ls (subprocess, stdin/stdout JSON-RPC)
                                   ↓
                              Roslyn (.sln → full type system)
  • Daemon: Auto-forks on first call. Shuts down after 5 min idle.
  • csharp-ls: Starts on first C# query. Shuts down after 5 min idle.
  • Cold start: Solution loading takes 30–60s for large projects. Subsequent queries ~200ms.

Project Detection

  1. Solution file (.sln) — best: enables cross-project references
  2. Project file (.csproj) — good: single project analysis
  3. Loose .cs files — limited: basic syntax only

What's Included

{baseDir}/
├── SKILL.md              # This file
└── scripts/
    ├── setup.sh          # One-time setup (idempotent)
    └── lsp-query.py      # LSP daemon + CLI (self-contained)

Troubleshooting

  • Install fails (DotnetToolSettings.xml): Pin version with dotnet tool install --global csharp-ls --version 0.20.0
  • Empty results: Check that LSP_WORKSPACE points to a directory with .sln or .csproj
  • Slow first query: Normal — Roslyn project loading takes 30–60s for large solutions
  • PATH issues: Add export PATH="$PATH:$HOME/.dotnet/tools" to your shell profile
  • Stale daemon: Run lsp-query shutdown and retry

Links

安全使用建议
This skill implements the advertised C# LSP but also bundles a multi-language Python daemon and makes system-level changes during setup. Before installing: (1) review scripts/lsp-query.py fully to confirm you are comfortable with multi-language behavior and any logging to /tmp; (2) run setup.sh in a constrained environment (or inspect it) — it may write to ~/.bashrc/.zshrc and will try to create /usr/local/bin/lsp-query (requires sudo); avoid exporting SUDO_PASS (do not provide your sudo password via env); (3) if you prefer less privilege, modify setup.sh to install the symlink to a user-local bin (e.g., ~/.local/bin) and remove automatic RC edits; (4) note that debug logging may record JSON-RPC messages and URIs — check /tmp/lsp-query-debug.log and the code that writes to it if you handle sensitive code. If you need high assurance, run the setup and tests inside an isolated container first.
功能分析
Type: OpenClaw Skill Name: csharp-lsp Version: 1.2.0 The skill provides a robust C# language server integration using csharp-ls and a custom Python-based daemon (lsp-query.py) that manages multiple LSP instances via Unix sockets. The setup script (setup.sh) performs standard environment configuration, including installing global dotnet tools, creating symlinks (using sudo if available), and ensuring PATH persistence by modifying shell RC files (.bashrc/.zshrc). While these actions involve high privileges, they are transparently documented and directly support the stated purpose of providing a persistent, low-latency code intelligence tool for AI agents.
能力评估
Purpose & Capability
The skill is advertised as a C#-only language server (csharp-ls), but the included lsp-query.py is a multi-language LSP client with configuration/commands for many languages (pyright, typescript-language-server, rust-analyzer, gopls, clangd, etc.). That mismatch (skill claims C# focus but ships a general multi-language daemon) is unexpected and may be intentional or leftover from a broader project.
Instruction Scope
SKILL.md instructs running scripts/setup.sh which installs a global dotnet tool, modifies shell RC files (~/.bashrc or ~/.zshrc) to add ~/.dotnet/tools, creates a symlink in /usr/local/bin, and runs a verification that creates and restores a test project. The Python daemon writes debug entries to /tmp/lsp-query-debug.log (server requests/notifications) without honoring the documented LSP_DEBUG guard, which may log URIs and JSON-RPC payload metadata.
Install Mechanism
No centralized install spec is declared, but setup.sh performs a global 'dotnet tool install --global csharp-ls', edits shell RC files, creates /usr/local/bin/lsp-query (using sudo if needed), and creates cache directories. These are common for CLI tools but involve elevated actions (symlink creation) and persistent filesystem changes.
Credentials
The skill declares no required credentials but uses several environment variables (LSP_WORKSPACE, LSP_TIMEOUT, LSP_DEBUG, LSP_SERVER) in practice. The installer optionally reads SUDO_PASS (if provided) to run sudo non-interactively — asking users to set SUDO_PASS is risky because it exposes a privileged credential to the environment. LSP_SERVER can override server commands, which increases attack surface if misused.
Persistence & Privilege
The skill installs a background daemon (auto-forking, idle shutdown), creates cache and socket files (~/.cache/lsp-query/*), and may place a symlink in /usr/local/bin and add PATH entries to shell RC files. always:false is set (not force-installed), which is appropriate; however the installation modifies user/system files and leaves a persistent daemon while idle, so be aware of that persistence.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install csharp-lsp
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /csharp-lsp 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.2.0
### Changed - SKILL.md rewritten in English (was Korean) - Added ClawHub badge to README ### Added - GitHub Actions workflow for automated ClawHub publish on tag push - ClawHub install option in README
v1.1.0
Self-contained csharp-ls integration. Idempotent setup, Docker tests, full docs.
元数据
Slug csharp-lsp
版本 1.2.0
许可证
累计安装 0
当前安装数 0
历史版本数 2
常见问题

C# LSP 是什么?

C# language server providing code intelligence, diagnostics, and navigation for .cs and .csx files. Uses csharp-ls (lightweight Roslyn-based). Requires .sln... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 306 次。

如何安装 C# LSP?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install csharp-lsp」即可一键安装,无需额外配置。

C# LSP 是免费的吗?

是的,C# LSP 完全免费(开源免费),可自由下载、安装和使用。

C# LSP 支持哪些平台?

C# LSP 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(linux, darwin, win32)。

谁开发了 C# LSP?

由 choi sung ki(@leafbird)开发并维护,当前版本 v1.2.0。

💬 留言讨论