| XML Comments in Visual Studio |
|
|
|
| Work - ASP.NET | |||
| Written by mbrock | |||
| Sunday, 08 June 2008 21:41 | |||
|
One of my pet peeves as a professional developer is that every so often you run across code written by someone else that has not been commented - or is commented very poorly. Non-commented or poorly commented code can be a big hassle for a developer. Suppose you need to fix a bug in someone else's code and this person no longer works with you or your company. If the code is not properly commented then you could spend a lot of time - and time is money - trying to figure out what the code does. Unless you are trying to obfuscate code to make it more difficult for someone to understand, there is really no excuse to not properly comment it. It only takes a few seconds to write a some words about what your code does. One of the cool things about the newer versions of Visual Studio is that Microsoft has made it easy to add XML comments to your methods. This is for Visual Studio 2003 and up for C# and Visual Studio 2005 and up for VB.NET.For C# applications, by typing three forward slashes, ///, just above a method a structured XML comment section will be automatically inserted for your method. (Although I have never tried it, this is also supposed to work for VB.NET applications by typing three single quotes, '''.) If you are compiling your project, you can use the /doc option to have these comments gathered into an XML file. This file can be used as documentation for your project. Note that in ASP.NET this will only work for a web project and not a web site. compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
compilerOptions="/doc:C:\Documentation\WebDocs.xml"Once you have your XML comment file, you can use the open source program, nDoc, to create help files for your application.
|





If you have been programming for any length of time, you know how important commenting your code is. You comment your code so that you will know how it works if someone, including yourself, has to go back and look at it again later. 