Giter Site home page Giter Site logo

Comments (7)

razzmatazz avatar razzmatazz commented on July 28, 2024

hey @ianzhang366, thank you for your kind words;

I am running/testing csharp-ls on both m1 mac and linux, so things should be ok.

as for your problem, I believe this is how it should be, when you start csharp-ls it enters LSP protocol mode where it waits for initialize command from the editor -- thus there is no output.

you can verify things work by running it with --help or --version parameter:

bob@mbp ~ % csharp-ls --help
USAGE: csharp-ls [--help] [--version] [--loglevel <level>] [--solution <solution>]

OPTIONS:

    --version, -v         display versioning information
    --loglevel, -l <level>
                          log level, <log|info|warning|error>; default is `log`
    --solution, -s <solution>
                          .sln file to load (relative to CWD)
    --help                display this list of options.

bob@mbp ~ %

what are you trying to achieve?

from csharp-language-server.

ianzhang366 avatar ianzhang366 commented on July 28, 2024

Hi @razzmatazz thanks for your reply.

I'm trying to setup csharp-ls on acme editor with acme-lsp.

Now, I'm seeing the go to definition request goes to csharp-ls and gets a response, but it seems the acme-lsp don't know how to handle the response...

acme-lsp: $HOME/golang/src/acme-lsp/internal/golang_org_x_tools/jsonrpc2/jsonrpc2.go:144:  Call, method: "textDocument/definition"
acme-lsp: $HOME/golang/src/acme-lsp/internal/golang_org_x_tools/jsonrpc2/jsonrpc2.go:197:   Call, method: "textDocument/definition": response: "[{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1038,\"character\":20,\"debuggerDisplay\":\"(1038,20)\"},\"end\":{\"line\":1038,\"character\":29,\"debuggerDisplay\":\"(1038,29)\"},\"debuggerDisplay\":\"(1038,20)-(1038,29)\"}},{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1045,\"character\":20,\"debuggerDisplay\":\"(1045,20)\"},\"end\":{\"line\":1045,\"character\":29,\"debuggerDisplay\":\"(1045,29)\"},\"debuggerDisplay\":\"(1045,20)-(1045,29)\"}},{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1052,\"character\":20,\"debuggerDisplay\":\"(1052,20)\"},\"end\":{\"line\":1052,\"character\":29,\"debuggerDisplay\":\"(1052,29)\"},\"debuggerDisplay\":\"(1052,20)-(1052,29)\"}},{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1074,\"character\":20,\"debuggerDisplay\":\"(1074,20)\"},\"end\":{\"line\":1074,\"character\":29,\"debuggerDisplay\":\"(1074,29)\"},\"debuggerDisplay\":\"(1074,20)-(1074,29)\"}},{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1081,\"character\":20,\"debuggerDisplay\":\"(1081,20)\"},\"end\":{\"line\":1081,\"character\":29,\"debuggerDisplay\":\"(1081,29)\"},\"debuggerDisplay\":\"(1081,20)-(1081,29)\"}},{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1088,\"character\":20,\"debuggerDisplay\":\"(1088,20)\"},\"end\":{\"line\":1088,\"character\":29,\"debuggerDisplay\":\"(1088,29)\"},\"debuggerDisplay\":\"(1088,20)-(1088,29)\"}},{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1095,\"character\":20,\"debuggerDisplay\":\"(1095,20)\"},\"end\":{\"line\":1095,\"character\":29,\"debuggerDisplay\":\"(1095,29)\"},\"debuggerDisplay\":\"(1095,20)-(1095,29)\"}},{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1102,\"character\":20,\"debuggerDisplay\":\"(1102,20)\"},\"end\":{\"line\":1102,\"character\":29,\"debuggerDisplay\":\"(1102,29)\"},\"debuggerDisplay\":\"(1102,20)-(1102,29)\"}},{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1109,\"character\":20,\"debuggerDisplay\":\"(1109,20)\"},\"end\":{\"line\":1109,\"character\":29,\"debuggerDisplay\":\"(1109,29)\"},\"debuggerDisplay\":\"(1109,20)-(1109,29)\"}},{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1116,\"character\":20,\"debuggerDisplay\":\"(1116,20)\"},\"end\":{\"line\":1116,\"character\":29,\"debuggerDisplay\":\"(1116,29)\"},\"debuggerDisplay\":\"(1116,20)-(1116,29)\"}},{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1171,\"character\":20,\"debuggerDisplay\":\"(1171,20)\"},\"end\":{\"line\":1171,\"character\":29,\"debuggerDisplay\":\"(1171,29)\"},\"debuggerDisplay\":\"(1171,20)-(1171,29)\"}},{\"uri\":\"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs\",\"range\":{\"start\":{\"line\":1179,\"character\":20,\"debuggerDisplay\":\"(1179,20)\"},\"end\":{\"line\":1179,\"character\":29,\"debuggerDisplay\":\"(1179,29)\"},\"debuggerDisplay\":\"(1179,20)-(1179,29)\"}}]"

