CodeContracts: ccrewrite fails with Object reference not set to an instance of an object
Posted
by Vyas Bharghava
on Stack Overflow
See other posts from Stack Overflow
or by Vyas Bharghava
Published on 2010-05-23T02:41:12Z
Indexed on
2010/05/23
2:50 UTC
Read the original article
Hit count: 336
The below code makes ccrewrite blow up! Ideas? BTW, If you comment out the ActualClass, ccrewrite succeeds...
[ContractClass(typeof(TestContracts))]
interface ITestInterface
{
bool IsStarted { get; set; }
void Begin();
}
class ActualClass : ITestInterface
{
public bool IsStarted { get; set; }
public void Begin()
{
this.IsStarted = true;
}
}
[ContractClassFor(typeof(ITestInterface))]
class TestContracts : ITestInterface
{
ITestInterface Current { get; set; }
private TestContracts()
{
Current = this;
}
#region ITestInterface Members
bool ITestInterface.IsStarted
{
get; set;
}
void ITestInterface.Begin()
{
Contract.Requires(!Current.IsStarted);
Contract.Ensures(Current.IsStarted);
}
Thanks in advance!
© Stack Overflow or respective owner