Convert Extension Method to Plain Static refactoring
ReSharper | Refactor | Convert | Extension Method to Plain Static…
To assign a shortcut, go to Tools | Options | Environment | Keyboard and find the ReSharper_Extension2StaticAction
command.
This refactoring helps you convert an extension method to a static method and update all usages in the current solution accordingly.
tip
The reverse functionality is available with the Convert Static to Extension Method refactoring refactoring.
Consider the following example:
Before refactoring
public static void DoSomething(this string s){}private static void Test(string str){ str.DoSomething();}
After refactoring
public static void DoSomething(string s){}private static void Test(string str){ DoSomething(str);}
Place the caret at the declaration or a usage of an extension method in the editor, or select it in the File Structure window window.
Do one of the following:
Press and then choose Extension Method to Plain Static.
Right-click and choose Refactor | Extension Method to Plain Static from the context menu.
Choose ReSharper | Refactor | Convert | Extension Method to Plain Static… from the main menu.
The refactoring is carried out without requiring you to specify any further options.
This feature is supported in the following languages and technologies:
The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the Languages and frameworks section.