Tool to find un-used methods from assemblies

V

Venkat

Hi,

My application is splitted into more than one assembly. And I
want to clean up the methods which are not called or not used among any of
the assemblies. And also I want to remove the code for those methods which
are not called in any of my assemblies.



1) I want to remove all methods (either private,
protected, internal or public) methods which are not called (invoked) among
any of my assemblies.

2) If public access modifier is not required for that
method then I want to make it either internal of protected which ever is
applicable.

3) If no method is overridden in the derived classes
which are marked as virtual in base classes then I want to remove the
virtual keyword from the method signature in the base class.





It will be great if any one suggests me the tool which does all of tasks and
it will be great if that tool can remove the code from my source code as
well. Otherwise it will be great if any of the tools generates a report
based on my conditions.



Can any one suggest me the tools available to find and remove the un-used
methods or members?



Thanks in advance,

venkat
 
N

Nicholas Paldino [.NET/C# MVP]

Venkat,

I have to ask, for what reason do you want to do this? It's almost
impossible to do. It would mean that you have to explore every single code
branch, for every possible type of input from the main executable, to see
how your code is traversed through.

On top of that, if you add a new reference to your assembly, you have to
do the analysis all over again.

Finally, you will pollute your design by doing such things. Just
because methods aren't used doesn't mean that they aren't important, or
shouldn't be there.

For example, if you had a Dog object, and you didn't call it's Bark
method (but accessed it's NumberOfLegs property), it doesn't make sense to
remove the Bark method. All dogs bark, after all.

Hope this helps.
 
G

Guest

See this tool:
http://msdn.microsoft.com/msdnmag/issues/06/03/TestRun/default.aspx

BTW you can use some IDE tools, like ReSharper 2.0 - it has feature to show
you unused fields/methods and allows to clean it up

My application is splitted into more than one assembly. And I
want to clean up the methods which are not called or not used among any of
the assemblies. And also I want to remove the code for those methods which
are not called in any of my assemblies.



1) I want to remove all methods (either private,
protected, internal or public) methods which are not called (invoked) among
any of my assemblies.

2) If public access modifier is not required for that
method then I want to make it either internal of protected which ever is
applicable.

3) If no method is overridden in the derived classes
which are marked as virtual in base classes then I want to remove the
virtual keyword from the method signature in the base class.





It will be great if any one suggests me the tool which does all of tasks and
it will be great if that tool can remove the code from my source code as
well. Otherwise it will be great if any of the tools generates a report
based on my conditions.



Can any one suggest me the tools available to find and remove the un-used
methods or members?

--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
W

William Stacey [MVP]

The new Phoenix framework will do this sort of thing and much more. Not out
yet, but hope is on the way.

--
William Stacey [MVP]

| Hi,
|
| My application is splitted into more than one assembly. And I
| want to clean up the methods which are not called or not used among any of
| the assemblies. And also I want to remove the code for those methods which
| are not called in any of my assemblies.
|
|
|
| 1) I want to remove all methods (either private,
| protected, internal or public) methods which are not called (invoked)
among
| any of my assemblies.
|
| 2) If public access modifier is not required for that
| method then I want to make it either internal of protected which ever is
| applicable.
|
| 3) If no method is overridden in the derived classes
| which are marked as virtual in base classes then I want to remove the
| virtual keyword from the method signature in the base class.
|
|
|
|
|
| It will be great if any one suggests me the tool which does all of tasks
and
| it will be great if that tool can remove the code from my source code as
| well. Otherwise it will be great if any of the tools generates a report
| based on my conditions.
|
|
|
| Can any one suggest me the tools available to find and remove the un-used
| methods or members?
|
|
|
| Thanks in advance,
|
| venkat
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top