sachin dimbre

sachin dimbre

  • NA
  • 15
  • 18.9k

Finding un-used constants in MS Visual Studio

Jan 2 2014 2:35 AM
I have some constants file like as following.

namespace ConstantsFile
{
public class myCostants
{
public static WebDocument CONSTANT1 = "constant1";
public static WebDocument CONSTANT2 = "constant2";
public static WebDocument CONSTANT3 = "constant3";
public static WebDocument CONSTANT4 = "constant4";
public static WebDocument CONSTANT5 = "constant5";
}
}

And I am using these constants in my entire project something like this "myCostants.CONSTANT1" and "myCostants.CONSTANT2" and so on.
But this ConstantsFile.myCostants is a huge file containing too many constants and many of them are un-used for ex. it coule be the case that I am no where using "myCostants.CONSTANT3" and still CONSTANT3 is there
in myCostants class.

So My quesion is "Is there any way in MS visual studio to find out such unused constants in one go(and not one by one. I know that right click on constant and click Find All References will give me where all this used or not used at all)".

If there is no way to find out in MS Visual studio, can we write any small utility to find out un-used occurrences.

Thanks and Regards
Sachin

Answers (1)