语法建议:允许(否则无意义)属性递归来制定后置条件 [英] Syntax suggestion: Allow (otherwise senseless) property recursion to formulate postcondition

查看:103
本文介绍了语法建议:允许(否则无意义)属性递归来制定后置条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

在编写包括结果验证在内的一些后置条件时,我想知道以下语法是否合适:

while writing some postconditions including result verification, I wondered whether the following syntax would be nice to have:


public sealed class Foo
{
public string Bar
{
get
{
Contract.Ensures(!String.IsNullOrEmpty(this.Bar));
Contract.Ensures(this.Bar.Length == 5);

//...
}
}
}


由于这种递归没有任何意义,它可以用来避免复杂的Contarct.Result< T> ;()调用属性getter。

As this recursion would not make any sense, it could be used to avoid complicated Contarct.Result<T>() calls inside property getters.

你怎么看?

 

干杯

winSharp93

winSharp93

推荐答案

谢谢!是的,这是一个有趣的想法。我会把这个提到小组。
Thanks! Yes, that is an interesting idea. I'll bring that up with the group.


这篇关于语法建议:允许(否则无意义)属性递归来制定后置条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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