静态检查员无法证明合同 [英] static checker fails to prove contract
本文介绍了静态检查员无法证明合同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class Implementation<T> : IInterface<T>
{
T _instance;
public Implementation(T instance)
{
Contract.Requires(instance != null);
_instance = instance;
}
public T Instance
{
get
{
return _instance;
}
set
{
Contract.Requires(value != null);
_instance = value;
}
}
void IInterface<T>.ReplaceInstance(object instance)
{
var tmp = (T)instance;
Contract.Assume(tmp != null);
Instance = tmp;
}
}
[ContractClass(typeof(IInterfaceContract<>))]
public interface IInterface<out T>
{
T Instance { get; }
void ReplaceInstance(object instance);
}
[ContractClassFor(typeof(IInterface<>))]
abstract class IInterfaceContract<T> : IInterface<T>
{
T IInterface<T>.Instance
{
get { throw new NotImplementedException(); }
}
void IInterface<T>.ReplaceInstance(object instance)
{
Contract.Requires(instance != null);
throw new NotImplementedException();
}
}
推荐答案
你好Dluk,
Hi Dluk,
我无法重现它。我们已经修好了,或者我没有使用你正在使用的相同开关,你能告诉我你正在使用哪些开关吗?
I cannot reproduce it. Either we already fixed it, or I am not using the same switches you are using, can you please tell me which ones you are using?
谢谢!
f
这篇关于静态检查员无法证明合同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文