You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an implementation of the [Language Server Protocol](https://github.com/Microsoft/language-server-protocol) written entirely in C# for .NET.
8
4
9
-
This is currently under heavy development and the API's are subject to change.
5
+
# Getting Started
6
+
1. git clone
7
+
2. run `build.ps1` / `build.sh`
8
+
3. ...
9
+
4. Profit
10
+
11
+
# Concepts
12
+
13
+
## JSON-RPC
14
+
We have an implementation of JSON-RPC designed to implement the [JSON-RPC](https://www.jsonrpc.org/specification) as correctly as possible.
15
+
16
+
For more information about using the `JsonRpcServer` on it's own [here](./docs/jsonrpc.md).
17
+
18
+
## MediatR
19
+
Internally this library revolves around the request and response model. To make things easier we use [MediatR](https://github.com/jbogard/MediatR) as core piece that manages how requests and responses are handled.
20
+
21
+
## Microsoft.Extensions.*
22
+
We re-use some of the common packages used by .NET Core.
23
+
*`Microsoft.Extensions.Configuration` for common configuration
24
+
*`Microsoft.Extensions.DependencyInjection` for common Dependency Injection abstractions
25
+
*`Microsoft.Extensions.Logging` for logging.
26
+
27
+
## Language Server Protocol
28
+
We strive to ensure that we implement all the types, request and notifications that are defined by the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/). Sometimes this is difficult due to the nature of LSP TypeScript upbringing, but the goal is 100% conformance with the protocol itself.
29
+
30
+
For more information about using the `LanguageClient` / `LanguageServer` on it's own [here](./docs/lsp.md).
31
+
32
+
## Debug Adapter Protocol
33
+
We strive to ensure that we implement all the types, events and requests that are defined by the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/).
34
+
35
+
For more information about using the `DebugAdapterClient` / `DebugAdapterServer` on it's own [here](./docs/dap.md).
36
+
10
37
11
38
# Status
12
39
<!-- badges -->
@@ -16,29 +43,49 @@ This is currently under heavy development and the API's are subject to change.
OmniSharp is provided as-is under the MIT license. For more information see [LICENSE](https://github.com/OmniSharp/omnisharp-roslyn/blob/master/license.md).
74
+
75
+
## Code of Conduct
76
+
77
+
This project has adopted the code of conduct defined by the [Contributor Covenant](http://contributor-covenant.org/)
78
+
to clarify expected behavior in our community.
79
+
For more information see the [.NET Foundation Code of Conduct](http://www.dotnetfoundation.org/code-of-conduct).
80
+
81
+
## Contribution License Agreement
82
+
83
+
By signing the [CLA](https://cla.dotnetfoundation.org/OmniSharp/omnisharp-roslyn), the community is free to use your contribution to .NET Foundation projects.
84
+
85
+
## .NET Foundation
86
+
87
+
This project is supported by the [.NET Foundation](http://www.dotnetfoundation.org).
OmniSharp is provided as-is under the MIT license. For more information see [LICENSE](https://github.com/OmniSharp/omnisharp-roslyn/blob/master/license.md).
99
-
100
-
## Code of Conduct
101
-
102
-
This project has adopted the code of conduct defined by the [Contributor Covenant](http://contributor-covenant.org/)
103
-
to clarify expected behavior in our community.
104
-
For more information see the [.NET Foundation Code of Conduct](http://www.dotnetfoundation.org/code-of-conduct).
105
-
106
-
## Contribution License Agreement
107
-
108
-
By signing the [CLA](https://cla.dotnetfoundation.org/OmniSharp/omnisharp-roslyn), the community is free to use your contribution to .NET Foundation projects.
109
-
110
-
## .NET Foundation
111
-
112
-
This project is supported by the [.NET Foundation](http://www.dotnetfoundation.org).
One of the benefits of the [JSON-RPC protocol](https://www.jsonrpc.org/specification) is that communication can be fully bi-directional. Through some sort of interface agreement, like LSP / DAP, both sides can act as both client (sender) and server (reciever).
3
+
4
+
# Creating a JsonRpcServer
5
+
`JsonRpcServer` can be created through two methods.
6
+
7
+
## Standalone
8
+
9
+
> `JsonRpcServer.Create(options => {})`
10
+
This will create a server where you provide options, handlers and more. An optional `IServiceProvider` can be provided that will be used as a fallback container when `IJsonRcpHandlers` are being resolved.
This will add `JsonRpcServer` to your service collection, or any number of named `JsonRpcServer`s.
16
+
17
+
* In the event that you add multiple named servers, they must be resolved using `JsonRpcServerResolver`.
18
+
19
+
When created through Microsoft DI the server will use the `IServiceProvider` as a fallback when resolving `IJsonRpcHandlers`.
20
+
21
+
## Options
22
+
23
+
Some of the important options include...
24
+
25
+
*`options.WithInput()` takes an input `Stream` or `PipeReader`
26
+
*`options.WithOutput()` takes an output `Stream` or `PipeWriter`
27
+
*`options.WithAssemblies()` takes additional assemblies that will participate in scanning operations.
28
+
* Sometimes we scan this list of assemblies for potential strongly typed requests and notifications
29
+
*`options.AddHandler` allows you to add handlers that implement `IJsonRpcNotificationHandler<>`, `IJsonRpcRequestHandler<>`, `IJsonRpcRequestHandler<,>`.
30
+
* Handlers can be added as an instance, type or a factory that is given a `IServiceProvider`
31
+
*`options.OnNotification` / `options.OnRequest`
32
+
* These methods can be used to create handler delegates without having to implement the request interfaces.
* These methods can be used to create handler delegates without having to implement the request interfaces.
35
+
* These json `JToken` an the request / response types.
36
+
*`options.WithMaximumRequestTimeout()`
37
+
* Sets the maximum timeout before a request is cancelled
38
+
* Defaults to 5 minutes
39
+
*`options.WithSupportsContentModified()`
40
+
* Sets the into a special model that is used more for Language Server Protocol.
41
+
* In this mode any `Serial` request will cause any outstanding `Parallel` requests will be cancelled with an error message.
42
+
*`options.WithRequestProcessIdentifier()`
43
+
* This allows you to control how requests are "identified" or how they will behave (Serial / Parallel)
44
+
45
+
## Testing
46
+
47
+
We have some helper classes that can be used to aid in Unit Testing such as `JsonRpcServerTestBase`.
48
+
49
+
## Handlers
50
+
Handlers can be implemented as classes that implement `IJsonRpcNotificationHandler<>`, `IJsonRpcRequestHandler<>`, `IJsonRpcRequestHandler<,>` or as delegates on the `JsonRpcServer` itself.
51
+
52
+
Additionally handlers can be dynamically added and removed after the server has been initialized by using the registry.
53
+
54
+
`server.Register(registry => {})` will return an `IDisposable` that can be used to remove all the handlers that were registered at that time.
0 commit comments