/// <nodoc /> public void Dispose() { Logger.LanguageServerStopped(LoggingContext); m_mainRpcChannel.Dispose(); m_projectManagementProvider = null; var workspaceLoadTask = LoadWorkspaceAsync(); if (workspaceLoadTask.IsCompleted) { workspaceLoadTask.Result.Item2?.Dispose(); } m_tracer?.Dispose(); }
/// <summary> /// Initializes a new instance of the <see cref="JsonRpc"/> class and immediately starts listening. /// </summary> /// <param name="sendingStream">The stream used to transmit messages. May be null.</param> /// <param name="receivingStream">The stream used to receive messages. May be null.</param> /// <param name="target">An optional target object to invoke when incoming RPC requests arrive.</param> /// <returns>The initialized and listening <see cref="JsonRpc"/> object.</returns> public static JsonRpc Attach(Stream sendingStream, Stream receivingStream, object target = null) { if (sendingStream == null && receivingStream == null) { throw new ArgumentException(Resources.BothReadableWritableAreNull); } var rpc = new JsonRpc(sendingStream, receivingStream, target); try { if (receivingStream != null) { rpc.StartListening(); } return(rpc); } catch { rpc.Dispose(); throw; } }