CodeContracts路线图? [英] CodeContracts roadmap?

查看:49
本文介绍了CodeContracts路线图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!

是否有您计划实施的功能的公开列表或代码合同的演变方式的声明?

Is there public list of features you're planning to implement or any declarations of the way code contracts will be evolved?

如果不是,这个论坛是否是提议提交建议的方式?我要使用MS connect,但代码合同没有连接目录。

If no, is this forum the proposed way to submit suggestions? I'd to use MS connect, but there's no connection directory for code contracts.

 

我再次尝试的主要原因是再次在生产中使用代码合同是静态合同验证。可悲的是,就像现在一样,这几乎是不可能的。

The main reason I'm trying again and again to use code contracts in production is the static contract verification. Sadly, as it is for now, it's almost impossible.

首先,CC要求在调用链中明确定义每个_each_方法的合约。这是非常不切实际的,因为它使所有代码通过其合同定义紧密耦合。因此,方法的每个更改都要求您在所有呼叫者,呼叫者的所有呼叫者等上仔细添加或删除断言
。此外,如果仅使用动态验证则没有任何意义。因此,您必须使用[条件("DEBUG")]属性定义一些检查,并复制其中的一部分以启用运行时验证,而无需支付
冗余重新检查。

First of all, CC requires to explicitly define contracts per _each_ method in call chain. It's _very_ impractical because it makes all code tightly coupled by its contract definitions. So, every change in method require you to carefully add or remove assertions on all callers, all callers of callers etc. Also, it has no sense if you use just dynamic verification. So, you'd had to define some checks with [Conditional("DEBUG")] attributes and duplicate part of them to enable runtime verification without paying for redundant re-checking.

问题不是我独有的,有一些讨论:

The problem is not unique to me, there're some discussions:

- http://stackoverflow.com/questions/2754060/how-do-i-imply-code -contracts-of-chain-methods-to-avoid-superfluous-check-whil

- http://stackoverflow.com/questions/2754060/how-do-i-imply-code-contracts-of-chained-methods-to-avoid-superfluous-checks-whil

- http://stackoverflow.com/questions/2539497/code-contracts-do-we-必须指定合同 - 要求 - 陈述 - 冗余/ 2626997

- http://stackoverflow.com/questions/2539497/code-contracts-do-we-have-to-specify-contract-requires-statements-redundant/2626997

- http://social.msdn.microsoft.com/Forums/en-US/codecontracts/thread/434fdb77 -262e-474b-84ee-1fb0d5a843b1

- http://social.msdn.microsoft.com/Forums/en-US/codecontracts/thread/434fdb77-262e-474b-84ee-1fb0d5a843b1

建议的解决方案相对简单:只需允许我们添加[ContractTransparent]属性以自动推断代码合约。

The proposed solution is relatively simple: just allow us to add [ContractTransparent] attribute to deduce code contracts automatically.

 

其次,以正确的方式实现帮助方法非常困难。默认的Contract.Requires<>不允许使用字符串格式化并且不允许指定消息 - 您传递的字符串将保存为ArgumentException的参数
name。

Second, it is _very_ hard to implement helper methods in the proper way. The default Contract.Requires<> does not allow to use string formating and does not allow to specify message - the string you pass will be saved as an ArgumentException's parameter name.

 如果您决定使用旧式if-then-throw - 还有另一个问题:没有办法提供真正的参数名称 - 你会得到很多"CodeContracts:需要unproven:argument!= null"构建警告。

 If you'd decide to use old-style if-then-throw - there's another issue: no way to supply real argument names - you'll get a lot of "CodeContracts: requires unproven: argument != null" build warnings.

同样,建议的解决方案很简单 - 只需使用标记为[ArgumentName]的帮助程序参数来推断正在验证的参数名称。

Again, the proposed solution will be simple - just use helper's parameter marked as [ArgumentName] to deduce the name of argument being verified.

有更多的showstoppers,但这两个是最关键的。

There're more of showstoppers, but these two are most critical ones.

谢谢!

 

 

 

推荐答案

再次上传。


这篇关于CodeContracts路线图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