0

I have this code:

public interface IMyClass
{
    void DoStuff();
    int MyProperty { get; set; }
}

public class MyClass : IMyClass
{
    public void DoStuff()
    {}
    public int MyProperty { get; set; }
}

If I apply file layout using Resharper, I get this:

public interface IMyClass
{
    int MyProperty { get; set; }
    void DoStuff();
}

public class MyClass : IMyClass
{
    public void DoStuff()
    {}

    public int MyProperty { get; set; }
}

For the interface it is just as expected (properties before methods).

How do I get Resharper to also rearrange the code in the class?

Update

If the class does not implement the interface, it is rearranged as expected.

public class MyClass //: IMyClass
{
    public void DoStuff()
    { }
    public int MyProperty { get; set; }
}

becomes

public class MyClass //: IMyClass
{
    public int MyProperty { get; set; }

    public void DoStuff()
    { }
}

But it would be nice if it could rearrange classes with interfaces.

2 Answers 2

0

In your vstudio go to Extensions -> Resharper -> Options

Then go to Code Editing

Under Code Editing, go to C# -> File Layout.

There you can customize the order that ReSharper will rearrange your code.

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I have tried looking into it, but I cannot figure out how to make it rearrange both class and interface. See my update to the question.
0

It's not just a method and a property, it's Interface Implementations. If it's not necessary to reorder them, then it can be removed from the pattern: enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.