Skip to content

Commit 4bb39c6

Browse files
committed
refactoring docs
1 parent 2715269 commit 4bb39c6

29 files changed

Lines changed: 524 additions & 112 deletions

docs/ide/TOC.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# [IDE and Tools for Visual C++ Development](ide-and-tools-for-visual-cpp-development.md)
22
# [Writing and refactoring code (C++)](writing-and-refactoring-code-cpp.md)
3-
# [Visual C++ Tools and Features in Visual Studio Editions](visual-cpp-tools-and-features-in-visual-studio-editions.md)
3+
## [Change Signature](refactoring/change-signature.md)
4+
## [Convert to Raw String Literal](refactoring/convert-to-raw-string-literal.md)
5+
## [Create Declaration / Definition](refactoring/create-declaration-definition.md)
6+
## [Extract Function](refactoring/extract-function.md)
7+
## [Implement Pure Virtuals](refactoring/implement-pure-virtuals.md)
8+
## [Move Function Definition](refactoring/move-definition-location.md)
9+
## [Rename](refactoring/rename.md)
10+
# [Visual C++ Tools and Templates in Visual Studio Editions](visual-cpp-tools-and-templates-in-visual-studio-editions.md)
411
# [Creating and Managing Visual C++ Projects](creating-and-managing-visual-cpp-projects.md)
512
## [Visual C++ Project Types](visual-cpp-project-types.md)
613
## [Using Visual C++ Add New Item Templates](using-visual-cpp-add-new-item-templates.md)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: "Change Signature | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "11/16/2016"
5+
ms.prod: "visual-studio-dev15"
6+
ms.reviewer: ""
7+
ms.suite: ""
8+
ms.technology:
9+
- "devlang-cpp"
10+
ms.tgt_pltfrm: ""
11+
ms.topic: "article"
12+
ms.assetid: 8daaa060-7305-4035-99d2-8b460b4f4454
13+
author: "BrianPeek"
14+
ms.author: "brpeek"
15+
manager: "ghogen"
16+
translation.priority.ht:
17+
- "cs-cz"
18+
- "de-de"
19+
- "es-es"
20+
- "fr-fr"
21+
- "it-it"
22+
- "ja-jp"
23+
- "ko-kr"
24+
- "pl-pl"
25+
- "pt-br"
26+
- "ru-ru"
27+
- "tr-tr"
28+
- "zh-cn"
29+
- "zh-tw"
30+
---
31+
32+
# Change Signature
33+
**What:** Lets you modify a function's parameters.
34+
35+
**When:** You want to re-order, add, remove, or modify a function's parameters that is currently being used in a variety of locations.
36+
37+
**Why:** You could manually change these parameters yourself, and then find all calls to that function and change them one-by-one, but that could lead to errors. This refactoring tool will perform the task automatically.
38+
39+
**How:**
40+
41+
1. Place the text or mouse cursor inside the name of the method to modify, or one of its usages:
42+
43+
![Highlighted code](images/changesignature_highlight.png)
44+
45+
1. Next, do one of the following:
46+
* **Keyboard**
47+
* Press **Ctrl+R**, then **Ctrl+O**. (Note that your keyboard shortcut may be different based on which profile you've selected.)
48+
* Press **Ctrl+.** to trigger the **Quick Actions and Refactorings** menu and select **Change Signature** from the context menu.
49+
* **Mouse**
50+
* Select **Edit > Refactor > Reorder Parameters**.
51+
* Right-click the code, select the **Quick Actions and Refactorings** menu and select **Change Signature** from the context menu.
52+
53+
1. In the **Change Signature** dialog that pops up, you can use the buttons on the right side to change the method signature:
54+
55+
![Change Signature dialog](images/changesignature_dialog.png)
56+
57+
| Button | Description
58+
| ------ | ---
59+
| **Up/Down** | Move the selected parameter up and down the list
60+
| **Add** | Add a new paramater to the list
61+
| **Remove** | Remove the selected parameter from the list
62+
| **Modify** | Modify the selected parameter by changing its type, name, and whether it is optional, and what its injected value would be
63+
| **Revert** | Restore the selected parameter its original state
64+
| **Revert All** | Restore all parameters to their original state
65+
66+
> [!TIP]
67+
> Use the **Skip preview reference changes if all references are confirmed** checkbox to make the changes immediately without the preview window popping up first.
68+
69+
When adding or modifying a parameter, you will see the **Add Parameter** or **Edit Parameter** window.
70+
71+
![Add/Modify parameter](images/changesignature_addmodify.png)
72+
73+
Here, you can do the following:
74+
75+
| Entry | Description
76+
| ----- | ---
77+
| **Type** | The type of the parameter (int, double, float, etc.)
78+
| **Name** | The name of the parameter
79+
| **Optional Parameter** | Makes the parameter optionally specified
80+
| **Injected Value** | The value inserted into any calls to the function where the parameter isn't specified (only valid for **Add**)
81+
| **Default value** | The value used by the function if the caller doesn't specify one (only valid for **Optional Parameters**)
82+
83+
1. Use the **Search scope** drop down to select if the changes will apply to the project or the entire solution.
84+
85+
1. When you are finished, press the **OK** button to make the changes. Ensure that the changes you are requesting are being made appropriately. Use the checkboxes in the top half of the window to enable or disable the renaming of any item.
86+
87+
![Change Signature preview](images/changesignature_preview.png)
88+
89+
1. When everything looks good, click the **Apply** button and the function will be changed in your source code.
90+
91+
![Change Signature result](images/changesignature_result.png)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: "Convert to Raw String Literal | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "11/16/2016"
5+
ms.prod: "visual-studio-dev15"
6+
ms.reviewer: ""
7+
ms.suite: ""
8+
ms.technology:
9+
- "devlang-cpp"
10+
ms.tgt_pltfrm: ""
11+
ms.topic: "article"
12+
ms.assetid: fffbfee4-66ee-42ba-aeb9-df07fb702c51
13+
author: "BrianPeek"
14+
ms.author: "brpeek"
15+
manager: "ghogen"
16+
translation.priority.ht:
17+
- "cs-cz"
18+
- "de-de"
19+
- "es-es"
20+
- "fr-fr"
21+
- "it-it"
22+
- "ja-jp"
23+
- "ko-kr"
24+
- "pl-pl"
25+
- "pt-br"
26+
- "ru-ru"
27+
- "tr-tr"
28+
- "zh-cn"
29+
- "zh-tw"
30+
---
31+
32+
# Convert to Raw String Literal
33+
**What:** Lets you turn any string into a C++ raw string literal.
34+
35+
**When:** You have a string with escaped characters which shouldn't be processed as escaped characters.
36+
37+
**Why:** You could double-escape characters, but this often leads to confusing and unreadable strings. Using raw string literals makes strings much easier to read.
38+
39+
**How:**
40+
41+
1. Place text or mouse cursor over the escaped string to convert.
42+
43+
![Highlighted code](images/stringliteral_highlight.png)
44+
45+
1. Next, do one of the following:
46+
* **Keyboard**
47+
* Press **Ctrl+.** to trigger the **Quick Actions and Refactorings** menu and select **Convert to Raw String Literal** from the context menu.
48+
* **Mouse**
49+
* Right-click the code, select the **Quick Actions and Refactorings** menu and select **Convert to Raw String Literal** from the context menu.
50+
* Click the ![Lightbulb](images/bulb.png) icon which appears in the left margin and select **Convert to Raw String Literal** from the context menu.
51+
52+
1. The string will be immediately converted into a raw string literal.
53+
54+
![Raw String Literal result](images/stringliteral_result.png)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: "Create Declaration / Definition | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "11/16/2016"
5+
ms.prod: "visual-studio-dev15"
6+
ms.reviewer: ""
7+
ms.suite: ""
8+
ms.technology:
9+
- "devlang-cpp"
10+
ms.tgt_pltfrm: ""
11+
ms.topic: "article"
12+
ms.assetid: 6b1cdcb2-765e-4b93-8cef-92b861f64eba
13+
author: "BrianPeek"
14+
ms.author: "brpeek"
15+
manager: "ghogen"
16+
translation.priority.ht:
17+
- "cs-cz"
18+
- "de-de"
19+
- "es-es"
20+
- "fr-fr"
21+
- "it-it"
22+
- "ja-jp"
23+
- "ko-kr"
24+
- "pl-pl"
25+
- "pt-br"
26+
- "ru-ru"
27+
- "tr-tr"
28+
- "zh-cn"
29+
- "zh-tw"
30+
---
31+
32+
# Create Declaration / Definition
33+
**What:** Lets you immediately generate the declaration or definition of a function.
34+
35+
**When:** You have a function that needs a delcaration, or vice-versa.
36+
37+
**Why:** You could manually create the declaration/definition, but this will create it automatically, creating the header/code file if required.
38+
39+
**How:**
40+
41+
1. Place your text or mouse cursor over the function for which you want to create the declaration or definition.
42+
43+
![Highlighted code](images/createdefinition_highlight.png)
44+
45+
1. Next, do one of the following:
46+
* **Keyboard**
47+
* Press **Ctrl+.** to trigger the **Quick Actions and Refactorings** menu and select **Create Declaration / Definition** from the context menu.
48+
* **Mouse**
49+
* Right-click and select the **Quick Actions and Refactorings** menu and select **Create Declaration / Definition** from the context menu.
50+
51+
1. The function's declaration/definition will be created in the source or header file, which you will see in a popup preview window. If the source or header file does not exist, it will also be created and placed in the project.
52+
53+
![Create Declaration / Definition result](images/createdefinition_result.png)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: "Extract Function | Microsoft Docs"
3+
ms.custom: ""
4+
ms.date: "11/16/2016"
5+
ms.prod: "visual-studio-dev15"
6+
ms.reviewer: ""
7+
ms.suite: ""
8+
ms.technology:
9+
- "devlang-cpp"
10+
ms.tgt_pltfrm: ""
11+
ms.topic: "article"
12+
ms.assetid: e31d1249-9705-4511-acbd-9f6fe73bdf2d
13+
author: "BrianPeek"
14+
ms.author: "brpeek"
15+
manager: "ghogen"
16+
translation.priority.ht:
17+
- "cs-cz"
18+
- "de-de"
19+
- "es-es"
20+
- "fr-fr"
21+
- "it-it"
22+
- "ja-jp"
23+
- "ko-kr"
24+
- "pl-pl"
25+
- "pt-br"
26+
- "ru-ru"
27+
- "tr-tr"
28+
- "zh-cn"
29+
- "zh-tw"
30+
---
31+
32+
# Extract Function
33+
**What:** Lets you turn a fragment of code into its own function.
34+
35+
**When:** You have a fragment of existing code in some function that needs to be called from another function.
36+
37+
**Why:** You could copy/paste that code, but that would lead to duplication. A better solution is to refactor that fragment into its own function which can be called freely by any other function.
38+
39+
**How:**
40+
41+
1. Highlight the code to be extracted:
42+
43+
![Highlighted code](images/extractfunction_highlight.png)
44+
45+
1. Next, do one of the following:
46+
* **Keyboard**
47+
* Press **Ctrl+R**, then **Ctrl+M**. (Note that your keyboard shortcut may be different based on which profile you've selected.)
48+
* Press **Ctrl+.** to trigger the **Quick Actions and Refactorings** menu and select **Extract Function (Experimental)** from the context menu.
49+
* **Mouse**
50+
* Select **Edit > Refactor > Extract Function (Experimental)**.
51+
* Right-click the code, select the **Quick Actions and Refactorings** menu and select **Extract Function (Experimental)** from the context menu.
52+
* Click the ![Lightbulb](images/bulb.png) icon which appears in the left margin and select **Extract Function (Experimental)** from the context menu.
53+
54+
1. In the **Extract Function/Method (Experimental)** window, enter the new function name, select where you want the code to be placed, and click the **OK** button.
55+
56+
![Extract function function](images/extractfunction_dialog.png)
57+
58+
1. The new function will be created where you specified, a function prototype in the corresponding header file, and the original code will be changed to call that function.
59+
60+
![Extract function result](images/extractfunction_result.png)
451 Bytes
Loading
4.64 KB
Loading
15.9 KB
Loading
6.33 KB
Loading
18.4 KB
Loading

0 commit comments

Comments
 (0)