Don't Be Stupid (like me)
I had a frustrating situation last week. I was trying to debug some unmanaged code through a managed project and discovered that something had happened to my system such that it was impossible to start up a project with unmanaged debugging turned on. If you had it switched off, any project would run fine in the debugger. If you had it switched on, the app would crash hard with an ExecutionEngineException before entering Main.
I can't tell you what changed on my system to cause this. I had a few suspicions, but nothing that I could act upon. I reinstalled VisualStudio hoping that would solve the issue, but no go.
After losing two days, I chose to have my machine nuked from orbit. I made a checklist of all the apps that I would lose and copied my documents (stored in My Documents) to an external hard drive. I made one very stupid mistake. I assumed that source control was my friend (more so than any reasonable person should) and neglected to make a back up of my source tree. When my machine was nuked it took out all the files I had checked out. Was it really 93? Yikes. Most of those were files that I was conditionally compiling out of the existing code, so some 80 or so of those were easy to recreate by breaking the locks and redoing the work of adding in
#if USE_OLD_CODE_LIBRARY
...
#endif
Fortunately, all the "hard" work I had done had been checked in and I lost only a small amount of that code. What I had lost was mostly managed code, for which I still had copies of the compiled dll's in test rigs on my backup. I pulled those and used .NET Reflector to get back an approximation of my original code. In two days, I was back to where I was and in better shape, as I fixed one bug along the way just from reading code (and it turns out, fixed the bug I was looking for when managed debugging went away).
In total, this situation cost me four days and my stupidity cost me two of those. Hindsight tells me that I was not scrupulous enough in making a checklist of things to do before nuking a machine. "What about my source?" should have been number one on my list.
It occurs to me as well that this is exactly something that a tightly integrated source code system like tfs should be able to manage for me. Tfs knows when I save a file locally. Couldn't it also shadow my changes into the server as well? In this way my code is one save away from recovery instead of one check-in or shelve.