views:

83

answers:

2

I am using Visual Studio 2010 and would like to exclude the generated service reference code from my code coverage statistics.

I found an article pre 2010 that mentions using DebuggerNonUserCode and DebuggerHidden attributes. I have tried this an it works as advertised. DebuggerNonUserCode is set at the class level, but with 50+ classes generated in each of the generated service reference code files, this is not an attractive option.

Does anyone have any alternative solutions?

+1  A: 

You could create a code generator that emits partial classes with the DebuggerNonUserCode attribute.

Jonathan Allen
Unfortunately the cost of creating the code generator, testing etc, outways the cost of adding this manually to the existing generated code. Thanks for the idea.
btlog
A: 

In Reference.cs, you can find an existing attribute, like "[System.Diagnostics.DebuggerStepThroughAttribute()]" and do a search and replace with "[System.Diagnostics.DebuggerStepThroughAttribute()] [System.Diagnostics.DebuggerNonUserCode()]". The major drawback is that you have to redo this each time you update the reference.

I don't understand why MS does not make the code coverage tool smart enough to skip service reference generated code.

Kevin