Derik Whittaker



Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at
Enforcing Coding Standards using Resharper

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

  1. Create your Coding Styles
    Go through the list of available options and choose your settings.

  2. 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.

  3. 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.

  4. 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.

kick it on

Posted 06-28-2007 7:37 AM by Derik Whittaker
Filed under:



Rani wrote re: Enforcing Coding Standards using Resharper
on 01-25-2008 3:23 AM

Can you elaborate a bit, with example, on how this is done, even for a simple rule like "private member should start with 'm_' ?

Can those rules be applied on existing code to make an old code comply to the standards ?

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)