views:

49

answers:

1

I'd like to hook this so I remember to remove it if I don't wind up using it or needing it. Resharper won't pick it up because it's javascript. Even the VS2008 task list won't scrape it out of the comments.

My thoughts were either a //TODO: or #warning directive, but so far I can't find anything that works and gives no errors.

Sample attempt:

<script type="text/javascript">
    //ClientSide validation
    function CheckRootCause(sender, args) {

    //TODO: remove this if not needed
    <% #warning "unused code" %>
        var iValue = parseInt(args.Value);
        args.IsValid = iValue > 0;

    }
</script>


The TODO isn't picked up by VS's task list, the <% #warning %> gives 3 warnings instead of just 1. The warning itself, an Expected expression warning, and an Invalid character warning. It also gives 3 resharper underlines whe I'm looking at the code, including a red one as if it was a no-compile error.

I'm looking for something that does any of the following

  • Visual Studio picks up into the Task List
  • Visual Studio picks up as a single warning on the ErrorList
  • Visual Studio warns about because it's marked Obsolete
  • Resharper picks up as a todo on code-analysis

Or any other trick that would help me find this and clean it later.

Is there anything?

+2  A: 

I've never used the #warning myself before. But what if you did it something like so:


<% 
    #warning "unused code" 
    //TODO: remove this if not needed
%>
<script type="text/javascript">
    //ClientSide validation
    function CheckRootCause(sender, args) {
        var iValue = parseInt(args.Value);
        args.IsValid = iValue > 0;

    }
</script>

I think your "server" code is being ignored because it's in the <script> tag.

Anthony Shaw
Seems to work well enough, and I couldn't do any better...
Kobi
+1 this works, unless I want to tag a specific function inside a function list in `<script></script>` tags. I'll accept if a function specific solution doesn't come.
Maslow
if it's something you plan to remove at some point if it's not needed, you can also create a separate script block around it until you've determined whether you'll need it or not. If you find you do, combine it with the rest of your scripts in another script block (if there is one)
Anthony Shaw