views:

271

answers:

1

Hi!

I'm really anal and would like to order my class properties alphabetically/by type.

Is this possible using a pre-existing feature in VS, or a macro that can do this?

Eg:

public string foo {get; set;}
public string bar {get; set;}
public int fong {get; set;}
public string loo {get; set;}

to (if you want to order alphabetically)

public string bar {get; set;}
public int fong {get; set;}
public string foo {get; set;}
public string loo {get; set;}

or (if you want to order by type, and then alphabeticall)

public string bar {get; set;}
public string foo {get; set;}
public string loo {get; set;}
public int fong {get; set;}

Many thanks!

+2  A: 

Not to my knowledge - but both DevExpress' CodeRush/Refactor (through an add-on) as well as Resharper through their code formatting features support this.

Marc

marc_s
Sadly, CodeRush and Resharper, whilst good products, are quite expensive and something I'm disinclined to pay for it for one small feature (albeit, I'll probably grow to want the other ones). Do you know if this is supported in DevExpress Refactor!™ Pro, which is currently on my machine?
Dan Atkinson
Yes, both cost money - although there *IS* a free Coderush Xpress version - did you know? Check out:http://www.devexpress.com/Home/Announces/CodeRushXpress.xml
marc_s
Download CodeRush Xpress (for C#) from:http://www.devexpress.com/Products/Visual_Studio_Add-in/CodeRushX/
marc_s
And then grab the "CR_ClassCleaner" plugin, which supports ordering your properties, member variables etc. in alphabetical order: http://www.codeplex.com/CRClassCleaner
marc_s
Hi Dan - if you have RefactorPro on your machine, you also have the "DXCore" components. As far as I understand the CR_ClassCleaner site on Codeplex, it's a "DXCore plugin" - so chances are it'll work with RefactorPro installed - give it a whirl!
marc_s
That's wonderful!Thanks Marc!
Dan Atkinson