Giter Site home page Giter Site logo

csharp-language-server's Introduction

Description

This is a hacky Roslyn-based LSP server for C#, as an alternative to omnisharp-roslyn.

csharp-ls requires .NET 8 SDK to be installed. However it has been reported to work with projects using older versions of dotnet SDK, including .NET Core 3, .NET Framework 4.8 and possibly older ones too as it uses the standard Roslyn/MSBuild libs that Visual Studio & omnisharp does.

See CHANGELOG.md for the list of recent improvements/fixes.

Acknowledgements

  • csharp-ls is not affiliated with Microsoft Corp;
  • csharp-ls uses LSP interface from Ionide.LanguageServerProtocol;
  • csharp-ls uses Roslyn to parse and update code; Roslyn maps really nicely to LSP w/relatively little impedance mismatch;
  • csharp-ls uses ILSpy/ICSharpCode.Decompiler to decompile types in assemblies to C# source.

Installation

dotnet tool install --global csharp-ls

See csharp-ls nuget page

Settings

  • csharp.solution - solution to load, optional

Clients/Editor plugins

csharp-ls implements the standard LSP protocol to interact with your editor. However there are some features that need a non-standard implementation and this is where editor-specific plugins can be helpful.

Emacs

emacs/lsp-mode

Supports automatic installation, go-to-metatada (can view code from nuget/compiled dlls) and some additional features.

See emacs/lsp-mode.

Visual Studio Code

vytautassurvila/vscode-csharp-ls

  • Supports code decompilation from metadata

See csharp-ls and vscode-csharp-ls @ github.

statiolake/vscode-csharp-ls

See vscode-csharp-ls.

Building

On Linux/macOS

$ (cd src && dotnet build)

Features

  • symbol rename;
  • code refactorings from roslyn;
  • go-to-definition;
  • find references;
  • document/workspace symbol search;
  • textDocument/documentHighlight support:
    • highlighting other symbol references in the document on hover;
  • codeAction/resolve support for better performance when invoking code actions;
  • semantic token support (thanks to @tcx4c70);
  • inlay hint support (thanks to @tcx4c70);
  • go-to-definition in metadata support (needs integration from your LSP client).

TODO list

  • check we're not doing lense stuff or other funny things on metadata code (emacs-lsp/lsp-mode issue?);
  • find-refs is blocking r/w operations, request scheduling needs smarter refactoring;
    • should we cancel existing ones? -- where cancellable? how to know?
  • support for pull diagnostics (lsp 3.17);
  • go-to-def in metadata does not work for Attribute as those have Attribute suffix;
  • progress support;
  • properly escape docxml text, e.g. backquote is a special character in markdown;
  • selection range provider
  • ability to run tests / test browser support like fsac has?
  • razorls integration (server-side)
  • analyzer support
  • code generator support
  • vscode plugin

FAQ

decompile for your editor , with the example of neovim

api

The api is "csharp/metadata", in neovim ,you can request it like

  local result, err = client.request_sync("csharp/metadata", params, 10000)

sender

You need to send a uri, it is like

csharp:/metadata/projects/trainning2/assemblies/System.Console/symbols/System.Console.cs

In neovim, it will be result(s) from vim.lsp.handles["textDocument/definition"]

and the key of uri is the key,

The key to send is like

local params = {
	timeout = 5000,
	textDocument = {
		uri = uri,
	}
}

The key of textDocument is needed. And timeout is just for neovim. It is the same if is expressed by json.

receiver

The object received is like

{
	projectName = "csharp-test",
	assemblyName = "System.Runtime",
	symbolName = "System.String",
	source = "using System.Buffers;\n ...."
}

And In neovim, You receive the "result" above, you can get the decompile source from

local result, err = client.request_sync("csharp/metadata", params, 10000)
local source
if not err then
	source = result.result.source	
end

And there is a plugin of neovim for you to decompile it.

csharpls-extended-lsp.nvim

csharp-language-server's People

Contributors

razzmatazz avatar tcx4c70 avatar kstatz12 avatar decodetalkers avatar vytautassurvila avatar weirongxu avatar beaucranston avatar arussellk avatar sharpsteff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.