How to: Create Task List Comments
The Task List displays comments in your code that begin with the comment marker for your development language. Next to the comments, the Task List also displays a default task token, such as TODO, HACK, or UNDONE, or a custom comment token. The number of comments that appear in the Task List may change, depending on the type of project you are working on. With Visual Basic and Visual C#, the Task List displays all the comments in the solution. With Visual C++ projects, the Task List displays only the comments that are found in the file that is currently active in the editor.
Task List comments can be used to indicate a variety of work to be done at the location marked, including:
features to be added;
problems to be corrected;
classes to implement;
place markers for error-handling code; and
reminders to check in the file.
As with other Task List entries, you can double-click any comment entry to display the file indicated in the Code Editor and jump to the line of code marked.
To add a comment to the Task List
Open a source code file in the Code Editor.
Begin a comment on a line of code you want to mark with <marker><token>, where <marker> is the comment marker for your development language, and <token> is the name of a recognized Task List comment token, such as TODO, HACK, or UNDONE, or a custom comment token.
Note
To add task tokens programmatically, set the DefaultCommentToken of the TaskList.
Complete the comment with text describing the task. For example:
// TODO Fix this function.
- or -
' HACK Update this procedure.
On the View menu, click Task List.
The Task List is displayed.
In the Categories list, click Comments.
The Comments list displays the comment text. You can click any Task List comment to activate the file in the Code Editor and jump to the line of code that the comment marks.
To change a comment or remove it from the Task List
Open your code file for editing in the Code Editor.
Modify or delete the comment in your code.
To change the default priority of a comment
On the Tools menu, click Options.
Expand the Environment folder and then click Task List.
In Token list, select the comment token you want to change the default priority of.
Note
You cannot change the priority for the TODO comment.
In the Priority drop-down list, select a different priority type.
Click OK.
To create a custom comment token
On the Tools menu, click Options. Expand the Environment folder and then click Task List.
The Task List, Environment, Options Dialog Box is displayed.
In the Comment tokens box, type a Name for your custom token.
From the Priority list, select Normal, Low, or High.
Click Add, and then click OK.
For more information about adding custom tokens to the Token List, see How to: Create Custom Comment Tokens.
Example
// The following C# code file contains several TODO reminders.
// Note that each line task reminder begins, like this comment,
// with the C# comment indicator, '//'.
// TODO: Add standard code header comment here.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
// TODO: Add references to specific resources here.
namespace TodoExample
{
partial class TodoExample : Form
{
public TodoExample()
{
InitializeComponent();
}
}
}
// TODO: It is even possible to add comments at the end.
The example shows that you can place TODO comments anywhere in a code file. Task List comments are best used to indicate work that must be done on specific lines or sections of your code. They are less appropriate for more lengthy descriptions of general development tasks.