title: Removing unused code in Visual Studio
body: <p>In relation to this question: "<a href="https://stackoverflow.com/questions/81597/remove-unused-references-using">Remove unused references (!= &quot;using&quot;)</a>", I would like to know if there is a tool for removing unused classes, structs, delegates, etc from a Visual Studio solution.</p>
  
  <p><strong>Scenario:</strong></p>
  
  <p>I have an unorganised Visual Studio Solution which consists of 1000's of:</p>
  
  <ul>
  <li>Native method imports </li>
  <li>Structures </li>
  <li>Delegates</li>
  <li>Enumerations</li>
  </ul>
  
  <p>Rather than trawling through each file clicking "Find All References" and determining if the code is being used somewhere, is there any mechanism by where I can simply remove redundant code files easily?</p>
  
  <p><strong>Example:</strong></p>
  
  <pre><code>//This class contains a method called getRandomValue which returns type RANDOM
  public class NativeMethods
  {
      [DllImport("random.dll")]
      public static extern RANDOM getRandomValue();
  }
  
  //This is the RANDOM object as referenced by getRandomValue();
  [StructLayout(LayoutKind.Sequential)]
  public struct RANDOM
  {
      uint a;
      uint b;
      uint c;
  }
  
  //This is redundant since nothing is referencing it.
  [StructLayout(LayoutKind.Sequential)]
  public struct MESSAGE
  {
      IntPtr sender;
      IntPtr recipient;
      char[] mText;
  }
  </code></pre>
  
  <p><strong>Note to self:</strong></p>
  
  <p>My gut feeling is that this is going to be tricky since unlike Java, object names do not have to be identical to the file name, and multiple object declarations can reside within a single file, however in this instance (my scenario) every object is declared within its own file (with an identical name).</p>