Option to Suppress SA1600 for MSTest Unit Test Methods?

Jun 25, 2012 at 10:43 AM

We would like to have SA1600 turned on with no exemptions on our code base to encourage developers to add /// comments to all members in the source code to ensure things are sufficiently commented and developers get Intellisense comments when working in the IDE.

However, we don't require developers to add /// comments to MSTest unit test methods as we prefer to use the [Description] attribute instead and duplicating the content twice in the /// comments and the attribute would be a waste of effort and increase the chances of the content become out of sync between the two.

Currently the best we can do to enforce comments whilst not requiring them for unit test code is to force generation of XML documentation for our non unit test projects so we get compiler warnings for public/protected members that aren't documented.  This of course doesn't pick up internal and/or private members that aren't documented.

Is it possible to add an option to StyleCop to allow methods decorated with the [TestMethod] attribute of MSTest to be excempt from SA1600?  We've got thousands of unit tests, so it isn't practical to add a [SuppressMessage] attribute to every single test method to get StyleCop to not raise a SA1600 violation.

Jul 9, 2012 at 8:32 AM

I tried using the approach specified in http://stylecop.codeplex.com/workitem/7352 on the assembly. but that doesn't appear to have any effect either.