According to this feature matrix, Visual Studio 2010 Premium (RC) includes "static code analysis".
However, adding calls to Contract.Requires
at the start of my methods doesn't seem to have any effect. I don't get runtime exceptions if the contract is violated. I don't get compiler warnings if a contract cannot be proven. I also can't find a "Code Contracts" tab in the project settings.
Am I missing something obvious or is this feature only available in the Ultimate edition?
Help -> About . The version of the installation will be SP1Rel if SP1 is installed.
New Features and Enhancements in VS2010enhanced support for multi-targeting. support for call hierarchy of methods. support for parallel programming and debugging. support for XSLT profiling and debugging.
You can download Visual Studio 2010 from My.VisualStudio.com. My.VisualStudio.com requires a free Dev Essentials subscription, or a Visual Studio Subscription.
There does indeed seem to be some confusion about whether or not Code Contracts is included in the framework that comes with beta 2 of VS2010, or even in VS2010 itself. The Code Contracts forum (and expecially this post) has several mentions of this with no answers as of yet.
I don't think that Code Contracts falls under the heading of static code analysis. I think static code analysis refers to other code analysis tools like FxCop.
I have tried using Contract.Requires
in VS2010 beta 2 ultimate edition, but I get the same behaviour as you. If you look in the project properties under the Code Analysis tab, you can enable code analysis, but this doesn't relate to Code Contracts.
According to the comment by Melitta (from the Base Class Libraries Team) on the connect article Make data contract static checking available in Professional Edition:
...but the restriction on the static analysis tool stands for this upcoming release. It keeps the code analysis story consistent, in that the static analysis tools require VSTS.
This suggests that you (will) have to have the team system version to get the compile-time version of Code Contracts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With