dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.85k stars 4.01k forks source link

Providing consistent behavior for Rename operation in custom files #9397

Open Mylan719 opened 8 years ago

Mylan719 commented 8 years ago

Hi, I am working on Visual Studio 2015 extension. Is there any API that would let me use the renaming/refactoring dialog like in Code Editor, but inside my custom markup files? I know there is Renamer class for renaming symbols in roslyn workspace. But I would like to make use of renaming In my custom markup files. So I quess I need to rename symbols in my markup by myself, then use Renamer helper class on roslyn workspace. But it would be nice if renaming behaved the same in markup as it does in Code editor.

Example of markup i wish to use renaming tools in:

@viewmodel MyViewModel, MyAssembly
<div>
{{_this.MyPropety}}
<div>

Code file:

public class MyViewModel
{
     public string MyProperty {get; set;}
}

The behaviour I want to reproduce in my markup file is:

  1. Whith cursor on MyPropety in markup file I hit Ctrl+R+R
  2. Renaming dialog appears
  3. I rename MyPropety to something else
  4. I commit the rename operation
  5. Here I would like to insert my own behaviour that would rename the symbols in my markup files and then rename it in the workspace. (I already have functionality that gives me resolved roslyn ISymbol for position inside my markup file in place.)

I have read quite a bit of roslyn source but everything thought could use is internal.

liviriniu commented 5 months ago

This would be very very helpful for at least refactoring scenarios of large code scope / volume that involve markup files and their C# code-behind counterparts. Also would significantly ease tight development where you test & refactor as you go.

Relevant in situations of highly coupled code files with markup files (by bindings).