Is it possible to select all the parameters of a method and ask ReSharper to create a class from those parameters as a "method parameter object?"
Asked
Active
Viewed 1,196 times
2 Answers
15
ReSharper supports the command Extract Class From Parameters:
The Extract Class From Parameters refactoring allows you to quickly create a new class or structure using (some of) the parameters of a given method. ReSharper analyses the selected method and detects the variables that can be converted into members. After extraction, the new class is created with the necessary fields generated from the selected method's parameters.
To invoke it:
- Place the cursor on the method with the parameters you want to generate a class for
- Press Ctrl + Shift + R
- Select 'Extract Class From Parameters'
- Do any additional configuration in the dialog box.

Ray
- 187,153
- 97
- 222
- 204
-
1That's awesome ... I didn't know you could do that! – Martin Nov 01 '10 at 16:40
4
In ReSharper 2018.1, the sequence is now:
- Place the cursor on the method name.
- Press CTRL+Shift+R
- Select Transform Parameters
- Change the default class name from InClassName to something appropriate.
- Click Next (which should really be OK because it immediately makes the change)

Developer Guy
- 2,318
- 6
- 19
- 37

user3785010
- 1,029
- 1
- 10
- 11