Code Contracts: Why are some invariants not considered outside the class?
Consider this immutable type: public class Settings { public string Path { get; private set; } [ContractInvariantMethod] private void ObjectInvariants() { Contract.Invariant(Path != null); } public Settings(string path) { Contract.Requires(path != null); Path = path; } } Two things to notice here: There is a contract invariant which ensures the Path property can never be null The constructor checks the path argument value to respect the previous contract invariant At this point, a Setting instance can never have a null Path property. Now, look at this type: public class Program { private