The Inline Parameter refactoring allows you to replace a method parameter with actual argument value from a method call.
- Place the caret at the parameter to be inlined.
Do one of the following:
- On the main menu, choose ReSharper| Refactor | Inline | Inline.
- Choose Refactor | Inline | Inline on the context menu.
- Press Ctrl+Alt+NCtrl+R,I.
Depending on the values passed to the method for this parameter,
the refactoring either applies immediately or
you are prompted to provide additional information.
- If a constant value is passed to the method, for example some numeric value, the method parameter is removed and all its occurrences within method body are replaced with this value.
- If you have several method invocations and some of arguments are not constant, for example a property of an object, or you just have different kinds of arguments, ReSharper displays the Inline Parameter dialog box. Choose the value that should be used for replacement and specify whether to create new arguments.
For example, you want to restructure your code so that the UpdateSeverity method takes an object of the SeverityOption type as a parameter and then uses its Severity property.
Invoke the refactoring at the argument and inline it.
After applying the refactoring the value parameter of the Severity type is replaced with the severityOption parameter of the SeverityOption type.
This feature is supported in the following languages/technologies:
The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see the corresponding topics in the ReSharper by Language section.