Skip to content
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

Generating overrides issue #3558

Closed
3 tasks done
pro-anon opened this issue Jun 7, 2022 · 10 comments
Closed
3 tasks done

Generating overrides issue #3558

pro-anon opened this issue Jun 7, 2022 · 10 comments
Labels

Comments

@pro-anon
Copy link

pro-anon commented Jun 7, 2022

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

This is csharp-mode with lsp as backend
I can't generate overrides using lsp-execute-code-action

This is the error it shows:

Debugger entered--Lisp error: (wrong-type-argument hash-table-p nil)
  lsp--execute-code-action(nil)
  lsp-execute-code-action(#<hash-table equal 2/2 0x155c434687a5>)
  funcall-interactively(lsp-execute-code-action #<hash-table equal 2/2 0x155c434687a5>)
  command-execute(lsp-execute-code-action)

Steps to reproduce

  1. Open a C# project
  2. Try to generate an override using lsp code actions
  3. Error appears and no override method is generated

Expected behavior

Should show a list of methods that can be overridden, and then insert its signature in the editor upon selection.

Which Language Server did you use?

csharp-ls

OS

Linux

Error callstack

[Trace - 07:04:15 PM] Sending request 'textDocument/codeAction - (641)'.
Params: {
  "textDocument": {
    "uri": "file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs"
  },
  "range": {
    "start": {
      "line": 25,
      "character": 0
    },
    "end": {
      "line": 25,
      "character": 0
    }
  },
  "context": {
    "diagnostics": []
  }
}


[Trace - 07:04:15 PM] Received response 'textDocument/codeAction - (641)' in 13ms.
Result: [
  {
    "title": "Generate overrides...",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate Equals(object)...",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate Equals and GetHashCode...",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate constructor 'ApplicationDbContext(options)'",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate constructor 'ApplicationDbContext()'",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate all",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate constructor...",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Add 'DebuggerDisplay' attribute",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  }
]


[Trace - 07:04:16 PM] Sending request 'codeAction/resolve - (642)'.
Params: {
  "title": "Generate overrides...",
  "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
}


[Trace - 07:04:16 PM] Received response 'codeAction/resolve - (642)' in 9ms.
Result: null


[Trace - 07:04:17 PM] Sending request 'textDocument/codeAction - (643)'.
Params: {
  "textDocument": {
    "uri": "file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs"
  },
  "range": {
    "start": {
      "line": 25,
      "character": 0
    },
    "end": {
      "line": 25,
      "character": 0
    }
  },
  "context": {
    "diagnostics": []
  }
}


[Trace - 07:04:17 PM] Received response 'textDocument/codeAction - (643)' in 38ms.
Result: [
  {
    "title": "Generate overrides...",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate Equals(object)...",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate Equals and GetHashCode...",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate constructor 'ApplicationDbContext(options)'",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate constructor 'ApplicationDbContext()'",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate all",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Generate constructor...",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  },
  {
    "title": "Add 'DebuggerDisplay' attribute",
    "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
  }
]


### Anything else?

_No response_
@pro-anon pro-anon added the bug label Jun 7, 2022
@yyoncho
Copy link
Member

yyoncho commented Jun 7, 2022

cc @razzmatazz

@razzmatazz
Copy link
Collaborator

hey @pro-anon which lsp server are you using, omnisharp or csharp-ls?

@razzmatazz
Copy link
Collaborator

oops, sorry; I see that you have that on your report..

@pro-anon
Copy link
Author

pro-anon commented Jun 7, 2022

@razzmatazz I don't think omnisharp supports code generation. Iirc it only had fixing imports/using statements as a code action

@pro-anon
Copy link
Author

pro-anon commented Jun 7, 2022

@razzmatazz does it work on your machine? It might be an issue with my config, I'm not sure. I'm using spacemacs

@razzmatazz
Copy link
Collaborator

It does work for me (doom emacs mostly, and vim sometimes), but in your case you hit some funny case where codeAction/resolve returns a null reponse..

[Trace - 07:04:16 PM] Sending request 'codeAction/resolve - (642)'.
Params: {
  "title": "Generate overrides...",
  "data": "{\"TextDocumentUri\":\"file:///home/<user>/HDD/Projects/MyProject/Data/ApplicationDbContext.cs\",\"Range\":{\"Start\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"End\":{\"Line\":25,\"Character\":0,\"DebuggerDisplay\":\"(25,0)\"},\"DebuggerDisplay\":\"(25,0)-(25,0)\"}}"
}


[Trace - 07:04:16 PM] Received response 'codeAction/resolve - (642)' in 9ms.
Result: null

Would it be possible to get reduced test case for this (a zip file with project contents)? Unless your project is open-source or a trivial?

@razzmatazz
Copy link
Collaborator

it can also be that generate overrides... is a code action that is not implemented currently.. actually let me check if that works on my machine:)

name for this code action could indicate that the action requires parameters to be specified for the code to be generated and we dont pass any..

@razzmatazz
Copy link
Collaborator

razzmatazz commented Jun 7, 2022

oh my... it really does not work; I will register this on csharp-ls repo:

will track the solution there

@razzmatazz
Copy link
Collaborator

if it is ok for you @pro-anon I am closing this as this is actually a bug in csharp-ls (sorry for transfering you to a second repo already today :E )

@pro-anon
Copy link
Author

pro-anon commented Jun 7, 2022

No problem

@pro-anon pro-anon closed this as completed Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants