protected override async Task Initialize() { // Add handlers for common events this.SetEventHandler(PublishDiagnosticsNotification.Type, HandlePublishDiagnosticsEvent); // Send the 'initialize' request and wait for the response var initializeRequest = new InitializeRequest { RootPath = "", Capabilities = new ClientCapabilities() }; await this.SendRequest( InitializeRequest.Type, initializeRequest); }
public void Start() { // If the test is running in the debugger, tell the language // service to also wait for the debugger string languageServiceArguments = string.Empty; if (System.Diagnostics.Debugger.IsAttached) { languageServiceArguments = "/waitForDebugger"; } this.languageServiceProcess = new System.Diagnostics.Process { StartInfo = new ProcessStartInfo { FileName = "Microsoft.PowerShell.EditorServices.Host.exe", Arguments = languageServiceArguments, CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true, StandardOutputEncoding = Encoding.UTF8, }, EnableRaisingEvents = true, }; // Start the process this.languageServiceProcess.Start(); // Attach to the language service process if debugging if (System.Diagnostics.Debugger.IsAttached) { AttachToProcessIfDebugging(this.languageServiceProcess.Id); } IMessageSerializer messageSerializer = new JsonRpcMessageSerializer(); // Open the standard input/output streams this.inputStream = this.languageServiceProcess.StandardOutput.BaseStream; this.outputStream = this.languageServiceProcess.StandardInput.BaseStream; // Set up the message reader and writer this.MessageReader = new MessageReader( this.inputStream, messageSerializer); this.MessageWriter = new MessageWriter( this.outputStream, messageSerializer); // Send the 'initialize' request and wait for the response var initializeRequest = new InitializeRequest { RootPath = "", Capabilities = new ClientCapabilities() }; // TODO: Assert some capability data? this.MessageWriter.WriteRequest(InitializeRequest.Type, initializeRequest, 1).Wait(); Message initializeResponse = this.MessageReader.ReadMessage().Result; }