How to compile for the first time

StyleCop Contrib needs the StyleCop assemblies to work. They are not included in the project so you will need to copy them from the StyleCop installation folder usually found in C:\Program Files\Microsoft StyleCop 4.3.2.1.

The assemblies needed are the following:
Microsoft.StyleCop.dll
Microsoft.StyleCop.CSharp.dll
Microsoft.StyleCop.CSharp.Rules.dll

Just copy them in the folder StyleCop of the Contrib solution root folder.

Please note that StyleCop installation is mandatory to use the StyleCop Contrib.

How to TDD a new custom rule

  1. Add a set of example code files in the TargetFiles folder of the test project.
  2. Add a new value in the ContribRule enumeration for new rule.
  3. Add a new entry for the rule in CustomAnalyzer.xml in the Analyzers folder.
  4. Create a new test class deriving from RuleTestBase in the CustomRules.Tests project.
  5. For each code file you added in #1 create a test method and call the following methods:
    1. SetTargetFile and set your code file path
    2. AddExpectation and use the enum value created at #2 and the list of line number where the violation should be expected.
    3. Analyze and finally ValidateExpectation.
  6. Add a new class deriving from SourceAnalyzer in the CustomRules project or add your custom rule inside an existing Analyzers class. Please look into StyleCop SDK documentation on how to create a custom rule for more information.

How to submit a new custom rule or send a patch for a bug

If you plan to contribute a new rule for the project you will need to respect the following guidelines:
  • New code will need to be 100% StyleCop and CodeAnalysis clean (using the default project settings).
  • Your rule needs to be 100% covered by unit tests.
  • Your rule needs to be generic enough to be useful to other people, not only you.
  • The naming convention prefix for rule code when submitting patch should be XX1234 where XX is anything but SC. This will reduce name collision before accepting and renaming the code to the SC1234 form (we will do the renaming).
  • If your rule only overlap an existing rule but include a new behavior you might consider modifying the existing rule to also cover the new behavior.

How to submit a bug for an existing custom rule

If you find a bug in an existing rule or you want to add a new behavior to the rule please include examples files with expected violations and line numbers in the issue.

How to request a new custom rule

If you have a need for a rule not included in StyleCop nor already available in the Contrib project you may submit a request in the Issue Tracker. To help us understand how to rule should work we might need example file with expected violations and line numbers. Those should be attached to the issue.

Important!!!
Only contributor of the project might create a custom rule matching your need. If nobody needs the rule you require then don't be surprised if it never gets done. In that case I suggest you create it yourself and summit it back to the project if you feel somebody else might need it.

Last edited Oct 18, 2009 at 2:52 AM by plaurin, version 10

Comments

No comments yet.