Enables you to change the order of parameters including promoting out parameters in the signature to the return value.
Reorder Parameters is a cascading refactoring. That is, the refactoring affects all method calls and method declarations in interfaces, base and descendant classes. For instance, if you apply the refactoring to the method declaration within an interface, it also changes the appropriate method declarations in all implementors and all calls to these methods.
- Parameter reordering is great when you need to change the parameter declaration order so that the most important parameters appear first, which is a common practice that increases a method's usability. This refactoring is also useful when you have several similar methods or several method overloads and you need to set the same parameter order for each of them.
- Another situation appropriate for the Reorder Parameters refactoring is when you have out parameters in your method. This refactoring allows you to eliminate an out parameter, making it the method's return value and vice versa.
- Reorder Parameters is also used to enhance the flexibility of the Extract Method refactoring.
From the context menu or via shortcuts:
- when the caret is on a method declaration.
- when a parameter with its type declaration is selected.
The refactoring is available for method declarations in interfaces, base and descendant classes as well as for the declaration in the current class. Unlike other cascading refactorings, Reorder Parameters is unavailable for method calls.
- Once Reorder Parameters has been applied, parameter selectors become active.
- Once you've selected the new order of your parameters, Reorder Parameters searches for all calls to your method and asks for your confirmation on changing the calling code to adjust to the new parameter order. Replacer progress indicator is activated for this purpose.
- If you've promoted an out parameter to become the method's return value, the method body and the calling code blocks can change. Reorder Parameters indicates the lines that are about to be inserted or deleted to reflect the changes made. You can confirm or cancel these automatic changes for the method body itself and for all the calling code blocks.
- You can specify whether the parameters animate when the order is being changed, or snap to their new positions without any animation.
- You can specify whether the code lines, which are suggested to be removed after reordering, should be completely removed or should just be commented out.
- You can control whether the hint should be displayed when the method body changes as the result of reordering parameters.
- You can customize the appearance of check signs, underline and strikethrough lines that indicate the lines of code that will be inserted or removed.
private void TestMethod(│int a, int b, out int c)
c = a + b;
Private Function │TestMethod(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer) As Integer
private int GetC(│int a, int b)
int c = a + b;
Private Function TestMethod(ByVal a As Integer, ByVal c As Integer, ByVal b As Integer) As Integer