csharp-language-server-protocol
csharp-language-server-protocol copied to clipboard
While initializing an LSP client, how to set ProcessId in InitializeParams
While initializing an LSP client, is there a way to set InitializeParams.ProcessId? This code:
public async Task Initialize(CancellationToken token)
{
var @params = new InitializeParams {
Trace = _trace,
ClientInfo = _clientInfo,
Capabilities = _clientCapabilities,
RootUri = _rootUri!,
RootPath = _rootUri?.GetFileSystemPath() ?? string.Empty,
WorkspaceFolders = new Container<WorkspaceFolder>(WorkspaceFoldersManager.CurrentWorkspaceFolders),
InitializationOptions = _initializationOptions!
};
Doesn't seem to include ProcessId from anywhere. Some servers require ProcessId to be set, so I came up with the following workaround:
options.OnInitialize(OnInitialize);
//...
private Task OnInitialize(ILanguageClient client, InitializeParams request, CancellationToken cancellationToken)
{
request.GetType().GetProperty("ProcessId").SetValue(request, (long)System.Diagnostics.Process.GetCurrentProcess().Id);
return Task.CompletedTask;
}
Is there a proper way to accomplish this?
That is an effective workaround... however this should be handled better I would think. I'll take a look.