Code Monkey home page Code Monkey logo

Comments (5)

AArnott avatar AArnott commented on May 22, 2024

I faintly recall that we had a reason why we couldn't support this, but I don't remember it now. So perhaps it's fine. @tinaschrepfer might remember.

from vs-streamjsonrpc.

efoerster avatar efoerster commented on May 22, 2024

Are the any updates on this? It would be quite useful for implementing the Language Server Protocol.

from vs-streamjsonrpc.

AArnott avatar AArnott commented on May 22, 2024

@efoerster We haven't given this any further thought. Can you elaborate on how Language Server Protocol requires this? We have at least some LSP messages going over streamjsonrpc as it is today.

from vs-streamjsonrpc.

efoerster avatar efoerster commented on May 22, 2024

@AArnott It's not required. But with this limitation the signature of remote method has to be like this

    [JsonRpcMethod(Methods.TextDocumentDidOpen)]
    public void OnTextDocumentOpened(JToken arg)
    {
        var parameter = arg.ToObject<DidOpenTextDocumentParams>();
        ...
    }

Or do I miss something? Instead it would be pretty cool if we could avoid the manual conversion and deduce the type via reflection from the declaration in the target class:

    [JsonRpcMethod(Methods.TextDocumentDidOpen)]
    public void OnTextDocumentOpened(DidOpenTextDocumentParams arg)
    {
        ...
    }

from vs-streamjsonrpc.

AArnott avatar AArnott commented on May 22, 2024

@efoerster can you share an example of the JSON-RPC message itself (i.e. the json) that would invoke this method?

If the JToken you are receiving is actually a JObject that directly deserializes to a DidOpenTextDocumentParams, then once we support named arguments, the C# method would not look like what you've proposed, but rather it would take this form:

[JsonRpcMethod(Methods.TextDocumentDidOpen)]
public void OnTextDocumentOpened(TextDocumentItem TextDocument) {}

This is because per the json-rpc spec, when using the params object, each field on that object...

with member names that match the Server expected parameter names. The absence of expected names MAY result in an error being generated. The names MUST match exactly, including case, to the method's expected parameters.

So if the params object today in JSON is actually the serialized version of a DidOpenTextDocumentParams object, then that type's members (and not the type itself) must be what the method takes as parameters.

Does that raise any concerns for you?

from vs-streamjsonrpc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.