public override async Task DisposeAsync() { await LanguageClient.Shutdown(); await _psesProcess.Stop(); LanguageClient?.Dispose(); }
public override async Task DisposeAsync() { try { await LanguageClient.Shutdown(); await _psesProcess.Stop(); LanguageClient?.Dispose(); } catch (ObjectDisposedException) { // Language client has a disposal bug in it } }
/// <summary> /// The main asynchronous program entry-point. /// </summary> /// <returns> /// A <see cref="Task"/> representing program operation. /// </returns> static async Task AsyncMain() { ProcessStartInfo serverStartInfo = new ProcessStartInfo("dotnet") { Arguments = $"\"{ServerAssembly}\"" }; Log.Information("Starting server..."); LanguageClient client = new LanguageClient(Log.Logger, serverStartInfo) { ClientCapabilities = { Workspace = { DidChangeConfiguration = new DidChangeConfigurationCapability { DynamicRegistration = false } } } }; using (client) { // Listen for log messages from the language server. client.Window.OnLogMessage((message, messageType) => { Log.Information("Language server says: [{MessageType:l}] {Message}", messageType, message); }); // Listen for our custom notification from the language server. client.HandleNotification <DummyParams>("dummy/notify", notification => { Log.Information("Received dummy notification from language server: {Message}", notification.Message ); }); await client.Initialize(workspaceRoot : @"C:\Foo"); Log.Information("Client started."); // Update server configuration. client.Workspace.DidChangeConfiguration( new JObject( new JProperty("setting1", true), new JProperty("setting2", "Hello") ) ); // Invoke our custom handler. await client.SendRequest("dummy", new DummyParams { Message = "Hello, world!" }); Log.Information("Stopping language server..."); await client.Shutdown(); Log.Information("Server stopped."); } }