Skip to content

Commit 6638e15

Browse files
committed
add namedpipe type
1 parent 3f89b8a commit 6638e15

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { RoslynLanguageServerEvents } from './languageServerEvents';
5454
import { registerShowToastNotification } from './showToastNotification';
5555
import { registerRazorCommands } from './razorCommands';
5656
import { registerOnAutoInsert } from './onAutoInsert';
57+
import { NamedPipeInformation } from './roslynProtocol';
5758

5859
let _channel: vscode.OutputChannel;
5960
let _traceChannel: vscode.OutputChannel;
@@ -62,11 +63,6 @@ let _traceChannel: vscode.OutputChannel;
6263
// Used to determine if we need to restart the server on extension changes.
6364
let _wasActivatedWithCSharpDevkit: boolean | undefined;
6465

65-
interface TransmittedInformation {
66-
Key: string;
67-
Value: string;
68-
}
69-
7066
export class RoslynLanguageServer {
7167
// These are notifications we will get from the LSP server and will forward to the Razor extension.
7268
private static readonly provideRazorDynamicFileInfoMethodName: string = 'razor/provideDynamicFileInfo';
@@ -80,7 +76,7 @@ export class RoslynLanguageServer {
8076
/**
8177
* The regular expression used to find the named pipe key in the LSP server's stdout stream.
8278
*/
83-
private static readonly namedPipeKeyRegex = /{"Key":"NamedPipeInformation","Value":"[^"]+"}/;
79+
private static readonly namedPipeKeyRegex = /{"pipeName":"[^"]+"}/;
8480

8581
/**
8682
* The timeout for stopping the language server (in ms).
@@ -560,15 +556,15 @@ export class RoslynLanguageServer {
560556

561557
// The server process will create the named pipe used for communcation. Wait for it to be created,
562558
// and listen for the server to pass back the connection information via stdout.
563-
const namedPipeConnectionPromise = new Promise<TransmittedInformation>((resolve) => {
559+
const namedPipeConnectionPromise = new Promise<NamedPipeInformation>((resolve) => {
564560
childProcess.stdout.on('data', (data: { toString: (arg0: any) => any }) => {
565561
const result: string = isString(data) ? data : data.toString(RoslynLanguageServer.encoding);
566562
_channel.append('[stdout] ' + result);
567563

568564
// Use the regular expression to find all JSON lines
569565
const jsonLines = result.match(RoslynLanguageServer.namedPipeKeyRegex);
570566
if (jsonLines) {
571-
const transmittedPipeNameInfo: TransmittedInformation = JSON.parse(jsonLines[0]);
567+
const transmittedPipeNameInfo: NamedPipeInformation = JSON.parse(jsonLines[0]);
572568
_channel.appendLine('received named pipe information from server');
573569
resolve(transmittedPipeNameInfo);
574570
}
@@ -581,7 +577,7 @@ export class RoslynLanguageServer {
581577

582578
const socketPromise = new Promise<net.Socket>((resolve) => {
583579
_channel.appendLine('attempting to connect client to server...');
584-
const socket = net.createConnection(pipeConnectionInfo.Value, () => {
580+
const socket = net.createConnection(pipeConnectionInfo.pipeName, () => {
585581
_channel.appendLine('client has connected to server');
586582
resolve(socket);
587583
});

src/lsptoolshost/roslynProtocol.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ export interface BuildOnlyDiagnosticIdsResult {
141141
ids: string[];
142142
}
143143

144+
export interface NamedPipeInformation {
145+
pipeName: string;
146+
}
147+
144148
export namespace WorkspaceDebugConfigurationRequest {
145149
export const method = 'workspace/debugConfiguration';
146150
export const messageDirection: lsp.MessageDirection = lsp.MessageDirection.clientToServer;

0 commit comments

Comments
 (0)