title: Tool for examining potential casting problems in C#
body: <p>I have the following situation on my hands. In the project I work on we have this abstract class <strong>A</strong> which has two descendants, <strong>A_concrete1</strong> and <strong>A_concrete2</strong>. These two were around for some time now.</p>
  
  <p>The time has come to add the third descendant, <strong>A_concrete3</strong>. The problem is, a lot of time in existing codebase you'll find something like that:</p>
  
  <pre><code>A instance;
  // ...
  // assignment of instance
  // ...
  if (!(A is A_concrete1))
    A_concrete2 = (A_concrete2)A;
  </code></pre>
  
  <p>So now, when <strong>A</strong> has more than two descendants, this code is obviously broken and will fail at runtime.</p>
  
  <p>My question is: how do I locate all these situations automatically so I could fix them? What is the best way/tool to do it? I tried to use Resharper, but it doesn't provide anything for casting analysis. So I'd be glad to hear some suggestions and pointers on this one.</p>
  
  <p>Thanks in advance</p>