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