我
犯罪嫌疑人
这是因为合同电话最后都在电话亭里
MoveNext()
public static IEnumerable<UnboundTag> GetUnboundTagsRecursively
(Type bindingType)
{
Contract.Requires(bindingType != null);
Contract.Ensures(Contract.Result<IEnumerable<UnboundTag>>() != null);
return GetUnboundTagsRecursivelyImpl(bindingType);
}
private static IEnumerable<UnboundTag> GetUnboundTagsRecursivelyImpl
(Type bindingType)
{
// Iterator block code here
}
现在你可能需要做一些额外的工作来获得
方法编译而不违反任何契约。例如:
public static IEnumerable<UnboundTag> GetUnboundTagsRecursively
(Type bindingType)
{
Contract.Requires(bindingType != null);
Contract.Ensures(Contract.Result<IEnumerable<UnboundTag>>() != null);
IEnumerable<UnboundTag> ret = GetUnboundTagsRecursivelyImpl(bindingType);
// We know it won't be null, but iterator blocks are a pain.
Contract.Assume(ret != null);
return ret;
}
Assume
如果我听说代码合同团队正在解决这个问题,我不会感到惊讶。。。我想我听说过类似的事情,但我记不清细节了。这个
release notes
对迭代器上契约的初始支持
... 但假设您使用的是最新版本,那么初步支持可能还不够:)