Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I turn off the "Convert Extension Method to Plain Static" automatic refactoring in resharper?

When using Resharper, for some reason, when I call an extension method, it automatically converts it into a static method call. This is the so called Convert Extension Method to Plain Static refactoring.

foo.Bar()

becomes

MyStaticExtensions.Bar(foo);

Ironically, it then flags this as a code smell. How do I turn this off?

like image 839
Charles Graham Avatar asked Aug 25 '09 05:08

Charles Graham


People also ask

Why does ReSharper suggest static methods?

After you mark the methods as static, the compiler will emit non-virtual call sites to these members. Emitting nonvirtual call sites will prevent a check at runtime for each call that makes sure that the current object pointer is non-null. This can achieve a measurable performance gain for performance-sensitive code.

How do I refactor with ReSharper?

Press Ctrl+Shift+R or choose ReSharper | Refactor | Refactor This… from the main menu . Alternatively, you can press Ctrl+Shift+A , start typing the command name in the popup, and then choose it there. The Refactor This list appears. Choose an item from the list and click it or press Enter .

Can we write extension method for interface?

You can use extension methods to extend a class or interface, but not to override them. An extension method with the same name and signature as an interface or class method will never be called. At compile time, extension methods always have lower priority than instance methods defined in the type itself.


1 Answers

This feature is embedded in the IntelliSense of Resharper. I'm using Linq-to-sql extensions a lot, so I have disabled this feature: Resharper - Options - IntelliSense - Enable Radiobutton Visual Studio

like image 50
Theo Avatar answered Oct 15 '22 05:10

Theo