2 writes to Length
Microsoft.Extensions.Primitives (2)
StringSegment.cs (2)
32Length = buffer?.Length ?? 0; 61Length = length;
276 references to Length
Microsoft.AspNetCore.Components (4)
src\aspnetcore\src\Http\Routing\src\Patterns\RoutePatternMatcher.cs (4)
81if (stringSegment.Length == 0) 87if (pathSegment == null && stringSegment.Length > 0) 230if (stringSegment.Length == 0 && 271if (requestSegment.Length > 0)
Microsoft.AspNetCore.Http (30)
Features\FormFeature.cs (1)
389if (boundary.Length > lengthLimit)
src\aspnetcore\src\Http\Shared\CookieHeaderParserShared.cs (14)
69if (StringSegment.IsNullOrEmpty(value) || (index == value.Length)) 81if (current == value.Length) 101index = value.Length; 109if ((separatorFound && !supportsMultipleValues) || (!separatorFound && (current < value.Length))) 120index = value.Length; 132Contract.Requires(startIndex <= input.Length); // it's OK if index == value.Length. 137if (current == input.Length || input[current] != ';') 151while (current < input.Length && input[current] == ';') 181if (StringSegment.IsNullOrEmpty(input) || (offset >= input.Length)) 219Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - offset))); 223if (offset >= input.Length) 238offset = input.Length; 247if (offset == input.Length || input[offset] != '"') 267if (offset >= input.Length || input[offset] != '=')
src\aspnetcore\src\Shared\HttpRuleParser.cs (15)
59Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 61if (startIndex >= input.Length) 73Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 75if (startIndex >= input.Length) 83while (current < input.Length) 96if ((current + 2 < input.Length) && (input[current + 1] == LF)) 111return input.Length - startIndex; 116Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 117Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 136while (current < input.Length) 168Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 178if ((startIndex + 2 > input.Length) || (input[startIndex + 1] > 127)) 223Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 233while (current < input.Length) 237if ((current + 2 < input.Length) &&
Microsoft.AspNetCore.Http.Abstractions (8)
HostString.cs (8)
149var encoded = s_idnMapping.GetAscii(host.Buffer!, host.Offset, host.Length); 236for (int i = 0; i < port.Length; i++) 260if (pattern.StartsWith("*.", StringComparison.Ordinal) && host.Length >= pattern.Length) 265var hostRoot = host.Subsegment(host.Length - allowedRoot.Length); 365if (index + 2 < value.Length && value[index + 1] == ':') 371&& index < value.Length - 1
Microsoft.AspNetCore.Mvc.Abstractions (5)
ModelBinding\ModelStateDictionary.cs (5)
878if (subKey.Length == 0) 898if (subKey.Length == 0) 938var result = midKey.Length - searchKey.Length; 946searchKey.Length,
Microsoft.AspNetCore.Mvc.Core (26)
Formatters\AcceptHeaderParser.cs (1)
158return result.MediaType.Length;
Formatters\MediaType.cs (3)
36: this(mediaType.Buffer ?? string.Empty, mediaType.Offset, mediaType.Length) 221var restOffset = charsetOffset + charset.Length; 222var restLength = mediaType.Length - restOffset;
Routing\ViewEnginePath.cs (3)
63if (segment.Length == 0 || 80if (segment.Length == 0) 111builder.Append(segment.Buffer, segment.Offset, segment.Length);
src\aspnetcore\src\Shared\HttpRuleParser.cs (15)
59Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 61if (startIndex >= input.Length) 73Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 75if (startIndex >= input.Length) 83while (current < input.Length) 96if ((current + 2 < input.Length) && (input[current + 1] == LF)) 111return input.Length - startIndex; 116Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 117Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 136while (current < input.Length) 168Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 178if ((startIndex + 2 > input.Length) || (input[startIndex + 1] > 127)) 223Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 233while (current < input.Length) 237if ((current + 2 < input.Length) &&
src\aspnetcore\src\Shared\MediaType\ReadOnlyMediaTypeHeaderValue.cs (4)
29: this(mediaType.Buffer ?? string.Empty, mediaType.Offset, mediaType.Length) 71SubTypeWithoutSuffix = subType.Subsegment(0, subType.Length - subtypeSuffixLength - 1); 72SubTypeSuffix = subType.Subsegment(subType.Length - subtypeSuffixLength, subtypeSuffixLength); 147var startPos = subType.Offset + subType.Length - 1;
Microsoft.AspNetCore.Mvc.TagHelpers (12)
Cache\CacheTagKey.cs (1)
283if (trimmedValue.Length != 0)
EnvironmentTagHelper.cs (3)
94if (environment.HasValue && environment.Length > 0) 113if (environment.HasValue && environment.Length > 0) 131if (environment.HasValue && environment.Length > 0)
GlobbingUrlBuilder.cs (8)
246var length = Math.Max(xSegment.Length, ySegment.Length); 272if (enumerator.Current.HasValue && enumerator.Current.Length > 0) 286if (!value.HasValue || value.Length == 0) 294value = new StringSegment(value.Buffer, value.Offset + 2, value.Length - 2); 300value = new StringSegment(value.Buffer, value.Offset + 1, value.Length - 1); 315while (offset < value.Offset + value.Length) 325var trimmedEnd = value.Offset + value.Length - 1;
Microsoft.AspNetCore.Routing (23)
Patterns\RoutePatternMatcher.cs (4)
81if (stringSegment.Length == 0) 87if (pathSegment == null && stringSegment.Length > 0) 230if (stringSegment.Length == 0 && 271if (requestSegment.Length > 0)
src\aspnetcore\src\Shared\HttpRuleParser.cs (15)
59Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 61if (startIndex >= input.Length) 73Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 75if (startIndex >= input.Length) 83while (current < input.Length) 96if ((current + 2 < input.Length) && (input[current + 1] == LF)) 111return input.Length - startIndex; 116Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 117Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 136while (current < input.Length) 168Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 178if ((startIndex + 2 > input.Length) || (input[startIndex + 1] > 127)) 223Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 233while (current < input.Length) 237if ((current + 2 < input.Length) &&
src\aspnetcore\src\Shared\MediaType\ReadOnlyMediaTypeHeaderValue.cs (4)
29: this(mediaType.Buffer ?? string.Empty, mediaType.Offset, mediaType.Length) 71SubTypeWithoutSuffix = subType.Subsegment(0, subType.Length - subtypeSuffixLength - 1); 72SubTypeSuffix = subType.Subsegment(subType.Length - subtypeSuffixLength, subtypeSuffixLength); 147var startPos = subType.Offset + subType.Length - 1;
Microsoft.Extensions.FileProviders.Embedded (1)
Manifest\EmbeddedFilesManifest.cs (1)
50if (trimmed.Length == 0)
Microsoft.Extensions.Primitives (40)
Extensions.cs (1)
21return builder.Append(segment.Buffer, segment.Offset, segment.Length);
InplaceStringBuilder.cs (1)
71Append(segment.Buffer, segment.Offset, segment.Length);
StringSegment.cs (36)
82public string? Value => HasValue ? Buffer.Substring(Offset, Length) : null; 97/// <paramref name="index"/> is greater than or equal to <see cref="Length"/> or less than zero. 103if ((uint)index >= (uint)Length) 105ThrowArgumentOutOfRangeExclusive(index, Length); 117public ReadOnlySpan<char> AsSpan() => Buffer.AsSpan(Offset, Length); 127/// <paramref name="start"/> is greater than or equal to <see cref="Length"/> or less than zero. 133ThrowInvalidArguments(start, Length - start); 136return Buffer.AsSpan(Offset + start, Length - start); 149/// greater than <see cref="Length"/>. 153if (!HasValue || start < 0 || length < 0 || (uint)(start + length) > (uint)Length) 165public ReadOnlyMemory<char> AsMemory() => Buffer.AsMemory(Offset, Length); 375/// <paramref name="offset"/> is greater than or equal to <see cref="Length"/> or less than zero. 377public string Substring(int offset) => Substring(offset, Length - offset); 389/// greater than <see cref="Length"/>. 394if (!HasValue || offset < 0 || length < 0 || (uint)(offset + length) > (uint)Length) 410/// <paramref name="offset"/> is greater than or equal to <see cref="Length"/> or less than zero. 412public StringSegment Subsegment(int offset) => Subsegment(offset, Length - offset); 423/// greater than <see cref="Length"/>. 427if (!HasValue || offset < 0 || length < 0 || (uint)(offset + length) > (uint)Length) 445/// greater than <see cref="Length"/>. 454if ((uint)start > (uint)Length) 456ThrowArgumentOutOfRangeInclusive(start, Length); 459if ((uint)count > (uint)(Length - start)) 461ThrowArgumentOutOfRangeInclusive(count, Length - start); 482/// <paramref name="start"/> is greater than or equal to <see cref="Length"/> or less than zero. 484public int IndexOf(char c, int start) => IndexOf(c, start, Length - start); 491public int IndexOf(char c) => IndexOf(c, 0, Length); 508/// greater than <see cref="Length"/>. 517if ((uint)startIndex > (uint)Length) 519ThrowArgumentOutOfRangeInclusive(startIndex, Length); 522if ((uint)count > (uint)(Length - startIndex)) 524ThrowArgumentOutOfRangeInclusive(count, Length - startIndex); 546/// <paramref name="startIndex"/> is greater than or equal to <see cref="Length"/> or less than zero. 550return IndexOfAny(anyOf, startIndex, Length - startIndex); 562return IndexOfAny(anyOf, 0, Length); 642if (!value.HasValue || value.Length == 0)
StringTokenizer.cs (2)
109if (!_value.HasValue || _index > _value.Length) 119next = _value.Length;
Microsoft.Net.Http.Headers (127)
BaseHeaderParser.cs (3)
34if (StringSegment.IsNullOrEmpty(value) || (startIndex == value.Length)) 47if (current == value.Length) 77if ((separatorFound && !SupportsMultipleValues) || (!separatorFound && (current < value.Length)))
CacheControlHeaderValue.cs (7)
524if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 533while (current < input.Length) 563return input.Length - startIndex; 576switch (name.Length) 725if ((valueString.Length < 3) || (valueString[0] != '\"') || (valueString[valueString.Length - 1] != '\"')) 732var maxLength = valueString.Length - 1; // -1 because we don't want to parse the final '"'.
ContentDispositionHeaderValue.cs (17)
279if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 298if ((current < input.Length) && (input[current] == ';')) 315Contract.Requires((input.Length > 0) && (startIndex < input.Length)); 342if ((dispositionTypeLength == 0) || (tempDispositionType.Length != dispositionType.Length)) 360dateString = dateString.Subsegment(1, dateString.Length - 2); 471result = result.Subsegment(1, result.Length - 2); 507var builder = new StringBuilder(result.Length); 508for (int i = 0; i < result.Length; i++) 528return value.Length > 1 && value.StartsWith("\"", StringComparison.Ordinal) 580if (!IsQuoted(processedInput) || processedInput.Length < 10) 719unescapedBytes = ArrayPool<byte>.Shared.Rent(dataString.Length); 721for (var index = 0; index < dataString.Length; index++) 765if ((pattern.Length - index) < 3) 797if ((index < 0) || (index >= pattern.Length)) 802&& (pattern.Length - index >= 3))
ContentRangeHeaderValue.cs (6)
233if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 257if (current == input.Length) 270if ((current == input.Length) || (input[current] != '/')) 278if (current == input.Length) 350if ((current == input.Length) || (input[current] != '-')) 359if (current == input.Length)
CookieHeaderValue.cs (2)
187if (result.Length != value.Length)
EntityTagHeaderValue.cs (4)
61(length != tag.Length)) 216if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 239if ((current + 2 >= input.Length) || (input[current] != '/')) 258if (tagLength == input.Length)
HeaderUtilities.cs (16)
156Contract.Requires(startIndex <= input.Length); // it's OK if index == value.Length. 161if ((current == input.Length) || (input[current] != ',')) 174while ((current < input.Length) && (input[current] == ',')) 372if (string.IsNullOrEmpty(value.Buffer) || value.Length == 0) 398if (string.IsNullOrEmpty(value.Buffer) || value.Length == 0) 414var inputLength = input.Length; 593input = input.Subsegment(1, input.Length - 2); 605return !StringSegment.IsNullOrEmpty(input) && input.Length >= 2 && input[0] == '"' && input[input.Length - 1] == '"'; 626return string.Create(input.Length - backSlashCount, input, (span, segment) => 630for (var i = 0; i < segment.Length && (uint)spanIndex < (uint)spanLength; i++) 633if ((uint)nextIndex < (uint)segment.Length && segment[i] == '\\') 657for (var i = 0; i < input.Length; i++) 659if (i < input.Length - 1 && input[i] == '\\') 697return string.Create(input.Length + backSlashCount + 2, input, (span, segment) => 703for (var i = 0; i < segment.Length; i++)
HttpHeaderParser.cs (1)
43Contract.Requires((value == null) || ((index >= 0) && (index <= value.Length)));
MediaTypeHeaderValue.cs (7)
566if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 584if ((current < input.Length) && (input[current] == ';')) 606Contract.Requires((input.Length > 0) && (startIndex < input.Length)); 623if ((current >= input.Length) || (input[current] != '/')) 663if ((mediaTypeLength == 0) || (tempMediaType.Length != mediaType.Length))
NameValueHeaderValue.cs (8)
193if (StringSegment.IsNullOrEmpty(value) || (GetValueLength(value, 0) == value.Length)) 342if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 361if ((current == input.Length) || (input[current] != '=')) 396if ((StringSegment.IsNullOrEmpty(input)) || (startIndex >= input.Length)) 416if ((current == input.Length) || (input[current] != delimiter)) 436Contract.Requires(name.Length > 0); 456if (startIndex >= input.Length) 484if (!(StringSegment.IsNullOrEmpty(value) || (GetValueLength(value, 0) == value.Length)))
RangeConditionHeaderValue.cs (3)
140if (StringSegment.IsNullOrEmpty(input) || (startIndex + 1 >= input.Length)) 177if (current != input.Length) 190current = input.Length;
RangeHeaderValue.cs (3)
158if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 176if ((current == input.Length) || (input[current] != '=')) 192Contract.Assert(current == input.Length, "GetRangeItemListLength() should consume the whole string or fail.");
RangeItemHeaderValue.cs (7)
112if ((StringSegment.IsNullOrEmpty(input)) || (startIndex >= input.Length)) 121if (current == input.Length) 142if ((current < input.Length) && !separatorFound) 147if (current == input.Length) 162if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 183if ((current == input.Length) || (input[current] != '-')) 196if (current < input.Length)
SetCookieHeaderValue.cs (9)
191var length = _name.Length + EqualsToken.Length + _value.Length; 209length += SeparatorToken.Length + DomainToken.Length + EqualsToken.Length + Domain.Length; 214length += SeparatorToken.Length + PathToken.Length + EqualsToken.Length + Path.Length; 248length += SeparatorToken.Length + extension.Length; 480if (StringSegment.IsNullOrEmpty(input) || (offset >= input.Length)) 511while (offset < input.Length) 683if (offset >= input.Length || input[offset] != '=') 714end = input.Length;
src\aspnetcore\src\Http\Shared\CookieHeaderParserShared.cs (14)
69if (StringSegment.IsNullOrEmpty(value) || (index == value.Length)) 81if (current == value.Length) 101index = value.Length; 109if ((separatorFound && !supportsMultipleValues) || (!separatorFound && (current < value.Length))) 120index = value.Length; 132Contract.Requires(startIndex <= input.Length); // it's OK if index == value.Length. 137if (current == input.Length || input[current] != ';') 151while (current < input.Length && input[current] == ';') 181if (StringSegment.IsNullOrEmpty(input) || (offset >= input.Length)) 219Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - offset))); 223if (offset >= input.Length) 238offset = input.Length; 247if (offset == input.Length || input[offset] != '"') 267if (offset >= input.Length || input[offset] != '=')
src\aspnetcore\src\Shared\HttpRuleParser.cs (15)
59Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 61if (startIndex >= input.Length) 73Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 75if (startIndex >= input.Length) 83while (current < input.Length) 96if ((current + 2 < input.Length) && (input[current + 1] == LF)) 111return input.Length - startIndex; 116Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 117Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 136while (current < input.Length) 168Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 178if ((startIndex + 2 > input.Length) || (input[startIndex + 1] > 127)) 223Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 233while (current < input.Length) 237if ((current + 2 < input.Length) &&
StringWithQualityHeaderValue.cs (5)
191if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 209if ((current == input.Length) || (input[current] != ';')) 233if ((current == input.Length) || ((input[current] != 'q') && (input[current] != 'Q'))) 242if ((current == input.Length) || (input[current] != '=')) 250if (current == input.Length)