2 writes to Length
Microsoft.Extensions.Primitives (2)
StringSegment.cs (2)
32Length = buffer?.Length ?? 0; 61Length = length;
271 references to Length
Microsoft.AspNetCore.Components (4)
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 (28)
Features\FormFeature.cs (1)
385if (boundary.Length > lengthLimit)
src\Http\Shared\CookieHeaderParserShared.cs (12)
69if (StringSegment.IsNullOrEmpty(value) || (index == value.Length)) 81if (current == value.Length) 98if ((separatorFound && !supportsMultipleValues) || (!separatorFound && (current < value.Length))) 110Contract.Requires(startIndex <= input.Length); // it's OK if index == value.Length. 115if ((current == input.Length) || (input[current] != ',' && input[current] != ';')) 129while ((current < input.Length) && ((input[current] == ',') || (input[current] == ';'))) 147if (StringSegment.IsNullOrEmpty(input) || (offset >= input.Length)) 185Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - offset))); 189if (offset >= input.Length) 204offset = input.Length; 213if (offset == input.Length || input[offset] != '"') 233if (offset >= input.Length || input[offset] != '=')
src\Shared\HttpRuleParser.cs (15)
56Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 58if (startIndex >= input.Length) 70Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 72if (startIndex >= input.Length) 80while (current < input.Length) 93if ((current + 2 < input.Length) && (input[current + 1] == LF)) 108return input.Length - startIndex; 113Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 114Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 133while (current < input.Length) 165Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 175if ((startIndex + 2 > input.Length) || (input[startIndex + 1] > 127)) 220Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 230while (current < input.Length) 234if ((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); 356if (index + 2 < value.Length && value[index + 1] == ':') 362&& 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\Shared\HttpRuleParser.cs (15)
56Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 58if (startIndex >= input.Length) 70Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 72if (startIndex >= input.Length) 80while (current < input.Length) 93if ((current + 2 < input.Length) && (input[current + 1] == LF)) 108return input.Length - startIndex; 113Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 114Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 133while (current < input.Length) 165Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 175if ((startIndex + 2 > input.Length) || (input[startIndex + 1] > 127)) 220Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 230while (current < input.Length) 234if ((current + 2 < input.Length) &&
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)
245var length = Math.Max(xSegment.Length, ySegment.Length); 271if (enumerator.Current.HasValue && enumerator.Current.Length > 0) 285if (!value.HasValue || value.Length == 0) 293value = new StringSegment(value.Buffer, value.Offset + 2, value.Length - 2); 299value = new StringSegment(value.Buffer, value.Offset + 1, value.Length - 1); 314while (offset < value.Offset + value.Length) 324var 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\Shared\HttpRuleParser.cs (15)
56Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 58if (startIndex >= input.Length) 70Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 72if (startIndex >= input.Length) 80while (current < input.Length) 93if ((current + 2 < input.Length) && (input[current + 1] == LF)) 108return input.Length - startIndex; 113Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 114Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 133while (current < input.Length) 165Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 175if ((startIndex + 2 > input.Length) || (input[startIndex + 1] > 127)) 220Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 230while (current < input.Length) 234if ((current + 2 < input.Length) &&
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)
43if (trimmed.Length == 0)
Microsoft.Extensions.Primitives (35)
Extensions.cs (1)
21return builder.Append(segment.Buffer, segment.Offset, segment.Length);
InplaceStringBuilder.cs (1)
80Append(segment.Buffer, segment.Offset, segment.Length);
StringSegment.cs (31)
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) 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, ExceptionArgument.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); 381/// <paramref name="offset"/> is greater than or equal to <see cref="Length"/> or less than zero. 383public string Substring(int offset) => Substring(offset, Length - offset); 395/// greater than <see cref="Length"/>. 400if (!HasValue || offset < 0 || length < 0 || (uint)(offset + length) > (uint)Length) 416/// <paramref name="offset"/> is greater than or equal to <see cref="Length"/> or less than zero. 418public StringSegment Subsegment(int offset) => Subsegment(offset, Length - offset); 429/// greater than <see cref="Length"/>. 433if (!HasValue || offset < 0 || length < 0 || (uint)(offset + length) > (uint)Length) 451/// greater than <see cref="Length"/>. 460if ((uint)start > (uint)Length) 465if ((uint)count > (uint)(Length - start)) 488/// <paramref name="start"/> is greater than or equal to <see cref="Length"/> or less than zero. 490public int IndexOf(char c, int start) => IndexOf(c, start, Length - start); 497public int IndexOf(char c) => IndexOf(c, 0, Length); 514/// greater than <see cref="Length"/>. 523if ((uint)startIndex > (uint)Length) 528if ((uint)count > (uint)(Length - startIndex)) 552/// <paramref name="startIndex"/> is greater than or equal to <see cref="Length"/> or less than zero. 556return IndexOfAny(anyOf, startIndex, Length - startIndex); 568return IndexOfAny(anyOf, 0, Length); 648if (!value.HasValue || value.Length == 0)
StringTokenizer.cs (2)
119if (!_value.HasValue || _index > _value.Length) 129next = _value.Length;
Microsoft.Net.Http.Headers (129)
BaseHeaderParser.cs (3)
26if (StringSegment.IsNullOrEmpty(value) || (index == value.Length)) 39if (current == value.Length) 60if ((separatorFound && !SupportsMultipleValues) || (!separatorFound && (current < value.Length)))
CacheControlHeaderValue.cs (7)
524if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 533while (current < input.Length) 561return input.Length - startIndex; 574switch (name.Length) 723if ((valueString.Length < 3) || (valueString[0] != '\"') || (valueString[valueString.Length - 1] != '\"')) 730var maxLength = valueString.Length - 1; // -1 because we don't want to parse the final '"'.
ContentDispositionHeaderValue.cs (18)
280if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 299if ((current < input.Length) && (input[current] == ';')) 316Contract.Requires((input.Length > 0) && (startIndex < input.Length)); 343if ((dispositionTypeLength == 0) || (tempDispositionType.Length != dispositionType.Length)) 361dateString = dateString.Subsegment(1, dateString.Length - 2); 472result = result.Subsegment(1, result.Length - 2); 483else if (!needsQuotes && HttpRuleParser.GetTokenLength(result, 0) != result.Length) 508var builder = new StringBuilder(result.Length); 509for (int i = 0; i < result.Length; i++) 529return value.Length > 1 && value.StartsWith("\"", StringComparison.Ordinal) 581if (!IsQuoted(processedInput) || processedInput.Length < 10) 720unescapedBytes = ArrayPool<byte>.Shared.Rent(dataString.Length); 722for (var index = 0; index < dataString.Length; index++) 766if ((pattern.Length - index) < 3) 798if ((index < 0) || (index >= pattern.Length)) 803&& (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 (3)
172if (HttpRuleParser.GetTokenLength(name, 0) != name.Length) 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] != '/')) 255if (tagLength == input.Length)
HeaderUtilities.cs (18)
78if (HttpRuleParser.GetTokenLength(value, 0) != value.Length) 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] == '\\') 696return string.Create(input.Length + backSlashCount + 2, input, (span, segment) => 702for (var i = 0; i < segment.Length; i++) 722for (var i = 0; i < input.Length; i++)
HttpHeaderParser.cs (1)
35Contract.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)) 170if (current != input.Length) 183current = 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) 673if (offset >= input.Length || input[offset] != '=') 704end = input.Length;
src\Http\Shared\CookieHeaderParserShared.cs (12)
69if (StringSegment.IsNullOrEmpty(value) || (index == value.Length)) 81if (current == value.Length) 98if ((separatorFound && !supportsMultipleValues) || (!separatorFound && (current < value.Length))) 110Contract.Requires(startIndex <= input.Length); // it's OK if index == value.Length. 115if ((current == input.Length) || (input[current] != ',' && input[current] != ';')) 129while ((current < input.Length) && ((input[current] == ',') || (input[current] == ';'))) 147if (StringSegment.IsNullOrEmpty(input) || (offset >= input.Length)) 185Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - offset))); 189if (offset >= input.Length) 204offset = input.Length; 213if (offset == input.Length || input[offset] != '"') 233if (offset >= input.Length || input[offset] != '=')
src\Shared\HttpRuleParser.cs (15)
56Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 58if (startIndex >= input.Length) 70Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 72if (startIndex >= input.Length) 80while (current < input.Length) 93if ((current + 2 < input.Length) && (input[current + 1] == LF)) 108return input.Length - startIndex; 113Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 114Contract.Ensures((Contract.Result<int>() >= 0) && (Contract.Result<int>() <= (input.Length - startIndex))); 133while (current < input.Length) 165Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 175if ((startIndex + 2 > input.Length) || (input[startIndex + 1] > 127)) 220Contract.Requires((startIndex >= 0) && (startIndex < input.Length)); 230while (current < input.Length) 234if ((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)