XML Comments!

I’ve started using the XML commenting feature in VS 2008. It’s great!!!

I knew that it was there, but I never realized that there was Intellisense support for writing the comments. I figured I have to remember a bunch of XML tags and write it all by hand. Not so. It’ super easy to write the comments using the XML comments blocks!

To get started just try it. All you have to do is type three apostrophes and VS will inject an XML comment block with a summary, remarks and sections for each of the parameters on the method. Then you just type your comments. If you hit enter, it will automatically put in another line with three apostrophes for you.

There are two great benefits to using these comments:

1. Intellisense:
You get immediate Intellisense support within your project as you write it. Projects that reference your DLL will also get Intellisense if the .XML file is available when they add a reference.
Figure 1: XML Comments block and the resulting Intellisense support.

Figure 2: XML Comments block and the resulting Intellisense support on the method parameter.


2. Documentation:
You can run tools like Sandcastle against the code to create very nice help documentation. This will be very helpful for some of the common libraries that we have.
(Sandcastle is a tool that will inspect your code and output documentation that looks similar to the class library documentation available from MSDN.)

There are other articles out there that go into this stuff in detail, but I wanted to spread the word that it is super easy and will provide immediate benefit to you right away!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: