The Change Signature refactoring combines several different modifications that can be made to the signatures of methods, constructors, properties, and indexers. It performs the following modifications:
Along with changing the signature itself, ReSharper searches for all usages of the method, property, constructor, or indexer and updates all calls, implementations and overrides that can be safely modified to reflect the change.
WarningChanging a return type or a parameter type may cause errors, which you will need to correct manually in the code.
- Place the caret at the name of a method, property, constructor, or indexer in the editor or select it in the File Structure window.
- Do one of the following:
- On the main menu, choose ReSharper | Refactor | Change Signature.
- Choose Refactor | Change Signature on the context menu.
- Press Ctrl+F6Ctrl+R,S.
- If the selected method overrides or implements some other methods, ReSharper suggests to modify the base methods. Click Yes to change the base methods. Click No to change only the selected method without modifying base methods.
- The Change Signature dialog box opens.
- Type a new name of the symbol in the Name text box. Change the return type by clicking the values in the Return type list.
- In the Parameters area, edit types, names, modifiers and default values of the existing parameters. Click Add to create a new parameter. Click Remove to delete existing parameters. Click Move Up and Move Down to reorder parameters.
- Specify how you want existing method calls to be changed:
- If you want to modify existing method calls, click Modify.
- If you don't want to change the existing method calls, you can let ReSharper override the method and delegate calls, so click Delegate via overloading method.
- Look at the result in the Signature preview text area, then click Next. If a new parameter is to be added, ReSharper prompts you to choose the default value for it. Click Next.
- If no conflicts are discovered, the changes apply immediately, otherwise resolve conflicts.
NoteIf you changed some parameter type or a return type to a type not available in the current namespace or to a type that can be resolved ambiguously, ReSharper suggests that you specify the desired type and its full name.
Consider the example below. The FindCommonDeclarations method has no parameters.
Also, it is called somewhere in the code.
After adding a new string parameter, there are two opportunities to update the calls.
This feature is supported in the following languages/technologies:
Tip
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.
See Also
Procedures: