The Inline Method refactoring transfers a method's body into the body of some or all of its callers and optionally removes the original method altogether. Static, instance and extension methods are all supported.
The reverse functionality is provided by the
TipThis refactoring also works with properties.
- Position the caret at a method declaration or method call to inline, or select a method
declaration in File Structure:
- Choose ReSharper | Refactor | Inline, or press Ctrl+Alt+N. The Inline Method dialog
box will display:
- Specify refactoring options:
- Inline all usages: if selected, inlines all usages of a method. If deselected, inlines only the method call that you positioned the caret at in the text editor. Becomes inactive in selected mode if the refactoring is executed upon a method declaration.
- Remove inlined method declaration: if selected, removes the original method; otherwise, leaves it as is, without any usages.
- Click Next. If no conflicts are found, the refactoring will be
NoteReSharper will display a warning if you attempt to inline a method that has no usages, such as a