with error:

can't open /csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs: No such file or directory

To my understanding, the csharp:/metadata already has the source file in memory, but it's not putting the source file to disk... that's why I got the above error...

but my question is, how do I let the csharp-ls put source file to disk? or how would the acme-lsp adapt to make this happen?

from csharp-language-server.

ianzhang366 avatar ianzhang366 commented on July 28, 2024

Hi @razzmatazz

I was able to send request to csharp/metadata, but I'm getting error from the response, any idea what went wrong?

definition locations

L: /Users/ianzhang/golang/src/acme-lsp/internal/lsp/acmelsp/remote.go:133: ianzhang RemoteCmd Call, method: 

locations: []protocol.Location{protocol.Location{
URI:"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs", 
Range:1038:20-1038:29
}, 

request to csharp/metadata

L: /Users/ianzhang/golang/src/acme-lsp/internal/lsp/acmelsp/remote.go:135: ianzhang RemoteCmd Call, method: csharp/metadata with params: 
&protocol.MetadataParams{
    URI:"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs"
}, 
source: (*protocol.MetaSource)(nil), 
response error: response error: Object reference not set to an instance of an object.

Object reference not set to an instance of an object sounds like the metadata is not generated when I send out the csharp/metadata request..

from csharp-language-server.

razzmatazz avatar razzmatazz commented on July 28, 2024

Mhm, null ref exception sounds weird.

You could look into emacs and nvim implementations to figure out what things to do:

there is more info here #21 (comment)

But basically the editor should:

  • recognize csharp:/ uri coming from "go to definition" request (versus "normal" files on disk where uri prefix is file:/)
  • invoke csharp/metadata request with the uri
  • collect the parsed source and path components from response and
  • pass it somehow for the editor for the metadata to be rendered

not sure why you get object not found response.. can you pass me test project in a .zip or somehow so I could test it works for me with emacs?

from csharp-language-server.

ianzhang366 avatar ianzhang366 commented on July 28, 2024

Hi @razzmatazz

thanks for your reply.

Here's the sample code, I'm working with.

setup.zip

I will call 'text/Definition' at setup/Program.cs:7, which will call csharp/metadata with URI csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs

Then the error will show up.

from csharp-language-server.

razzmatazz avatar razzmatazz commented on July 28, 2024

hmm, I think it is working for me with emacs, here is lsp trace when i do "go to definition" with cursor on Console on line 6 (7 if 1-based numbering)

[Trace - 09:18:32 PM] Sending request 'textDocument/definition - (201)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/bob/Downloads/setup/Program.cs"
  },
  "position": {
    "line": 6,
    "character": 8
  }
}


[Trace - 09:18:32 PM] Received response 'textDocument/definition - (201)' in 3ms.
Result: [
  {
    "uri": "csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs",
    "range": {
      "start": {
        "line": 7,
        "character": 20,
        "debuggerDisplay": "(7,20)"
      },
      "end": {
        "line": 7,
        "character": 27,
        "debuggerDisplay": "(7,27)"
      },
      "debuggerDisplay": "(7,20)-(7,27)"
    }
  }
]


[Trace - 09:18:32 PM] Sending request 'csharp/metadata - (202)'.
Params: {
  "textDocument": {
    "uri": "csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs"
  }
}


[Trace - 09:18:32 PM] Received response 'csharp/metadata - (202)' in 3ms.
Result: {
  "projectName": "setup",
  "assemblyName": "System.Console",
  "symbolName": "System.Console",
  "source": "<decompiled source>"
}

does it look different in your case, maybe you just need to tune the params a bit?

from csharp-language-server.

ianzhang366 avatar ianzhang366 commented on July 28, 2024

Hi @razzmatazz thanks for the input!

You are right, I was sending bad request parameters... Now with

request: {"jsonrpc":"2.0","method":"csharp/metadata","params":{"textDocument":{"uri":"csharp:/metadata/projects/setup/assemblies/System.Console/symbols/System.Console.cs"}},"id":15}

I'm getting the metadata back! Thanks a lot.

from csharp-language-server.

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.