By Faiza Ajaz
There are times when you need to explain the core structure and logic of your program, having an intention to make it encapsulated and hidden at the same time. It always pays to keep away your actual coding from the reach of your client, and in some cases, from your fellow-programmers. So in such cases, you need to give a bird-eye view of your program, which encompasses the number of classes and a brief description of methods and variables used in them. This information is more than enough for anyone to familiarize himself with your program.
Fortunately, Microsoft .Net programmers were vigilant and kind enough to provide us with a feature that is amazingly easy and fun. You can view the structure of your code using code comment Web reports. These reports display information about the structure of your code in a series of .htm pages. If you are coding in C#, you can also add custom comments to your code that can then display in the report. The feature is provided in none other than Visual Studios .Net IDE. Here in this article, I am presenting the way it is done.
Consider a very simple sample project to make the web based project report.
namespace UsingWebComments
{
using System;
///
/// Summary description for Class1.
///
public class Class1
{
public Class1()
{
//
// TODO: Add Constructor Logic here
//
}
public static int Main()
{
//
// TODO: Add code to start application here
//
Class2 PrintName = new Class2();
PrintName.Display();
return 0;
}
}
class Class2
{
private static string Name = "Faiza Ajaz";
public void Display()
{
Console.WriteLine(Name);
}
}
}
The program is saved as UsingWebComments. It has two classes namely Class1 and Class2, both having one function each namely Main() and Display() in Class1 and Class2 respectively. Class2 has a private and static string variable. Let's see how a it is dealt by the feature under discussion.
1. With the above program displayed in the code window of the IDE,
Go to Tools -> Build Comment Web Pages
2. You'll see a dialogue box with options in it. Let's discuss them briefly.
Build for entire solution
This option creates .htm pages for the structure and code comments for all of the projects and files in the solution.
Build for selected projects
This option creates .htm pages for the structure and code comments only for the projects selected in the list.
Save web pages in
Specifies the location where the .htm pages are to be saved. Type a path in the text box or select Browse to navigate to a path. By default, the comment web page is saved in the directory where your project is saved.
Add to Favorites
When selected, creates a shortcut in the Favorites window to the .htm pages generated. When you choose OK, the Add to Favorites dialog box appears, allowing you to enter a name for the link. We're not adding our project in favorites here.
3. Click OK to finish the process.
Voila!!! Mission accomplished. The Web Based Comment Report has been created. Just browse to the folder where you have saved it and you'll see something like this.
Clicking on UsingWebComments will lead you the view shown below.
Now you can view the details of your project from here. My project in this report would look like this:
I believe it is justified to comment that this feature is highly important and productive, as it allows quick and easy preparation of a Web Based Project Report and can save you from a lot of trouble.