razor icon indicating copy to clipboard operation
razor copied to clipboard

Rename Symbol `F2` doesn’t work in Razor templates

Open davidwengier opened this issue 3 years ago • 3 comments

Transferred from https://github.com/OmniSharp/omnisharp-vscode/issues/5419

Issue Description

Renaming a symbol using F2 renames symbols only in .cs files but doesn’t update Razor templates. This requires you to remember to manually change all Razor templates. The server fails to start up and lets you know where you messed up but I got caught by this too many times.

Steps to Reproduce

  1. Create a class
  2. Use it in a Razor template
  3. Rename the class in your .cs using F2

Expected Behavior

All occurrences are renamed

Actual Behavior

Only occurrences in .cs files are renamed. Razor templates are ignored and need to be manually changed.

Environment information

VSCode version: 1.72.2 C# Extension: 1.25.0 .NET SDK: 6.0.401 (0906eae6f8)

davidwengier avatar Oct 27 '22 00:10 davidwengier

it looks like we is calling the Razor middleware to remap rename text edits - is there something missing on the razor end? https://github.com/OmniSharp/omnisharp-vscode/blob/master/src/features/renameProvider.ts#L40

davidwengier avatar Oct 27 '22 00:10 davidwengier

For @allisonchou to follow up post VS Code insertion.

DustinCampbell avatar Oct 27 '22 21:10 DustinCampbell

This is still a bug post-VS code insertion. Rename works if the Razor file and underlying C# file are open but fails if the Razor file is closed. Moving to triage.

allisonchou avatar Jan 04 '23 02:01 allisonchou

This should be fixed in the next C# release

ryzngard avatar May 06 '25 05:05 ryzngard