|
| 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 | +  |
| 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 | +  |
| 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 | +  |
| 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 | +  |
| 88 | + |
| 89 | +1. When everything looks good, click the **Apply** button and the function will be changed in your source code. |
| 90 | + |
| 91 | +  |
0 commit comments