This documentation is archived and is not being maintained.

How to: Create Task List Comments 

The Task List displays comments embedded in your project code that begin with the comment marker for your development language, followed by 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 changes, depending on the type of project you are working on. With Visual Basic projects, the Task List displays all of the comments in the project. With Visual C# and Visual J# projects, the Task List displays only the comments that are found in the files currently opened for edit. With Visual C++ projects, the Task List displays only the comments that are found in the file 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

  1. Open a source code file for editing in the Code Editor.

  2. 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.

    NoteNote

    To add task tokens programmatically, set the DefaultCommentToken of the TaskList.

  3. Complete the comment with text describing the task. For example:

    // TODO Fix this function.
    

    - or -

    ' HACK Update this procedure.
    
  4. On the View menu, select Other Windows and choose Task List.

    The Task List is displayed.

  5. Select the Categories list, and choose Comments.

    The text of the comment is displayed in the Comments list, and will appear there whenever you open this code file for editing. 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

  1. Open your code file for editing in the Code Editor.

  2. Modify or delete the comment in your code.

To change the default priority of a comment

  1. From the Tools menu, choose Options.

  2. Expand the Environment folder and then select Task List.

  3. In Token list, select the comment token you want to change the default priority of.

    NoteNote

    You cannot change the priority for the TODO comment.

  4. In the Priority drop-down, select a different priority type.

  5. Click OK.

To create a custom comment token

  1. On the Tools menu, choose Options. Expand the Environment folder and select Task List.

    The Task List, Environment, Options Dialog Box is displayed.

  2. In the Comment tokens box, type a Name for your custom token.

  3. From the Priority list, choose Normal, Low, or High.

  4. Click Add, and then choose OK.

    For more information on 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 preceding example shows that you can place TODO comments anywhere in a code file. Generally, Task List comments are best used to indicate briefly 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.

Task List comments are not attached to the solution and project nodes displayed in Solution Explorer. For this reason, they do not appear when a solution is first opened. Rather, they are embedded within individual code files. Whenever a code file is opened for editing, any comments that begin with recognized tokens are displayed in the Task List.

See Also

Show: