ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Detect unused code (C#)

(1/1)

Ruffnekk:
I am looking for a tool/trick/technique to detect any unused methods/functions in my C# application. It's quite a large application (Argus) and it has over 37 code files, totalling about 25000 lines of code. I want to run a tool or something to see if I have any code that is unused (never called). When I'm coding I'm in another mindstate and tend to forget to delete subs or functions I don't need anymore. I organize my code into regions and comments them, but still it's a tedious job to do this manually... Using "Find all references" has helped me already, but that's not very useful if one unused method calls another unused method and so on... Any ideas about this?

PhilKC:
FXCop can do that, I think..
http://www.gotdotnet.com/Team/FxCop/

PhilKC

Ruffnekk:
And to think I already have FXCop installed  :-[ Thanks PhilKC!  :P

mouser:
By the way, this is called "code coveragew" analysis in the world of program analysis/optimization/debugging, and is used often to make sure that all of the code is tested thoroughly.

Ruffnekk:
Thanks for the info mouser.

I'm now checking the assemblies with FxCop and so far I had over 1000 issues, which I will solve before 1.0 comes out :D. Good learning practice and very useful! I just hadn't thought about it before until PhilKC reminded me ;)

Navigation

[0] Message Index

Go to full version