📜 ⬆️ ⬇️

C ++ code refactoring in Visual Studio 2015

Hello C ++ World!

Last Friday, the release of Visual Studio 2015 Preview was released, in which new features were presented to increase development productivity, including C ++ code refactoring. To a large extent, the feedback from the community, which was obtained during the testing of Visual Studio "14" CTPs, influenced the implementation of this functionality, so thanks to everyone who participated.

In this article, we will consider the following features of Visual Studio 2015 Preview for working on C ++ code, like:


Renaming is by far the most frequently needed tool. Thus, we placed it at the very top of the context menu with a right click on the class \ function \ variable. In addition, you can activate it by double-clicking the Ctrl + R combination. The tool itself is two-step - in the first window you specify the rename settings, the second window shows the preview.
')
image
image

Helpful hints


Extraction of the function was the second by the number of feature requests. We are still in the process of working on it, so for now it has been implemented as an extension . After installing it, select the block of code that you want to select into a separate function, then right-click and select “Extract Function / Method” in the “Refactor ...” menu.

image

Helpful hints


Generation of stubs of virtual methods allows you to create the bodies of all purely virtual methods in the inherited class. Multiple inheritance is supported. The tool is called from the context menu of the class declaration.

image

Helpful hints


Important point : all the above functions only work when IntelliSense is enabled.

Generating method declarations / stubs allows you to quickly generate a missing declaration or method body stub.

image

image

Helpful hints


Moving method declarations allows you to quickly move the method body from a header file to a cpp file or vice versa.

image

Helpful hints


Conversion to Raw-String allows you to convert any string to Raw-String, which greatly improves the readability of strings with escape sequences. The function is called from the context menu anywhere in the line.

image

Helpful hints

Source: https://habr.com/ru/post/243437/


All Articles