34

Background:

I am fairly new to Visual Studio 2010 (worked on Lua, LIMSBasic (Labware) and a few others that didn't use decent IDEs and love the idea of task lists being pulled out of the comments I write right in the code.

I have worked out how to use comments to generate all manner of "// TODO:" and other task list and found some good lists on stackoverflow for what type I can do but I can't establish (no mater how hard I abuse google) even if it's possible to add them to csHTML files nevermind how!

I have tried using all of the following:

<!--// TODO: Work out how to add todo stuff to the tasklist!-->
// TODO: Work out how to add todo stuff to the tasklist!
<!--TODO: Work out how to add todo stuff to the tasklist!-->
<!-- TODO: Work out how to add todo stuff to the tasklist!-->
@// TODO: Work out how to add todo stuff to the tasklist!

...but nothing was added to the Task List.

Question:

So my question(s) is/are: Is it possible to add "TODO:" and other task list item to csHTML (MVC 3 using razor) and if so HOW?

GazB
  • 3,510
  • 1
  • 36
  • 42

1 Answers1

71

The following should work.

@{
    //TODO: do stuff here
 }

or

@{/* TODO: do stuff here */}

As it first has to go into "code" mode, and then you can use a task comment.

But apparently the following does not work (in my visual studio):

@*TODO: do stuff here *@
Yet Another Geek
  • 4,251
  • 1
  • 28
  • 40
  • Thanks that was it! I had tried @//TODO but forgot to put it on the list above (added now for future readers). – GazB May 28 '11 at 09:42
  • 1
    In razor it sees @code different than @{code}. @code is equivalent to <%=code%> in aspx syntax, and @{code} is eqivalent to <%code%> – Yet Another Geek May 28 '11 at 09:44
  • Oh and @{// TODO: Work out how to add todo stuff to the tasklist!} doesn't work but I'm sure you could work that out as the last } is ignored because of the comment... ;) I't goto be on another line. – GazB May 28 '11 at 09:46
  • 7
    Yes then you should use @{/*TODO: do stuff here */} – Yet Another Geek May 28 '11 at 09:49
  • Thanks that looks a bit tidier now it's on one line. – GazB May 28 '11 at 10:21
  • Any idea why the tasklist items only show when the page is open in VS? As soon as I close that specific cshtml file (leaving it in the project and solution but just closing it) the entry disappears of the tasklist. Obviously that makes it fairly useless! – GazB Jul 11 '11 at 19:30
  • 2
    Strange, this doesn't work at all for me. Tried the solution as given, and the single line @{/*TODO: do stuff here */}. Anyone else found this? – Richard Fawcett Mar 08 '12 at 00:13
  • 1
    @RichardFawcett - are your files open? (See http://stackoverflow.com/questions/1663914/todo-comments-are-not-showing-up-in-the-task-list) - alternatively, you may need to go to 'Tools > Options > Environment > Task List' to check your settings – Chris Oct 19 '12 at 17:50