Installing and using Code Contracts
Posted: (EET/GMT+2)
Recently, I've received many questions regarding MSDN DevLabs' recent addition, Code Contracts. The two most common questions were, do I need to install the DevLabs setup package for Visual Studio 2010 Beta 1 (#1), and secondly, why cannot I see the results of the static analysis anywhere (#2).
Herewith quick answers to these questions. #1: Yes, you need to install the package. You can use the Contract class(es) without the installation in Visual Studio 2010, but the static analysis and project settings won't be available then. #2: The static analysis appear on the Error List window in Visual Studio IDE. But, they are created using an asynchronous process, which is launched after the C# compiler. Because of the asynchronous nature, the results cannot immediately be seen; you might need to wait more than a minute to see them. Be patient.
Presently, I'm also working on a longer article on the topic, so stay tuned!