I don’t want to write comments or run code coverage on autogenerated code
The “warning CS1591: Missing XML comment for publicly visible type or member” issue
You’ve created a WCF service proxy and you’ve XML documentation turned on like the picture shows below.
Then you most likely will have a lot of warnings the next time you build your project like so:
Don’t despair the solution is close.
Solution
Find the Reference.cs file if you added a Service Reference manually or if you auto generated the Service Reference using the svcutil.exe utility open up the generated class.
Add the following line of code in your namespace:
#pragma warning disable 1591 //Disables CS1591 Warning
Auto generated code has lousy Code Coverage
Then you’ll be left with the issue that your auto generated code has lousy Code Coverage, if you haven’t written any tests against it that is. The question if you should write tests on auto generated code or not I leave it up to you. I’ll leave at that with the cowardly answer “it depends” The before picture might look like this:
Notice how the auto generated namespaces are listed in Code Coverage.
Solution
This is as easily fixed as the XML Warning. In the file where you have the auto generated code use search and replace to add the
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
attribute to every class.
Finish things off with a Edit->Advanced->Format Document to get a nice formatting and your good to go!
Try compiling and watch as your code coverage goes up!
Cheers,
Hugo
Comments