csharp-language-server icon indicating copy to clipboard operation
csharp-language-server copied to clipboard

Uncontrolled error when no `.csproj` file is found

Open Zeioth opened this issue 2 years ago • 3 comments

I've installed csharp-language-server using mason.

But when I open a C# file I get the next errors

screenshot_2023-08-12_17-31-51_219540441 screenshot_2023-08-12_17-32-02_178694102 screenshot_2023-08-12_17-32-08_554257612

I've got dotnet and .NET 7.0.9 installed. I'm missing something?

Zeioth avatar Aug 12 '23 15:08 Zeioth

Hey @Zeioth Could you get the full log of the from neovim? Last screenshot indicates some sort of a crash but heading lines are missing. I am not an expert in neovim so I am not sure how to show errors from lsp integration exactly..

razzmatazz avatar Aug 12 '23 15:08 razzmatazz

@razzmatazz I've been able to get the full log by using :redir > ~/mylog.log and then :messages after opening a C# file.

See full log in pastebin

Zeioth avatar Aug 12 '23 16:08 Zeioth

Ok it seems to be saying it requires a .csproj file.

I have another another project with a .csproj, so I can test it: Opening a file of this project shows the next message instead:

LSP[csharp_ls][Info] csharp-ls: initializing, csharp-ls version 0.8.0.0; cwd: "/home/zeioth/.local/share/nvim/lazy/compiler.nvim/tests/examples/cs/build-dotnet"
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][Info] csharp-ls: MSBuildLocator: will register ".NET Core SDK", Version=7.0.109 as default instance
LSP[csharp_ls][Log] csharp-ls: attempting to find and load solution based on cwd ("/home/zeioth/.local/share/nvim/lazy/compiler.nvim/tests/examples/cs/build-dotnet")..
LSP[csharp_ls][Log] csharp-ls: 0 solution(s) found: []
LSP[csharp_ls][Log] csharp-ls: no or multiple .sln files found on /home/zeioth/.local/share/nvim/lazy/compiler.nvim/tests/examples/cs/build-dotnet
LSP[csharp_ls][Log] csharp-ls: looking for .csproj/fsproj files on /home/zeioth/.local/share/nvim/lazy/compiler.nvim/tests/examples/cs/build-dotnet..
LSP[csharp_ls][Log] csharp-ls: loading project "/home/zeioth/.local/share/nvim/lazy/compiler.nvim/tests/examples/cs/build-dotnet/project.csproj"..
LSP[csharp_ls][Log] csharp-ls: OK, 1 project files loaded

And in this case it seems to work correcty screenshot_2023-08-12_18-17-56_150534206

Maybe the only issue is the scary error when no project file has been found. Some error like "Your project needs to have a .csproj file" or something would probably be more useful. In a notification preferably, so it doesn't cut the user's flow.

If the .csproj file is found correctly, we should be showing any message probably.

Zeioth avatar Aug 12 '23 16:08 Zeioth