I am a fan of having coding standards within a development
team. I think that the standardization
it brings actually allows for a better, cleaner code base (this post is not
meant to discuss the pros/cons of coding standards). The problem with coding standards is that they
are hard to enforce.
If you are using ReShaper, enforcing coding standards can be
simple. Among the many features that are
offered by ReSharper is the ability to ReSharper format/reformat your code for
you.
How to get to the Code Style options:
ReSharper -> Option -> Code Style -> C# (I am using v2.5, C# only)
Creating, Saving and
Importing settings
- Create your Coding Styles
Go through the list of available options and choose your settings.
- Save your Coding Styles
After you have set your options, save them to a file.
To do this, click on the Code Style tree node in the options screen. Click the Export button and save off the
file.
- Share your Coding Styles
Now that you have saved the Coding Styles to disk, time to share them with the
team. I would suggest putting this file
in your source control repository in order to have easy access as well as a
common storage location.
- Importing your Coding Styles
After you have put your styles document in source control, it is time to import
them so you can start using your newly created standards.
In order to import the saved off XML file, you simple
go to the Code Style tree node in the options screen. When in this screen, select the radio button ‘From
external file for the current solution:’.
Then click the ‘…’ button to find and select the file.
Now you have enabled ReSharper to be the police of your
coding standards. Now that was easy.
Posted
06-28-2007 7:37 AM
by
Derik Whittaker