dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

Find All References finds definition #6217

Open Novack opened 1 year ago

Novack commented 1 year ago

Type: Bug

Issue Description

My VSCode setup is mainly focused in Unity3D projects., with C# Dev Kit, and so on.

As oppossed to Visual Studio, using "Find All References", finds and lists among the references the symbols own definition. This is incorrect and distracting to read among the listed references, as well as misguiding in the cases when there are in fact, no references to that symbol.

I have found no settings that may help with this behaviour, can I change it somehow? Thanks for any help!

Steps to Reproduce

  1. Use Find all references. (In my case is in a Unity project setup, with C# Dev Kit).
  2. The symbol definition will be listed among its references.

Environment information

VSCode version: 1.81.1 C# Extension: 2.0.413 Using OmniSharp: false

Dotnet Information Host: Version: 7.0.10 Architecture: x64 Commit: a6dbb800a4 .NET SDKs installed: No SDKs were found. .NET runtimes installed: Microsoft.NETCore.App 7.0.10 [c:\Users\Operador\AppData\Roaming\VSCodium\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\shared\Microsoft.NETCore.App] Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation] Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
Visual Studio Code Extensions |Extension|Author|Version|Folder Name| |---|---|---|---| |code-settings-sync|Shan|3.4.3|shan.code-settings-sync-3.4.3| |codeium|Codeium|1.2.71|codeium.codeium-1.2.71| |csdevkit|ms-dotnettools|0.3.21|ms-dotnettools.csdevkit-0.3.21-win32-x64| |csharp|ms-dotnettools|2.0.413|ms-dotnettools.csharp-2.0.413-win32-x64| |github-dark-plus|NAPTheDevHcj|0.0.1|napthedevhcj.github-dark-plus-0.0.1| |one-monokai|azemoh|0.5.0|azemoh.one-monokai-0.5.0| |open-unity-meta|codesteady|0.0.1|codesteady.open-unity-meta-0.0.1| |renamer|VolcanicBytes|0.1.0|volcanicbytes.renamer-0.1.0| |shortcuts|gizak|0.0.1|gizak.shortcuts-0.0.1| |smartsemicolon|seunghwan|1.0.3|seunghwan.smartsemicolon-1.0.3| |trailing-spaces|shardulm94|0.4.1|shardulm94.trailing-spaces-0.4.1| |unity-code-snippets|kleber-swf|2.2.5|kleber-swf.unity-code-snippets-2.2.5| |unity-event-lens|dgileadi|1.0.0|dgileadi.unity-event-lens-1.0.0| |unity-find-in-prefabs|jarvisjiang|1.0.11|jarvisjiang.unity-find-in-prefabs-1.0.11| |unity-quick-docs|ColdThunder11|1.0.2|coldthunder11.unity-quick-docs-1.0.2| |vscode-csharp-snippets|jorgeserrano|1.1.0|jorgeserrano.vscode-csharp-snippets-1.1.0| |vscode-dotnet-runtime|ms-dotnettools|1.7.0|ms-dotnettools.vscode-dotnet-runtime-1.7.0-universal| |vscode-unitymeta|PTD|0.0.7|ptd.vscode-unitymeta-0.0.7| |vstuc|visualstudiotoolsforunity|0.9.0|visualstudiotoolsforunity.vstuc-0.9.0|;

Extension version: 2.0.413 VSCodium version: VSCodium 1.81.1 (aef377c42cea6e9aea642829953104f07097abfa, 2023-08-10T18:29:45.715Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 9 3900X 12-Core Processor (24 x 3793)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.92GB (17.33GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
JanusTida commented 1 year ago

I'm encountering the same problem,this incorrect behavior really sucks,It feels like I'm not using c# but another script-like language!

Alumniminium commented 1 year ago

You're more lucky than me. Go to Definition, Find References,... nothing works for me, just says not found

Novack commented 1 year ago

You're more lucky than me. Go to Definition, Find References,... nothing works for me, just says not found

Checkout the "Environment information" section on the report. Was generated automatically, may give you some hint on what you need. I didnt anything special btw.

Novack commented 7 months ago

Any news on this one? Has been sitting there for 7 months now.

CyrusNajmabadi commented 7 months ago

@Novack No news. But we welcome contributions. Cheers! :)

Novack commented 7 months ago

@Novack No news. But we welcome contributions. Cheers! :)

LMAO, that has to be one of the most shameless Microsoft official responses on the status of their software bugs to the date. A bit more politness, and a bit less cynicism would be better received (and more professional). Let me translate that for you:

"No we wont fix this long standing bug in the basic IDE functionality, better luck next year. Btw, you can fix it yourself. If you do it, give it to us. Cheers!".

Also, I guess VSCode team is kind of confused about being open source? I can't imagine such a basic issue living in the code base for that long in Visual Studio.

diamondgelato commented 5 months ago

Hey! I'm also facing this issue and found this thread. Feels a little less frustrating that there are other people with the same issue too. But this is a very big part of my workflow and I'm really considering switching back to Visual Studio because of this. I hope there's some updates on this soon

Novack commented 1 week ago

15 months after being reported and placed in the next milestone by @arunchndr, a broken basic functionality sits there abandoned.

I guess putting broken stuff on backlog without reason or explanation must be exiting to some.

CyrusNajmabadi commented 6 days ago

@Novack we welcome contributions. If this is important to you, we'd be happy to work with you if you want to make a pr here.

Novack commented 6 days ago

That is your professional reply? A bug standing there in the open in a basic feature, for a year and a half untouched, and all you can answer is "do it yourself"? Microsoft has lowered the standards quite a bit lately.

JoeRobich commented 5 days ago

I took a little time to see what was going on here. In VS, Roslyn also returns symbol declarations, however, the presentation in the FAR panel uses them for grouping by default.

Looking at the LSP spec, the Find References request the client is sending a context value containing an includeDeclarations boolean. Testing locally by setting the C# output logging level to Trace. Image Then switching to the C# LSP Trace Logs in the output pane. I am seeing that VS Code is passing true for includeDeclaration. Image

It is a straight forward change to have the FindUsagesLSPContext respect the Reference Context value. I will have to do some more investigation to determine how the user can set the includeDeclaration context value.