O'Reilly logo

Instant StyleCop Code Analysis How-to by Franck LEVEQUE

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating custom rules (Intermediate)

In this recipe, we will see how to create our own custom rules for the StyleCop engine. We will also see how to add parameters to this rule.

Getting ready

For this recipe, you will need to have:

  • StyleCop 4.7 installed
  • Visual Studio 2008

How to do it...

In the early days of StyleCop, lots of the rules chosen by Microsoft were criticized. One of them was the fact that the developer couldn't add an underscore at the beginning of their private instance fields. In this recipe, we will take this rule as an example and try to implement it at the beginning of non public instance fields.

Note

This rule directly conflicts with the following StyleCop rules:

SA1306: Variable names and private field names must start with a lower-case ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required