c# - Visual Studio 加载项 : How to use the Refactor > Rename using a custom code?

标签 c# visual-studio

在 visual studio 中,有一个功能可以让您执行以下操作:

  1. 右键单击您的方法/类/属性
  2. 重构> 重命名

这样做将使更改在当前解决方案中的所有项目中保持一致。

我想知道 DTE 或此类类上是否有任何 API 方法可用于使用自定义代码执行此操作。所以这就是我要找的东西

var myCodeElement = selectMyMethod();
myCodeElement.rename("myNewName");
//or
RefactorEngine.rename(myCodeElement, "myNewName");

感谢您的宝贵时间。

最佳答案

CodeElement2.RenameSymbol .这会影响您调用它的任何代码元素(因此您需要使用 FileCodeModel 来指定所需的元素,但听起来您已经掌握了它),并允许您指定新名称。

关于c# - Visual Studio 加载项 : How to use the Refactor > Rename using a custom code?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2239268/

相关文章:

c# - 隐藏成员函数不起作用

c# - 在运行时编译 C# 代码 [更新 : or Alternatives]

c# - Xamarin DependencyService : System. MissingMethodException:找不到 [Interface] 的默认构造函数

c# - 为非主键属性配置一对多外键

c++ - 编译器堆空间不足

c++ - 'BYTE' 没有命名类型 || 'BOOL' 尚未声明

c++ - 简单密集光流程序 calcOpticalFlowFarneback() openCV 3.2 cpp

c# - 使用 SVN 时在 Visual Studio 中更改文件夹名称

c++ - dll 链接静态库 - 来自未使用函数的未解析链接器符号

c# - 关于以AOP方式记录方法的每次调用