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?
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.
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 .
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With