Thursday, May 17, 2007

Force Code Comment

Writing comments is like seeing dentists: we all know it’s good, but we choose not to do it anyway…

Here is a way I see in this post here that forces developers to write XML comment in Visual Studio 2005:

  • In Project Property page, choose to output “Xml Documentation file” during build.
  • Treat the following warnings as errors:
    1591,1592,1573,1571,1570,1572

Now if a public class, property or method is missing XML comment, the project build will fail. This can be enforce on the build/integration server, so that any time anyone misses a comment, a nasty blame email will be on its way (any Payroll Department is always on the CC list).

But is it a good idea to force comments on every public class, method, property, etc? I honestly don’t know…