Hi,

I have an application that is getting long in the tooth and I am finding methods that are no longer being referenced anywhere in the code. I'm sure they were useful at some point but now just take up space and are confusing for the maintenance guys.

I suspect there may be quite a few methods like this as there has been numerous changes over the years.

Are there any freeware tools I can use which can go through my code and let me know the methods no longer being referenced?

Recommended Answers

All 5 Replies

There is one method really for free in Visual Studio!
It is called Find, it is in the Edit menu.
Success!

Unfortunately I don't know any "quick" utilities to do such things. However, in VS there is an option when you right click on a method or variable called "Find All References"

This will show you where this method/variable has been referenced.
It's a bit long winded but will help you cut your code down.

Note: It will always find a reference to itself and in C++ the reference from the header file.

Yes I am very aware of those two methods of finding code that references a method.

This is a decent size project, 70 - 80 thousand lines of code and hundreds of classes so manually checking each method in each class is the least desirable method.

At one point I had an add-in in an earlier version of VS that gave feedback on the complexity of the code and I thought the orphaned methods too.

Hopefully someone else will know, if I find out I will update this post.

I found this as I was google-ing. Would it perform the task you require?

FxCop

Also, I totally forgot, but ReSharper does this. Unfortunately you would have to pay a license fee.

Some 20 years ago I worked on a 100000 and more of lines project.
Unix had some commands to perform the task you want.
Perhaps Linux does too.
Don't remember them anymore, but a bit of googling these days should do wonders.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.