Megosztás a következőn keresztül:


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

  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.

    Note

    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.

    Note

    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.

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.

See Also

Tasks

How to: Bookmark Code

How to: Control the Task List

Reference

Task List (Visual Studio)

Supplying XML Code Comments

Bookmark Window

Other Resources

Setting Bookmarks in Code