- Finalizers (Destructors)
Doing all this by hand is tedious, but as with most things, ReSharper (R#) makes it easier!
R# has a couple of features that, when combined, will mean you are fully SA1201 compliant (and, quite possibly well within the 20 seconds compliance window!) Firstly, there is a feature called Code Cleanup:
You can get R# to do various things during code clean-up. One of them is Reorder Type Members. R# does a decent job of moving stuff around by default, but it’s not perfect and doesn’t stop all warnings about SA1201. Thankfully, Reorder Type Members is configurable. The interface is straight XML in the R# Options screen. It’d be nice to have a GUI over it, but as yet (in R# 4.1 and 4.5), there isn’t one. Thankfully, you can’t bugger things up too much as the XML is validated against an XSD before it’s saved.
I was going through a legacy project recently and wanted a way to automatically reorder things, so I modified the R# XML configuration. To get your environment set-up, download the new XML configuration, go to ReSharper/Options and under languages/C# there an entry named Type Members Layout.
Deselect Use Default Patterns check-box and past in the new XML and click OK.
If you want a C# class that contains most of the things that should be reorganised, download it here. Mash it up a bit and then run StyleCop on it to ensure no SA1201 errors.