tags:

views:

605

answers:

3

Typical scenario: a class that a lot of people have worked on. I'd like to sort methods, properties, etc... in alphabetical order.

I'd like to be able to do this within the region or globally in the class.

I see the feature in Resharper to do it, but it does not seem to do anything.

+7  A: 

Use the "Cleanup Code" functionality.

The order of the members can be set up in the ReSharper options in Languages, C#, Type Members Layout. This is a well documented XML layout specification which ReSharper uses when reordering members.

Lucero
+1  A: 

An alternative to consider is Regionerate. We use and like ReSharper, but Regionerate fits our needs for creating regions and sorting/rearranging members. And it's all customizable, of course.

UPDATE: We've started using ReSharper's Code Cleanup for this instead.

TrueWill
we used it for about 2 weeks but then when a proliferation of nested regions infested our code we all throw it away. It is a matter of personal taste of course but make sure you all agree on how it is to be used...
zzzuperfly
@zzzuperfly: Yes, everyone needs to agree on the standards and you need to tweak the configuration.
TrueWill
if you use regions its normally a sign that your classes are too big, big = classes mean that you have too many responsibilities per class
Miau
@Miau: While I believe in the Single Responsibility Principle, it's nice to separate properties/public methods/constructors/private methods/fields into their own regions and alphabetize those.
TrueWill
+2  A: 

Another tool worth to check is NArrange I'd like it more than Regionerate

Maciej