Transform Parameters refactoring
ReSharper | Refactor | Convert | Transform parameters…
To assign a shortcut, go to Tools | Options | Environment | Keyboard and find the ReSharper_TransformParameters
command.
This refactoring helps you quickly change method signature by transforming parameters — for example, get rid of out
parameters, wrap parameters in a tuple or in a new class, and so on. — and automatically update all usages of the method in your solution.
tip
ReSharper lets you change method signature in other ways (add, remove, rename, reorder parameters, change return type) with the Change Signature refactoring.
The refactoring lets you perform the following transformations:
Create a new class with public fields or auto-properties for types corresponding to the selected parameters, and use the newly created class instead of parameters.
Replace parameters with a tuple object.
For a method returning
void
, transform a selectedout
parameter to method return.For a method returning
void
, wrap multiple selectedout
parameters to a tuple object and use it as method return.For a method returning
void
, create a new class with public fields or auto-properties for types corresponding to the selectedout
parameters, and use the newly created class as method return.For non-void methods with
out
parameters, combineout
parameters with return type in a tuple object or in a newly created class.
note
In projects targeting .NET Framework 3.5 or lower this refactoring will not suggest transforming parameters or return method to tuple objects.
The example below demonstrates a mix of transformations - we replace out
parameter with method return, and we wrap two other parameters with a new class:
Before refactoring
class TestClass{ public void DrawCircle(Point ctr, float rad, out bool res) { // draw... res = true; }}
After refactoring
class TestClass{ public bool DrawCircle(Circle circle) { // draw... . var res = true; return res; }}internal class Circle{ public Circle(Point ctr, float rad) { Ctr = ctr; Rad = rad; } public Point Ctr { get; private set; } public float Rad { get; private set; }}
Place the caret at the declaration or a usage of method in the editor, or select the method in the File Structure window window. Or, alternatively, place the caret at any of method parameters.
Do one of the following:
Press AltEnter and choose Transform Parameters.
Press CtrlShift0R and then choose Transform Parameters.
Right-click and choose Refactor | Transform Parameters from the context menu.
Choose ReSharper | Refactor | Convert | Transform parameters… from the main menu.
The Transform Parameters dialog will open.
Select parameters you want to transform.
Depending on selected in/out parameters, ReSharper enables Method receives and/or Method returns selectors. Use these selectors to choose how in/out parameters should be transformed. If you choose to create a new class for parameters, you will be able to specify its name in a field to the right of it.
To apply the refactoring, click Next.
If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, it prompts you to resolve conflicts.

This feature is supported in the following languages and technologies:
The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the Languages and frameworks section.