Skip to content

Commit e637b3f

Browse files
Started work on some starter documentation (#333)
* Started work on some starter documentation * Updated build chart * Updated DI note * moved generated references
1 parent e037110 commit e637b3f

File tree

4 files changed

+328
-43
lines changed

4 files changed

+328
-43
lines changed

README.md

+70-43
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
1-
[![nuget-server](https://img.shields.io/nuget/dt/OmniSharp.Extensions.LanguageServer?label=OmniSharp.Extensions.LanguageServer&logo=nuget)](https://www.nuget.org/packages/OmniSharp.Extensions.LanguageServer/)
2-
[![nuget-client](https://img.shields.io/nuget/dt/OmniSharp.Extensions.LanguageClient?label=OmniSharp.Extensions.LanguageClient&logo=nuget)](https://www.nuget.org/packages/OmniSharp.Extensions.LanguageClient/)
3-
[![codecov](https://img.shields.io/codecov/c/gh/OmniSharp/csharp-language-server-protocol?label=codecov&logo=codecov)](https://codecov.io/gh/OmniSharp/csharp-language-server-protocol)
4-
5-
## C# Language Server Protocol
1+
# C# Language Server Protocol
62

73
This is an implementation of the [Language Server Protocol](https://github.com/Microsoft/language-server-protocol) written entirely in C# for .NET.
84

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+
1037

1138
# Status
1239
<!-- badges -->
@@ -16,29 +43,49 @@ This is currently under heavy development and the API's are subject to change.
1643
<!-- badges -->
1744

1845
<!-- history badges -->
19-
| Azure Pipelines | GitHub Actions |
20-
| --------------- | -------------- |
21-
| [![azurepipelines-badge]][azurepipelines] | [![github-badge]][github] |
46+
| Azure Pipelines | GitHub Actions |
47+
| --------------------------------------------------------- | --------------------------------- |
48+
| [![azurepipelines-badge]][azurepipelines] | [![github-badge]][github] |
2249
| [![azurepipelines-history-badge]][azurepipelines-history] | [![github-history-badge]][github] |
2350
<!-- history badges -->
2451

2552
<!-- nuget packages -->
26-
| Package | NuGet |
27-
| ------- | ----- |
28-
| OmniSharp.Extensions.DebugAdapter | [![nuget-version-hefb6om79mfg-badge]![nuget-downloads-hefb6om79mfg-badge]][nuget-hefb6om79mfg] |
29-
| OmniSharp.Extensions.DebugAdapter.Client | [![nuget-version-94qjnkon/cda-badge]![nuget-downloads-94qjnkon/cda-badge]][nuget-94qjnkon/cda] |
30-
| OmniSharp.Extensions.DebugAdapter.Server | [![nuget-version-f/4jrt4grmdg-badge]![nuget-downloads-f/4jrt4grmdg-badge]][nuget-f/4jrt4grmdg] |
31-
| OmniSharp.Extensions.DebugAdapter.Shared | [![nuget-version-2fkn0yzdbhmg-badge]![nuget-downloads-2fkn0yzdbhmg-badge]][nuget-2fkn0yzdbhmg] |
32-
| OmniSharp.Extensions.DebugAdapter.Testing | [![nuget-version-jppuysmkpfcw-badge]![nuget-downloads-jppuysmkpfcw-badge]][nuget-jppuysmkpfcw] |
33-
| OmniSharp.Extensions.JsonRpc | [![nuget-version-a1bmkwyotvkg-badge]![nuget-downloads-a1bmkwyotvkg-badge]][nuget-a1bmkwyotvkg] |
34-
| OmniSharp.Extensions.JsonRpc.Testing | [![nuget-version-punkj7/efvjq-badge]![nuget-downloads-punkj7/efvjq-badge]][nuget-punkj7/efvjq] |
35-
| OmniSharp.Extensions.LanguageClient | [![nuget-version-fclou9t/p2ba-badge]![nuget-downloads-fclou9t/p2ba-badge]][nuget-fclou9t/p2ba] |
36-
| OmniSharp.Extensions.LanguageProtocol | [![nuget-version-vddj9t6jnirq-badge]![nuget-downloads-vddj9t6jnirq-badge]][nuget-vddj9t6jnirq] |
53+
| Package | NuGet |
54+
| --------------------------------------------- | ---------------------------------------------------------------------------------------------- |
55+
| OmniSharp.Extensions.DebugAdapter | [![nuget-version-hefb6om79mfg-badge]![nuget-downloads-hefb6om79mfg-badge]][nuget-hefb6om79mfg] |
56+
| OmniSharp.Extensions.DebugAdapter.Client | [![nuget-version-94qjnkon/cda-badge]![nuget-downloads-94qjnkon/cda-badge]][nuget-94qjnkon/cda] |
57+
| OmniSharp.Extensions.DebugAdapter.Server | [![nuget-version-f/4jrt4grmdg-badge]![nuget-downloads-f/4jrt4grmdg-badge]][nuget-f/4jrt4grmdg] |
58+
| OmniSharp.Extensions.DebugAdapter.Shared | [![nuget-version-2fkn0yzdbhmg-badge]![nuget-downloads-2fkn0yzdbhmg-badge]][nuget-2fkn0yzdbhmg] |
59+
| OmniSharp.Extensions.DebugAdapter.Testing | [![nuget-version-jppuysmkpfcw-badge]![nuget-downloads-jppuysmkpfcw-badge]][nuget-jppuysmkpfcw] |
60+
| OmniSharp.Extensions.JsonRpc | [![nuget-version-a1bmkwyotvkg-badge]![nuget-downloads-a1bmkwyotvkg-badge]][nuget-a1bmkwyotvkg] |
61+
| OmniSharp.Extensions.JsonRpc.Testing | [![nuget-version-punkj7/efvjq-badge]![nuget-downloads-punkj7/efvjq-badge]][nuget-punkj7/efvjq] |
62+
| OmniSharp.Extensions.LanguageClient | [![nuget-version-fclou9t/p2ba-badge]![nuget-downloads-fclou9t/p2ba-badge]][nuget-fclou9t/p2ba] |
63+
| OmniSharp.Extensions.LanguageProtocol | [![nuget-version-vddj9t6jnirq-badge]![nuget-downloads-vddj9t6jnirq-badge]][nuget-vddj9t6jnirq] |
3764
| OmniSharp.Extensions.LanguageProtocol.Testing | [![nuget-version-md8c3c/bo/8g-badge]![nuget-downloads-md8c3c/bo/8g-badge]][nuget-md8c3c/bo/8g] |
38-
| OmniSharp.Extensions.LanguageServer | [![nuget-version-fkxlzvrmzpbw-badge]![nuget-downloads-fkxlzvrmzpbw-badge]][nuget-fkxlzvrmzpbw] |
39-
| OmniSharp.Extensions.LanguageServer.Shared | [![nuget-version-4htmykprzq1a-badge]![nuget-downloads-4htmykprzq1a-badge]][nuget-4htmykprzq1a] |
65+
| OmniSharp.Extensions.LanguageServer | [![nuget-version-fkxlzvrmzpbw-badge]![nuget-downloads-fkxlzvrmzpbw-badge]][nuget-fkxlzvrmzpbw] |
66+
| OmniSharp.Extensions.LanguageServer.Shared | [![nuget-version-4htmykprzq1a-badge]![nuget-downloads-4htmykprzq1a-badge]][nuget-4htmykprzq1a] |
4067
<!-- nuget packages -->
4168

69+
## License
70+
71+
Copyright © .NET Foundation, and contributors.
72+
73+
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).
88+
4289
<!-- generated references -->
4390
[github-release]: https://github.com/OmniSharp/csharp-language-server-protocol/releases/latest
4491
[github-release-badge]: https://img.shields.io/github/release/OmniSharp/csharp-language-server-protocol.svg?logo=github&style=flat "Latest Release"
@@ -91,32 +138,12 @@ This is currently under heavy development and the API's are subject to change.
91138
[nuget-downloads-4htmykprzq1a-badge]: https://img.shields.io/nuget/dt/OmniSharp.Extensions.LanguageServer.Shared.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads"
92139
<!-- generated references -->
93140

94-
## License
95-
96-
Copyright © .NET Foundation, and contributors.
97-
98-
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).
113-
114141
<!-- nuke-data
115142
github:
116143
owner: OmniSharp
117144
repository: csharp-language-server-protocol
118145
azurepipelines:
119146
account: omnisharp
120-
teamproject: Build
147+
teamproject: Builds
121148
builddefinition: 1
122149
-->

docs/dap.md

Whitespace-only changes.

docs/jsonrpc.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Using Json Rpc Standalone
2+
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.
11+
12+
## Microsoft.Extensions.DependencyInjection
13+
14+
> `services.AddJsonRpcServer([string name, ], options => {})`
15+
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.
33+
* `options.OnJsonNotification` / `options.OnJsonRequest`
34+
* 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

Comments
 (0)