Visual Studio automatically takes code comments that include
Works for single-line, multi-line, and documentation comments in both Visual Basic and C#.
The default behavior is to create a warning about any comment line that starts with
This can be overridden by including an
A todo-warn.config file can also be specified in your user's ApplicationData directory. (You can get to this by entering
For example, if the config file contained the line
It is possible to control the type of error that is reported and filter beyond just how a comment starts.
Setting the output type
A line in the config file may, optionally, start with one of the following.
Filtering output by line content
In addition to a config file line containing plain text, that is treated as the line start value to use when identifying comments of interest, it is also possible for a line in a config file to be comprised of "config blocks."
A config block takes the format
The following keywords are supported
Each config block is optional but must be listed in the order shown above and can only be included once.
This allows for the creation of rules such as "Show a message if a comment starting 'TODO' includes an issue number but isn't 'low-priority'."
It would look like:
Or you could have an error displayed if a comment line included, at any point, the text "before check-in" with the line
Excluding files from output
If you do not wish a warning to be raised in a specific file (or files) this can be achieved with the
Specify a line in the config that starts with
This will prevent the reporting of any file named "Program.cs" or has a name that ends this way and so will, for example, also match "MyProgram.cs".
To match the file name exactly, include the path separator, like so
A single wild card (*) can be included in the path and one is assumed at the start. The following lines are treated as identical.
Adding a wildcard at the end of the instruction can be useful to exclude all files in a directory. The following would prevent the reporting of warnings about any files in the "Controllers" directory, including in any sub-directory.
A wildcard can also be included in the middle of the text. The following prevents reporting of warnings about any file in the "Views" directory that ends with "Page" and has the ".cs" extension.
Multiple exclusion instructions can be specified in the config file and if any match the full path of a file being analyzed it will prevent any warnings for that file being reported.
The following are all examples of valid lines in a config file.