“提取变量”在没有 ReSharper 的 Visual Studio 中
我目前的工作中没有 ReSharper,而且我怀念“提取变量”重构。我知道可以在 VS 中编写自己的重构“片段”。有人有这样做的吗?
I don't have ReSharper at my current gig, and I miss the "Extract Variable" refactoring. I understand that it's possible to write your own refactoring "snippet" in VS. Does anybody have one that does this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Visual Studio 2017 中,如果您选择某些内容,右键单击您将找到一个菜单选项“快速操作和重构”,使用快捷键 ctrl+。。
这似乎有点类似于ReSharper的ALT+Enter。
这允许您提取变量,如本例中选择文本然后按下 ctrl+. :
In Visual Studio 2017, if you select something, on right-click you will find a menu option "Quick Actions and Refactorings", with shortcut ctrl+..
This seems to be somewhat similar to ReSharper's ALT+Enter.
This allows you to extract a variable, as in this example where the text was selected and then ctrl+. was pressed:
看看这篇文章,但它确实似乎没有记录的功能:
另一种方法是使用 EnvDTE 编程模型编写宏。不容易,但应该是可行的。
Have a look at this post, but it does not seem to be a documented feature:
Another way would be a write a macro using the EnvDTE programming model. Not easy, but should be feasible.