Recently I was debugging a "poof-all-customer-data-is-gone" problem. It did not take much time to figure out that a wrong branch led to a Directory.Delete(customerRoot, true)
line of code. The catastrophic line was written by a regular GUI developer. There are not many lines that can lead to such a disaster. So my question is how to prevent this particular call. (DirectoryInfo.Delete()
is the second one).
Here is my prioritized list of possible solutions
- Compilation error with no third parties altering a build process
- Run-time interception with no third parties
- Run-time interception with third party (no altering a build process)
- Compilation error with third party (I guess PostSharp will do it)
- Educational seminar for GUI developers about how customers love their data
Any other idea?
I will mention that our system has a dedicated service (validated and logged) for file/folder delete.