开发者

"Extract Variable" in Visual Studio without ReSharper

开发者 https://www.devze.com 2023-02-22 15:41 出处:网络
I don\'t have ReSharper at my current gig, and I miss the \"Extract Varia开发者_开发知识库ble\" refactoring. I understand that it\'s possible to write your own refactoring \"snippet\" in VS. Does anyb

I don't have ReSharper at my current gig, and I miss the "Extract Varia开发者_开发知识库ble" refactoring. I understand that it's possible to write your own refactoring "snippet" in VS. Does anybody have one that does this?


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:

"Extract Variable" in Visual Studio without ReSharper


Have a look at this post, but it does not seem to be a documented feature:

Snippets For Refactoring

Browse to your "Program Files\Microsoft Visual Studio 8\VC#\Snippets\language id\Refactoring" directory and you'll find the snippets used to perform the refactoring techniques in the Refactor menu. (...) If you're going to try modifying these snippets then (...)

Another way would be a write a macro using the EnvDTE programming model. Not easy, but should be feasible.

0

精彩评论

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