When I verify contracts on this code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Diagnostics.Contracts;
namespace ContractTest
{
public sealed class MyClass
{
public int MyProperty { get; set; }
public void Test()
{
Contract.Requires(GetType() != null);
Contract.Requires(GetType().GetProperties() != null );
Contract.Requires(GetType().GetProperties().Length == 1);
}
public void Test2()
{
Test();
}
}
}
I get
MyClass.cs(23,13): warning : CodeContracts: requires unproven
MyClass.cs(18,13): warning : + location related to previous warning
It's complaining about the line
Contract.Requires(GetType().GetProperties().Length == 1);
Am I missing something or is the static checker unable to verify constraints based on reflection?