sublimelsp / LSP-OmniSharp

Convenience plugin to install/update OmniSharp for LSP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Unable to open" error on goto definition on external references

ssoher opened this issue · comments

LSP GoTo definition doesn't open the definition on external references. Tested using Unity game engine. Doesn't matter if I have omnisharp.enableDecompilationSupport true or false.

Unable to open /E/project/P/Assets/_game/script/$metadata$/Project/p/Assembly/UnityEngine/CoreModule/Symbol/UnityEngine/Debug.cs
Traceback (most recent call last):
  File "E:\app\Sublime Text\Lib\python33\sublime_plugin.py", line 859, in on_load
    run_view_callbacks('on_load', view_id)
  File "E:\app\Sublime Text\Lib\python33\sublime_plugin.py", line 708, in run_view_callbacks
    callback(v, *args)
  File "E:\app\Sublime Text\Lib\python33\sublime_plugin.py", line 152, in profiler
    return event_handler(*args)
  File "G:\My Drive\backup\Sublime Text\Installed Packages\LSP.sublime-package\boot.py", line 167, in on_load
    if fn == file_name or os.path.samefile(fn, file_name):
  File "./python3.3/ntpath.py", line 603, in samefile
FileNotFoundError: [WinError 3] The system cannot find the path specified: '$metadata$\\Project\\p\\Assembly\\UnityEngine\\CoreModule\\Symbol\\UnityEngine\\Debug.cs'

Is your folder called “$metadata$“ ?

Is your folder called “$metadata$“ ?

nope

Can you open the LSP Log Panel (from the command palette) and post the exact request to the OmniSharp server and corresponding response here?

Can you open the LSP Log Panel (from the command palette) and post the exact request to the OmniSharp server and corresponding response here?

:: --> OmniSharp textDocument/definition(93): {'workDoneToken': 'wd93', 'position': {'character': 15, 'line': 33}, 'textDocument': {'uri': 'file:///E:/project/RAVIN/Assets/_game/script/EnemyZombie.cs'}}
:: <<< OmniSharp 93: {'range': {'start': {'character': 17, 'line': 18}, 'end': {'character': 22, 'line': 18}}, 'uri': 'file:///%24metadata%24%5CProject%5Cravin%5CAssembly%5CUnityEngine%5CCoreModule%5CSymbol%5CUnityEngine%5CDebug.cs'}
::  -> OmniSharp textDocument/didOpen: {'textDocument': {'text': '', 'version': 0, 'languageId': 'csharp', 'uri': 'file:///E:/project/RAVIN/Assets/_game/script/%24metadata%24/Project/ravin/Assembly/UnityEngine/CoreModule/Symbol/UnityEngine/Debug.cs'}}
:: --> OmniSharp textDocument/codeLens(94): {'textDocument': {'uri': 'file:///E:/project/RAVIN/Assets/_game/script/%24metadata%24/Project/ravin/Assembly/UnityEngine/CoreModule/Symbol/UnityEngine/Debug.cs'}}
:: <<< OmniSharp 94: []

Just to be clear, you’re trying to goto-def on something internal to Unity?

If so, it seems that $metadata$ is supposed to be a marker to possibly disassemble a Unity DLL. If that’s indeed the case, then I’m not versed well enough in the .NET ecosystem to readily write code to disassemble that DLL. Nonetheless, it should be possible to handle this in a custom on_open_uri_async callback on this plugin side, provided we know how to disassemble C# DLLs.

I see, well I've decided to try sublime text as an alternative to vs code a couple hours ago, trying to get everything setup to mimic the capabilities of what I've been doing in vs code. One thing they provide is the ability to disassemble dll's to provide go to definition support on them, including Unity internals.

We can look at what the VSCode extension is doing in such cases and translate it to Python

https://github.com/OmniSharp/omnisharp-vscode/blob/77ec34e0080939a02e15a63a06e005f2098134b6/src/features/definitionProvider.ts#L51-L100

Not exactly sure if this is the relevant part in the VSCode source code and how this can be adapted in ST LSP omnisharp. I'm just tired of firing up Visual Studio (not VSCode) whenever I need decompilation, which happens on a daily basis 😅

You seem to be right on the mark with that link. Crucially, I think we need to request "metadata info" with a custom request to resolve things: https://github.com/OmniSharp/omnisharp-vscode/blob/77ec34e0080939a02e15a63a06e005f2098134b6/src/omnisharp/utils.ts#L136

Kind of related: microsoft/language-server-protocol#1595