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

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

内容简介:阅读关于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代码合同实际上做什么呢?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

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

A Project Guide to UX Design

A Project Guide to UX Design

Russ Unger、Carolyn Chandler / New Riders Press / 2009-3-23 / USD 39.99

"If you are a young designer entering or contemplating entering the UX field this is a canonical book. If you are an organization that really needs to start grokking UX this book is also for you. " -......一起来看看 《A Project Guide to UX Design》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

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

Markdown 在线编辑器