开发者

Visual Studio Add-in: How to use the Refactor > Rename using a custom code?

In visual studio, there is a feature that lets you do the following:

  1. Right-click on your method/class/property
  2. Refactor > Rename

Doing this will make the change consistent across all the projects in the current solution.

I was wondering if there is any API method on the DTE or such classes that one can use to perform this action using a custom code. So this is something that I am looking for

var myCodeElement = selectMyMethod();
myCodeElement.rename("myNewName");
//or
RefactorEngine.ren开发者_如何学Goame(myCodeElement, "myNewName");

Thanks for your time.


CodeElement2.RenameSymbol. This affects whichever code element you call it against (so you will need to use the FileCodeModel to specify the desired element, but it sounds like you're already on top of that), and allows you to specify the new name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