Unable to prove Requires with IComparable<T>

Unanswered Unable to prove Requires with IComparable<T>

  • 2012년 3월 14일 수요일 오전 11:15
     
      코드 있음

    With the following code (from this SO question):

            public static bool Foo<T>(T value, T lowerBound, T upperBound)
            where T : IComparable<T>
            {
                Contract.Requires(upperBound.CompareTo(lowerBound) >= 0);
    
                return IsBetween(value, lowerBound, upperBound, 1);
            }
    
            public static bool IsBetween<T>(T value, T lowerBound, T upperBound, int test) where T : IComparable<T>
            {
                Contract.Requires(upperBound.CompareTo(lowerBound) >= 0);
    
                return false;
            }
    The call to IsBetween gets flagged with the warning "Requires unproven: upperBound.CompareTo(lowerBound) >= 0", which should be proven by the Requires in the containing method.