Giter Site home page Giter Site logo

csharp-language-server's People

Contributors

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csharp-language-server's Issues

csharp-ls stuck in startup on Emacs 28.1 `lsp-mode`

I'm using lsp-mode and installed csharp-ls automatically. I've added the relevant mode hooks to my lsp-mode config. When I visit a C# file, I see that lsp-mode emits LSP :: Connected to [csharp-ls:71243/starting]. to *Messages* buffer, but I never see a success message that the startup succeeded, and none of the expected LS functionality (symbol rename, goto definition, etc) works in the C# file's buffer.

*lsp-log*

Command "csharp-ls" is present on the path.
Command "csharp-ls" is present on the path.
Found the following clients for /Users/johanan/Developer/learning/csharp/hello-world/hello-world/Program.cs: (server-id csharp-ls, priority -2)
The following clients were selected based on priority: (server-id csharp-ls, priority -2)

Enabled lsp-toggle-trace-io:

[Trace - 03:33:14 pm] Sending request 'initialize - (1)'.
Params: {
  "processId": null,
  "rootPath": "/Users/johanan/Developer/learning/csharp/hello-world/hello-world",
  "clientInfo": {
    "name": "emacs",
    "version": "GNU Emacs 28.1 (build 2, aarch64-apple-darwin21.4.0, NS appkit-2113.40 Version 12.3.1 (Build 21E258))\n of 2022-04-07"
  },
  "rootUri": "file:///Users/johanan/Developer/learning/csharp/hello-world/hello-world",
  "capabilities": {
    "workspace": {
      "workspaceEdit": {
        "documentChanges": true,
        "resourceOperations": [
          "create",
          "rename",
          "delete"
        ]
      },
      "applyEdit": true,
      "symbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ]
        }
      },
      "executeCommand": {
        "dynamicRegistration": false
      },
      "didChangeWatchedFiles": {
        "dynamicRegistration": true
      },
      "workspaceFolders": true,
      "configuration": true,
      "codeLens": {
        "refreshSupport": true
      },
      "fileOperations": {
        "didCreate": false,
        "willCreate": false,
        "didRename": false,
        "willRename": false,
        "didDelete": false,
        "willDelete": false
      }
    },
    "textDocument": {
      "declaration": {
        "linkSupport": true
      },
      "definition": {
        "linkSupport": true
      },
      "implementation": {
        "linkSupport": true
      },
      "typeDefinition": {
        "linkSupport": true
      },
      "synchronization": {
        "willSave": true,
        "didSave": true,
        "willSaveWaitUntil": true
      },
      "documentSymbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ]
        },
        "hierarchicalDocumentSymbolSupport": true
      },
      "formatting": {
        "dynamicRegistration": true
      },
      "rangeFormatting": {
        "dynamicRegistration": true
      },
      "rename": {
        "dynamicRegistration": true,
        "prepareSupport": true
      },
      "codeAction": {
        "dynamicRegistration": true,
        "isPreferredSupport": true,
        "codeActionLiteralSupport": {
          "codeActionKind": {
            "valueSet": [
              "",
              "quickfix",
              "refactor",
              "refactor.extract",
              "refactor.inline",
              "refactor.rewrite",
              "source",
              "source.organizeImports"
            ]
          }
        },
        "resolveSupport": {
          "properties": [
            "edit",
            "command"
          ]
        },
        "dataSupport": true
      },
      "completion": {
        "completionItem": {
          "snippetSupport": true,
          "documentationFormat": [
            "markdown",
            "plaintext"
          ],
          "resolveAdditionalTextEditsSupport": true,
          "insertReplaceSupport": true,
          "deprecatedSupport": true,
          "resolveSupport": {
            "properties": [
              "documentation",
              "details",
              "additionalTextEdits",
              "command"
            ]
          },
          "insertTextModeSupport": {
            "valueSet": [
              1,
              2
            ]
          }
        },
        "contextSupport": true
      },
      "signatureHelp": {
        "signatureInformation": {
          "parameterInformation": {
            "labelOffsetSupport": true
          }
        }
      },
      "documentLink": {
        "dynamicRegistration": true,
        "tooltipSupport": true
      },
      "hover": {
        "contentFormat": [
          "markdown",
          "plaintext"
        ]
      },
      "foldingRange": {
        "dynamicRegistration": true
      },
      "callHierarchy": {
        "dynamicRegistration": false
      },
      "publishDiagnostics": {
        "relatedInformation": true,
        "tagSupport": {
          "valueSet": [
            1,
            2
          ]
        },
        "versionSupport": true
      },
      "linkedEditingRange": {
        "dynamicRegistration": true
      }
    },
    "window": {
      "workDoneProgress": true,
      "showMessage": null,
      "showDocument": {
        "support": true
      }
    }
  },
  "initializationOptions": null,
  "workDoneToken": "1"
}


