title: Is there any safe refactoring tool for .net (or at least c#)?
body: <p>I recently read Michael C. Feathers' book <code>Working effectively with legacy code</code> and came across the point where he mentioned a way to test the safety of automatic refactoring tools.</p>
  
  <p>My question is: <strong>Are there any safe refactoring tools for the .net platform?</strong>; that means tools which only allow real refactorings and e.g. don't allow the <code>inline variable</code> refactoring on the <code>temp</code> variable in the following example, or at least show a warning that I am changing logic.</p>
  
  <pre><code>class Program
  {
      private static int _x;
  
      static void Main()
      {
          int temp = Test();
          for (int i = 0; i &lt; 10; ++i)
          {
              Console.WriteLine(temp);
          }
          Console.ReadKey();
      }
  
  
      private static int Test()
      {
          return ++_x;
      }
  }
  </code></pre>
  
  <p>I've tested this example on the refactoring tools <code>Resharper</code> and <code>Coderush + Refactor pro</code> with the latest versions and both failed the test and allowed the refactoring to:</p>
  
  <pre><code>class Program
  {
      private static int _x;
  
      static void Main()
      {
          for (int i = 0; i &lt; 10; ++i)
          {
              Console.WriteLine(Test());
          }
          Console.ReadKey();
      }
  
      private static int Test()
      {
          return ++_x;
      }
  }
  </code></pre>