Export (0) Print
Expand All
6 out of 8 rated this helpful - Rate this topic

How to: Create Task List Comments

The Task List displays comments in the current code file that begin with the comment marker for your development language. The default comment markers are TODO, HACK, or UNDONE, but you can create 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.

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 general comments or long descriptions.

Important noteImportant

If you do not see C++ comments, you should enable them on the C++ Options page (Tools / Options /Text Editor /C/C++/Formatting). Under Miscellaneous, change Enumerate Comment Tasks to True.

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 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, click Task List.

    The Task List is displayed.

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

  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. Go to the Task List Options page (Tools / Options / Environment / Task List).

  2. In Token list, select the comment token for which you want to change the default priority.

    NoteNote

    You cannot change the priority for the TODO comment.

  3. In the Priority drop-down list, select a different priority type (Low/Normal/High.

  4. Click OK.

To create a custom comment token

  1. Go to the Task List Options page (Tools / Options / Environment / Task List).

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

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

  4. Click Add, and then click OK.

    For more information about adding custom tokens to the Token List, see How to: Create Custom Comment Tokens.

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.