ReSharper 8.0 Web Help

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:

Method
  • Change name and return type.
  • Change parameter names and types.
  • Add and remove parameters.
  • Reorder parameters.
Property
  • Change name and return type.
Constructor
  • Change parameter names and types.
  • Add and remove parameters.
  • Reorder parameters.
Indexer
  • Change name.
  • Change parameter names and types.
  • Add and remove parameters.
  • Reorder parameters.

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.

Warning

Changing a return type or a parameter type may cause errors, which you will need to correct manually in the code.
Since ReSharper 7.1 the Change Signature refactoring works with named arguments. So you can refactor your code and be sure that all usages of named arguments are updated properly.

To change a signature
  1. Place the caret at the name of a method, property, constructor, or indexer in the editor or select it in the File Structure window.
  2. 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.
  3. 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.
  4. The Change Signature dialog box opens.

    Refactorings__Change_Signature__dialog_box

  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. If no conflicts are discovered, the changes apply immediately, otherwise resolve conflicts.

Note

If 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.

Refactorings__Change_Signature__declaration

Also, it is called somewhere in the code.

Refactorings__Change_Signature__usage

After adding a new string parameter, there are two opportunities to update the calls.

Refactorings__Change_Signature__calls


This feature is supported in the following languages/technologies:

C# VB.NET HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available

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: