Skip to content

Conversation

david-driscoll
Copy link
Member

@david-driscoll david-driscoll commented May 22, 2020

So yeah... this is huge, sorry for that.

This includes the pipeline changes (and revealed a few problems with the InputHandler)

This rewrites the LanguageClient to be the LanguageServer just in reverse. Same design but mirrored methods. (ie. The server will PublishDiagostics and the client will have an IPublishDiagnosticsHandler to recieve them).

As a core part of this change the goal is to ensure consistency between handlers. This has introduced a few things.

JsonRpc

  • MethodAttribute has a new (optional) enum added to it for the Direction this handler, which is just used a hint for a JsonRpcServer. Direction is required for both LSP and DAP protocols however, if it's missing there is a unit test which will fail.

LSP/DAP

  • All request classes now require a method attribute. This method must match the method defined on the handler.
  • All method definitions must have a direction on them.
    • This used to ensure that there are appropriate methods and classes for both sending and recieving events.
  • Extension Methods Refactored
    • Notifications are "fire an forget" for the caller, on the callee side they might take a while, so notifications have overloads for async and sync.

LSP

  • Extension Methods Refactored
    • Requests that support IPartialResultRequest or IPartialResultsRequest have an overload for dealing with partial results
  • Progress is now supported via the all new IProgressManager
    • The server or client and monitor results sent by the other side.
  • Partial Results Progress is now supported by the new IProgressManager ( https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#partialResults )
    • The server implement logic using partial results even if the client does not support them, they will automatically be translated into the correct response object for you using MonitorUntil
    • The client will return a TaskLike object that is both an IObservable<T> and { GetAwaiter(): TaskAwaiter<TResponse> }
      • awaiting or observing should be transparent to the consumer.
  • Work Done Progress is now supported bt the new IServerWorkDoneManager and IClientWorkDoneManager ( https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workDoneProgress )
    • There is an extension method that works with IClientProxy for sending requests, which will enrich the request with a work done token.
    • There is then a method on IServerWorkDoneManager that is safe to call on IWorkDoneProgressParams even if workdone is not set, it will just be an Observer that goes no where

LSP/DAP Unit Testing

  • Unit testing is now a first class citizen with 3 new projects
    • OmniSharp.Extensions.JsonRpc.Testing - Enables base testing support for both a generic server (lsp/dap) and JsonRpcServer
    • OmniSharp.Extensions.DebugAdapter.Testing
    • OmniSharp.Extensions.LanguageProtocol.Testing
  • Unit Test classes are framework agnostic (no dependency on XUnit by default)
    • Includes settings for test timeout (with a CancellationToken)
    • Includes the ability to wait for servers and/or clients to Settle to ensure state is consistent on both sides
    • Logging is supported on both sides, so it can be tied into framework specific features (ie via ITestOutputHandler)

With the new client we now have the ability to test the library in both directions to help improve code coverage as well as help with developing tests for corner cases (such as servers that don't support dynamic registration for example).

@david-driscoll david-driscoll changed the base branch from master to feature/handlers-refactor May 22, 2020 02:29
@david-driscoll david-driscoll changed the base branch from feature/handlers-refactor to master May 22, 2020 02:40
… handler that uses the new pipelines for lower allocations of incomming data. Added validation tests for handler methods to ensure that all required methods exist when new handlers are added
@david-driscoll david-driscoll force-pushed the feature/client-refactor branch from 1d5d6c1 to cdfbbb9 Compare May 22, 2020 02:41
@codecov
Copy link

codecov bot commented May 22, 2020

Codecov Report

Merging #248 into master will increase coverage by 28.75%.
The diff coverage is 67.30%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #248       +/-   ##
===========================================
+ Coverage   33.37%   62.12%   +28.75%     
===========================================
  Files         391      383        -8     
  Lines       11626    11483      -143     
  Branches     1459     1361       -98     
===========================================
+ Hits         3880     7134     +3254     
+ Misses       7420     3782     -3638     
- Partials      326      567      +241     
Impacted Files Coverage Δ
...dapterConverters/DapClientNotificationConverter.cs 86.36% <ø> (+86.36%) ⬆️
...ebugAdapterConverters/DapClientRequestConverter.cs 83.33% <ø> (+83.33%) ⬆️
...bugAdapterConverters/DapClientResponseConverter.cs 84.61% <ø> (+84.61%) ⬆️
src/Dap.Protocol/Events/BreakpointExtensions.cs 80.00% <ø> (+80.00%) ⬆️
src/Dap.Protocol/Events/CapabilitiesExtensions.cs 80.00% <ø> (+80.00%) ⬆️
src/Dap.Protocol/Events/ContinuedExtensions.cs 80.00% <ø> (+80.00%) ⬆️
src/Dap.Protocol/Events/ExitedExtensions.cs 80.00% <ø> (+80.00%) ⬆️
src/Dap.Protocol/Events/InitializedExtensions.cs 80.00% <ø> (+80.00%) ⬆️
src/Dap.Protocol/Events/LoadedSourceExtensions.cs 80.00% <ø> (+80.00%) ⬆️
src/Dap.Protocol/Events/ModuleExtensions.cs 80.00% <ø> (+80.00%) ⬆️
... and 391 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bdec4c7...f76c619. Read the comment docs.

Copy link
Collaborator

@tintoy tintoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go for it - after this, it looks like none of the original client code is left in there but at least that's one less thing for me to worry about 🙂

…pogation of cancelled results back to the caller. Also fixed an issue where request cancellation was not working. Also request cancellation would not throw custom exceptions for anyone that was task like.
…e that the JToken is not sent through the serailzier (this ensure that the casing stays correct)
…/parallel)

Fixed a bug where things would lock due to response tasks being set in the same thread.
Copy link
Collaborator

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've battle tested this code pretty well :D

@david-driscoll david-driscoll merged commit 21f56ec into master Jun 2, 2020
@david-driscoll david-driscoll deleted the feature/client-refactor branch June 2, 2020 04:01
@TylerLeonhardt TylerLeonhardt mentioned this pull request Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants