OmniSharp / OmniSharp/csharp-language-server-protocol

sample project does not connect over stdio channel in vscode

Open
#1,176 0 comments 4 reactions 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

This library looks like an incredible project, so first off, thank you!

I was trying to get up and running with a vs-code extension client for the server, and following the sample project in this repo, I was having a devil of a time.
I got it working by changing vs-code to use the TransporkKind.pipe instead of stdio.

In the Program.cs, I did something like this,

public static class Program
{
    public static async Task Main(string[] args)
    {
        var pipeAddr = "";
        foreach (var t in args)
        {
            if (!t.StartsWith("--pipe=")) continue;
            
            pipeAddr = t.Substring("--pipe=".Length);
            break;
        }
        
        Log.Logger = new LoggerConfiguration()
            .Enrich.FromLogContext()
            .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day)
            .MinimumLevel.Verbose()
            .CreateLogger();
        
        var pipeClient = new NamedPipeClientStream(pipeAddr);
        await pipeClient.ConnectAsync();
        
        Log.Logger.Information("connected.");

       // the LanguageServer.From( .... goes here

And then when creating the input/output for the language server, doing this,

  .WithInput(pipeClient.UsePipeReader())
  .WithOutput(pipeClient.UsePipeWriter())

If I used stdio and the listed sample code to get the input/output streams from Console, then I would get errors from vscode about Content-Length not being supplied on the messages.

I mostly wanted to leave this here as a trace in case anyone else found it useful.

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 sample project's Program.cs and its Console-based input/output setup, then reproduce the VS Code client failure where messages lack Content-Length. Compare that path with the reported NamedPipeClientStream and LanguageServer input/output setup. Done means the sample communicates over stdio with VS Code without the Content-Length error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.