C++/CLI and XML Code Documentation

Finally, in Visual Studio 2005, Microsoft now supports XML Code Documentation.  Visual Studio now ships with XDCMake.exe which creates XML Documentation files that we so enjoyed back in C#.  Let's take a further look on how to use it.

First off, I created a new C++ CLR library in Visual Studio called AuditingLibrary.  Once the project has been created, right-click on the project and go to the properties page.  Notice on the left hand tree, that there is a XML Document Generator element.  Expand that element and it should show you the following:

x1p8HtBCMd0ISzOD5o9fQ0VDu6ClThvz7CLE7UC pJUHqqmMSW8GVB3g m4Zd3Muag5NKQU92zIYyykF6luBT9a06Z8tZ0peXenDSAsjTSV35ttq0JcFfzdUs9kKK0X4bWxrHeZ9vbForuxa9SEQFVQtw

Now that we see this, let's just leave it alone. Each element is fully described in this link:

http://msdn2.microsoft.com/en-us/library/ms235515.aspx

 Next, let's expand the C/C++ tree node, and go to the Output Files item.  From there, flip the switch on Generate XML Documentation Files to Yes.  Here is how it should look:

x1p8HtBCMd0ISzOD5o9fQ0VDu6ClThvz7CLE7UC pJUHqoGKCF7M7k6CU4Cz WuNlmP3nWJLD5cGRQtWcDSDAmFc0mLU2MSQF xuuCe7S0ugcmUOvhJ 7gISxIoxB4mAUtBZv mi5EwMMRD9pzh qn17A

Now we must follow the same standards that C# uses.  The full list of recommended tags are listed here:

http://msdn2.microsoft.com/en-us/library/ms177227.aspx

Now in our little example, I created a public value struct called AuditInfo.  I put the summary tag on it that looks like this:

///

/// This class holds auditing information.

///

public value struct AuditInfo { ... }

Unfortunately, C++ gives us no sort of intellisense that the C# version does.  This is a completely manual process which can be quite a pain.  Now put the summary tags on the properties as well.  Now, build the project and look at the results.  The XDCMake tool created XDC files for each object that it compiles for XML document purposes.  After the compilation, you can feel free to take a look at them.  Now, let's look at the XML document that was created:

            "AuditingLibrary"                             Gets or sets the access date time.                             Gets or sets the remote IP address.                             Gets or sets the logon name.                             This class holds the auditing information.            

As you can see, it's very simple things.  As you reference the library from any other .NET project, you now have the documentation available.  Very simple stuff.

This article is part of the GWB Archives. Original Author: Matthew Podwysocki

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.