Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

ReSharper comment token identification

Posted on March 25, 2008

ReSharper has a handy feature where it will identify tokens in your comments such as todo, note, bug etc. The Visual Studio IDE has a similar feature for TODO where it will identify those comments in the Task List window.

My issue with the ReSharper implementation is that it will identify these tokens even if they are in the middle of the comment rather than just at the start of the comment line. I originally posted an issue into the JetBrains Jira system thinking that this behaviour was not configurable, but then found that ReSharper identifies these tokens with regular expressions. If you open up ReSharper -> Options -> To-do Items, you will see a set of patterns identified.

The patterns defined are Todo, Note and Bug (I added Hack as a duplicate of Bug to support the default Visual Studio HACK token). I modified these regular expressions to ignore words beginning before the token. Instead, I just look for the beginning of the line. For example, the Note pattern was:


I have modified this to:


This will now only identify note comments if the NOTE token exists at the beginning of the comment only.