omnisharp-roslyn icon indicating copy to clipboard operation
omnisharp-roslyn copied to clipboard

Provide documentation/example of communication

Open mickaelistria opened this issue 8 years ago • 8 comments

I didn't manage to find any documentation or example of how requests/answers between OmniSharp-roslyn server and whethever client should look like. I've seem some clients doing that (for Vim, VSCode or Atom) and I tried to mimic what I thought would be necessary, without much success.

I also tried the example request shown on omnisharp-sever, but this one fail too.

Usually, the error I get with my (erroneous?) requests is

      An unhandled exception has occurred: Must be able aggregate the response to spread them out across all plugins for /autocomplete
System.NotSupportedException: Must be able aggregate the response to spread them out across all plugins for /autocomplete
   at OmniSharp.Middleware.Endpoint.EndpointHandler`2.<HandleAllRequest>d__19.MoveNext() in /home/travis/build/OmniSharp/omnisharp-roslyn/src/OmniSharp.Host/Middleware/Endpoint/EndpointHandler.cs:line 202

mickaelistria avatar Jul 07 '16 12:07 mickaelistria

@mickaelistria

Start the server

OmniSharp -v -s /path/to/my/project/

-v is important so you can see what the response looks like.

Omnisharp starts a webserver listening at localhost:2000 by default.

Query the server

See all the http endpoints available here.

You can then use curl to experiment.

Find the usage of each enum values and see which Request class is associated so you can know what parameters each endpoint expect.

Let's take an example.

GotoDefinition

The endpoint enumeration is GoToDefinition therefore the url will be http://localhost:2000/gotodefinition. After searching for its usages we can see it's used in the class GotoDefinitionRequest which inherits from Request. Each properties on those classes represent the http request parameters. Here are all the properties:

Line
Column
Buffer
Changes
FileName
Timeout
WantMetadata

From my experience I know that when you need to go to the definition of a symbol you need to at least send to the server the line, column and file name values (the rest are optional, ie. it won't blow up).

With this we can craft this query: curl -H "Content-Type: application/json" -X POST -d '{"Line":"31","Column":"26", "FileName":"/absolute/path/to/filename.cs"}' http://localhost:2000/gotodefinition

We should get the response back: {"FileName":"/absolute/path/to/method/file.cs","Line":34,"Column":46,"MetadataSource":null}

Hope that helps.

jtbm37 avatar Jul 09 '16 19:07 jtbm37

@jtbm37 Thanks, that's very helpful, and I made progress thanks to your help. Is there a way to set the workspace "remotely", using some HTTP request to load it instead of using the -s /path/to/project CLI parameter?

mickaelistria avatar Jul 11 '16 16:07 mickaelistria

@mickaelistria did you get things running in the end? I'm doing the same thing you did back in July, m first request works then the second fails, did you come against a similar problem?

danwalmsley avatar Aug 30 '16 21:08 danwalmsley

As I'm working on a client for a Java application (Eclipse, https://github.com/eclipselabs/eclipse-language-service ) and moved using the https://github.com/OmniSharp/omnisharp-node-client wrapper around OmniSharp, which implements https://github.com/Microsoft/language-server-protocol, I could use a nice Java client API ( https://github.com/TypeFox/ls-api ). The node client can understand JSon-RPC requests via stdin/stdout.

mickaelistria avatar Aug 31 '16 06:08 mickaelistria

@mickaelistria thanks, fyi it turned out verbose mode was breaking it. I opened issue #629 regarding that.

Thanks anyway

danwalmsley avatar Aug 31 '16 15:08 danwalmsley

A request from @thinca in the omnisharp-vim repo along the same lines as this request for (more) documentation:

I want:

  • API reference, which describes all endpoints, and its input and output.
  • Command line reference of OmniSharp command.
  • About stdio mode.

I understand manpower is not enough. However, it is difficult for non core member of omnisharp-roslyn to follow the latest version without documentation.

willl avatar Sep 27 '16 05:09 willl

So, is there a way to do what @mickaelistria wanted to do on https://github.com/OmniSharp/omnisharp-roslyn/issues/606#issuecomment-231793946 ? Or should I open a new issue for this?

JulCesWhat avatar Feb 15 '18 17:02 JulCesWhat

@jtbm37

Start the server

OmniSharp -v -s /path/to/my/project/

Unfortunately I failed at the first step on macOS, see #2440.

+1 for creating some documentation around how to get started

NxSoftware avatar Aug 20 '22 15:08 NxSoftware