razor icon indicating copy to clipboard operation
razor copied to clipboard

Cshtml references not properly shown

Open bogdan-iuga opened this issue 1 year ago • 6 comments

Type: Bug

Issue Description In a web MVC project, Go to References does not always find a field referenced in a *.Cshtml file. After opening a Cshtml file that contains a reference to said field, Go to References now sees the Cshtml reference, but does not allow you to open the file.

  1. Here you can see that the cshtml references are not shown for the NumberOfResults field. dotnet-issue-no-reference

  2. After opening the Index.cshtml file, Go to References now shows the cshtml references. Screenshot 2024-01-09 at 13 04 03

  3. Trying to open one of the references results in another error. Screenshot 2024-01-09 at 13 06 46


Expected behavior I'd expect the Go to References to:

  1. show all the references (even the cshtml ones)
  2. be able to navigate to the references in the cshtml files.

Environment information

Extension version: 2.14.8 VS Code version: Code 1.85.1 (Universal) (0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2, 2023-12-13T09:48:06.308Z) OS version: Darwin arm64 23.2.0 Modes:

System Info
Item Value
CPUs Apple M2 Max (12 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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) 5, 2, 2
Memory (System) 32.00GB (2.14GB free)
Process Argv
Screen Reader no
VM 0%

bogdan-iuga avatar Jan 09 '24 11:01 bogdan-iuga

Tagging @davidwengier for the Razor side - I cannot remember if this is expected behavior and you already have an issue tracking it, or if this something we need to fix on the Roslyn side. Do we have the generated source for non-open Razor files?

dibarbet avatar Jan 09 '24 21:01 dibarbet

We do, but VS Code automatically closes the documents after a while. We re-open them (hidden) when we get requests for their corresponding razor/cshtml document, but a Find Refs from Roslyn would never hit us, so it wouldn't happen.

davidwengier avatar Jan 10 '24 03:01 davidwengier

We do, but VS Code automatically closes the documents after a while. We re-open them (hidden) when we get requests for their corresponding razor/cshtml document, but a Find Refs from Roslyn would never hit us, so it wouldn't happen.

I assume this issue is resolved once we move to source generators right? If so, do you have an issue tracking that so I can dupe against it?

dibarbet avatar Jan 10 '24 21:01 dibarbet

I would leave this for Razor triage to decide, as we could dupe it, or we could do something else if priorities and timeframes dictate. If its easier for you to move these to the Razor repo in order to do that, that would be fine.

davidwengier avatar Jan 10 '24 22:01 davidwengier

Thanks - I'll move over to the Razor side.

dibarbet avatar Jan 10 '24 22:01 dibarbet

(10 months later) Any news?

alex-jitbit avatar Oct 13 '24 07:10 alex-jitbit