Hi,
When compiling code which uses code contracts, I have a very strange error I don't understand.
[ContractInvariantMethod]
private void ObjectInvariant()
{
Contract.Invariant(
this.isSubsidiary ||
this.parentCompanyId == default(Guid));
}
fails with the following error:
Malformed contract. Found Invariant after assignment in method '<ProjectName>.ObjectInvariant'.
If the code is modified like this:
[ContractInvariantMethod]
private void ObjectInvariant()
{
Contract.Invariant(
this.isSubsidiary ||
this.parentCompanyId == Guid.Empty);
// Noticed the Guid.Empty instead of default(Guid)?
}
it compiles well.
What's wrong with my default(Guid)
?