那么C#4.0代码合同实际上做什么呢?

栏目: ASP.NET · 发布时间: 6年前

内容简介:阅读关于System.Diagnostics.Contracts.Contract受静态类影响的静态类后,我很高兴,并立即开始对Call.Requires()和Contract.Ensures()的调用进行编码.我想这只是因为我的代码是非常棒的,没有bug的,检查那些电话实际上做的只是直到最近才出现.一个错误滑过来,我意识到这些电话没有做任何事情!我本来以为他们至少在违反条件时抛出异常,但没有这样的运气.我错过了什么吗?有人知道这是什么意思吗?

阅读关于System.Diagnostics.Contracts.Contract受静态类影响的静态类后,我很高兴,并立即开始对Call.Requires()和Contract.Ensures()的调用进行编码.

我想这只是因为我的代码是非常棒的,没有bug的,检查那些电话实际上做的只是直到最近才出现.一个错误滑过来,我意识到这些电话没有做任何事情!我本来以为他们至少在违反条件时抛出异常,但没有这样的运气.

我错过了什么吗?有人知道这是什么意思吗?

the Contract Class page at MSDN
You must use a binary rewriter to  insert run-time enforcement of  contracts. Otherwise, contracts such  as the Contract.Ensures method can  only be tested statically and will not  throw exceptions during run time if a  contract is violated. You can download  the binary rewriter CCRewrite from  Code Contracts on the MSDN DevLabs Web  site. CCRewrite comes with a Visual  Studio add-in that enables you to  activate run-time contract enforcement  from the project Properties page. The  binary rewriter and the Visual Studio  add-in do not ship with Visual Studio  2010 or the Windows SDK.

http://stackoverflow.com/questions/2883717/so-do-c4-0-code-contracts-actually-do-anything


以上所述就是小编给大家介绍的《那么C#4.0代码合同实际上做什么呢?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

PHP for the World Wide Web, Second Edition (Visual QuickStart Gu

PHP for the World Wide Web, Second Edition (Visual QuickStart Gu

Larry Ullman / Peachpit Press / 2004-02-02 / USD 29.99

So you know HTML, even JavaScript, but the idea of learning an actual programming language like PHP terrifies you? Well, stop quaking and get going with this easy task-based guide! Aimed at beginning ......一起来看看 《PHP for the World Wide Web, Second Edition (Visual QuickStart Gu》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具