Friday, April 15, 2011

Finding used functions in a library project

We have several library projects which are referenced as using statements like this:

Using XYZ.Controllers;
namespace test
{
   Public partial class testing: System.Web.UI.Page 
   //...
   Private void aTest()
   {
      string Fred=AController.GetAName();
   }
   //...
}

The controller AController would be created in another project (XYZ) which is referenced from this project as above. What I would like to able to do is to identify which routines in the XYZ project are no longer in use. (because code changed, new requirements etc).

Does anyone know of a way of finding out which functions are called and or which are not?

Simon

From stackoverflow
  • ReSharper can do this, if you are willing to pay.

    FxCop will do it for compiled code. This is a free utility.

    Brian : They've got a free trial as well, so you can check it out before paying.
    J.W. : I feel Resharper tool is great, except sometimes, it uses so much memory that it slows down your typing.
  • Ok, the following is not straight-forward, but quite simple and should give good results:

    1. Create a backup of the referenced library (not necessary if you can easily revert your changes using your favorite SCM tool).
    2. Make all members private (search and replace).
    3. Compile and the list of errors will show you all members used.

0 comments:

Post a Comment