locked
ObjectInvariant Method: Invariant fails because property has default value RRS feed

  • Question

  • In some class 

    class Some
     {  public int X {get; set;}  
    public int Y {get; set;}
    [ContractInvariantMethod]
    private void ObjectInvariant()
    {
    Contract.Invariat(this.Y > 0) // Invariant failed becuase Y = 0
    }

    Friday, April 29, 2016 11:23 AM

All replies

  • In some class 

    class Some
     {  public int X {get; set;}  
    public int Y {get; set;}
    [ContractInvariantMethod]
    private void ObjectInvariant()
    {
    Contract.Invariat(this.Y > 0) // Invariant failed becuase Y = 0
    }

    Ok i fix it with binding defualt values, is there any solution?


    Friday, April 29, 2016 11:54 AM