ReSharper, day 28: Really Extract Static Method and Extract Property

Welcome to day 28 of my 31 Days of ReSharper.

Today, I’ll touch on a couple more refactorings (besides Introduce Parameter, discussed yesterday) that you can use in conjunction with Extract Method.

Really Extract Static Method

ReSharper won’t always let you extract a static method (e.g., if the code references instance fields or methods). But you can get there in two steps, by first extracting the method, and then using the Make Method Static refactoring.

ReSharper's Make Method Static dialog box

I haven’t used this refactoring much, so I won’t go into details. I just wanted to note that it’s there.

Extract Property

ReSharper doesn’t have an “Extract Property” refactoring. But you can get there in two steps: first you extract a method, and then you use Method to Property.

ReSharper's Method to Property dialog box

There’s also a Property to Method refactoring, if you ever need to go the other way.

Leave a Reply

Your email address will not be published. Required fields are marked *