Antipod
Antipod

Reputation: 1643

How to easyily find unused public methods/properties

I have a .Net(C#) solution. The solution contains bunch of projects. The projects were implemented not by me. It is not a framework, it means that I need to have amount of public methods/properties as less as possible. My task is to identify methods and properties which are not used, but exist in the projects. Well, I can find private methods which are not used using R#. But it is completely unclear how to find public methods/properties which are not used.

I heard that they have NDepend tool, but it is not very simple tool, is it.

So, the question is: could you please point to a tool which can be used to identify methods which are not used in a solution. It is OK with me to have command line tool or something pretty simple.

UPD: I tried to use trial NDepend.

Well, first of all it seems like it is possible to see public methods (properties are represented as get_ set_ methods) which are not used in this particular assembly.

But NDepend does not recognize if the public method is used from another project/assembly, which is a part of the solution and shows the method as unused. But this is not true.

UPD2: mcintyre321 advised to use R#. Please read a first comment below.

Upvotes: 8

Views: 3197

Answers (2)

mcintyre321
mcintyre321

Reputation: 13306

If you turn on solution wide analysis in ReSharper (5.0 and above) it will flag them for you. This includes public methods.

Upvotes: 8

David Basarab
David Basarab

Reputation: 73301

Heck I have done it old school. I just comment out methods I don't think are being used and build. If I get an error, then I leave it there.

Upvotes: 0

Related Questions