You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the OmniSharp C# Language Client to get diagnostic information about a C# project. So far I have been unsuccessful in this attempt.
I have been able to start the omnisharp service and initialize but OnPublishDiagnostics never seems to fire. When attempting to open and change a document I get an exception on the server.
at OmniSharp.Cake.Services.CakeScriptService.Generate(FileChange fileChange) in D:\a\1\s\src\OmniSharp.Cake\Services\CakeScriptService.cs:line 55
I am not sure if this is an issue with the server, the client or me just understanding the protocol. Any guidance you could provide on the issue would be much appreciated. The code for my sample is below.
usingSystem;usingSystem.Collections.Generic;usingSystem.Diagnostics;usingSystem.IO;usingSystem.Linq;usingSystem.Threading;usingSystem.Threading.Tasks;usingOmniSharp.Extensions.LanguageServer.Client;usingOmniSharp.Extensions.LanguageServer.Protocol.Models;namespaceOmniSharpClient{classProgram{staticasyncTaskMain(string[]args){varloggerFactory=newMicrosoft.Extensions.Logging.LoggerFactory();varomniSharpInfo=newProcessStartInfo{FileName=@"C:\Users\username\OneDrive\Scratch\LangServer\omnisharp-win-x64\OmniSharp.exe",Arguments=@"-lsp cake:enabled=false"//Arguments = @"-s C:\Users\username\Desktop\LangServer\ConsoleTest"};varcancellationSource=newCancellationTokenSource();cancellationSource.CancelAfter(TimeSpan.FromSeconds(30));using(varclient=newLanguageClient(loggerFactory,omniSharpInfo)){client.Window.OnLogMessage((stringmessage,MessageTypemessageType)=>{Console.WriteLine(message);});client.TextDocument.OnPublishDiagnostics(DiagnosticPublished);Console.WriteLine("Init...");awaitclient.Initialize(workspaceRoot:@"C:\Users\username\OneDrive\Scratch\LangServer\ConsoleTest",initializationOptions:new{},// If the server requires initialisation options, you pass them here.cancellationToken:cancellationSource.Token);awaitclient.IsReady;awaitTask.Delay(10000);varfileName=@"C:\Users\username\OneDrive\Scratch\LangServer\ConsoleTest\Program.cs";client.TextDocument.DidOpen(fileName,"csharp");//File.ReadAllText(fileName)awaitTask.Delay(3000);//client.TextDocument.DidClose(fileName);client.TextDocument.DidChange(fileName,"csharp",1);awaitTask.Delay(10000);Console.WriteLine("Shutdown...");awaitclient.Shutdown();}}publicstaticvoidDiagnosticPublished(UridocumentUri,List<Diagnostic>diagnostics){Console.WriteLine(documentUri);}}}
The text was updated successfully, but these errors were encountered:
I am trying to use the OmniSharp C# Language Client to get diagnostic information about a C# project. So far I have been unsuccessful in this attempt.
I have been able to start the omnisharp service and initialize but OnPublishDiagnostics never seems to fire. When attempting to open and change a document I get an exception on the server.
at OmniSharp.Cake.Services.CakeScriptService.Generate(FileChange fileChange) in D:\a\1\s\src\OmniSharp.Cake\Services\CakeScriptService.cs:line 55
I am not sure if this is an issue with the server, the client or me just understanding the protocol. Any guidance you could provide on the issue would be much appreciated. The code for my sample is below.
The text was updated successfully, but these errors were encountered: