Reputation: 13491
I have a C# .NET assembly, in visual studio 2008. If required I could upgrade it to VS 2010.
How can I find which code in the assembly is not called? Ideally if something could analyse the whole solution in one go. It is too much for me to analyse it all myself manually.
The assembly is shared between a client and server project so I need to understand which code is used where.
Upvotes: 3
Views: 575
Reputation: 17388
You could try the safe delete function of ReSharper, keeping in mind it will say it's safe to delete code which is only used via reflection (such as Fluent automapping conventions).
Couldn't hurt to download a 30 day trial to see if it does what you need anyhow.
Upvotes: 1
Reputation: 160862
In VS 2010 you can use code coverage together with unit tests for that - so if you can refactor your client code into actual unit tests you can use that.
To quote from MSDN:
To determine what proportion of your project's code is actually being tested using unit tests, you can use the code coverage feature of Visual Studio Application Lifecycle Management. To do this, first edit the run configuration to indicate the assembly that contains the code whose coverage you want to measure. Then run tests on that code. Detailed code coverage statistics appear in a window, and you can also see, line-by-line, which code has been tested.
Upvotes: 2
Reputation: 70307
FxCOP is a free tool from Microsoft that includes dead code detection.
For best resulsts, don't mark classes/methods public unless they really need to be public. It assumes that any public method is used by external assemblies.
Upvotes: 1
Reputation: 2467
http://www.jetbrains.com/resharper/
Providing you don't mind buying something to do it, ReSharper will go off and find unused code for you.
Upvotes: 1
Reputation: 7691
Try getting resharper. That does that for you. You can get a free trial version from their website. http://www.jetbrains.com/resharper/download/
Upvotes: 1