I am using Visual Stdio 2010 and its testing and code coverage features, and I have a bunch of generated code that I don't want to be included in code coverage results. These are generated as partial classes.
I've read in a few places (example: How to ignore generated code from code coverage data) how I can have the code coverage tools ignore the entire class or specific members using attributes. So I've modified the generator to include the [ExcludeFromCodeCoverage]
attribute on all of the classes it generates, but that prevents the code I write in partials from being tracked for code coverage as well.
How can I set things up such that code I manually write in partials are included in the code coverage results, but the generated code is not? The only option I am seeing now is to dig into the generator (a long, ugly T4 template) and add the [ExcludeFromCodeCoverage]
attribute at the property/method level instead of at the class level. Is there another way? I haven't seen anything like [IncludeFromCodeCoverage]
that I could add to my handful of properties/methods hand-written in partials to include those while ignoring the rest of the auto-generated class.