У меня есть фрагмент кода, для которого cccheck
говорит мне, что Requires()
недоказан, и что я должен добавить !string.IsNullOrWhitespace(...)
. Это условие уже проверено, так как я вызываю свой собственный метод расширения, который я написал во времена .Net 3.5:
public static bool IsEmpty(this string s)
{
if (s == null) return true;
if (s.Length == 0) return true;
for (int i = 0; i < s.Length; i++)
if (!char.IsWhitespace(s[i]))
return false;
return true;
}
public static bool IsNotEmpty(this string s)
{
return !IsEmpty(s);
}
Мой код уже требует, чтобы value
было IsNotEmpty
:
Contract.Requires(value.IsNotEmpty(), "The parameter 'value' cannot be null or empty.");
Как я могу сказать cccheck
(и остальной части платформы Code Contracts), что IsNotEmpty()
уже проверяет !string.IsNullOrWhitespace(...)
?