Skip to content

Commit bf617ef

Browse files
authored
feat(lsp): add --pipe parameter (#76351)
resolves #72871
2 parents bd782d4 + 6428ff4 commit bf617ef

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/LanguageServerTestComposition.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public static Task<ExportProvider> CreateExportProviderAsync(
3737
DevKitDependencyPath: devKitDependencyPath,
3838
RazorSourceGenerator: null,
3939
RazorDesignTimePath: null,
40-
ExtensionLogDirectory: string.Empty);
40+
ExtensionLogDirectory: string.Empty,
41+
ServerPipeName: null);
4142
var extensionManager = ExtensionAssemblyManager.Create(serverConfiguration, loggerFactory);
4243
assemblyLoader = new CustomExportAssemblyLoader(extensionManager, loggerFactory);
4344
return ExportProviderBuilder.CreateExportProviderAsync(extensionManager, assemblyLoader, devKitDependencyPath, cacheDirectory, loggerFactory);

src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ static async Task RunAsync(ServerConfiguration serverConfiguration, Cancellation
125125

126126
var languageServerLogger = loggerFactory.CreateLogger(nameof(LanguageServerHost));
127127

128-
var (clientPipeName, serverPipeName) = CreateNewPipeNames();
128+
var (clientPipeName, serverPipeName) = serverConfiguration.ServerPipeName is null
129+
? CreateNewPipeNames()
130+
: (serverConfiguration.ServerPipeName, serverConfiguration.ServerPipeName);
131+
129132
var pipeServer = new NamedPipeServerStream(serverPipeName,
130133
PipeDirection.InOut,
131134
maxNumberOfServerInstances: 1,
@@ -224,6 +227,12 @@ static CliRootCommand CreateCommandLineParser()
224227
Required = false
225228
};
226229

230+
var serverPipeNameOption = new CliOption<string?>("--pipe")
231+
{
232+
Description = "The name of the pipe the server will connect to.",
233+
Required = false,
234+
};
235+
227236
var rootCommand = new CliRootCommand()
228237
{
229238
debugOption,
@@ -236,7 +245,8 @@ static CliRootCommand CreateCommandLineParser()
236245
devKitDependencyPathOption,
237246
razorSourceGeneratorOption,
238247
razorDesignTimePathOption,
239-
extensionLogDirectoryOption
248+
extensionLogDirectoryOption,
249+
serverPipeNameOption
240250
};
241251
rootCommand.SetAction((parseResult, cancellationToken) =>
242252
{
@@ -250,6 +260,7 @@ static CliRootCommand CreateCommandLineParser()
250260
var razorSourceGenerator = parseResult.GetValue(razorSourceGeneratorOption);
251261
var razorDesignTimePath = parseResult.GetValue(razorDesignTimePathOption);
252262
var extensionLogDirectory = parseResult.GetValue(extensionLogDirectoryOption)!;
263+
var serverPipeName = parseResult.GetValue(serverPipeNameOption);
253264

254265
var serverConfiguration = new ServerConfiguration(
255266
LaunchDebugger: launchDebugger,
@@ -261,6 +272,7 @@ static CliRootCommand CreateCommandLineParser()
261272
DevKitDependencyPath: devKitDependencyPath,
262273
RazorSourceGenerator: razorSourceGenerator,
263274
RazorDesignTimePath: razorDesignTimePath,
275+
ServerPipeName: serverPipeName,
264276
ExtensionLogDirectory: extensionLogDirectory);
265277

266278
return RunAsync(serverConfiguration, cancellationToken);

src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/ServerConfigurationFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ internal record class ServerConfiguration(
5151
string? DevKitDependencyPath,
5252
string? RazorSourceGenerator,
5353
string? RazorDesignTimePath,
54+
string? ServerPipeName,
5455
string ExtensionLogDirectory);
5556

5657
internal class LogConfiguration

0 commit comments

Comments
 (0)