I also see that it spawns *csharp-ls::stderr* and *csharp-ls* buffers but those remain empty.

I'm assuming that it's stuck in startup but to be honest I'm not 100% sure this is the case, and I'm not sure how to verify.

On neovim decompile does not work

When I use csharpls, and use the jump of nvimlsp, it do not return a decompile file.

I see that you have support decompile, I think it should work

inconsistent textDocument/completion results

On vscode I get inconsistent completion results. I depends on how auto-completion was invoked - by trigger character or invoked via shortcut. Wild guess would be that autocompletion is done based on code that was before typing trigger character (trigger character is not accounted).

Sample file I tested on

namespace tests.proj._2
{
    public class Tests
    {
        public void Setup()
        {
        }

        public void Proj2_Test1()
        {
            this.
        }
    }
}

When I type this. I get autocompletion with items as, is, switch, with. Note that these options are valid for this (with space after it). Messages that are being sent to csharp-ls:

[LSP   - 8:12:37 PM] {"isLSPMessage":true,"type":"send-notification","message":{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///home/vytas/code/vscode/dotnettests/tests.proj.2/UnitTest1.cs","version":127},"contentChanges":[{"range":{"start":{"line":10,"character":16},"end":{"line":10,"character":16}},"rangeLength":0,"text":"."}]}},"timestamp":1648833157228}
[LSP   - 8:12:37 PM] {"isLSPMessage":true,"type":"send-request","message":{"jsonrpc":"2.0","id":603,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///home/vytas/code/vscode/dotnettests/tests.proj.2/UnitTest1.cs"},"position":{"line":10,"character":17},"context":{"triggerKind":2,"triggerCharacter":"."}}},"timestamp":1648833157229}
[LSP   - 8:12:37 PM] {"isLSPMessage":true,"type":"receive-notification","message":{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/vytas/code/vscode/dotnettests/tests.proj.2/UnitTest1.cs","diagnostics":[{"range":{"start":{"line":10,"character":17,"debuggerDisplay":"(10,17)"},"end":{"line":10,"character":17,"debuggerDisplay":"(10,17)"},"debuggerDisplay":"(10,17)-(10,17)"},"severity":1,"source":"lsp","message":"Identifier expected","debuggerDisplay":"[Error] ((10,17)-(10,17)) Identifier expected ()"},{"range":{"start":{"line":10,"character":17,"debuggerDisplay":"(10,17)"},"end":{"line":10,"character":17,"debuggerDisplay":"(10,17)"},"debuggerDisplay":"(10,17)-(10,17)"},"severity":1,"source":"lsp","message":"; expected","debuggerDisplay":"[Error] ((10,17)-(10,17)) ; expected ()"}]}},"timestamp":1648833157235}
[LSP   - 8:12:37 PM] {"isLSPMessage":true,"type":"receive-response","message":{"jsonrpc":"2.0","id":603,"result":{"isIncomplete":false,"items":[{"label":"as","kind":14,"insertTextFormat":1},{"label":"is","kind":14,"insertTextFormat":1},{"label":"switch","kind":14,"insertTextFormat":1},{"label":"with","kind":14,"insertTextFormat":1}]}},"timestamp":1648833157236}

But if I close autocompletion and trigger it via shortcut then I get correct items Equals, Setup, ToString and others. csharp-ls messages:

[LSP   - 8:15:39 PM] {"isLSPMessage":true,"type":"send-request","message":{"jsonrpc":"2.0","id":620,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///home/vytas/code/vscode/dotnettests/tests.proj.2/UnitTest1.cs"},"position":{"line":10,"character":17},"context":{"triggerKind":1}}},"timestamp":1648833339323}
[LSP   - 8:15:39 PM] {"isLSPMessage":true,"type":"receive-response","message":{"jsonrpc":"2.0","id":620,"result":{"isIncomplete":false,"items":[{"label":"Equals","kind":2,"insertTextFormat":1},{"label":"GetHashCode","kind":2,"insertTextFormat":1},{"label":"GetType","kind":2,"insertTextFormat":1},{"label":"MemberwiseClone","kind":2,"insertTextFormat":1},{"label":"Proj2_Test1","kind":2,"insertTextFormat":1},{"label":"Setup","kind":2,"insertTextFormat":1},{"label":"ToString","kind":2,"insertTextFormat":1}]}},"timestamp":1648833339332}

Note that it's not always reproducible. I guess it somehow depends on file size too. As when working with big files it happens more often than with this sample program.

The question is can you reproduce that on other clients? If needed I probably could implement some hack/fix on vscode language client to wait for textDocument/didChange response (maybe event add some delay) and only then emit textDocument/completion

Doesn't find installed sdk

I tried to use the c-sharp-server in neovim, but I ran into a error.
So I tried to run the server just by itself and I got:


You must install or update .NET to run this application.

App: /home/USER/.local/share/nvim/mason/packages/csharp-language-server/csharp-ls
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)
.NET location: /usr/lib/dotnet

No frameworks were found.

Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0&arch=x64&rid=pop.22.04-x64


But my I have 7.0 installed but it is at /usr/share/dotnet/sdk and not at /usr/lib/dotnet
I tried adding a symlink but it wouldn't help.
Then I realized I missed the runtime and installed it but I still got:


You must install .NET to run this application.

App: /home/notomoro/.local/share/nvim/mason/packages/csharp-language-server/csharp-ls
Architecture: x64
App host version: 7.0.2
.NET location: Not found

Learn about runtime installation:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=pop.22.04-x64&apphost_version=7.0.2


I am not sure if this is a installation problem of
I am using Pop-Os 22.04

dotnet --list-sdks
7.0.102 [/usr/share/dotnet/sdk]

dotnet --list-runtimes
Microsoft.AspNetCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

I installed csharp-language-server via https://github.com/williamboman/mason.nvim

Maybe this is a package problem on my side?

No parent project could be resolved

I'm trying to get csharp-ls to work with nvim coc within a Unity project. I'm getting the following error:

[coc.nvim] csharp-ls: No parent project could be resolved to add file "/c%3A/Users/blasc/Projects/path/in/project/assemblies/UnityEngine.CoreModule/symbols/UnityEngine.Vector3.cs" to workspace

Any idea if there is a way to make it work? Is this a known issue?

No frameworks were found when dotnet info outputs one

When running csharp-ls I am presented with this error:

It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '6.0.0' (x64) was not found.
  - No frameworks were found.

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=fedora.35-x64

However my dotnet --info output is this:

.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     fedora
 OS Version:  35
 OS Platform: Linux
 RID:         fedora.35-x64
 Base Path:   /home/wizardlink/.dotnet/sdk/6.0.100/

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  5.0.403 [/home/wizardlink/.dotnet/sdk]
  6.0.100 [/home/wizardlink/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.12 [/home/wizardlink/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0 [/home/wizardlink/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.12 [/home/wizardlink/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0 [/home/wizardlink/.dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

For reference, dotnet was installed manually following their documentation, I don't see why this issue is ocurring so I decided to open an issue as I'm not that knowledgeable with the dotnet toolchain.

Doesn't work if multiple target frameworks are specified in the csproj

I'm using csharp-ls 0.6.1 via neovim and nvim-lspconfig.

I can reproduce the problem with a project with a single .cs file:

using System;

namespace dotnet
{
  class Program
  {
    static void Main(string[] args)
    {
      var a = args;
    }
  }
}

If my .csproj file contains this:

<TargetFrameworks>net6.0;net7.0</TargetFrameworks>

then the LSP appears to initialise fine - I do not see anything that looks problematic in the logs, but none of the functionality works. Eg. if I have my cursor on the args in var a = args and try go-to-definition, nothing happens, and the logs say that the language server reported "No location found".

However if I replace the TargetFrameworks line in the csproj with any of the following, everything works fine:

<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>

handleInitialize tries to register capabilities prematurely

When csharp-language-server is used with vscode-languageclient then client crashes with error Unhandled method client/registerCapability. If I read code right culprit is in following two lines

let! regResult = lspClient.ClientRegisterCapability(
{ Registrations = [| didChangeWatchedFilesRegistration |] })
Those do send client/registerCapability to client immediately before emitting initialize result.

According to Lsp initialize request

In addition the server is not allowed to send any requests or notifications to the client until it has responded with an InitializeResult, with the exception that during the initialize request the server is allowed to send the notifications window/showMessage, window/logMessage and telemetry/event as well as the window/showMessageRequest request to the client

https://microsoft.github.io/language-server-protocol/specification#initialize

In order to register dynamic capabilities initialized notification should be used instead:

The server can use the initialized notification for example to dynamically register capabilities

https://microsoft.github.io/language-server-protocol/specification#initialized

And the vscode-languageclient code that starts listening on client/registerCapability only after successful initialization (first and last lines are relevant) https://github.com/microsoft/vscode-languageserver-node/blob/d9eeaf626fd9362eec69fe63322d15760f6794d1/client/src/common/client.ts#L3402-L3430

Crashes on lsp-mode with version 0.5.4

After updating to 0.5.4 csharp-ls crashes not long after initialization.

I don't know where to get a log, so if you need one please tell me where I can find it. The only error I get in stderr is Process csharp-ls stderr<1> finished

It crashes while moving the cursor, so my suspicion are either highlight or documentation.

AutoCompletion of Attribute-types includes `Attribute` suffix when not needed/required

Consider the following code:

[Route("Demo")]
public class DemoController : Controller
{
    [HttpGet]
    [Router("DemoOperation")]
    public IActionResult DemoOperation()
    {
        // some logic
    }
}

Now try chaning the [HttpGet] attribute into a [HttpPost] attribute, by deleting Get, entering P and wait for auto-completion to kick in.

Observed that:

  • HttpPost is not suggested
  • HttpPostAttribute is suggested
  • It is harder to write [HttpPost] than without auto-completion. Oops?

Basically, unless you are willing to live with the needlessly verbose attribute-name, auto-completion now kinda works against you.

Since attribute-completion is somewhat context-sensitive, I'm not sure if there are any simple solutions here... But if there is, that would really be appreciated ๐Ÿ˜„

Doesn't find installed sdk

I tried to use the c-sharp-server in neovim, but I ran into a error.
So I tried to run the server just by itself and I got:


You must install or update .NET to run this application.

App: /home/USER/.local/share/nvim/mason/packages/csharp-language-server/csharp-ls
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)
.NET location: /usr/lib/dotnet

No frameworks were found.

Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0&arch=x64&rid=pop.22.04-x64


But my I have 7.0 installed but it is at /usr/share/dotnet/sdk and not at /usr/lib/dotnet
I tried adding a symlink but it wouldn't help.
Then I realized I missed the runtime and installed it but I still got:


You must install .NET to run this application.

App: /home/notomoro/.local/share/nvim/mason/packages/csharp-language-server/csharp-ls
Architecture: x64
App host version: 7.0.2
.NET location: Not found

Learn about runtime installation:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=pop.22.04-x64&apphost_version=7.0.2


I am not sure if this is a installation problem of
I am using Pop-Os 22.04

dotnet --list-sdks
7.0.102 [/usr/share/dotnet/sdk]

dotnet --list-runtimes
Microsoft.AspNetCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Maybe this is a package problem on my side?

How to set indentation to 2 spaces?

I am accustomed to using 2 spaces of indentation, and I would like to know whether there is a variable to keep the indentation to 2 spaces or if there is any way to keep these 2 spaces of indentation. When I input a `;', the code becomes 4 spaces of indentation automatically, and I want to avoid this happening.

lsp-mode loading spinner no longer working

I was using version 0.3.x and when loading a new project, lsp-mode was able to show that the project/solution was loading. Now in version 0.5.3 lsp-mode gives no indication of loading, it thinks the project loaded instantly, which is not true. So I have to wait and arbitrarily try to use commands until something works showing that the solution was actually loaded.

$/cancelRequest incorrect error code

In vscode extension output window receives focus way to often. When it becomes focused then vscode hides terminal window.

At the moment csharp-ls returns error code 32000 for canceled request via $/cancelRequest. According to specs it should be 32800.

https://microsoft.github.io/language-server-protocol/specifications/specification-current/#cancelRequest

If the request returns an error response on cancellation it is advised to set the error code to ErrorCodes.RequestCancelled.

https://microsoft.github.io/language-server-protocol/specifications/specification-current/#responseMessage

export const RequestCancelled: integer = -32800;

Logs:

[LSP   - 8:47:00 AM] {"isLSPMessage":true,"type":"send-request","message":{"jsonrpc":"2.0","id":436,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///home/REDACTED.cs"},"range":{"start":{"line":868,"character":32},"end":{"line":868,"character":37}},"context":{"diagnostics":[{"range":{"start":{"line":868,"character":32},"end":{"line":868,"character":37}},"message":"The name 'order' does not exist in the current context","severity":1,"source":"lsp"}]}}},"timestamp":1650520020837}
[LSP   - 8:47:01 AM] {"isLSPMessage":true,"type":"send-notification","message":{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///home/REDACTED.cs","version":199},"contentChanges":[{"range":{"start":{"line":868,"character":32},"end":{"line":868,"character":37}},"rangeLength":5,"text":"shoppingBasket"}]}},"timestamp":1650520021012}
[LSP   - 8:47:01 AM] {"isLSPMessage":true,"type":"send-notification","message":{"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":436}},"timestamp":1650520021015}
[LSP   - 8:47:01 AM] {"isLSPMessage":true,"type":"receive-response","message":{"jsonrpc":"2.0","id":436,"error":{"data":{"type":"System.Threading.Tasks.TaskCanceledException","message":"A task was canceled.","code":-2146233029},"code":-32000,"message":"A task was canceled."}},"timestamp":1650520021023}
[Error - 8:47:01 AM] Request textDocument/codeAction failed.
  Message: A task was canceled.
  Code: -32000 
[object Object]

Formatting changes tabs to spaces and does not respect vim settings passed by coc.nvim

Hi,

I am using csharp-ls with coc.nvim. My indentation settings are:

shiftwidth = 4, tabstop = 4, expandtab = false,

Passed on by coc.nvim as the following... looks fine to me.

[Trace - 1:36:19 PM] Sending request 'textDocument/formatting - (1)'. Params: { "textDocument": { "uri": "file:///Users/fl0kng/dev/Test.cs" }, "options": { "tabSize": 4, "insertSpaces": false, "insertFinalNewline": true } }#

Does csharp-ls handle formatting options? I had a quick look, and it seems as if it does not do anything... ;)
Thanks in advance and kind regards,
Florian

snippet support for COC.nvim?

I've tried to configure the language server in Coc as follows:
{
"languageserver": {
"csharp-ls": {
"command": "csharp-ls",
"filetypes": ["cs"],
"rootPatterns": ["*.csproj", ".vim/", ".git/", ".hg/"]
}
}
}
But it doesn't return snippets during completion
Does this language server currently support snippets?

csharp-ls cannot jump to metadata

Hi,

I've tested v0.1.5 of csharp-ls and still unable to jump to metadata.

Steps to reproduce:

  • Create new hello world project
    • On Console or WriteLine, do lsp-find-definition

Expected Result:

  • Jump to intended definition

Actual Behavior:

  • Still on the same buffer

System:

  • Emacs 27.2
    • Debian 10
    • lsp latest
  • csharp-ls, 0.1.5.0

log.txt
log-csharp.txt

Non-fatal exception

I keep getting this exception in message buffer when scrolling/navigating in 0.5.5:

LSP :: Error from the Language Server: System.AggregateException: One or more errors occurred. (Service of type 'Microsoft.CodeAnalysis.Options.ILegacyGlobalOptionsWorkspaceService' is required to accomplish the task but is not available from the workspace.)
 ---> System.InvalidOperationException: Service of type 'Microsoft.CodeAnalysis.Options.ILegacyGlobalOptionsWorkspaceService' is required to accomplish the task but is not available from the workspace.
   at Microsoft.CodeAnalysis.Host.HostWorkspaceServices.GetRequiredService[TWorkspaceService]()
   at Microsoft.CodeAnalysis.GenerateEqualsAndGetHashCodeFromMembers.GenerateEqualsAndGetHashCodeFromMembersCodeRefactoringProvider.CreateCodeActionWithDialogAsync(Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray`1 members, CleanCodeGenerationOptionsProvider fallbackOptions, Boolean generateEquals, Boolean generateGetHashCode, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.GenerateEqualsAndGetHashCodeFromMembers.GenerateEqualsAndGetHashCodeFromMembersCodeRefactoringProvider.CreateActionsAsync(Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray`1 selectedMembers, CleanCodeGenerationOptionsProvider fallbackOptions, Boolean hasEquals, Boolean hasGetHashCode, Boolean withDialog, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.GenerateEqualsAndGetHashCodeFromMembers.GenerateEqualsAndGetHashCodeFromMembersCodeRefactoringProvider.HandleNonSelectionAsync(CodeRefactoringContext context, CleanCodeGenerationOptionsProvider fallbackOptions)
   at Microsoft.CodeAnalysis.GenerateEqualsAndGetHashCodeFromMembers.GenerateEqualsAndGetHashCodeFromMembersCodeRefactoringProvider.ComputeRefactoringsAsync(CodeRefactoringContext context)
   --- End of inner exception stack trace --- (Internal Error)

It doesn't crash or anything. But it is kinda distracting.

decompile for Mircrosoft.ML

csharp_ls: -32000: Failed to resolve assembly: 'Microsoft.ML.DataView, Version=1.0.0.0, Culture=neutral, PublicKeyToken
=cc7b13ffcd2ddd51'

Is it a bug?

csharp-ls: could not OpenProjectAsync

I use neovim with csharp-ls and it suddenly stopped working. I really don't understand why.

Every time I startup the lsp I get an error on startup.

LSP[csharp_ls][Info] csharp-ls: initializing, csharp-ls version 0.4.0.0; options are: {
  "logLevel": 4
}
LSP[csharp_ls][Info] csharp-ls: csharp-ls is released under MIT license and is not affiliated with Microsoft Corp.; see https://github.com/razzmatazz/csharp-language-server
LSP[csharp_ls][Log] csharp-ls: attempting to find and load solution based on cwd: "/home/nikolai/repos/astar_maze"..
LSP[csharp_ls][Log] csharp-ls: looking for .csproj/fsproj files on /home/nikolai/repos/astar_maze..
LSP[csharp_ls][Log] csharp-ls: 0 solution(s) found: []
LSP[csharp_ls][Log] csharp-ls: no or multiple .sln files found on /home/nikolai/repos/astar_maze
LSP[csharp_ls][Log] csharp-ls: loading proj file /home/nikolai/repos/astar_maze/AStarMaze.csproj..
LSP[csharp_ls][Log] csharp-ls: could not OpenProjectAsync('/home/nikolai/repos/astar_maze/AStarMaze.csproj'): System.AggregateException: One or more errors occurred. (Could not load file or assembly 'System.Conf
iguration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Could not find or load a specific file. (0x80131621))
 ---> System.IO.FileLoadException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Could not find or load a specifi
c file. (0x80131621)
File name: 'System.Configuration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
 ---> System.IO.FileLoadException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass15_0.<RegisterMSBuildPath>g__TryLoadAssembly|3(AssemblyName assemblyName)
   at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass15_0.<RegisterMSBuildPath>b__2(AssemblyLoadContext _, AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProper
ties, ToolsetDefinitionLocations locations)
   at Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetConfigurationReader configReader)
   at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCo
unt, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly, Boolean useAsynchronousLogging)
   at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties)
   at Microsoft.CodeAnalysis.MSBuild.Build.ProjectBuildManager.StartBatchBuild(IDictionary`2 globalProperties)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.LoadAsync(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.LoadProjectInfoAsync(String projectFilePath, ProjectMap projectMap, IProgress`1 progress, ILogger msbuildLogger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.OpenProjectAsync(String projectFilePath, ILogger msbuildLogger, IProgress`1 progress, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
LSP[csharp_ls][Log] csharp-ls: OK, 1 project files loaded

Non of the lsp commands work

I found emacs-lsp/lsp-mode#3198 and #3

But I feel the issue should be fixed after those issues

I am on the latest version of csharp-ls

I am on the correct version of dotnet (6) Like I said it suddenly stopped working (I probably did a sudo apt upgrade)

I feel like I am missing something obvious but I cannot seem to find the issue here

Error when trying to go to implementation

When I do "gi" which is mapped to vim.lsp.buf.implementation nothing happens, there is a way to debug this?? I see no errors but my cursor is not moving to the class where that method is implemented, declaration goes fine but in C# projects it's often used Interfaces so I get stuck there.

hangs when using .NET SDK Arm64 (Apple M1)

Hello! Possibly related to #33.

I had to install the x64 distributions of the .NET SDK for things to work. It was weird because csharp-ls was not crashing when I ran it from the CLI, but it would hang in Emacs.

Once the x64 is installed, don't forget to reconfigure the DOTNET_ROOT environment variable to /usr/local/share/dotnet/x64 in Emacs.

Order of suggestions of code-fixes is not really optimized, especially with imports

Consider the following code:

a/Class1.cs

namespace A
{
    public class Class1
    {
        // code
    }
}

b/Class2.cs

namespace B
{
    public class Class2
    {
        var instance = new Class1();
    }
}

Then put your cursor on Class1() and invoke M-x lsp-execute-code-action in Emacs, or similar action in other editor.

Observed that

You will be provided several different options:

image
(Screenshot for demonstrationg-purposes. Does not match example code 1-to-1)

Expected that

Generally, in my experience, some actions are almost always "more" preferred than others.

In this particular case I almost always want to have using-statements as first suggestion, explicit-namespacing as second and create new class as third and expect to find code-fixes in that order.

Does the LSP protocol provide any sort of ... priority for the code actions or is it up to the LSP-client itself to determine how to present them?

README contains misleading information wrt to compatibility

The README clearly states:

csharp-ls unapologetically requires .NET 6 SDK to work and (probably) does not support .NET 3/4.x projects (.NET Framework)

Just wanted to let you know that I've now tested the latest csharp-ls and it works just fine with projects in other .NET Core versions (3.x, 5.0).

I even tried it on some regular .NET Framework projects (.net 4.8) with SDK-format CSPROJ-files, and that worked fine too.

So yeah... Now you know. Feel free to update the README based on that info... Or don't ๐Ÿ˜„

Doesn't work with latest Emacs git master?

This is a kinda of ... opaque bug, I know, but I just recently rebuild my Emacs from latest git sources with "everything" enabled:

cd build/emacs
git checkout master
git pull
make distclean
./configure --with-imagemagick --with-json  ^Cwith-native-compilation --with-xwidgets -with-xinput2
make -j6

I've nuked my $HOME/.emacs.d/elpa and reinstalled all packages.

And now everything works nicely... Except csharp-ls.

That is, other lsp-mode backends seems to work correctly (even omnisharp!), but csharp-ls fails to start and never provides any completions or anything. I've reinstalled csharp-ls (0.1.8) but to no avail. I've also tried downgrading to 0.1.7, but with no difference in behaviour.

So so far, the only significant change seems to be my Emacs build itself.

Could this be an issue with csharp-ls? Could this be an issue with how csharp-ls is registered/used in lsp-csharp? Anyone have any ideas?

Can anyone else reproduce this at all? ๐Ÿ˜„

support for dotnet 6.0.100?

Hi, first of all thank you for your amazing work! I am really loving it! Today, I upgrade dotnet to 6.0.100, unfortunately I didn't find csharp_ls server working as it supposed to be, in contrast it working like a charm before dotnet upgrade.

I haven't been able to find a workaround except downgrading dotnet. Do you have any clues?
client:

  • Neovim nightly
  • neovim-lsp: latest
  • csharp-ls: 0.1.5.0
[START][2021-11-09 09:54:51] LSP logging initiated
[ERROR][2021-11-09 09:54:52] .../vim/lsp/rpc.lua:412    "rpc"   "csharp-ls"     "stderr"        "It was not possible to find any compatible framework version\nThe framework 'Microsoft.NETCore.App', version '5.0.0' (arm64) was not found.\n  - The following frameworks were found:\n      6.0.0 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]\n\nYou can resolve the problem by installing the specified framework and/or SDK.\n\nThe specified framework can be found at:\n  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=5.0.0&arch=arm64&rid=osx.11.1-arm64\n"
[ERROR][2021-11-09 09:55:05] .../vim/lsp/rpc.lua:412    "rpc"   "csharp-ls"     "stderr"        "It was not possible to find any compatible framework version\nThe framework 'Microsoft.NETCore.App', version '5.0.0' (arm64) was not found.\n  - The following frameworks were found:\n      6.0.0 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]\n\nYou can resolve the problem by installing the specified framework and/or SDK.\n\nThe specified framework can be found at:\n  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=5.0.0&arch=arm64&rid=osx.11.1-arm64\n"
[START][2021-11-09 09:55:52] LSP logging initiated
[ERROR][2021-11-09 09:55:53] .../vim/lsp/rpc.lua:412    "rpc"   "csharp-ls"     "stderr"        "It was not possible to find any compatible framework version\nThe framework 'Microsoft.NETCore.App', version '5.0.0' (arm64) was not found.\n  - The following frameworks were found:\n      6.0.0 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]\n\nYou can resolve the problem by installing the specified framework and/or SDK.\n\nThe specified framework can be found at:\n  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=5.0.0&arch=arm64&rid=osx.11.1-arm64\n"
[START][2021-11-09 09:57:26] LSP logging initiated

Could not read windows path when create cs file in neovim.

If I create a cs file in neovim(with Neotree), csharp-ls will print "No parent project could be resolved to add file" message.
It looks like changed "E:" to "e%3A" and fail to read. But it will read succeed by quit and restart neovim. I don't know why.
How do I fix it? This problem will cause lsp feature failed.

image

Basic build configuration support

Hi !
I may have missed something but I feel like currently there is no way to handle Release/Debug configurations.
The main point of this request is for stuff like #if DEBUG.
I'm using this language server with NeoVim (lspconfig / csharp-ls) and it behaves only as a debug configuration. Looking into the code of this repository, I can't find an option to change the build configuration.
Is this something I've missed or is it not implemented ?

Exclude directories

Hi, thanks for the great project!

I'm having issues with exclusion of some directories. I'm using direnv (with nix on linux)
which puts, in the project directory, a .direnv directory where cached files are stored. It stores there *.sln and *.csproj files, too. Which is a problem, since csharp-ls detects them and thinks that there is a solution in there.

Currently, I'm using a custom patch to deal with this issue, but I was thinking maybe there is a better solution.

Does csharp-ls have a generic mechanism for exclusion of certain directories?

I presume it doesn't, because there is a hardcoded exclusion of node_modules directory. Should csharp-ls provide this generic mechanism?

In case you might need it, here is the patch:

diff --git a/src/CSharpLanguageServer/RoslynHelpers.fs b/src/CSharpLanguageServer/RoslynHelpers.fs
index 2cd6c9c..68f5e53 100644
--- a/src/CSharpLanguageServer/RoslynHelpers.fs
+++ b/src/CSharpLanguageServer/RoslynHelpers.fs
@@ -865,9 +865,15 @@ let findAndLoadSolutionOnDir logMessage dir = async {
         |> Seq.contains "node_modules"
         |> not
 
+    let fileNotOnDotDirenv (filename: string) =
+        filename.Split(Path.DirectorySeparatorChar)
+        |> Seq.contains ".direnv"
+        |> not
+
     let solutionFiles =
         Directory.GetFiles(dir, "*.sln", SearchOption.AllDirectories)
         |> Seq.filter fileNotOnNodeModules
+        |> Seq.filter fileNotOnDotDirenv
         |> Seq.toList
 
     logMessage (sprintf "%d solution(s) found: [%s]" solutionFiles.Length (String.Join(", ", solutionFiles)) )

Reported method-parameters in contextual help seems to appear in random order

See example below:

image

The cursor is on a call to the Url.Action(string action, string controller, object values) overload.

The documentation provided seems to be for this overload and is quite good.

The expanded parameter-list however is very confusing because:

  • lots of parameters
  • parameter names not shown in function signature above
  • to make matters worse this is an extension-method so it has one "hidden" parameter.
  • and all in all the parameters does not seem to appear in declared order (instance, action, parameter, values)

As a user I would expect the following order:

  • Extension method target (if shown at all)
  • First param (action)
  • Second param (controller)
  • Third param (values)

Are there any particular reason the parameters are currently presented as they are?

Cant seem to understand .sln with multiple .csproj

I have a .sln that consists multiple .csproj

But whenever i load a single .cs file, it attempts to find the .csproj but won't understand other connected .csproj within the solution. How do make it work?

.editorconfig support

I dont think document formatting picks up the .editorconfig. is this planned? I could take a stab at it

Missing method parameter completion

Apologies if this doesn't belong to csharp-ls, but I have no idea where to start looking and would appreciate any hints.

I'm trying to get Unity projects to work with Emacs and LSP, and I've gotten to a point where csharp-ls is starting, clearly understands the project and offers type information and references. However, I'm only getting completions for method names. So, instead of tabbable variable placeholders such as (typing "foo.")

foo.MyMethod(int bar)

it only offers

foo.MyMethod

The full method signature is shown in the echo area when I move over it, so the issue seems to be on the completion side.

The good old obsolete omnisharp-mode has been working perfectly in the same project. I'm testing this with Emacs 28.1, csharp-ls 0.4.3 and the latest lsp-mode from MELPA. lsp-mode is using the default :capf as the completion provider.

csharp-ls not working on .NET SDK (6.0.103)

Hi there,

Thanks for your work! It's very nice and addressed the annoying metadata of ' omnisharp-roslyn.

Here's my issue:
When I try to run csharp-ls on my M1 Chip with 'dotnet` at 6.0.103.

I run as: $HOME/.dotnet/tools/csharp-ls --loglevel log -s $HOME//csharp/src/setup/setup.sln

There isn't any log string printed.

Is there a preferred .Net version for csharp-ls? Or I'm missing something else.

csharp-ls not working with .NET SDK (7.0.100)

I'm using archlinux and dotnet has been updating. Even if I install dotnet-sdk-6.0 (v 6.0.11) I get the following error.

"rpc" "csharp-ls" "stderr" "You must install or update .NET to run this application. 
App: /home/jlaunay/.local/share/nvim/mason/packages/csharp-language-server/csharp-ls 
Architecture: x64 
Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64) 
.NET location: /usr/share/dotnet 
The following frameworks were found: 
  7.0.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App] 
Learn about framework resolution: 
https://aka.ms/dotnet/app-launch-failed 
To install missing framework, download: 
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=arch-x64
# /usr/share/dotnet/dotnet --list-sdks
6.0.111 [/usr/share/dotnet/sdk]
7.0.100 [/usr/share/dotnet/sdk]

Use Mono SDKS?

I'm trying to use coc.nvim with C#, and this appears to be new only supported LSP.

I'm on linux and I have the latest Mono SDKs and .NET core 5 & 6 installed, but I'm getting this when trying to use csharp-ls:

lies for .NETFramework,Version=v4.7.2 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpack
Loaded server for /home/tshannon/workspace/cold/cold.sln in 4.9s

So csharp-ls is running via .net 6, but the solution needs .net 4.7.2 which is supplied via mono. Anyone know how I work around this?

csharp-ls seems to conflate definition with implementation?

Not sure if this is the fault of csharp-ls or not, but it seems like a good place to start ๐Ÿ˜„

Consider the following c# code:

interface IDemo
{
    void Foo();
}

class Demo : IDemo
{
    void Foo()
    {
        Console.WriteLine("Bar");
    }
}

When positioning the cursor at IDemo (line 6) and selecting (in Emacs) lsp-find-definition I'm taken to line 1, where the interface is defined. This makes sense.

However when I use lsp-find-implementation at IDemo (line 1), I expect to be given the implementations of that interface (line 6). Instead the behaviour seems to be just like lsp-find-definition, and I remain at line 1.

Are these two functions implemented the same way inside csharp-ls? Or is this a lsp-mode issue? Or have I simply misunderstood something about what the current C# LSP providers are capable of?

Timeout while waiting for response. Method: csharp/metadata

First of all, thanks so much for this amazing hack! I've been using it for a few weeks now.

This timeout happens when using lsp-ui-peek-find-definitions to go into a metadata file but it doesn't happen on regular lsp-find-definition. Other than the error itself, Emacs also hangs. It seems I can mash C-g to get out of a little earlier.

I'm more than happy to blame something in my config, but I haven't been able to find a workaround so far. Do you have any clues?

Error When Attempting to use Go to Definition

When I attempt to us go to definition, I get the following error:
Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/util.lua:1047: Cursor position outside buffer
stack traceback:
[C]: in function 'nvim_win_set_cursor'
/usr/share/nvim/runtime/lua/vim/lsp/util.lua:1047: in function 'jump_to_location'
/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:345: in function 'handler'
/usr/share/nvim/runtime/lua/vim/lsp.lua:1173: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

Code Generator Support

Im on paternity leave starting Wednesday so ill pick up implementing code generator support unless its already in progress

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.