In this section, you will learn about Stylecop, what it is and how to install and use it on your project.  When you write code just for yourself, life is easy.  When you write code within a team codebase you need to agree on a workflow so your codebase looks like it's written by one person.  Stylecop will help you achieve that.

Some people hate Stylecop.  If you ask these people how they use it, a common response is, they write loads of code, run Stylecop once a week after they've made loads of changes and then complain it takes too long for the to fix the issue.

What I recommend is that you add Stylecop to your Visual Studio build to fail on warning.  Whenever you build your code locally, if it fails a Stylecop rule, you fix it there and then.  This way of working will prevent you need to do these big bang fixes.  It will also force you into a habit of writing your code in a Stylecop specific manner.

I definitely DO NOT recommend you use the default ruleset.  If you try and use all the rules your development life will be miserable.  Instead, create your own cut-down version as this will make your life a lot easier.  

What Is Stylecop?

When you work in a team it's a challenge to make sure that your codebase looks like it's been written by a single person.  Imagine reading a book where each chapter was written in a completely different style and approach.  It'd be pretty crap.  One [...]

How To Enable Stylecop Validation Of Visual Studio Build With A Custom Ruleset

If you are working in a big team, Stylecop is a great tool to ensure your team writes code in a consistent way (to learn more about Stylecop read this).   I recommend that anyone reading this post who isn't using Stylecop now should install it ASAP. [...]

Homepage C Sharp Bootcamp Clean Code Stylecop
Back to top