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