diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/LanguageServerTestComposition.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/LanguageServerTestComposition.cs index 98273baaa9111..33d4eb6fcc734 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/LanguageServerTestComposition.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/LanguageServerTestComposition.cs @@ -37,7 +37,8 @@ public static Task CreateExportProviderAsync( DevKitDependencyPath: devKitDependencyPath, RazorSourceGenerator: null, RazorDesignTimePath: null, - ExtensionLogDirectory: string.Empty); + ExtensionLogDirectory: string.Empty, + ServerPipeName: null); var extensionManager = ExtensionAssemblyManager.Create(serverConfiguration, loggerFactory); assemblyLoader = new CustomExportAssemblyLoader(extensionManager, loggerFactory); return ExportProviderBuilder.CreateExportProviderAsync(extensionManager, assemblyLoader, devKitDependencyPath, cacheDirectory, loggerFactory); diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs index 908ea6f6ce55f..e054470b1b666 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs @@ -125,7 +125,10 @@ static async Task RunAsync(ServerConfiguration serverConfiguration, Cancellation var languageServerLogger = loggerFactory.CreateLogger(nameof(LanguageServerHost)); - var (clientPipeName, serverPipeName) = CreateNewPipeNames(); + var (clientPipeName, serverPipeName) = serverConfiguration.ServerPipeName is null + ? CreateNewPipeNames() + : (serverConfiguration.ServerPipeName, serverConfiguration.ServerPipeName); + var pipeServer = new NamedPipeServerStream(serverPipeName, PipeDirection.InOut, maxNumberOfServerInstances: 1, @@ -224,6 +227,12 @@ static CliRootCommand CreateCommandLineParser() Required = false }; + var serverPipeNameOption = new CliOption("--pipe") + { + Description = "The name of the pipe the server will connect to.", + Required = false, + }; + var rootCommand = new CliRootCommand() { debugOption, @@ -236,7 +245,8 @@ static CliRootCommand CreateCommandLineParser() devKitDependencyPathOption, razorSourceGeneratorOption, razorDesignTimePathOption, - extensionLogDirectoryOption + extensionLogDirectoryOption, + serverPipeNameOption }; rootCommand.SetAction((parseResult, cancellationToken) => { @@ -250,6 +260,7 @@ static CliRootCommand CreateCommandLineParser() var razorSourceGenerator = parseResult.GetValue(razorSourceGeneratorOption); var razorDesignTimePath = parseResult.GetValue(razorDesignTimePathOption); var extensionLogDirectory = parseResult.GetValue(extensionLogDirectoryOption)!; + var serverPipeName = parseResult.GetValue(serverPipeNameOption); var serverConfiguration = new ServerConfiguration( LaunchDebugger: launchDebugger, @@ -261,6 +272,7 @@ static CliRootCommand CreateCommandLineParser() DevKitDependencyPath: devKitDependencyPath, RazorSourceGenerator: razorSourceGenerator, RazorDesignTimePath: razorDesignTimePath, + ServerPipeName: serverPipeName, ExtensionLogDirectory: extensionLogDirectory); return RunAsync(serverConfiguration, cancellationToken); diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/ServerConfigurationFactory.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/ServerConfigurationFactory.cs index e7a3c79ef06ab..25b4bceaf754f 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/ServerConfigurationFactory.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/ServerConfigurationFactory.cs @@ -51,6 +51,7 @@ internal record class ServerConfiguration( string? DevKitDependencyPath, string? RazorSourceGenerator, string? RazorDesignTimePath, + string? ServerPipeName, string ExtensionLogDirectory); internal class LogConfiguration