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.
- In the editor, position the caret at the name of the method to be used:
- On the ReSharper menu or on the context menu, choose Refactor | Extract Class From Parameters.
- In the Extract Class From Parameters dialog box, click one
of the radio buttons in the Create section to specify whether you
want to create a class or a structure.
- Click a radio button in the Declare as section to specify how
you want to declare the new class or structure:
- Nested means that the class will be declared inside the selected method.
- Top-level means that the class will be declared inside the class where the method is declared.
- In the Name field, enter the new class name.
- In the Parameters converted to fields list, check the parameters that will be included in the new class/interface. Use Select All to quickly select all parameters.
- Click Next. The new class is created in the same file: