views:

174

answers:

4

Hi Guys,

I have been working on a huge VS 2008 (C#) project. Recently we have been restructoring a section of the solution to use domain driven design in an attempt to increase the quality of the code and architecture.

Everything has gone fine, however there will be a large amount of redundant code now nestled in the old business layer (cant remove the whole business layer as it is still used elsewhere). So my question is.... is there a (preferrably free) tool out there which I can use to discover a list of methods that are not called anywhere in a solution?

+3  A: 

ReSharper will do this for you.

John Saunders
Thanks, I am using it :)
Scozzard
Then turn on solution-wide analysis.
John Saunders
@Downvoter: what's the reason for the downvote?
John Saunders
+3  A: 

See this article (by TrueWill) on detecting unused methods in C#:

Also, you might want to try FxCop or ReSharper.

rajax
Thanks for the link to my blog! I'd forgotten about that post. There's a bug with links that contain underscores, though - try http://tinyurl.com/ycl7j5v
TrueWill
hmm neither of the links work, however i've downloaded and giving ReSharper a go - thanks.
Scozzard
@Scozzard - the tinyurl works for me; weird. Alternately you can go to http://www.truewill.net/myblog/index.php and search for "Detect unused methods" - it's the link from 1/27/08. But ReSharper is a killer solution. :)
TrueWill
+1  A: 

TeamCity can report on duplicated code.

EDIT: Sorry, I misread your original question. As others have stated, ReSharper with Solution Wide Analysis on is a very good option, as is FxCop.

TrueWill
+1  A: 

NDepend is not free. But a very good tool. You can download a free trial.

It will do the job and you don't have to pay for it.

It will not let you refactor but you can use Refactoring tools that come with Visual Studio.

Vadim
NDepend is serious overkill for the job of finding unused code and, as you say, will not help in removing it.
John Saunders