Does visual studio 2010 Premium include the contract tools?

邮差的信 提交于 2019-12-05 05:27:21

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.

To get static analysis in Beta 2 you have to download and install the Code Contracts bits (1.2.21023.14 or higher) from MSDN DevLabs. Then under the project properties, there will now be a Code Contracts tab... from here you can turn on static analysis...

The behaviour you're seeing is because the Code Contracts API is in mscorlib assembly, which allows asserts to work, but nothing else.

I'm assuming this won't be necessary by RTM.

You need to turn on the code contracts runtime checking in the project properties. If that settings pane doesn't exist then you need to install the Code Contracts download from Microsoft (despite the fact that the Contract.Requires exists in the framework).

Only the runtime checking is available in the Professional editions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!