Inline Parameter refactoring
This refactoring allows you to replace a method parameter with argument value from a method call. If there are several calls, you can choose the call to take the argument from.
A simple case. Inlining a constant value of the parameter
If the argument that you want to be inlined depends on other variables and/or calculations, JetBrains Rider can replace the original parameter with other parameter(s) and move the calculations inside the target method.
In the following example, we apply the refactoring to the
action parameter of the
PerformAction method so that the whole lambda, which was used as an argument in the call moves into the method body, and two new parameters are created to pass necessary values:
Inline a parameter
Place the caret at the parameter in the method declaration or at the argument in the method call.
Do one of the following:
Press Ctrl+R, I and then choose Inline Parameter
Press Ctrl+Shift+R and then choose Inline Parameter
Choosein the main menu.
The Inline Parameter dialog will open.
If the method has multiple usages, select the usage whose argument you want to be inlined and click Next.
Select the parameter that you want to inline.
If the inlined argument depends on other variables, JetBrains Rider suggests one or more variables from the caller in the New arguments field. Select the desired arguments.
Check the preview of the new signature and click Next.
If no conflicts are found, JetBrains Rider performs the refactoring immediately. Otherwise, it prompts you to resolve conflicts.