Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding unused classes in C# app

Tags:

c#

I'm a C#/.net/Visual Studio noob. I inherited a half-completed C# application for a mobile phone. In the course of debugging, I came across several half-finished classes that don't seem to be used anywhere else in the code. Is there a way to get determine if a class definition is instantiated anywhere?

like image 230
limscoder Avatar asked Apr 27 '10 19:04

limscoder


2 Answers

The quickest way (in Visual Studio) is to right-click the type name and select Find all references from the context menu. This will show you all places where that type is referenced in the current solution.

like image 114
Andrew Hare Avatar answered Oct 15 '22 12:10

Andrew Hare


You should get Resharper - it will show "dead" code in grey and make refactoring a lot easier! You may also prefer CodeRush.

like image 27
Dead account Avatar answered Oct 15 '22 12:10

Dead account