Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any tools which can report on commented-out .NET code?

Tags:

Has anyone come across a tool to report on commented-out code in a .NET app? I'm talking about patterns like:

//var foo = "This is dead";

And

/*
var foo = "This is dead";
*/

This won't be found by tools like ReSharper or FxCop which look for unreferenced code. There are obvious implications around distinguishing commented code from commented text but it doesn't seem like too great a task.

Is there any existing tool out there which can pick this up? Even if it was just reporting of occurrences by file rather than full IDE integration.

Edit 1: I've also logged this as a StyleCop feature request. Seems like a good fit for the tool.

Edit 2: Yes, there's a good reason why I'd like to do this and it relates to code quality. See my comment below.

like image 443
Troy Hunt Avatar asked Apr 11 '11 21:04

Troy Hunt


People also ask

How do I find commented codes in Visual Studio?

In the visual studio. Select View->Task list. There would be a drop down at the top of the talk list window where you can select Comments. This would show all the comments in the solution.

Is commented out code dead code?

Overview. Dead code is code that is never executed. This can be a method that's no longer called, a commented out block of code, or code appearing after a return statement that's unreachable. In any case, it often reflects functionality that no longer exists in the software and offers no value.

Do comments get compiled C#?

No, comments are not in the compiled executable.


1 Answers

You can get an approximate answer by using a regexp that recognizes comments, that end with ";" or "}".

For a more precise scheme, see this answer: Tool to find commented out VHDL code

like image 185
Ira Baxter Avatar answered Dec 26 '22 18:12

Ira Baxter