Validation Application Block and .NET 4.0 Code Contracts
Has anyone implemented the Enterprise Library VAB along wtih Code Contracts in .NET 4.0?
If so, can you share some insights? Did it help in performance? Any other factors to be considered?
Both frameworks have a different scope so they could easily be used in the same project. However, you'll have to prevent using Code Contracts in your domain entities. When you do this, all callers must ensure that they don't set invalid values (a compile time error will occur when you do this). With Validation Application Block however, your entities must be allowed to have an (temporarily) invalid state. Otherwise VAB is unable to ever detect invalid objects.
Let me put it otherwise, Code Contracts is meant to prevent programming errors, not user errors and it gives compile time support for this. VAB prevents user errors, not programming errors* and gives runtime support for this.
*Okay, VAB could also be used for programming errors (and in fact, I do use it myself in this way) but main scenario is user input IMO.