I hate writing code that makes my software more solid. This is something the framework should have done! So, is anybody aware of a code "enhancing" utility that solidifies the code?
If I had to create something like this myself, it would work as follows: When you're compiling your code with a Debug flag, it would auto-magically add "solidifying" code for each method:
Warp the code with a try-catch and put a Debug.Assert(true) in the catch (so that exceptions are caught at their origin).
Log each method's entry, printing "ToString()" values of arguments, so I can trace what's going on.
Check each argument for null.
Use an "IsValid" framework to check the object itself and each argument, where IsValid() is the object's way of declaring that its expectations are true (for example, if I'm a TableOfContentsEntry I expect to always be in a Book that's IsValid() and to point to a Page that's IsValid().
So, why not?