zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
42.19k stars 2.21k forks source link

C# Extension - Go to Definition opens blank file #11104

Open epitaque opened 2 months ago

epitaque commented 2 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

  1. Make sure you have the C# extension installed, and the DOTNET_ROOT environment variable points to the correct location.
  2. Open an empty Unity project.
  3. Create a simple script and command-click one of the types from the Unity library (e.g. MonoBehaviour).
  4. Notice it brings up an empty editor.

For search indexing purposes, I think this feature is called "metadata as source" as well.

Related issue: https://github.com/OmniSharp/omnisharp-roslyn/issues/2238

Environment

Zed: v0.132.3 (Zed) OS: macOS 14.1.0 Memory: 36 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

wizzymore commented 2 months ago

Can confirm that this doesn't work for NuGet packages either

iinuwa commented 1 month ago

I'm not sure if this is the exact same issue, but I just get a crash on Linux when accessing definitions for files outside of my project (e.g. files beginning with $metadata$):

[2024-06-07T07:41:16-05:00 ERROR util] crates/workspace/src/persistence/model.rs:313: No worktree for path: "/$metadata$/Project/MyProject/Assembly/RabbitMQ/Client/Symbol/RabbitMQ/Client/IBasicProperties.cs"
Thread "<unnamed>" panicked with "Could not start watcher on parent directory: Error { kind: Io(Os { code: 2, kind: NotFound, message: \"No such file or directory\" }), paths: [\"/$metadata$/Project/MyProject/Assembly/System/Diagnostics/DiagnosticSource/Symbol/System/Diagnostics\"] }" at crates/fs/src/fs.rs:481:14
   0: Zed::reliability::init_panic_hook::{closure#0}
             at crates/zed/src/reliability.rs:54:29
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9
      std::panicking::rust_panic_with_hook
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:783:13
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:657:13
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:171:18
   4: rust_begin_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
   5: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
   6: core::result::unwrap_failed
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/result.rs:1654:5
   7: <core::result::Result<(), notify::error::Error>>::expect
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/result.rs:1034:23
      <fs::RealFs as fs::Fs>::watch::{closure#0}
             at crates/fs/src/fs.rs:475:9
   8: <core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = core::pin::Pin<alloc::boxed::Box<dyn futures_core::stream::Stream<Item = alloc::vec::Vec<std::path::PathBuf>> + core::marker::Send>>> + core::marker::Send>> as core::future::future::Future>::poll
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/future/future.rs:123:9
      worktree::start_background_scan_tasks::{closure#1}
             at crates/worktree/src/worktree.rs:706:64
   9: <core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = ()> + core::marker::Send>> as core::future::future::Future>::poll
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/future/future.rs:123:9
      <async_task::raw::RawTask<core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = ()> + core::marker::Send>>, (), <gpui::executor::BackgroundExecutor>::spawn_internal<()>::{closure#0}, ()>>::run
             at /home/iinuwa/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/raw.rs:557:17
  10: <async_task::runnable::Runnable>::run
             at /home/iinuwa/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/runnable.rs:781:18
      <gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}
             at crates/gpui/src/platform/linux/dispatcher.rs:45:34
      std::sys_common::backtrace::__rust_begin_short_backtrace::<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:155:18
  11: <std::thread::Builder>::spawn_unchecked_::<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}::{closure#0}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/thread/mod.rs:528:17
      <core::panic::unwind_safe::AssertUnwindSafe<<std::thread::Builder>::spawn_unchecked_<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panic/unwind_safe.rs:272:9
      std::panicking::try::do_call::<core::panic::unwind_safe::AssertUnwindSafe<<std::thread::Builder>::spawn_unchecked_<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}::{closure#0}>, ()>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:552:40
      std::panicking::try::<(), core::panic::unwind_safe::AssertUnwindSafe<<std::thread::Builder>::spawn_unchecked_<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}::{closure#0}>>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:516:19
      std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<<std::thread::Builder>::spawn_unchecked_<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}::{closure#0}>, ()>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panic.rs:146:14
      <std::thread::Builder>::spawn_unchecked_::<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/thread/mod.rs:527:30
      <<std::thread::Builder>::spawn_unchecked_<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
  12: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9
      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9
      std::sys::pal::unix::thread::Thread::new::thread_start
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys/pal/unix/thread.rs:108:17
  13: start_thread
             at ./nptl/pthread_create.c:442:8
  14: __GI___clone3
             at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Is there a way we can provide a hook into the LSP processing to do special handling for $metadata$ paths? Or do we need to provide a wrapper binary for the Zed extension around omnisharp that works around it?