ReSharper 8.0 Web Help

The Inline Method refactoring replaces the usages of a method with its body and optionally removes the original method declaration. Static, instance and extension methods are all supported.

Tip

This refactoring also works with properties.

The reverse functionality is provided by the Extract Method refactoring.

To inline a method
  1. Place the caret at a method declaration or method call to inline, or select a method declaration in the File Structure window.
  2. Do one of the following:
    • On the main menu, choose ReSharper| Refactor | Inline.
    • Choose Refactor | Inline on the context menu.
    • Press Ctrl+Shift+RCtrl+Shift+R, then click Inline Method.
    • Press Ctrl+Alt+NCtrl+R,I.
  3. The Inline Method dialog box opens.

    Refactorings__Inline_Method__dialog_box

  4. Select the Inline all usages check box to inline all usages of the method. Otherwise, ReSharper replaces only the usage where the caret is.
  5. Select the Remove inlined method declaration check box to remove the original method declaration. Otherwise, ReSharper leaves it as is.
  6. Click Next. If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, resolve conflicts.

Note

ReSharper displays a warning if you attempt to inline a method that has no usages, such as a Main() method.

Consider the example below:

Refactorings__Inline_Method__before

After applying the refactoring, the ProcessAssemblyMetadata method call is replaced with its body.

Refactorings__Inline_Method__after


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.