Are Refactorings safe?

The C# refactorings we're building in Whidbey are designed to be reliable. 

Not all of our customers use TDD, but many will use the refactoring tools we build.  If the tools don't work reliably, users will stop using them.

The big exception was unbuildable code.  We can't really guarantee preserved semantics of illegal code, since the semantics are undefined!

If you're doing TDD, this exception matters less, as you keep your code buildable pretty much all the time.  It's a prerequisite to running the tests, right?

There are some other subtle exceptions:

  1. Reordering the parameters to a method can have an unforeseen effect if the parameters you pass have side effects.  The side effects now happen in a different order.
  2. Removing a parameter to a method will change behavior if you pass a parameter with a side effect.

Both of these are difficult to guard against.  What should we do?  Remove the refactorings because they're unsafe?  Add cumbersome warning messages on the UI?

However, we're definitely working hard to make Rename and ExtractMethod very reliable.  They're the most important Refactorings we can provide, and we want you to use them a lot.