0

I use Resharper code cleanup before every commit to make sure we are not committing whitespace updates and everything is ordered in a defined fashion.

While working with some classes I would like Resharper sort to properties in a specific order which provides more visibility to the developers while developing or debugging.

As in the example below, I'd like Resharper to sort members so that Id is always the first property followed by Name and then Amount and so on and so forth...

Before Cleanup

public class A {
{
        public Account Account { get; set; }

        public string AccountId { get; set; }

        public decimal Amount { get; set; }

        public int OccurrenceNumber { get; set; }
        
        public string Id { get; set; }

        public string Name { get; set; }

        public DateTime StartDateTime { get; set; }

        public DateTime EndDateTime { get; set; }
    }
}

Desired result After Cleanup

    {
        public string Id { get; set; }

        public string Name { get; set; }

        public decimal Amount { get; set; }

        public Account Account { get; set; }

        public string AccountId { get; set; }

        public int OccurrenceNumber { get; set; }
      
        public DateTime StartDateTime { get; set; }

        public DateTime EndDateTime { get; set; }
    }

I have been trying to customise the File layout but I do not know what I am doing there.

smehnawal
  • 553
  • 1
  • 7
  • 16
  • I assume you are not using any source control or working with others. Automatic clean up can cause havoc with any diffs you may want to do to check what changes were done. If you are going to clean your code then it might be better to do them in their own separate commit. Not sure you can order your properties by type though (or is it by length?) – Piers Myers Oct 12 '21 at 14:50
  • I am using git and it is fine, we are a pretty large team actually. Test runs a full code cleanup for every push and fails if there any diffs. Just want to make sure code looks the same no matter who writes it. – smehnawal Oct 13 '21 at 01:42

0 Answers0