I have the following method:
static bool TextEquals(string text, char[] array, int start, int length)
{
Contract.Requires(text != null);
Contract.Requires(text.Length != length
|| text.Length == 0
|| (array != null && start >= 0 && start < array.Length));
if (text.Length != length)
{
return false;
}
for (var i = 0; i < text.Length; ++i)
{
if (text[i] != array[start + i])
{
return false;
}
}
return true;
}
However, Code Contracts is suggesting I add the following:
Contracts.Requires(text.Length == 0 || array != null || start < array.Length);
Contracts.Requires(text.Length == 0 || start < 0 || start < array.Length);
I am not seeing the added benefit of these two additional requirements. What path(s) are covered that the already existing requirements do not cover?
In particular, I do not see the case array == null && start < array.Length, which would be allowed by the first suggestion.
Is there any way to remove such suggestions?