3 out of 4 rated this helpful - Rate this topic

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.

Important noteImportant

By default, the Task List window does not display C++ comments. To display them, open the Tools menu, click Options, and then click Text Editor. Click C/C++, and then click 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. On the Tools menu, click Options.

  2. Expand the Environment folder and then click 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 list, select a different priority type.

  5. Click OK.

To create a custom comment token

  1. On the Tools menu, click Options. Expand the Environment folder and then click 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, 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. 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.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Task List - Visual Studio 2010 Express
$0$0 $0$0 $0To answer my own question... $0 $0If you want to enable the task list in Visual Studio 2010 Express, first go to Tools > Settings and enable Expert mode.$0 $0Then you can follow the instructions in the article.$0 $0$0 $0$0
VS 2010 Express

Is the task feature unavailable in Visual Studios 2010 Express?

    
Thanks

It is also not default enabled for C++ in Visual Studio 2010 Ultimate
Likewise, its confirmed that for VS2010 Ultimate, in C++, the task list comment feature starts off as disabled out of the box.
So you need to do 2 things:
1) Enable the list: View -> Other Windows -> Task List
2) Enable the population of the comment tasks in C++:  Tools -> Options -> Text Editor -> C/C++ -> Formatting -> Miscellaneous -> "Enumerate Comment Tasks" to TRUE
Visual C++ 2010: Task comments not enabled by default
On Visual C++ 2010 Express, and reportedly in Visual Studio 2010 Professional, these task comments are not enabled by default.

To enable them, use the Tools>Options... dialog.  Select Text Editor>C++>Formatting and change "Enumerate Comment Tasks" to "True".

Advertisement