Share via


Stylecop has been released

me

Microsoft released the internal tool StyleCop to public under the fancy yet boring name of Microsoft Source Analysis for C# . Even though the name is boring the product is not.

You'll love this tool when it imposes consistent coding style across your team. You'll hate this tool when it imposes the same on you. The result is stunning looking, consistently styled code which your whole team can follow uniformly.

StyleCop has been in use for a long time internally in Microsoft and many teams mandate it's usage. My previous team VSTT used it as well. The only crib I had is that it didn't allow single line getters and setters (and our team didn't agree to disable this rule either).

 // StyleCop didn't like this one
public int Foo
{
    get { return Foo; }
}

// StyleCop wanted this instead
public int Foo
{
    get
    {
        return Foo;
    }
}

Read more about using StyleCop here. You can set this up to be run as a part of your build process as documented here. Since this is plugged in as a MsBuild project you can use it in as a part of Team Foundation Build process as well.

Let the style wars begin in team meetings :)

Update: Jason corrected me in the comment, apparently StyleCop indeed allows single line getters and setters (seems like they got it fixed since the last time I used it).

Comments

  • Anonymous
    May 24, 2008
    The comment has been removed