Skip to content

[WIP] bring up to date with latest spec #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jan 8, 2018
Merged

Conversation

david-driscoll
Copy link
Member

@david-driscoll david-driscoll commented Dec 1, 2017

Things left to do...

  • Fix any build errors
  • Unit Tests of the changed bits
  • Unit Test the new bits
  • Synchronize the IXOptions interfaces with capabilities

Things to figure out

  • How do we want to enforce errors for things that are not supported by the old protocol?
    • In this case MarkedString was deprecated but it should still be supported for LSP 2.0 and existing LSP clients. We have contentFormat that we can run off of.
    • It feels like we'll have to refactor things and deal with instances of JsonSerializer or JsonSerializerSettings manually. Today we cheat and just use the static methods. With this latest change we have to adapt our serialization to what the editor supports.

@david-driscoll
Copy link
Member Author

Fair point I'll add a wrapper interface.

@codecov
Copy link

codecov bot commented Dec 6, 2017

Codecov Report

Merging #51 into master will increase coverage by 0.02%.
The diff coverage is 77.48%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #51      +/-   ##
==========================================
+ Coverage      70%   70.02%   +0.02%     
==========================================
  Files         223      211      -12     
  Lines        2830     2202     -628     
==========================================
- Hits         1981     1542     -439     
+ Misses        849      660     -189
Impacted Files Coverage Δ
...ization/Converters/BooleanNumberStringConverter.cs 86.66% <ø> (ø) ⬆️
src/Protocol/Models/DocumentFilter.cs 68.57% <ø> (ø) ⬆️
src/Protocol/Models/CodeActionContext.cs 100% <ø> (ø) ⬆️
...Protocol/Models/DocumentLinkRegistrationOptions.cs 100% <ø> (ø) ⬆️
...er/Capabilities/DocumentOnTypeFormattingOptions.cs 66.66% <ø> (ø) ⬆️
...els/DocumentOnTypeFormattingRegistrationOptions.cs 100% <ø> (ø) ⬆️
src/Protocol/Models/RegistrationParams.cs 100% <ø> (ø) ⬆️
...rotocol/Server/Capabilities/DocumentLinkOptions.cs 50% <ø> (ø) ⬆️
...ol/Serialization/Converters/NumberEnumConverter.cs 80% <ø> (ø) ⬆️
src/Protocol/Models/TextDocumentEdit.cs 100% <ø> (ø) ⬆️
... and 186 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 61c4255...69f9d6b. Read the comment docs.

@david-driscoll
Copy link
Member Author

cc @tintoy if you get a chance to look it over...

For serialization in the client I had to use a singleton instance of the new Serialzier, this needs to be fixed. Other than that all the serialization logic is now coupled to the Contract Resolver and Converter classes.

@tintoy
Copy link
Collaborator

tintoy commented Dec 6, 2017

I notice the empty notification handler delegate was removed - are notifications without payloads no longer supported?

@@ -50,7 +52,7 @@ public DelegateNotificationHandler(string method, NotificationHandler<TNotificat
await Task.Yield();

Handler(
notification != null ? notification.ToObject<TNotification>() : default(TNotification)
notification != null ? notification.ToObject<TNotification>(Serializer.Instance.JsonSerializer /* Fix me: this is ugly */) : default(TNotification)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I'm thinking maybe we could make the the JsonSerializerSettings assignable via a property on ICustomizeJsonSerializer (new interface with a SerializerSettings property that INotificationHandler and friends could inherit from)? Either that or pass it into the Invoke() methods but the property seems cleaner.

Copy link
Member Author

Choose a reason for hiding this comment

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

What if we change Invoke to take an object instead and deserialize the value before we call Invoke?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah that would be simpler - nice one :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Mind you, how do you know which type to deserialise into? I think that's why I did it in the handler because the parameter type is known.

Copy link
Collaborator

@tintoy tintoy Dec 7, 2017

Choose a reason for hiding this comment

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

I suppose the handler could expose a ParametersType / PayloadType property on IInvokeNotificationHandler / IInvokeRequestHandler?

@david-driscoll
Copy link
Member Author

I think I'm going to land this for now, and we can come back to the serialization problem. The behavior hasn't changed, the code just isn't as nice.

Let me know what you think.

@tintoy
Copy link
Collaborator

tintoy commented Dec 9, 2017

Sure works for me :)

@tintoy
Copy link
Collaborator

tintoy commented Dec 10, 2017

Want me to open a PR for fixing up the client serialiser stuff?

This is so the common JsonSerializerSettings can be used by the calling
code.

NOTE: This code is currently non-functional - handlers have been
modified to take an Object instead of a JObject but the calling code
does not yet perform deserialisation.
…ation

 Move payload deserialisation out of handlers
@david-driscoll
Copy link
Member Author

Getting back to things after the holidays, everything is passing, going to merge, let me know if you see any problems!

@david-driscoll david-driscoll merged commit cde3283 into master Jan 8, 2018
@david-driscoll david-driscoll deleted the refactor/protocol branch June 2, 2020 04:46
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.

2 participants