Wednesday, March 2, 2011

Xml Comment Warnings from Generated Code

I am a huge fan of ensuring high quality and consistency across all software libraries produced in a project.  To that end I always elevate all warnings to errors and require that Xml Documentation is activated, requiring documentation on all public methods.  (In addition to this I always use Code Analysis on "Microsoft All Rules"). For more information on guidelines see this previous post.

There's a problem with this, generated code sometimes gets generated outside of your control and obviously you do not want to go through it every time and add comments and make it comply with all rules. Only to have your changes removed when next it gets generated.  Specifically generated WCF service proxies always create code warnings for lack of XML code documentation.

The only reasonable way I have seen to prevent this is to add a pragma tag at the top of the generated file.

#pragma warning disable 1591

Not ideal, as it will need to be re-added with each regeneration of the code, but if someone else has a better solution I'd love to hear it.

No comments:

Post a Comment