Can I use multiple rulesets for different files in one project?

Aug 16, 2011 at 4:43 PM

I'm wondering about enabling StyleCop on an existing codebase and wondered if anyone had worked out a way to use two different StyleCop rulesets to process different files in the same project.

What I'm thinking I would like to do is this:

  1. Enable StyleCop on all the projects, with most/all of the rules turned on. This will give me a LOT of warnings (e.g. > 50,000 in one project alone, even with the documentation ones disabled).
  2. Exclude all the existing files (as described here). Newly added files will thus use the complete ruleset from step 1.
  3. Run Resharper's Code Cleanup to fix some of the simpler violations one-by-one (e.g. adding "this." to all member references).
  4. Do something to make StyleCop run against all the files excluded from the full processing (in step 2) but with a ruleset restricted to just the things already fixed (in step 3).

Step 4 is the difficult one (obviously), but it would enable us to start bringing our codebase up to standard incrementally, but actually enforcing some of the simpler stuff universally as we progress.