OmniSharp / OmniSharp/csharp-language-server-protocol

JSON RPC documentation or example app request

Open
#652 3 comments 0 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

Would it be possible to add to the documentation or as an example app something like:

using MediatR;
using Microsoft.Extensions.Hosting;
using OmniSharp.Extensions.JsonRpc;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static Task Main(string[] args) =>
            new HostBuilder()
                .ConfigureServices((context, services) =>
                    services.AddJsonRpcServer(options =>
                        options
                            .WithInput(Console.OpenStandardInput())
                            .WithOutput(Console.OpenStandardOutput())
                            .WithHandler<PingHandler>()))
                .Build()
                .RunAsync();

        class PingHandler : IJsonRpcRequestHandler<PingHandler.PingRequest, PingHandler.PongResponse>
        {
            [Method("ping", Direction.ClientToServer)]
            public Task<PongResponse> Handle(PingRequest request, CancellationToken cancellationToken)
            {
                return Task.FromResult(new PongResponse
                {
                    pong = request.ping + 1
                });
            }

            public class PongResponse
            {
                public int pong;
            }

            public class PingRequest : IRequest<PongResponse>
            {
                public int ping;
            }
        }
    }
}

It requres the nuget packages:

Microsoft.Extensions.Hosting
OmniSharp.Extensions.JsonRpc

When run, it should be able to read from the terminal something like:

{ "jsonrpc":"2.0", "id":2, "method": "ping", "params": { "ping": 41 }}

and throw out a { pong: 42} response.

It currently doesn't work, it never creates the json rpc service really, I will be checking now the source code of the tests, but if there was a minimal working example app, it'd get me going much faster, it'd probably help with the adoption of this tool as well.

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 by reading the existing JSON-RPC tests and compare them with the supplied host setup using Microsoft.Extensions.Hosting and OmniSharp.Extensions.JsonRpc. Verify the terminal request and response flow, then document or package a minimal working example that produces the expected pong response.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
documentation
Issue type
Documentation
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.