OmniSharp / OmniSharp/csharp-language-server-protocol

While initializing an LSP client, how to set ProcessId in InitializeParams

Open
#576 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
638
Forks
109
Avg merge
1m
Merged PRs (30d)
2

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Initialize method and its InitializeParams construction shown in the issue, then trace how the LSP client sends that request. Check how the OnInitialize callback is applied and whether ProcessId has a supported configuration path. Done means the client can set ProcessId without reflection and the value reaches servers that require it.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.