Extract Class from Parameters refactoring
This refactoring allows you to quickly create a new class or structure using parameters of a method. The selected parameters are converted into fields with properties, The method itself and all its usages are converted so that the method takes the newly created class as a parameter.
Consider the following example:
To extract a class from parameters of a function
- Place the caret at the declaration or a usage of a method in the editor, or select it in the File Structure window.
- Do one of the following:
- Press Ctrl+Shift+R and then choose Extract Class from Parameters
- Right-click and choose Refactor | Extract Class from Parameters in the context menu.
- Choose in the main menu.
- Choose whether you want to create a class or a structure and whether it should be nested in the current type or in the top level in the current namespace.
- Specify a name for the new class.
- Choose which parameters should become members of the new class.
- 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/technologies:
The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see corresponding topics in the ReSharper by Language section.
Last modified: 12 October 2017