private int DoGetLeadingTabCount(NSString text, int i) { Contract.Requires(text != null && !text.IsNil()); Contract.Requires(i >= 0); Contract.Requires(i == 0 || text[i-1] == '\n'); var textLen = text.length(); var j = i; while (j < textLen && text[j] == '\t') j++; return j - i; }