Suppose I have a class:
public class Foo
{
public int Bar { get; set; }
}
And an extension method:
public static class FooExtensions
{
public static void DoSomething(this Foo foo, int someNumber)
{
foo.Bar += someNumber;
}
}
What would be the most convenient way to remove the FooExtensions
class and alter Foo
so it becomes:
public class Foo
{
public int Bar { get; set; }
public void DoSomething(int someNumber)
{
Bar += someNumber;
}
}
ReSharper doesn't seem to offer a one-step action to do this (strangely enough as this seems a pretty straightforward refactoring), but which other actions might I combine to avoid too much copy/pasting around and manual work?
Apparently, there is a ReSharper action for this, but it is named a bit awkwardly (imho). It's called "Make Method Non-Static".
The documentation can be found here. Note that it doesn't mention extension methods specifically.
The same refactoring will work for other kinds of static methods (non-extension), which probably explains the naming.
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