8129 references to Length
Aspire.Dashboard (10)
ConsoleLogs\AnsiParser.cs (7)
84for (var i = 0; i < span.Length; i++) 273if (span.Length <= 2 || (span[0] != EscapeChar || span[1] != '[')) 337if (span.Length <= 2 || (span[0] != EscapeChar || span[1] != ']')) 388if (span.Length <= 5 || (span[0] != EscapeChar || span[1] != ']')) 401if (urlEndEscapePosition < 0 || span.Length < urlEndEscapePosition + 1 || span[urlEndEscapePosition + 1] != '\\') 409while (linkEndEscapePosition != -1 && span.Length > (linkEndEscapePosition + 2) && span[linkEndEscapePosition + 1] != ']') 415if (linkEndEscapePosition < 0 || span.Length < linkEndEscapePosition + 2 || span[linkEndEscapePosition + 2] != '8')
Extensions\StringExtensions.cs (1)
46if (s.Length == 0)
Otlp\Model\OtlpHelpers.cs (1)
81for (var pos = 0; pos < data.Length; pos++)
src\Shared\ConsoleLogs\TimestampParser.cs (1)
22if (match.Index + match.Length >= span.Length)
Aspire.Hosting (2)
src\Shared\ConsoleLogs\TimestampParser.cs (1)
22if (match.Index + match.Length >= span.Length)
VolumeNameGenerator.cs (1)
44for (var i = 0; i < nameSpan.Length; i++)
Aspire.Hosting.Docker (14)
EnvVarEscaper.cs (14)
35if (input.Length > MaxInputLength) 68for (var i = firstUnescaped; i < input.Length;) 85for (var i = 0; i < input.Length; i++) 101if (input.Length == 1) 123while (varLength < remaining.Length && (char.IsLetterOrDigit(remaining[varLength]) || remaining[varLength] == '_' || remaining[varLength] == '-')) 168for (var i = 0; i < remaining.Length; i++) 171if (remaining[i] == '$' && i + 1 < remaining.Length && remaining[i + 1] == '{') 194return input.Length; 206if (content.Length > MaxContentLength) 212var stripped = new char[Math.Min(content.Length, MaxContentLength)]; 271if (content.Length > MaxContentLength) 299for (var i = 0; i < content.Length - 1; i++) 301if (content[i] == '$' && i + 1 < content.Length && content[i + 1] == '{') 316else if (depth == 0 && content[i] == ':' && i + 1 < content.Length && content[i + 1] == '-')
BuildActionTelemetryTable (3)
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
CodeGenerator (1)
src\Shared\runtime\Http2\Hpack\HeaderField.cs (1)
20Debug.Assert(name.Length > 0);
ConfigurationSchemaGenerator (2)
RuntimeSource\Roslyn\GetBestTypeByMetadataName.cs (2)
162switch (span.Length) 170var builder = ImmutableArray.CreateBuilder<T>(span.Length);
GenerateDocumentationAndConfigFiles (46)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
http2cat (27)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (2)
60int entryLength = HeaderField.GetLength(name.Length, value.Length);
src\Shared\runtime\Http2\Hpack\HeaderField.cs (1)
20Debug.Assert(name.Length > 0);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (7)
188while (currentIndex < data.Length); 215if (currentIndex < data.Length) 287if (currentIndex < data.Length) 313if (currentIndex < data.Length) 425int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 463int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 640for (; currentIndex < data.Length; currentIndex++)
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (8)
424if (IntegerEncoder.Encode(value.Length, 7, destination, out int integerLength)) 429if (value.Length <= destination.Length) 434bytesWritten = integerLength + value.Length; 517if (values.Length == 0) 521else if (values.Length == 1) 530int valueLength = checked((values.Length - 1) * separator.Length); 561for (int i = 1; i < values.Length; i++) 576for (int i = 1; i < values.Length; i++)
src\Shared\runtime\Http2\Hpack\Huffman.cs (1)
692while (i < src.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 96Advance(source.Length); 138while (source.Length > 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\Http2\Http2FrameReader.cs (2)
229Debug.Assert(data.Length % SettingSize == 0, "Invalid settings payload length"); 230var settingsCount = data.Length / SettingSize;
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
IIS.FunctionalTests (27)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (2)
60int entryLength = HeaderField.GetLength(name.Length, value.Length);
src\Shared\runtime\Http2\Hpack\HeaderField.cs (1)
20Debug.Assert(name.Length > 0);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (7)
188while (currentIndex < data.Length); 215if (currentIndex < data.Length) 287if (currentIndex < data.Length) 313if (currentIndex < data.Length) 425int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 463int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 640for (; currentIndex < data.Length; currentIndex++)
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (8)
424if (IntegerEncoder.Encode(value.Length, 7, destination, out int integerLength)) 429if (value.Length <= destination.Length) 434bytesWritten = integerLength + value.Length; 517if (values.Length == 0) 521else if (values.Length == 1) 530int valueLength = checked((values.Length - 1) * separator.Length); 561for (int i = 1; i < values.Length; i++) 576for (int i = 1; i < values.Length; i++)
src\Shared\runtime\Http2\Hpack\Huffman.cs (1)
692while (i < src.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 96Advance(source.Length); 138while (source.Length > 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\Http2\Http2FrameReader.cs (2)
229Debug.Assert(data.Length % SettingSize == 0, "Invalid settings payload length"); 230var settingsCount = data.Length / SettingSize;
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
IIS.LongTests (27)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (2)
60int entryLength = HeaderField.GetLength(name.Length, value.Length);
src\Shared\runtime\Http2\Hpack\HeaderField.cs (1)
20Debug.Assert(name.Length > 0);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (7)
188while (currentIndex < data.Length); 215if (currentIndex < data.Length) 287if (currentIndex < data.Length) 313if (currentIndex < data.Length) 425int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 463int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 640for (; currentIndex < data.Length; currentIndex++)
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (8)
424if (IntegerEncoder.Encode(value.Length, 7, destination, out int integerLength)) 429if (value.Length <= destination.Length) 434bytesWritten = integerLength + value.Length; 517if (values.Length == 0) 521else if (values.Length == 1) 530int valueLength = checked((values.Length - 1) * separator.Length); 561for (int i = 1; i < values.Length; i++) 576for (int i = 1; i < values.Length; i++)
src\Shared\runtime\Http2\Hpack\Huffman.cs (1)
692while (i < src.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 96Advance(source.Length); 138while (source.Length > 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\Http2\Http2FrameReader.cs (2)
229Debug.Assert(data.Length % SettingSize == 0, "Invalid settings payload length"); 230var settingsCount = data.Length / SettingSize;
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
IIS.NewHandler.FunctionalTests (27)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (2)
60int entryLength = HeaderField.GetLength(name.Length, value.Length);
src\Shared\runtime\Http2\Hpack\HeaderField.cs (1)
20Debug.Assert(name.Length > 0);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (7)
188while (currentIndex < data.Length); 215if (currentIndex < data.Length) 287if (currentIndex < data.Length) 313if (currentIndex < data.Length) 425int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 463int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 640for (; currentIndex < data.Length; currentIndex++)
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (8)
424if (IntegerEncoder.Encode(value.Length, 7, destination, out int integerLength)) 429if (value.Length <= destination.Length) 434bytesWritten = integerLength + value.Length; 517if (values.Length == 0) 521else if (values.Length == 1) 530int valueLength = checked((values.Length - 1) * separator.Length); 561for (int i = 1; i < values.Length; i++) 576for (int i = 1; i < values.Length; i++)
src\Shared\runtime\Http2\Hpack\Huffman.cs (1)
692while (i < src.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 96Advance(source.Length); 138while (source.Length > 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\Http2\Http2FrameReader.cs (2)
229Debug.Assert(data.Length % SettingSize == 0, "Invalid settings payload length"); 230var settingsCount = data.Length / SettingSize;
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
IIS.NewShim.FunctionalTests (27)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (2)
60int entryLength = HeaderField.GetLength(name.Length, value.Length);
src\Shared\runtime\Http2\Hpack\HeaderField.cs (1)
20Debug.Assert(name.Length > 0);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (7)
188while (currentIndex < data.Length); 215if (currentIndex < data.Length) 287if (currentIndex < data.Length) 313if (currentIndex < data.Length) 425int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 463int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 640for (; currentIndex < data.Length; currentIndex++)
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (8)
424if (IntegerEncoder.Encode(value.Length, 7, destination, out int integerLength)) 429if (value.Length <= destination.Length) 434bytesWritten = integerLength + value.Length; 517if (values.Length == 0) 521else if (values.Length == 1) 530int valueLength = checked((values.Length - 1) * separator.Length); 561for (int i = 1; i < values.Length; i++) 576for (int i = 1; i < values.Length; i++)
src\Shared\runtime\Http2\Hpack\Huffman.cs (1)
692while (i < src.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 96Advance(source.Length); 138while (source.Length > 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\Http2\Http2FrameReader.cs (2)
229Debug.Assert(data.Length % SettingSize == 0, "Invalid settings payload length"); 230var settingsCount = data.Length / SettingSize;
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
IIS.ShadowCopy.Tests (8)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 96Advance(source.Length); 138while (source.Length > 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\Http2\Http2FrameReader.cs (2)
229Debug.Assert(data.Length % SettingSize == 0, "Invalid settings payload length"); 230var settingsCount = data.Length / SettingSize;
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
IISExpress.FunctionalTests (27)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (2)
60int entryLength = HeaderField.GetLength(name.Length, value.Length);
src\Shared\runtime\Http2\Hpack\HeaderField.cs (1)
20Debug.Assert(name.Length > 0);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (7)
188while (currentIndex < data.Length); 215if (currentIndex < data.Length) 287if (currentIndex < data.Length) 313if (currentIndex < data.Length) 425int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 463int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 640for (; currentIndex < data.Length; currentIndex++)
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (8)
424if (IntegerEncoder.Encode(value.Length, 7, destination, out int integerLength)) 429if (value.Length <= destination.Length) 434bytesWritten = integerLength + value.Length; 517if (values.Length == 0) 521else if (values.Length == 1) 530int valueLength = checked((values.Length - 1) * separator.Length); 561for (int i = 1; i < values.Length; i++) 576for (int i = 1; i < values.Length; i++)
src\Shared\runtime\Http2\Hpack\Huffman.cs (1)
692while (i < src.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 96Advance(source.Length); 138while (source.Length > 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\Http2\Http2FrameReader.cs (2)
229Debug.Assert(data.Length % SettingSize == 0, "Invalid settings payload length"); 230var settingsCount = data.Length / SettingSize;
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
illink (7)
ILLink.RoslynAnalyzer (3)
CompilationExtensions.cs (2)
150switch (span.Length) 158var builder = ImmutableArray.CreateBuilder<T>(span.Length);
INamedTypeSymbolExtensions.cs (1)
19while (roSpan.Length > 0)
InMemory.FunctionalTests (2)
ResponseTests.cs (1)
3435encoder.Convert(source, writer.GetSpan(), flush: source.Length == 0, out var charsUsed, out var bytesUsed, out completed);
src\Servers\Kestrel\shared\test\Http3\Http3InMemory.cs (1)
623if (span.Length > 0)
Metrics (47)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (1)
126if (remaining[index] == '\r' && remaining.Length > index + 1 && remaining[index + 1] == '\n')
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Metrics.Legacy (47)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (1)
126if (remaining[index] == '\r' && remaining.Length > index + 1 && remaining[index + 1] == '\n')
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Microsoft.AspNetCore.Authorization (2)
src\Shared\Debugger\DebuggerHelpers.cs (2)
30if (values.Length == 0) 42for (var i = 0; i < values.Length; i++)
Microsoft.AspNetCore.Components (17)
NavigationManagerExtensions.cs (2)
116_builder = new(uriWithoutQueryStringAndHash.Length + additionalCapacity); 761newQueryStringBuilder = new(uriWithoutQueryStringAndHash, query.Length + hash.Length);
PersistentStateValueProvider.cs (1)
211GrowBuffer(ref pool, ref keyBuffer, keySpan.Length * 4 + preKey.Length);
src\Components\Shared\src\ArrayBuilder.cs (2)
87var requiredCapacity = _itemsInUse + source.Length; 101_itemsInUse += source.Length;
src\Http\Routing\src\Constraints\FileNameRouteConstraint.cs (2)
124if (value.Length == 0) 143for (var i = dotIndex + 1; i < value.Length; i++)
src\Http\Routing\src\Patterns\RoutePatternMatcher.cs (4)
342var lastIndex = requestSegment.Length; 404if (part is RoutePatternLiteralPart literal && ((indexOfLiteral + literal.Content.Length) != requestSegment.Length)) 408else if (part is RoutePatternSeparatorPart separator && ((indexOfLiteral + separator.Content.Length) != requestSegment.Length)) 464if (parameterValueSpan.Length == 0)
src\Shared\QueryStringEnumerable.cs (1)
99var buffer = new char[source.Length];
src\Shared\UrlDecoder\UrlDecoder.cs (5)
20if (destination.Length < source.Length) 29return DecodeInPlace(destination.Slice(0, source.Length), isFormEncoding); 363return DecodeInPlace(destination.Slice(0, source.Length)); 591if ((uint)tempIdx >= (uint)buffer.Length) 603return (uint)c >= (uint)CharToHexLookup.Length ? -1 : CharToHexLookup[c];
Microsoft.AspNetCore.Components.Endpoints (5)
FormMapping\FormDataReader.cs (5)
175if (CurrentPrefix.Span.Length == 0) 203var keyLength = key.Length; 235Debug.Assert(_prefixBuffer.Length >= (_currentPrefixBuffer.Length + separator.Length)); 239var startingPoint = _currentPrefixBuffer.Length + separator.Length; 240_currentPrefixBuffer = _prefixBuffer.Slice(0, startingPoint + key.Length);
Microsoft.AspNetCore.Components.Forms (2)
src\Components\Shared\src\ExpressionFormatting\ReverseStringBuilder.cs (2)
40var startIndex = _nextEndIndex - span.Length; 65newEndIndex -= span.Length;
Microsoft.AspNetCore.Components.Server (30)
src\Components\Shared\src\ArrayBuilder.cs (2)
87var requiredCapacity = _itemsInUse + source.Length; 101_itemsInUse += source.Length;
src\SignalR\common\Shared\MemoryBufferWriter.cs (4)
237totalWritten += segment.Span.Length; 266totalWritten += segment.Span.Length; 319_position += span.Length; 320_bytesWritten += span.Length;
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\BufferWriter.cs (3)
162if (_span.Length >= source.Length) 165Advance(source.Length); 231int bytesLeftToCopy = source.Length;
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\MessagePackReader.cs (3)
736if (this.reader.CurrentSpanIndex + length <= this.reader.CurrentSpan.Length) 771if (unreadSpan.Length >= byteLength) 1109int bytesRead = Math.Min(remainingByteLength, this.reader.UnreadSpan.Length);
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\MessagePackWriter.cs (4)
744int length = (int)src.Length; 856var length = utf8stringBytes.Length; 946ref byte buffer = ref this.WriteString_PrepareSpan(value.Length, out int bufferSize, out int useOffset); 950int byteCount = StringEncoding.UTF8.GetBytes(pValue, value.Length, pBuffer + useOffset, bufferSize);
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\SequenceReader.cs (12)
69this.nextPosition = sequence.GetPosition(first.Length); 71this.moreData = first.Length > 0; 216if (this.CurrentSpanIndex >= this.CurrentSpan.Length) 337if ((count & TooBigOrNegative) == 0 && this.CurrentSpan.Length - this.CurrentSpanIndex > (int)count) 347else if (this.CurrentSpan.Length - this.CurrentSpanIndex == (int)count) 369if (this.usingSequence && this.CurrentSpanIndex >= this.CurrentSpan.Length) 387Debug.Assert(this.CurrentSpanIndex < this.CurrentSpan.Length, "this.CurrentSpanIndex < this.CurrentSpan.Length"); 417int remaining = this.CurrentSpan.Length - this.CurrentSpanIndex; 457if (firstSpan.Length >= destination.Length) 474Debug.Assert(firstSpan.Length < destination.Length, "firstSpan.Length < destination.Length"); 476int copied = firstSpan.Length; 484int toCopy = Math.Min(nextSpan.Length, destination.Length - copied);
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\SequenceReaderExtensions.cs (2)
35if (span.Length < sizeof(T)) 72Debug.Assert(reader.UnreadSpan.Length < sizeof(T), "reader.UnreadSpan.Length < sizeof(T)");
Microsoft.AspNetCore.Components.Web (6)
Routing\NavLink.cs (4)
191if (currentUriAbsolute.Length == hrefAbsolute.Length - 1) 201if (hrefAbsolute[hrefAbsolute.Length - 1] == '/' && 202currentUriAbsolute.SequenceEqual(hrefAbsolute.Slice(0, hrefAbsolute.Length - 1), CaseInsensitiveComparer))
src\Components\Shared\src\ExpressionFormatting\ReverseStringBuilder.cs (2)
40var startIndex = _nextEndIndex - span.Length; 65newEndIndex -= span.Length;
Microsoft.AspNetCore.Components.WebView (2)
src\Components\Shared\src\ArrayBuilder.cs (2)
87var requiredCapacity = _itemsInUse + source.Length; 101_itemsInUse += source.Length;
Microsoft.AspNetCore.CookiePolicy (1)
ResponseCookiesWrapper.cs (1)
142var nonSuppressedValues = new List<KeyValuePair<string, string>>(keyValuePairs.Length);
Microsoft.AspNetCore.Cors (2)
src\Shared\Debugger\DebuggerHelpers.cs (2)
30if (values.Length == 0) 42for (var i = 0; i < values.Length; i++)
Microsoft.AspNetCore.Cryptography.Internal (2)
CryptoUtil.cs (2)
98Assert(bufA.Length == bufB.Length, "countA == countB");
Microsoft.AspNetCore.DataProtection (6)
SP800_108\ManagedSP800_108_CTR_HMACSHA512.cs (6)
69var prfInputLength = checked(sizeof(uint) /* [i]_2 */ + label.Length + 1 /* 0x00 */ + (contextHeader.Length + contextData.Length) + sizeof(uint) /* [K]_2 */); 92contextHeader.CopyTo(prfInput.Slice(sizeof(uint) + label.Length + 1)); 93contextData.CopyTo(prfInput.Slice(sizeof(uint) + label.Length + 1 + contextHeader.Length));
Microsoft.AspNetCore.Diagnostics.Middleware.Tests (1)
Latency\AcceptanceTests.cs (1)
86for (int i = 0; i < span.Length; i++)
Microsoft.AspNetCore.Http (2)
Internal\ResponseCookies.cs (1)
91var cookies = new string[keyValuePairs.Length];
src\Shared\HttpRuleParser.cs (1)
65return (firstNonTokenCharIdx == -1) ? subspan.Length : firstNonTokenCharIdx;
Microsoft.AspNetCore.Http.Abstractions (7)
src\Shared\Debugger\DebuggerHelpers.cs (2)
30if (values.Length == 0) 42for (var i = 0; i < values.Length; i++)
src\Shared\UrlDecoder\UrlDecoder.cs (5)
20if (destination.Length < source.Length) 29return DecodeInPlace(destination.Slice(0, source.Length), isFormEncoding); 363return DecodeInPlace(destination.Slice(0, source.Length)); 591if ((uint)tempIdx >= (uint)buffer.Length) 603return (uint)c >= (uint)CharToHexLookup.Length ? -1 : CharToHexLookup[c];
Microsoft.AspNetCore.Http.Connections (4)
src\SignalR\common\Shared\MemoryBufferWriter.cs (4)
237totalWritten += segment.Span.Length; 266totalWritten += segment.Span.Length; 319_position += span.Length; 320_bytesWritten += span.Length;
Microsoft.AspNetCore.Http.Connections.Common (1)
src\SignalR\common\Shared\Utf8BufferTextWriter.cs (1)
169while (buffer.Length > 0)
Microsoft.AspNetCore.Http.Extensions (11)
src\Components\Endpoints\src\FormMapping\FormDataReader.cs (5)
175if (CurrentPrefix.Span.Length == 0) 203var keyLength = key.Length; 235Debug.Assert(_prefixBuffer.Length >= (_currentPrefixBuffer.Length + separator.Length)); 239var startingPoint = _currentPrefixBuffer.Length + separator.Length; 240_currentPrefixBuffer = _prefixBuffer.Slice(0, startingPoint + key.Length);
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (3)
249if (pos > _chars.Length - value.Length) 251Grow(value.Length); 255_pos += value.Length;
UriHelper.cs (3)
219text.CopyTo(buffer.Slice(index, text.Length)); 220return index + text.Length; 234if (uriParts.path.Length > 0 && pathBaseSpan.Length > 0 && pathBaseSpan[^1] == '/')
Microsoft.AspNetCore.Http.Results (1)
src\Shared\ResultsHelpers\SharedUrlHelper.cs (1)
81for (var i = 0; i < readOnlySpan.Length; i++)
Microsoft.AspNetCore.HttpLogging (6)
RequestBufferingStream.cs (2)
84if (span.Length == 0) 94var innerCount = Math.Min(remaining, span.Length);
ResponseBufferingStream.cs (1)
85var innerCount = Math.Min(remaining, span.Length);
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (3)
249if (pos > _chars.Length - value.Length) 251Grow(value.Length); 255_pos += value.Length;
Microsoft.AspNetCore.HttpOverrides (1)
ForwardedHeadersMiddleware.cs (1)
455if ((uint)hostEndIdx >= (uint)host.Length || // No ']'. The uint cast is there to eliminate the
Microsoft.AspNetCore.Identity (5)
Passkeys\BufferSourceJsonConverter.cs (5)
47Span<byte> byteSpan = utf8Unescaped.Length <= StackallocByteThreshold ? 49(pooledArray = ArrayPool<byte>.Shared.Rent(utf8Unescaped.Length)); 63Debug.Assert(bytesConsumed == utf8Unescaped.Length); 79var encodedLength = Base64Url.GetEncodedLength(bytes.Length); 86Debug.Assert(bytesConsumed == bytes.Length);
Microsoft.AspNetCore.Identity.FunctionalTests (2)
src\Identity\Extensions.Core\src\Base32.cs (2)
78if (trimmedInput.Length == 0) 83var output = new byte[trimmedInput.Length * 5 / 8];
Microsoft.AspNetCore.Mvc.Core (3)
Routing\UrlHelperBase.cs (1)
363for (var i = 0; i < readOnlySpan.Length; i++)
src\Shared\HttpRuleParser.cs (1)
65return (firstNonTokenCharIdx == -1) ? subspan.Length : firstNonTokenCharIdx;
src\Shared\ResultsHelpers\SharedUrlHelper.cs (1)
81for (var i = 0; i < readOnlySpan.Length; i++)
Microsoft.AspNetCore.Mvc.ViewFeatures (1)
Rendering\TagBuilder.cs (1)
183while (remainingName.Length > 0)
Microsoft.AspNetCore.OpenApi (5)
src\SignalR\common\Shared\MemoryBufferWriter.cs (4)
237totalWritten += segment.Span.Length; 266totalWritten += segment.Span.Length; 319_position += span.Length; 320_bytesWritten += span.Length;
src\SignalR\common\Shared\Utf8BufferTextWriter.cs (1)
169while (buffer.Length > 0)
Microsoft.AspNetCore.OutputCaching (8)
FormatterBinaryWriter.cs (3)
182else if ((offset + value.Length) <= length) 185offset += value.Length; 200var toWrite = Math.Min(value.Length, available.Length);
OutputCacheEntryFormatter.cs (1)
174writer.Write7BitEncodedInt(span.Length);
RecyclableSequenceBuilder.cs (3)
92if (available.Length >= buffer.Length) 95Advance(buffer.Length); 100var toWrite = Math.Min(buffer.Length, available.Length);
Streams\OutputCacheStream.cs (1)
145if (_segmentWriteStream.Length + buffer.Length > _maxBufferSize)
Microsoft.AspNetCore.OutputCaching.Microbenchmarks (2)
EndToEndBenchmarks.cs (2)
83var bytes = Math.Min(rand.Next(4, 1024), value.Length); 96var bytes = Math.Min(rand.Next(4, 1024), value.Length);
Microsoft.AspNetCore.ResponseCaching (1)
src\Shared\SegmentWriteStream.cs (1)
143var bytesWritten = Math.Min(buffer.Length, _segmentSize - (int)_bufferStream.Length);
Microsoft.AspNetCore.Routing (18)
Constraints\FileNameRouteConstraint.cs (2)
124if (value.Length == 0) 143for (var i = dotIndex + 1; i < value.Length; i++)
Matching\DfaMatcher.cs (3)
218for (var i = 0; i < segments.Length; i++) 244if ((uint)segmentIndex < (uint)segments.Length) 266if ((uint)segmentIndex < (uint)segments.Length)
Matching\FastPathTokenizer.cs (1)
35var length = span.Length;
Matching\HostMatcherPolicy.cs (2)
105if (host.Length == 0 || MemoryExtensions.Equals(host, WildcardHost, StringComparison.OrdinalIgnoreCase)) 131else if (port.Length > 0 && (!int.TryParse(port, out var parsed) || parsed != requestPort))
Matching\SingleEntryAsciiJumpTable.cs (3)
47Debug.Assert(a.Length == b.Length && b.Length == length);
Patterns\RoutePatternMatcher.cs (4)
342var lastIndex = requestSegment.Length; 404if (part is RoutePatternLiteralPart literal && ((indexOfLiteral + literal.Content.Length) != requestSegment.Length)) 408else if (part is RoutePatternSeparatorPart separator && ((indexOfLiteral + separator.Content.Length) != requestSegment.Length)) 464if (parameterValueSpan.Length == 0)
src\Shared\Debugger\DebuggerHelpers.cs (2)
30if (values.Length == 0) 42for (var i = 0; i < values.Length; i++)
src\Shared\HttpRuleParser.cs (1)
65return (firstNonTokenCharIdx == -1) ? subspan.Length : firstNonTokenCharIdx;
Microsoft.AspNetCore.Server.HttpSys (7)
RequestProcessing\ResponseBody.cs (1)
296chunk.Anonymous.FromMemory.BufferLength = (uint)bytes.Length;
RequestProcessing\ResponseStreamAsyncResult.cs (1)
175chunk.Anonymous.FromMemory.BufferLength = (uint)bytes.Length;
src\Shared\HttpSys\RequestProcessing\NativeRequestContext.cs (1)
197if (index < timestamps.Length && timestamps[index] > 0)
src\Shared\HttpSys\RequestProcessing\RequestHeaders.cs (2)
281for (int i = 0; i < HeaderKeys.Length; i++) 295for (int i = 0; i < HeaderKeys.Length; i++)
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (26)
HttpsTests.cs (1)
274Assert.True(requestTimingFeature.Timestamps.Length > (int)HttpSysRequestTimingType.Http3HeaderDecodeEnd);
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (2)
60int entryLength = HeaderField.GetLength(name.Length, value.Length);
src\Shared\runtime\Http2\Hpack\HeaderField.cs (1)
20Debug.Assert(name.Length > 0);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (7)
188while (currentIndex < data.Length); 215if (currentIndex < data.Length) 287if (currentIndex < data.Length) 313if (currentIndex < data.Length) 425int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 463int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 640for (; currentIndex < data.Length; currentIndex++)
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (8)
424if (IntegerEncoder.Encode(value.Length, 7, destination, out int integerLength)) 429if (value.Length <= destination.Length) 434bytesWritten = integerLength + value.Length; 517if (values.Length == 0) 521else if (values.Length == 1) 530int valueLength = checked((values.Length - 1) * separator.Length); 561for (int i = 1; i < values.Length; i++) 576for (int i = 1; i < values.Length; i++)
src\Shared\runtime\Http2\Hpack\Huffman.cs (1)
692while (i < src.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 96Advance(source.Length); 138while (source.Length > 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\Http2\Http2FrameReader.cs (2)
229Debug.Assert(data.Length % SettingSize == 0, "Invalid settings payload length"); 230var settingsCount = data.Length / SettingSize;
Microsoft.AspNetCore.Server.IIS (9)
src\Shared\HttpSys\RequestProcessing\NativeRequestContext.cs (1)
197if (index < timestamps.Length && timestamps[index] > 0)
src\Shared\HttpSys\RequestProcessing\RequestHeaders.cs (2)
281for (int i = 0; i < HeaderKeys.Length; i++) 295for (int i = 0; i < HeaderKeys.Length; i++)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 96Advance(source.Length); 138while (source.Length > 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
Microsoft.AspNetCore.Server.Kestrel.Core (144)
Internal\Http\DateHeaderValueManager.cs (2)
47var dateBytes = new byte[DatePreambleBytes.Length + dateValue.Length]; 49Encoding.ASCII.GetBytes(dateValue, dateBytes.AsSpan(DatePreambleBytes.Length));
Internal\Http\Http1OutputProducer.cs (4)
308if (_advancedBytesForChunk > 0 || buffer.Length > 0) 326if (buffer.Length > 0) 328writer.WriteBeginChunkBytes(buffer.Length); 589if (buffer.Length > 0)
Internal\Http\HttpHeaders.cs (17)
355while (value.Length > 0) 360for (offset = 0; offset < value.Length; offset++) 371if ((uint)offset > (uint)value.Length) 386if (c == 'k' && byteValue.Length >= (2 * sizeof(ulong) + sizeof(ushort))) 406else if (c == 'u' && byteValue.Length >= (sizeof(ulong) + sizeof(uint))) 420else if (c == 'c' && byteValue.Length >= sizeof(ulong)) 429if ((uint)offset >= (uint)value.Length) 440for (offset = 0; offset < value.Length; offset++) 454if ((uint)offset >= (uint)value.Length) 466if ((uint)offset >= (uint)value.Length) 542while (values.Length > 0) 547for (offset = 0; offset < values.Length; offset++) 558if ((uint)offset > (uint)values.Length) 591if ((uint)offset >= (uint)values.Length) 601for (offset = 0; offset < values.Length; offset++) 615if ((uint)offset >= (uint)values.Length) 624if ((uint)offset >= (uint)values.Length)
Internal\Http\HttpHeaders.Generated.cs (4)
7522switch (name.Length) 7891if (previousValue.Length == value.Length && 8107if (previousValue.Length == value.Length && 8310if (previousValue.Length == value.Length &&
Internal\Http\HttpParser.cs (20)
75if (next == 0 || requestLine.Length == 0) 78reader.Rewind(requestLine.Length + 1); 79var readResult = reader.TryReadExact(requestLine.Length + 1, out var requestLineSequence); 98if ((uint)offset >= (uint)requestLine.Length) 139for (; (uint)offset < (uint)requestLine.Length; offset++) 153while ((uint)offset < (uint)requestLine.Length 163if ((uint)offset + 9 != (uint)requestLine.Length || requestLine[offset + 8] != ByteCR) 168if (_disableHttp1LineFeedTerminators || (uint)offset + 8 != (uint)requestLine.Length) 204if (span.Length >= 2 && span[0] == ByteCR && span[1] == ByteLF) 224if ((uint)span.Length > (uint)(crIndex + 1) && span[crIndex + 1] == ByteLF) 233span = span.Slice(0, span.Length - 1); 253var stopIndex = Math.Min(crIndex + 2, span.Length); 284if (span.Length == 0) 321var array = new byte[span.Length + (lineFeedOnly ? 1 : 2)]; 470if ((uint)nameEnd >= (uint)headerLine.Length) 493if ((uint)valueStart < (uint)headerLine.Length) 502if ((uint)valueStart < (uint)headerLine.Length) 510for (; valueStart < headerLine.Length; valueStart++) 524var valueEnd = headerLine.Length - 1; 574return (requestLine.Length >= MinTlsRequestSize && requestLine[0] == SslRecordTypeHandshake);
Internal\Http\HttpRequestHeaders.cs (1)
103consumed != value.Length)
Internal\Http2\Http2Connection.cs (9)
564if (readableBuffer.Length >= ClientPreface.Length) 641if (requestLine.Length > 10 && requestLine[requestLine.Length - 1] == (byte)'\r') 643httpVersion = HttpUtilities.GetKnownVersion(requestLine.Slice(requestLine.Length - 9, 8)); 663Debug.Assert(buffer.Length >= ClientPreface.Length, "Not enough content to match preface."); 665var preface = buffer.Slice(0, ClientPreface.Length); 1579_totalParsedHeaderSize += name.Length + value.Length; 1670for (var i = 0; i < name.Length; i++)
Internal\Http2\Http2FrameWriter.cs (4)
509_outgoingFrame.PayloadLength = ContinueBytes.Length; 610while (dataToFrame.Length > 0) 619var currentSize = Math.Min(dataToFrame.Length, _maxFrameSize); 621if (endOfHeaders && dataToFrame.Length == currentSize)
Internal\Http2\Http2OutputProducer.cs (4)
398if (_completeScheduled || data.Length == 0) 407EnqueueDataWrite(data.Length); 534if (_completeScheduled || data.Length == 0) 543EnqueueDataWrite(data.Length);
Internal\Http2\Http2Stream.cs (4)
434Span<byte> pathBuffer = pathSegment.Length <= MaxPathBufferStackAllocSize 437? stackalloc byte[MaxPathBufferStackAllocSize].Slice(0, pathSegment.Length) 440: new byte[pathSegment.Length]; 442for (var i = 0; i < pathSegment.Length; i++)
Internal\Http3\Http3FrameWriter.cs (1)
272_outgoingFrame.RemainingLength = ContinueBytes.Length;
Internal\Http3\Http3OutputProducer.cs (2)
339if (_streamCompleted || data.Length == 0) 364if (_streamCompleted || data.Length == 0)
Internal\Http3\Http3Stream.cs (7)
298_totalParsedHeaderSize += name.Length + value.Length; 380for (var i = 0; i < name.Length; i++) 1196Span<byte> pathBuffer = pathSegment.Length <= MaxPathBufferStackAllocSize 1199? stackalloc byte[MaxPathBufferStackAllocSize].Slice(0, pathSegment.Length) 1202: new byte[pathSegment.Length]; 1204for (var i = 0; i < pathSegment.Length; i++)
Internal\Http3\QPack\DecoderStreamReader.cs (1)
58for (var i = 0; i < span.Length; i++)
Internal\Http3\QPack\EncoderStreamReader.cs (1)
105for (var i = 0; i < span.Length; i++)
Internal\Http3\QPackHeaderWriter.cs (2)
126buffer[2] = (byte)statusBytes.Length; 129return 3 + statusBytes.Length;
Internal\Infrastructure\HttpUtilities.cs (10)
78Debug.Assert(bytes.Length == 8, "Mask must be exactly 8 bytes long."); 92var str = string.Create(span.Length, span, static (destination, source) => 181for (var i = 0; i < Math.Min(span.Length, maxChars); i++) 187if (span.Length > maxChars) 217if (sizeof(uint) <= span.Length) 224else if (sizeof(ulong) <= span.Length) 281Debug.Assert(WordListForPerfectHashOfMethods.Length == (MaxHashValue + 1) && methodsLookup.Length == (MaxHashValue + 1)); 287&& index < (uint)methodsLookup.Length) 332return (uint)str.Length + associatedValues[c]; 383if (span.Length > sizeof(ulong) && span[sizeof(ulong)] == (byte)'\r')
Middleware\Internal\LoggingStream.cs (5)
160builder.Append(buffer.Length); 163if (buffer.Length > 0) 174for (int i = 0; i < buffer.Length; i++) 193if (i != buffer.Length - 1) 208var numBytesInLastLine = buffer.Length % 16;
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (2)
60int entryLength = HeaderField.GetLength(name.Length, value.Length);
src\Shared\runtime\Http2\Hpack\HeaderField.cs (1)
20Debug.Assert(name.Length > 0);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (7)
188while (currentIndex < data.Length); 215if (currentIndex < data.Length) 287if (currentIndex < data.Length) 313if (currentIndex < data.Length) 425int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 463int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 640for (; currentIndex < data.Length; currentIndex++)
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (8)
424if (IntegerEncoder.Encode(value.Length, 7, destination, out int integerLength)) 429if (value.Length <= destination.Length) 434bytesWritten = integerLength + value.Length; 517if (values.Length == 0) 521else if (values.Length == 1) 530int valueLength = checked((values.Length - 1) * separator.Length); 561for (int i = 1; i < values.Length; i++) 576for (int i = 1; i < values.Length; i++)
src\Shared\runtime\Http2\Hpack\Huffman.cs (1)
692while (i < src.Length)
src\Shared\runtime\Http3\Helpers\VariableLengthIntegerHelper.cs (1)
42if (buffer.Length != 0)
src\Shared\runtime\Http3\QPack\QPackDecoder.cs (8)
239while (currentIndex < data.Length); 287int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 342if (currentIndex < data.Length) 373int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 426if (currentIndex < data.Length) 534if (currentIndex < data.Length) 563if (currentIndex < data.Length) 689for (; currentIndex < data.Length; currentIndex++)
src\Shared\runtime\Http3\QPack\QPackEncoder.cs (5)
222if (values.Length == 1) 227if (values.Length == 0) 237int valueLength = separator.Length * (values.Length - 1); 266for (int i = 1; i < values.Length; i++) 281for (int i = 1; i < values.Length; i++)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 96Advance(source.Length); 138while (source.Length > 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\Http2\Http2FrameReader.cs (2)
229Debug.Assert(data.Length % SettingSize == 0, "Invalid settings payload length"); 230var settingsCount = data.Length / SettingSize;
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
src\Shared\UrlDecoder\UrlDecoder.cs (5)
20if (destination.Length < source.Length) 29return DecodeInPlace(destination.Slice(0, source.Length), isFormEncoding); 363return DecodeInPlace(destination.Slice(0, source.Length)); 591if ((uint)tempIdx >= (uint)buffer.Length) 603return (uint)c >= (uint)CharToHexLookup.Length ? -1 : CharToHexLookup[c];
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (1)
src\Shared\test\Shared.Tests\runtime\Http3\QPackDecoderTest.cs (1)
374if (name.Length == 0)
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (1)
src\Servers\Kestrel\shared\test\Http3\Http3InMemory.cs (1)
623if (span.Length > 0)
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (2)
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
Microsoft.AspNetCore.Shared.Tests (52)
runtime\Http3\QPackDecoderTest.cs (1)
374if (name.Length == 0)
src\Shared\HttpSys\RequestProcessing\NativeRequestContext.cs (1)
197if (index < timestamps.Length && timestamps[index] > 0)
src\Shared\HttpSys\RequestProcessing\RequestHeaders.cs (2)
281for (int i = 0; i < HeaderKeys.Length; i++) 295for (int i = 0; i < HeaderKeys.Length; i++)
src\Shared\QueryStringEnumerable.cs (1)
99var buffer = new char[source.Length];
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (2)
60int entryLength = HeaderField.GetLength(name.Length, value.Length);
src\Shared\runtime\Http2\Hpack\HeaderField.cs (1)
20Debug.Assert(name.Length > 0);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (7)
188while (currentIndex < data.Length); 215if (currentIndex < data.Length) 287if (currentIndex < data.Length) 313if (currentIndex < data.Length) 425int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 463int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 640for (; currentIndex < data.Length; currentIndex++)
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (8)
424if (IntegerEncoder.Encode(value.Length, 7, destination, out int integerLength)) 429if (value.Length <= destination.Length) 434bytesWritten = integerLength + value.Length; 517if (values.Length == 0) 521else if (values.Length == 1) 530int valueLength = checked((values.Length - 1) * separator.Length); 561for (int i = 1; i < values.Length; i++) 576for (int i = 1; i < values.Length; i++)
src\Shared\runtime\Http2\Hpack\Huffman.cs (1)
692while (i < src.Length)
src\Shared\runtime\Http3\Helpers\VariableLengthIntegerHelper.cs (1)
42if (buffer.Length != 0)
src\Shared\runtime\Http3\QPack\QPackDecoder.cs (8)
239while (currentIndex < data.Length); 287int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 342if (currentIndex < data.Length) 373int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 426if (currentIndex < data.Length) 534if (currentIndex < data.Length) 563if (currentIndex < data.Length) 689for (; currentIndex < data.Length; currentIndex++)
src\Shared\runtime\Http3\QPack\QPackEncoder.cs (5)
222if (values.Length == 1) 227if (values.Length == 0) 237int valueLength = separator.Length * (values.Length - 1); 266for (int i = 1; i < values.Length; i++) 281for (int i = 1; i < values.Length; i++)
src\Shared\SegmentWriteStream.cs (1)
143var bytesWritten = Math.Min(buffer.Length, _segmentSize - (int)_bufferStream.Length);
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 96Advance(source.Length); 138while (source.Length > 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\Http2\Http2FrameReader.cs (2)
229Debug.Assert(data.Length % SettingSize == 0, "Invalid settings payload length"); 230var settingsCount = data.Length / SettingSize;
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
26var resultString = string.Create(span.Length, span, static (destination, source) => 56return string.Create(span.Length, span, static (destination, source) =>
src\Shared\UrlDecoder\UrlDecoder.cs (5)
20if (destination.Length < source.Length) 29return DecodeInPlace(destination.Slice(0, source.Length), isFormEncoding); 363return DecodeInPlace(destination.Slice(0, source.Length)); 591if ((uint)tempIdx >= (uint)buffer.Length) 603return (uint)c >= (uint)CharToHexLookup.Length ? -1 : CharToHexLookup[c];
Microsoft.AspNetCore.SignalR.Client.Tests (4)
src\SignalR\common\Shared\MemoryBufferWriter.cs (4)
237totalWritten += segment.Span.Length; 266totalWritten += segment.Span.Length; 319_position += span.Length; 320_bytesWritten += span.Length;
Microsoft.AspNetCore.SignalR.Common (5)
src\SignalR\common\Shared\MemoryBufferWriter.cs (4)
237totalWritten += segment.Span.Length; 266totalWritten += segment.Span.Length; 319_position += span.Length; 320_bytesWritten += span.Length;
src\SignalR\common\Shared\Utf8BufferTextWriter.cs (1)
169while (buffer.Length > 0)
Microsoft.AspNetCore.SignalR.Protocols.Json (1)
src\SignalR\common\Shared\Utf8BufferTextWriter.cs (1)
169while (buffer.Length > 0)
Microsoft.AspNetCore.SignalR.Protocols.MessagePack (4)
src\SignalR\common\Shared\MemoryBufferWriter.cs (4)
237totalWritten += segment.Span.Length; 266totalWritten += segment.Span.Length; 319_position += span.Length; 320_bytesWritten += span.Length;
Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson (5)
src\SignalR\common\Shared\MemoryBufferWriter.cs (4)
237totalWritten += segment.Span.Length; 266totalWritten += segment.Span.Length; 319_position += span.Length; 320_bytesWritten += span.Length;
src\SignalR\common\Shared\Utf8BufferTextWriter.cs (1)
169while (buffer.Length > 0)
Microsoft.AspNetCore.SignalR.Specification.Tests (4)
src\SignalR\common\Shared\MemoryBufferWriter.cs (4)
237totalWritten += segment.Span.Length; 266totalWritten += segment.Span.Length; 319_position += span.Length; 320_bytesWritten += span.Length;
Microsoft.AspNetCore.SignalR.StackExchangeRedis (4)
src\SignalR\common\Shared\MemoryBufferWriter.cs (4)
237totalWritten += segment.Span.Length; 266totalWritten += segment.Span.Length; 319_position += span.Length; 320_bytesWritten += span.Length;
Microsoft.AspNetCore.WebSockets (6)
HandshakeHelpers.cs (3)
97if (value.Length == 0) 222if (value.Length == 0) 230if (value[0] == '"' && value.EndsWith("\"".AsSpan()) && value.Length > 1)
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (3)
249if (pos > _chars.Length - value.Length) 251Grow(value.Length); 255_pos += value.Length;
Microsoft.AspNetCore.WebUtilities (29)
FormPipeReader.cs (14)
164while (span.Length > 0) 175span = span.Slice(keyValuePair.Length + andDelimiter.Length); 176consumed += keyValuePair.Length + andDelimiter.Length; 185if ((uint)span.Length > (uint)KeyLengthLimit + (uint)ValueLengthLimit) 194consumed += keyValuePair.Length; 202if (keyValuePair.Length > KeyLengthLimit) 214if (key.Length > KeyLengthLimit) 219value = keyValuePair.Slice(equals + equalsDelimiter.Length); 220if (value.Length > ValueLengthLimit) 269Debug.Assert(segmentConsumed == keyValuePair.FirstSpan.Length); 388if (readOnlySpan.Length == 0) 398var span = MemoryMarshal.CreateSpan(ref MemoryMarshal.GetReference(readOnlySpan), readOnlySpan.Length);
HttpResponseStreamWriter.cs (2)
145var remaining = value.Length; 660var remaining = Math.Min(_charBufferSize - _charBufferCount, value.Length);
MultipartBoundary.cs (1)
20FinalBoundaryLength = BoundaryBytes.Length + 2; // Include the final '--' terminator.
MultipartReaderStream.cs (6)
194var length = _boundary.BoundaryBytes.Length; 211var length = _boundary.BoundaryBytes.Length; 275var length = _boundary.BoundaryBytes.Length; 297var length = _boundary.BoundaryBytes.Length; 335matchOffset = Math.Max(segment1.Offset, segment1.Offset + segment1.Count - matchBytes.Length); 343for (matchCount = 0; matchCount < matchBytes.Length && matchCount < countLimit; matchCount++)
src\Shared\QueryStringEnumerable.cs (1)
99var buffer = new char[source.Length];
src\Shared\UrlDecoder\UrlDecoder.cs (5)
20if (destination.Length < source.Length) 29return DecodeInPlace(destination.Slice(0, source.Length), isFormEncoding); 363return DecodeInPlace(destination.Slice(0, source.Length)); 591if ((uint)tempIdx >= (uint)buffer.Length) 603return (uint)c >= (uint)CharToHexLookup.Length ? -1 : CharToHexLookup[c];
Microsoft.Build.Tasks.CodeAnalysis (6)
src\Compilers\Core\Portable\InternalUtilities\CommandLineUtilities.cs (6)
67while (i < commandLine.Length) 69while (i < commandLine.Length && char.IsWhiteSpace(commandLine[i])) 74if (i == commandLine.Length) 86while (i < commandLine.Length && (!char.IsWhiteSpace(commandLine[i]) || (quoteCount % 2 != 0))) 99} while (i < commandLine.Length && commandLine[i] == '\\'); 102if (i >= commandLine.Length || commandLine[i] != '"')
Microsoft.Build.Tasks.CodeAnalysis.Sdk (6)
src\Compilers\Core\Portable\InternalUtilities\CommandLineUtilities.cs (6)
67while (i < commandLine.Length) 69while (i < commandLine.Length && char.IsWhiteSpace(commandLine[i])) 74if (i == commandLine.Length) 86while (i < commandLine.Length && (!char.IsWhiteSpace(commandLine[i]) || (quoteCount % 2 != 0))) 99} while (i < commandLine.Length && commandLine[i] == '\\'); 102if (i >= commandLine.Length || commandLine[i] != '"')
Microsoft.CodeAnalysis (85)
CaseInsensitiveComparison.cs (7)
127int len = Math.Min(str1.Length, str2.Length); 138return str1.Length - str2.Length; 176if (str1.Length != str2.Length) 181for (int i = 0; i < str1.Length; i++)
CodeGen\PrivateImplementationDetails.cs (1)
590char[] c = new char[hash.Length * 2];
CommandLine\CommandLineParser.cs (7)
104if (optionName.Length != value.Length) 141arg.Length > 0 && (arg[0] == '/' || arg[0] == '-'); 956while (i < arg.Length) 981Debug.Assert(i < arg.Length); 984while (i < arg.Length && arg[i] == '\\') 990if (i < arg.Length && arg[i] == '"') 1090for (int i = 0; i < span.Length; i++)
DiaSymReader\Writer\SymUnmanagedWriterImpl.cs (6)
172if (algorithmId != default(Guid) && checksum.Length > 0) 180documentWriter.SetCheckSum(algorithmId, (uint)checksum.Length, bytes); 198documentWriter.SetSource((uint)source.Length, bytes); 489if (yieldOffsets.Length != resumeOffsets.Length) 496int count = yieldOffsets.Length;
FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
InternalUtilities\CommandLineUtilities.cs (6)
67while (i < commandLine.Length) 69while (i < commandLine.Length && char.IsWhiteSpace(commandLine[i])) 74if (i == commandLine.Length) 86while (i < commandLine.Length && (!char.IsWhiteSpace(commandLine[i]) || (quoteCount % 2 != 0))) 99} while (i < commandLine.Length && commandLine[i] == '\\'); 102if (i >= commandLine.Length || commandLine[i] != '"')
InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
MemoryExtensions.cs (4)
15for (int i = startIndex; i < span.Length; i++) 28for (int i = 0; i < span.Length; i++) 96if (span.Length > 1 && span[0] == '"' && span[span.Length - 1] == '"')
MetadataReader\MetadataHelpers.cs (2)
502int emittedTypeNameLength = emittedTypeName.Length; 535if (aritySpan is { Length: >= 1 and <= 5 } and not ['0', ..])
Operations\ControlFlowGraphBuilder.cs (1)
7818ArrayBuilder<IOperation> statementsBuilder = ArrayBuilder<IOperation>.GetInstance(statements.Length);
PEWriter\MetadataWriter.cs (1)
464_pseudoSymbolTokenToTokenMap = new EntityHandle[referencesInIL.Length];
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
StrongName\CryptoBlobParser.cs (3)
162var w = new BlobWriter(3 * sizeof(uint) + s_offsetToKeyData + pubKeyData.Length); 165w.WriteUInt32((uint)(s_offsetToKeyData + pubKeyData.Length)); 182w.WriteBytes(bytes, pubKeyData.Length);
Symbols\CommonGeneratedNameParser.cs (1)
32for (int i = metadataNameSuffix.Length - 1; i >= -1; i--)
Syntax\SeparatedSyntaxList.cs (4)
22if (nodes.Length == 0) 25if (nodes.Length == 1) 28var builder = new CodeAnalysis.Syntax.SeparatedSyntaxListBuilder<TNode>(nodes.Length); 34for (int i = 1, n = nodes.Length; i < n; i++)
Syntax\SyntaxList`1.cs (4)
23if (nodes.Length == 0) 30switch (nodes.Length) 37var copy = new ArrayElement<GreenNode>[nodes.Length]; 38for (int i = 0, n = nodes.Length; i < n; i++)
Syntax\SyntaxNodeOrTokenList.cs (4)
71if (nodesAndTokens.Length == 0) 82switch (nodesAndTokens.Length) 93var copy = new ArrayElement<GreenNode>[nodesAndTokens.Length]; 94for (int i = 0, n = nodesAndTokens.Length; i < n; i++)
Syntax\SyntaxTokenList.cs (4)
67if (tokens.Length == 0) 75switch (tokens.Length) 84var copy = new ArrayElement<GreenNode>[tokens.Length]; 85for (int i = 0, n = tokens.Length; i < n; i++)
Syntax\SyntaxTriviaList.cs (4)
73if (trivias.Length == 0) 81switch (trivias.Length) 90var copy = new ArrayElement<GreenNode>[trivias.Length]; 91for (int i = 0, n = trivias.Length; i < n; i++)
Syntax\SyntaxTriviaListBuilder.cs (1)
88this.Add(items, 0, items.Length);
Microsoft.CodeAnalysis.Analyzers (47)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (1)
126if (remaining[index] == '\r' && remaining.Length > index + 1 && remaining[index + 1] == '\n')
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Microsoft.CodeAnalysis.AnalyzerUtilities (47)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (1)
126if (remaining[index] == '\r' && remaining.Length > index + 1 && remaining[index + 1] == '\n')
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Microsoft.CodeAnalysis.BannedApiAnalyzers (47)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (1)
126if (remaining[index] == '\r' && remaining.Length > index + 1 && remaining[index + 1] == '\n')
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Microsoft.CodeAnalysis.CodeStyle (50)
src\Analyzers\Core\Analyzers\DiagnosticCustomTags.cs (2)
64Debug.Assert(customTags.Length == tags.Length); 66for (var i = 0; i < tags.Length; i++)
src\Analyzers\Core\Analyzers\Helpers\DiagnosticHelper.cs (2)
359_formatArguments = new string[formatArguments.Length]; 360for (var i = 0; i < formatArguments.Length; i++)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Microsoft.CodeAnalysis.Collections.Package (1)
Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
Microsoft.CodeAnalysis.CSharp (21)
CommandLine\CSharpCommandLineParser.cs (2)
1767while (index < valueSpan.Length) 1777if (nextIndex < valueSpan.Length)
CSharpParseOptions.cs (1)
216while (currentIndex < @namespace.Length && @namespace.IndexOf('.', currentIndex) is not -1 and var dotIndex)
Lowering\ExtensionMethodBodyRewriter.cs (1)
59Debug.Assert(symbol.Parameters.Length == rewrittenParameters.Length);
Parser\LanguageParser_InterpolatedString.cs (10)
154if (text.Length == 0) 177while (currentIndex < text.Length) 195var isBlankLine = (currentIndex == text.Length && isLast) || (currentIndex < text.Length && SyntaxFacts.IsNewLine(text[currentIndex])); 222currentIndex = Math.Min(currentIndex, lineStartPosition + indentationWhitespace.Length); 299for (int i = 0, n = Math.Min(currentLineWhitespace.Length, indentationLineWhitespace.Length); i < n; i++) 326while (currentIndex < text.Length && SyntaxFacts.IsWhitespace(text[currentIndex])) 334while (currentIndex < text.Length) 343currentIndex += SlidingTextWindow.GetNewLineWidth(ch, currentIndex + 1 < text.Length ? text[currentIndex + 1] : '\0');
Parser\QuickScanner.cs (1)
204var charPropLength = CharProperties.Length;
Symbols\FunctionPointers\FunctionPointerMethodSymbol.cs (3)
560if (parameterTypes.Length > 0) 562var paramsBuilder = ArrayBuilder<FunctionPointerParameterSymbol>.GetInstance(parameterTypes.Length); 564for (int i = 0; i < parameterTypes.Length; i++)
Symbols\MemberSignatureComparer.cs (3)
768Debug.Assert(params1.Length == params2.Length); 770var numParams = params1.Length;
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ExpressionGenerator.cs (1)
302for (var i = 0; i < names.Length; i++)
Microsoft.CodeAnalysis.CSharp.EditorFeatures2.UnitTests (1)
EmbeddedLanguages\RegularExpressions\CSharpRegexParserTests.cs (1)
326for (var i = regexes.Length - 2; i >= 0; i--)
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ExpressionGenerator.cs (1)
302for (var i = 0; i < names.Length; i++)
Microsoft.CodeAnalysis.EditorFeatures (1)
Shared\Extensions\IProjectionBufferFactoryServiceExtensions.cs (1)
245if (exposedLineSpans.Length > 0)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
EmbeddedLanguages\StackFrame\StackFrameSyntaxFactory.cs (2)
69var separatedList = parameters.Length == 0 80for (var i = 1; i < parameters.Length; i++)
Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider (7)
src\Compilers\Core\Portable\CaseInsensitiveComparison.cs (7)
127int len = Math.Min(str1.Length, str2.Length); 138return str1.Length - str2.Length; 176if (str1.Length != str2.Length) 181for (int i = 0; i < str1.Length; i++)
Microsoft.CodeAnalysis.Extensions.Package (4)
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
Microsoft.CodeAnalysis.Features (13)
Common\GlyphExtensions.cs (1)
21using var _ = ArrayBuilder<Glyph>.GetInstance(tags.Length, out var builder);
ConvertIfToSwitch\AbstractConvertIfToSwitchCodeRefactoringProvider.Analyzer.cs (3)
103while (current < operations.Length && 115if (operations.Length == 0) 129if (current < operations.Length)
EmbeddedLanguages\RegularExpressions\RegexCharClass.cs (1)
207if ((uint)chDiv8 < (uint)asciiLookup.Length)
MetadataAsSource\AbstractMetadataAsSourceService.DocCommentFormatter.cs (4)
176while (span.Length > 0) 180if (span.Length == 0) 197end = span.Length; 227source = source.Slice(index + separator.Length);
src\Analyzers\Core\Analyzers\DiagnosticCustomTags.cs (2)
64Debug.Assert(customTags.Length == tags.Length); 66for (var i = 0; i < tags.Length; i++)
src\Analyzers\Core\Analyzers\Helpers\DiagnosticHelper.cs (2)
359_formatArguments = new string[formatArguments.Length]; 360for (var i = 0; i < formatArguments.Length; i++)
Microsoft.CodeAnalysis.Features.Test.Utilities (2)
EditAndContinue\SourceMarkers.cs (2)
177for (var i = 0; i < span.Length; i++) 190for (var i = span.Length - 1; i >= 0; i--)
Microsoft.CodeAnalysis.InteractiveHost (8)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
Microsoft.CodeAnalysis.LanguageServer.Protocol (1)
Protocol\Internal\Converters\VSInternalExtensionUtilities.cs (1)
82var valueLength = reader.HasValueSequence ? reader.ValueSequence.Length : reader.ValueSpan.Length;
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (47)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (1)
126if (remaining[index] == '\r' && remaining.Length > index + 1 && remaining[index + 1] == '\n')
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Microsoft.CodeAnalysis.PublicApiAnalyzers (47)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (1)
126if (remaining[index] == '\r' && remaining.Length > index + 1 && remaining[index + 1] == '\n')
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Microsoft.CodeAnalysis.ResxSourceGenerator (47)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (1)
126if (remaining[index] == '\r' && remaining.Length > index + 1 && remaining[index + 1] == '\n')
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Microsoft.CodeAnalysis.Test.Utilities (8)
Assert\AssertEx.cs (6)
368if (expected.Length != actual.Length) 371for (int i = 0; i < expected.Length; i++) 794var expectedString = join(itemSeparator, expected[..Math.Min(expected.Length, maxDisplayedExpectedEntries)], itemInspector); 807if (expected.Length > maxDisplayedExpectedEntries) 817if (TryGenerateExpectedSourceFileAndGetDiffLink(actualString, expected.Length, expectedValueSourcePath, expectedValueSourceLine, out var link))
TestHelpers.cs (2)
157if (input.Length % 2 != 0) 162var bytes = new byte[input.Length >> 1];
Microsoft.CodeAnalysis.Threading.Package (1)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
Microsoft.CodeAnalysis.Workspaces (49)
FindSymbols\FindReferences\Finders\AbstractReferenceFinder_GlobalSuppressions.cs (2)
133if (expectedDocCommentId.Length < docCommentId.Length) 137if (docCommentId.Span[expectedDocCommentId.Length] != '.')
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Workspace\Solution\Checksum.cs (1)
54if (checksum.Length < HashSize)
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (25)
src\Compilers\Core\Portable\CaseInsensitiveComparison.cs (7)
127int len = Math.Min(str1.Length, str2.Length); 138return str1.Length - str2.Length; 176if (str1.Length != str2.Length) 181for (int i = 0; i < str1.Length; i++)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\CommandLineUtilities.cs (6)
67while (i < commandLine.Length) 69while (i < commandLine.Length && char.IsWhiteSpace(commandLine[i])) 74if (i == commandLine.Length) 86while (i < commandLine.Length && (!char.IsWhiteSpace(commandLine[i]) || (quoteCount % 2 != 0))) 99} while (i < commandLine.Length && commandLine[i] == '\\'); 102if (i >= commandLine.Length || commandLine[i] != '"')
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
Microsoft.CodeAnalysis.Workspaces.UnitTests (3)
XxHash128Tests.cs (3)
111ReadOnlySpan<byte> slice = input.Slice(0, rand.Next(0, input.Length) + 1); 113input = input.Slice(slice.Length); 114processed += slice.Length;
Microsoft.CSharp (1)
Microsoft\CSharp\RuntimeBinder\Semantics\ExpressionBinder.cs (1)
1635Debug.Assert(ek >= ExpressionKind.FirstOp && (ek - ExpressionKind.FirstOp) < (int)EK2NAME.Length);
Microsoft.Data.Analysis (168)
Computations\Arithmetic.net8.cs (40)
113for (var i = 0; i < x.Length; i++) 121for (var i = 0; i < x.Length; i++) 129for (var i = 0; i < y.Length; i++) 139for (var i = 0; i < x.Length; i++) 147for (var i = 0; i < x.Length; i++) 155for (var i = 0; i < x.Length; i++) 163for (var i = 0; i < x.Length; i++) 171for (var i = 0; i < x.Length; i++) 179for (var i = 0; i < x.Length; i++) 187for (var i = 0; i < x.Length; i++) 195for (var i = 0; i < x.Length; i++) 203for (var i = 0; i < x.Length; i++) 211for (var i = 0; i < x.Length; i++) 219for (var i = 0; i < x.Length; i++) 227for (var i = 0; i < x.Length; i++) 471for (var i = 0; i < x.Length; i++) 479for (var i = 0; i < x.Length; i++) 487for (var i = 0; i < x.Length; i++) 495for (var i = 0; i < x.Length; i++) 503for (var i = 0; i < x.Length; i++) 511for (var i = 0; i < x.Length; i++) 519for (var i = 0; i < x.Length; i++) 527for (var i = 0; i < x.Length; i++) 535for (var i = 0; i < x.Length; i++) 543for (var i = 0; i < x.Length; i++) 551for (var i = 0; i < x.Length; i++) 559for (var i = 0; i < x.Length; i++) 572while (i < x.Length) 583while (i < x.Length) 594while (i < y.Length) 605while (i < x.Length) 616while (i < x.Length) 627while (i < y.Length) 638while (i < x.Length) 649while (i < x.Length) 660while (i < y.Length) 669for (var i = 0; i < x.Length; i++) 677for (var i = 0; i < x.Length; i++) 685for (var i = 0; i < x.Length; i++) 693for (var i = 0; i < x.Length; i++)
DataFrameColumns\ArrowStringDataFrameColumn.cs (3)
212mutableDataBuffer.IncreaseSize(value.Length); 214mutableOffsetsBuffer.Append(mutableOffsetsBuffer[mutableOffsetsBuffer.Length - 1] + value.Length); 262return Encoding.UTF8.GetString(data, bytes.Length);
DataFrameColumns\StringDataFrameColumn.cs (2)
351for (int i = 0; i < span.Length; i++) 373for (int i = 0; i < span.Length; i++)
DataFrameColumns\VBufferDataFrameColumn.cs (2)
237for (int i = 0; i < span.Length; i++) 259for (int i = 0; i < span.Length; i++)
DateTimeComputation.cs (4)
39for (int i = 0; i < readOnlySpan.Length; i++) 111for (int i = 0; i < readOnlySpan.Length; i++) 203for (int i = 0; i < readOnlySpan.Length; i++) 261for (int i = 0; i < readOnlySpan.Length; i++)
PrimitiveColumnContainer.BinaryOperations.cs (5)
129if (availableInRetSpan < leftSpan.Length) 144index += leftSpan.Length; 171if (availableInRetSpan < leftSpan.Length) 186index += leftSpan.Length; 194for (var i = 0; i < left.Length; i++)
PrimitiveColumnContainer.cs (11)
575for (int i = 0; i < span.Length; i++) 594for (int i = 0; i < span.Length; i++) 613for (int i = 0; i < span.Length; i++) 632for (int i = 0; i < span.Length; i++) 651for (int i = 0; i < span.Length; i++) 670for (int i = 0; i < span.Length; i++) 689for (int i = 0; i < span.Length; i++) 708for (int i = 0; i < span.Length; i++) 727for (int i = 0; i < span.Length; i++) 746for (int i = 0; i < span.Length; i++) 765for (int i = 0; i < span.Length; i++)
PrimitiveDataFrameColumn.cs (2)
370for (int i = 0; i < span.Length; i++) 625for (int i = 0; i < readOnlySpan.Length; i++)
PrimitiveDataFrameColumnComputations.cs (98)
129for (int i = 0; i < span.Length; i++) 147for (int i = 0; i < span.Length; i++) 282for (int i = 0; i < readOnlySpan.Length; i++) 346for (int i = 0; i < readOnlySpan.Length; i++) 410for (int i = 0; i < readOnlySpan.Length; i++) 474for (int i = 0; i < readOnlySpan.Length; i++) 537for (int i = 0; i < readOnlySpan.Length; i++) 585for (int i = 0; i < readOnlySpan.Length; i++) 632for (int i = 0; i < readOnlySpan.Length; i++) 677for (int i = 0; i < readOnlySpan.Length; i++) 769for (int i = 0; i < readOnlySpan.Length; i++) 833for (int i = 0; i < readOnlySpan.Length; i++) 897for (int i = 0; i < readOnlySpan.Length; i++) 961for (int i = 0; i < readOnlySpan.Length; i++) 1024for (int i = 0; i < readOnlySpan.Length; i++) 1072for (int i = 0; i < readOnlySpan.Length; i++) 1119for (int i = 0; i < readOnlySpan.Length; i++) 1164for (int i = 0; i < readOnlySpan.Length; i++) 1256for (int i = 0; i < readOnlySpan.Length; i++) 1320for (int i = 0; i < readOnlySpan.Length; i++) 1384for (int i = 0; i < readOnlySpan.Length; i++) 1448for (int i = 0; i < readOnlySpan.Length; i++) 1511for (int i = 0; i < readOnlySpan.Length; i++) 1559for (int i = 0; i < readOnlySpan.Length; i++) 1606for (int i = 0; i < readOnlySpan.Length; i++) 1651for (int i = 0; i < readOnlySpan.Length; i++) 1743for (int i = 0; i < readOnlySpan.Length; i++) 1807for (int i = 0; i < readOnlySpan.Length; i++) 1871for (int i = 0; i < readOnlySpan.Length; i++) 1935for (int i = 0; i < readOnlySpan.Length; i++) 1998for (int i = 0; i < readOnlySpan.Length; i++) 2046for (int i = 0; i < readOnlySpan.Length; i++) 2093for (int i = 0; i < readOnlySpan.Length; i++) 2138for (int i = 0; i < readOnlySpan.Length; i++) 2230for (int i = 0; i < readOnlySpan.Length; i++) 2294for (int i = 0; i < readOnlySpan.Length; i++) 2358for (int i = 0; i < readOnlySpan.Length; i++) 2422for (int i = 0; i < readOnlySpan.Length; i++) 2485for (int i = 0; i < readOnlySpan.Length; i++) 2533for (int i = 0; i < readOnlySpan.Length; i++) 2580for (int i = 0; i < readOnlySpan.Length; i++) 2625for (int i = 0; i < readOnlySpan.Length; i++) 2717for (int i = 0; i < readOnlySpan.Length; i++) 2781for (int i = 0; i < readOnlySpan.Length; i++) 2845for (int i = 0; i < readOnlySpan.Length; i++) 2909for (int i = 0; i < readOnlySpan.Length; i++) 2972for (int i = 0; i < readOnlySpan.Length; i++) 3020for (int i = 0; i < readOnlySpan.Length; i++) 3067for (int i = 0; i < readOnlySpan.Length; i++) 3112for (int i = 0; i < readOnlySpan.Length; i++) 3204for (int i = 0; i < readOnlySpan.Length; i++) 3268for (int i = 0; i < readOnlySpan.Length; i++) 3332for (int i = 0; i < readOnlySpan.Length; i++) 3396for (int i = 0; i < readOnlySpan.Length; i++) 3459for (int i = 0; i < readOnlySpan.Length; i++) 3507for (int i = 0; i < readOnlySpan.Length; i++) 3554for (int i = 0; i < readOnlySpan.Length; i++) 3599for (int i = 0; i < readOnlySpan.Length; i++) 3691for (int i = 0; i < readOnlySpan.Length; i++) 3755for (int i = 0; i < readOnlySpan.Length; i++) 3819for (int i = 0; i < readOnlySpan.Length; i++) 3883for (int i = 0; i < readOnlySpan.Length; i++) 3946for (int i = 0; i < readOnlySpan.Length; i++) 3994for (int i = 0; i < readOnlySpan.Length; i++) 4041for (int i = 0; i < readOnlySpan.Length; i++) 4086for (int i = 0; i < readOnlySpan.Length; i++) 4178for (int i = 0; i < readOnlySpan.Length; i++) 4242for (int i = 0; i < readOnlySpan.Length; i++) 4306for (int i = 0; i < readOnlySpan.Length; i++) 4370for (int i = 0; i < readOnlySpan.Length; i++) 4433for (int i = 0; i < readOnlySpan.Length; i++) 4481for (int i = 0; i < readOnlySpan.Length; i++) 4528for (int i = 0; i < readOnlySpan.Length; i++) 4573for (int i = 0; i < readOnlySpan.Length; i++) 4665for (int i = 0; i < readOnlySpan.Length; i++) 4729for (int i = 0; i < readOnlySpan.Length; i++) 4793for (int i = 0; i < readOnlySpan.Length; i++) 4857for (int i = 0; i < readOnlySpan.Length; i++) 4920for (int i = 0; i < readOnlySpan.Length; i++) 4968for (int i = 0; i < readOnlySpan.Length; i++) 5015for (int i = 0; i < readOnlySpan.Length; i++) 5060for (int i = 0; i < readOnlySpan.Length; i++) 5152for (int i = 0; i < readOnlySpan.Length; i++) 5216for (int i = 0; i < readOnlySpan.Length; i++) 5280for (int i = 0; i < readOnlySpan.Length; i++) 5344for (int i = 0; i < readOnlySpan.Length; i++) 5407for (int i = 0; i < readOnlySpan.Length; i++) 5455for (int i = 0; i < readOnlySpan.Length; i++) 5502for (int i = 0; i < readOnlySpan.Length; i++) 5547for (int i = 0; i < readOnlySpan.Length; i++) 5639for (int i = 0; i < readOnlySpan.Length; i++) 5703for (int i = 0; i < readOnlySpan.Length; i++) 5767for (int i = 0; i < readOnlySpan.Length; i++) 5831for (int i = 0; i < readOnlySpan.Length; i++) 5894for (int i = 0; i < readOnlySpan.Length; i++) 5942for (int i = 0; i < readOnlySpan.Length; i++) 5989for (int i = 0; i < readOnlySpan.Length; i++) 6034for (int i = 0; i < readOnlySpan.Length; i++)
Utils\BitUtility.cs (1)
151Debug.Assert(span.Length >= endByteIndex);
Microsoft.Data.Analysis.Tests (4)
VBufferColumnTests.cs (4)
32Assert.Equal(5, vBufferColumn[0].GetValues().Length); 45Assert.Equal(5, vBufferColumn[0].GetValues().Length); 64Assert.Equal(5, values.Length); 66for (int i = 0; i < values.Length; i++)
Microsoft.DotNet.StrongName (3)
Signing.cs (3)
263var w = new BlobWriter(3 * sizeof(uint) + Constants.OffsetToKeyData + pubKeyData.Length); 266w.WriteUInt32((uint)(Constants.OffsetToKeyData + pubKeyData.Length)); 283w.WriteBytes(bytes, pubKeyData.Length);
Microsoft.DotNet.SwaggerGenerator.CodeGenerator (8)
Helpers.cs (8)
24for (int idx = pos; idx < value.Length; idx++) 45pos = value.Length; 64while ((word = GetNextWord(value, ref pos)).Length != 0) 66for (var i = 0; i < word.Length; i++) 94while ((word = GetNextWord(value, ref pos)).Length != 0) 96for (var i = 0; i < word.Length; i++) 123while ((word = GetNextWord(value, ref pos)).Length != 0) 129for (var i = 0; i < word.Length; i++)
Microsoft.Extensions.AI (6)
ChatCompletion\DistributedCachingChatClient.cs (2)
145int length = FixedValuesCount + additionalValues.Length + clientValues.Length; 154clientValues.CopyTo(arr, FixedValuesCount + additionalValues.Length);
ChatCompletion\FunctionInvokingChatClient.cs (2)
757var contents = new List<AIContent>(results.Length); 758for (int i = 0; i < results.Length; i++)
Embeddings\DistributedCachingEmbeddingGenerator.cs (2)
116int length = FixedValuesCount + clientValues.Length + values.Length; 123clientValues.CopyTo(arr, FixedValuesCount + values.Length);
Microsoft.Extensions.AI.Abstractions (7)
Contents\DataUriParser.cs (2)
152if (value!.Length % 4 != 0) 158var index = value.Length - 1;
Embeddings\BinaryEmbedding.cs (3)
64int length = reader.HasValueSequence ? checked((int)reader.ValueSequence.Length) : reader.ValueSpan.Length; 69BitArray result = new(utf8.Length); 71for (int i = 0; i < utf8.Length; i++)
src\Shared\JsonSchemaExporter\JsonSchemaExporter.cs (1)
561for (int i = 0; i < path.Length; i++)
Utilities\AIJsonUtilities.cs (1)
149var chars = new char[hashData.Length * 2];
Microsoft.Extensions.AI.AzureAIInference (4)
AzureAIInferenceEmbeddingGenerator.cs (4)
128if (base64.Length < 2 || base64[0] != (byte)'"' || base64[base64.Length - 1] != (byte)'"') 133base64 = base64.Slice(1, base64.Length - 2); 136byte[] bytes = ArrayPool<byte>.Shared.Rent(Base64.GetMaxDecodedFromUtf8Length(base64.Length));
Microsoft.Extensions.AI.Evaluation.NLP (6)
Common\NGramExtensions.cs (6)
35ReadOnlySpan<T> next = input.Slice(0, Math.Min(n, input.Length)); 37while (next.Length == n) 42next = input.Slice(0, Math.Min(n, input.Length)); 65maxN = input.Length; // Update to use Length instead of Count() 74for (int i = 0; i <= input.Length - minN; i++) 76for (int s = minN; s <= maxN && s <= input.Length - i; s++)
Microsoft.Extensions.AI.Evaluation.Quality (1)
Utilities\JsonOutputFixer.cs (1)
27if (trimmed.Length > markerLength && trimmed.Slice(0, markerLength).SequenceEqual(JsonMarker.AsSpan()))
Microsoft.Extensions.AI.Integration.Tests (3)
QuantizationEmbeddingGenerator.cs (3)
50var result = new BitArray(vector.Length); 51for (int i = 0; i < vector.Length; i++) 82var result = new Half[vector.Length];
Microsoft.Extensions.AI.OpenAI (14)
src\Shared\ServerSentEvents\Helpers.cs (6)
52Span<byte> buffer = writer.GetSpan(value.Length); 53Debug.Assert(value.Length <= buffer.Length); 55writer.Advance(value.Length); 65int maxByteCount = Encoding.UTF8.GetMaxByteCount(value.Length); 75bytesWritten = Encoding.UTF8.GetBytes(chars, value.Length, bytes, maxByteCount); 122Encoding.UTF8.GetString(ptr, bytes.Length);
src\Shared\ServerSentEvents\SseFormatter.cs (1)
156if (data[i++] == '\r' && i < data.Length && data[i] == '\n')
src\Shared\ServerSentEvents\SseParser_1.cs (7)
125while (FillLineBuffer() != 0 && _lineLength < Utf8Bom.Length); 205while (await FillLineBufferAsync(cancellationToken).ConfigureAwait(false) != 0 && _lineLength < Utf8Bom.Length) ; 392ReadOnlySpan<byte> remainder = _lineBuffer.AsSpan(_newlineIndex + newlineLength, _lineLength - line.Length - newlineLength); 394(remainder[0] is LF || (remainder[0] is CR && remainder.Length > 1))) 396advance = line.Length + newlineLength + (remainder.StartsWith(CRLF) ? 2 : 1); 420_dataLength += fieldValue.Length; 462advance = line.Length + GetNewLineLength();
Microsoft.Extensions.Caching.Hybrid (3)
Internal\HybridCachePayload.cs (3)
193if (bytes.Length < 19) // minimum needed for empty payload and zero tags 298if (bytes.Length != payloadLength + 2 343|| buffer.Length < (length = (int)u64Length)) // note buffer is now past the prefix via "ref"
Microsoft.Extensions.Compliance.Abstractions (4)
Redaction\NullRedactor.cs (3)
20public override int GetRedactedLength(ReadOnlySpan<char> input) => input.Length; 28Throw.IfBufferTooSmall(destination.Length, source.Length, nameof(destination)); 31return source.Length;
Redaction\Redactor.cs (1)
251var fmt = format.Length > 0 ? format.ToString() : string.Empty;
Microsoft.Extensions.Compliance.Abstractions.Tests (2)
Redaction\RedactorTest.cs (2)
331public override int GetRedactedLength(ReadOnlySpan<char> input) => input.Length; 336return source.Length;
Microsoft.Extensions.Compliance.Redaction.Tests (2)
FakePlaintextRedactor.cs (2)
10public override int GetRedactedLength(ReadOnlySpan<char> input) => input.Length; 15return source.Length;
Microsoft.Extensions.DependencyModel (6)
DependencyContextJsonReader.cs (6)
66long expectedLength = Math.Max(utf8Bom.Length, stream.Length - stream.Position) + 1; 81Debug.Assert(rented.Length >= utf8Bom.Length); 86utf8Bom.Length - written); 89} while (lastRead > 0 && written < utf8Bom.Length); 92if (written == utf8Bom.Length && 93utf8Bom.SequenceEqual(rented.AsSpan(0, utf8Bom.Length)))
Microsoft.Extensions.Diagnostics.ResourceMonitoring (26)
Linux\LinuxUtilizationParserCgroupV1.cs (12)
137stat = stat.Slice(StartingTokens.Length, stat.Length - StartingTokens.Length); 224ReadOnlySpan<char> inactiveMemorySlice = memoryFile.Slice(index + TotalInactiveFile.Length, memoryFile.Length - index - TotalInactiveFile.Length); 274ReadOnlySpan<char> totalMemory = firstLine.Slice(MemTotal.Length, firstLine.Length - MemTotal.Length); 283if (next == -1 || totalMemory.Length - next < 2) 288ReadOnlySpan<char> unit = totalMemory.Slice(totalMemory.Length - 2, 2); 383while (numberStart < buffer.Length && char.IsWhiteSpace(buffer[numberStart])) 388if (numberStart == buffer.Length || !char.IsDigit(buffer[numberStart])) 397while (numberEnd < buffer.Length && char.IsDigit(buffer[numberEnd])) 405return numberEnd < buffer.Length ? numberEnd : -1; 415if (quotaBuffer.IsEmpty || (quotaBuffer.Length == 2 && quotaBuffer[0] == '-' && quotaBuffer[1] == '1')) 433if (periodBuffer.IsEmpty || (periodBuffer.Length == 2 && periodBuffer[0] == '-' && periodBuffer[1] == '1')) 471if (cpuPodWeightBuffer.IsEmpty || (cpuPodWeightBuffer.Length == 2 && cpuPodWeightBuffer[0] == '-' && cpuPodWeightBuffer[1] == '1'))
Linux\LinuxUtilizationParserCgroupV2.cs (14)
128if (colonIndex == -1 || colonIndex + 1 >= fileContent.Length) 181stat = stat.Slice(StartingTokens.Length, stat.Length - StartingTokens.Length); 373ReadOnlySpan<char> inactiveMemorySlice = memoryFile.Slice(index + InactiveFile.Length, memoryFile.Length - index - InactiveFile.Length); 419ReadOnlySpan<char> totalMemory = firstLine.Slice(MemTotal.Length, firstLine.Length - MemTotal.Length); 428if (next == -1 || totalMemory.Length - next < 2) 433ReadOnlySpan<char> unit = totalMemory.Slice(totalMemory.Length - 2, 2); 573while (numberStart < buffer.Length && char.IsWhiteSpace(buffer[numberStart])) 578if (numberStart == buffer.Length || !char.IsDigit(buffer[numberStart])) 587while (numberEnd < buffer.Length && char.IsDigit(buffer[numberEnd])) 595return numberEnd < buffer.Length ? numberEnd : -1; 633if (quotaBuffer.IsEmpty || (quotaBuffer.Length == 2 && quotaBuffer[0] == '-' && quotaBuffer[1] == '1')) 654ReadOnlySpan<char> cpuPeriodSlice = quotaBuffer.Slice(index + quotaString.Length, quotaBuffer.Length - index - quotaString.Length); 695else if (content.Length >= 2 && content[0] == '-' && content[1] == '1') 766if (cpuPodWeightBuffer.IsEmpty || (cpuPodWeightBuffer.Length == 2 && cpuPodWeightBuffer[0] == '-' && cpuPodWeightBuffer[1] == '1'))
Microsoft.Extensions.Http.Diagnostics (10)
Http\DownstreamDependencyMetadataManager.cs (8)
112if (routeSpan.Length > 1 && routeSpan[routeSpan.Length - 1] == '/') 114routeSpan = routeSpan.Slice(0, routeSpan.Length - 1); 125else if (routeSpan.Length != route.Length) 366if (requestRouteAsSpan.Length > 1) 368if (requestRouteAsSpan[requestRouteAsSpan.Length - 1] == '/') 370requestRouteAsSpan = requestRouteAsSpan.Slice(0, requestRouteAsSpan.Length - 1); 381var requestPathEndIndex = requestRouteAsSpan.Length;
Latency\Internal\HttpClientLatencyLogEnricher.cs (2)
70for (int i = 0; i < latencyData.Checkpoints.Length; i++) 77for (int i = 0; i < latencyData.Checkpoints.Length; i++)
Microsoft.Extensions.Identity.Core (2)
Base32.cs (2)
78if (trimmedInput.Length == 0) 83var output = new byte[trimmedInput.Length * 5 / 8];
Microsoft.Extensions.Logging.Abstractions (3)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
Microsoft.Extensions.Logging.Console (4)
AnsiParser.cs (3)
56for (int i = 0; i < span.Length; i++) 58if (span[i] == EscapeChar && span.Length >= i + 4 && span[i + 1] == '[') 78else if (span.Length >= i + 5 && span[i + 4] == 'm')
JsonConsoleFormatter.cs (1)
106var logMessageBuffer = ArrayPool<char>.Shared.Rent(Encoding.UTF8.GetMaxCharCount(messageBytes.Length));
Microsoft.Extensions.Logging.Generators (3)
LoggerMessageGenerator.Emitter.cs (1)
634=> variableOrTemplateName.Length > 0 && variableOrTemplateName[0] == '@';
src\libraries\Common\src\Roslyn\GetBestTypeByMetadataName.cs (2)
162switch (span.Length) 170var builder = ImmutableArray.CreateBuilder<T>(span.Length);
Microsoft.Extensions.Options.SourceGeneration (2)
src\libraries\Common\src\Roslyn\GetBestTypeByMetadataName.cs (2)
162switch (span.Length) 170var builder = ImmutableArray.CreateBuilder<T>(span.Length);
Microsoft.Extensions.Primitives (2)
StringSegment.cs (2)
596for (i = 0; i < span.Length; i++) 616for (i = span.Length - 1; i >= 0; i--)
Microsoft.Extensions.ServiceDiscovery.Dns (3)
Resolver\DnsDataWriter.cs (2)
112if (_buffer.Length - _position < value.Length) 118_position += value.Length;
Resolver\DnsPrimitives.cs (1)
19if (buffer.Length < DnsMessageHeader.HeaderLength)
Microsoft.Extensions.ServiceDiscovery.Dns.Tests.Fuzzing (5)
Fuzzers\DnsResponseFuzzer.cs (1)
37_length = data.Length;
Fuzzers\EncodedDomainNameFuzzer.cs (3)
10byte[] buffer = ArrayPool<byte>.Shared.Rent(data.Length); 16for (int i = 0; i < data.Length; i++) 18if (!DnsPrimitives.TryReadQName(buffer.AsMemory(0, data.Length), i, out EncodedDomainName name, out _))
Fuzzers\WriteDomainNameRoundTripFuzzer.cs (1)
16byte[] buffer = ArrayPool<byte>.Shared.Rent(data.Length * 2);
Microsoft.Extensions.Telemetry (19)
Http\HttpRouteFormatter.cs (2)
75if (startIndex >= httpPathAsSpan.Length) 93length = httpPathAsSpan.Slice(startIndex).Length;
Http\HttpRouteParser.cs (2)
68if (startIndex < httpPathAsSpan.Length) 77length = httpPathAsSpan.Slice(startIndex).Length;
Latency\Internal\LatencyConsoleExporter.cs (12)
55latencyData.Checkpoints.Length, 56latencyData.Tags.Length, 57latencyData.Measures.Length); 60if (_outputCheckpoints && latencyData.Checkpoints.Length > 0) 63for (int i = 0; i < latencyData.Checkpoints.Length; i++) 69for (int i = 0; i < latencyData.Checkpoints.Length; i++) 76if (_outputTags && latencyData.Tags.Length > 0) 79for (int i = 0; i < latencyData.Tags.Length; i++) 85for (int i = 0; i < latencyData.Tags.Length; i++) 92if (_outputMeasures && latencyData.Measures.Length > 0) 95for (int i = 0; i < latencyData.Measures.Length; i++) 101for (int i = 0; i < latencyData.Measures.Length; i++)
Logging\JustInTimeRedactor.cs (3)
114inputAsSpan = f.ToString(format.Length > 0 ? format.ToString() : string.Empty, formatProvider).AsSpan(); 128int maxLenToRedact = inputAsSpan.Length + DiscriminatorSeparator.Length + _discriminator.Length + MaxDayOfYearLength; 136charsInWorkBuffer = inputAsSpan.Length;
Microsoft.Extensions.Telemetry.Abstractions.Tests (12)
Latency\LatencyDataTests.cs (9)
15Assert.True(ld.Checkpoints.Length == 0); 16Assert.True(ld.Measures.Length == 0); 17Assert.True(ld.Tags.Length == 0); 31Assert.True(ld.Checkpoints.Length == num); 32Assert.True(ld.Measures.Length == num); 33Assert.True(ld.Tags.Length == num); 50Assert.True(ld.Checkpoints.Length == numCheckpoints); 51Assert.True(ld.Measures.Length == numMeasures); 52Assert.True(ld.Tags.Length == numTags);
Latency\NoopLatencyContextTests.cs (3)
73Assert.True(latencyData.Checkpoints.Length == 0); 74Assert.True(latencyData.Measures.Length == 0); 75Assert.True(latencyData.Tags.Length == 0);
Microsoft.Extensions.Telemetry.Tests (7)
Latency\Internal\LatencyContextProviderTests.cs (6)
60Assert.True(lc.LatencyData.Checkpoints.Length == 1); 61Assert.True(lc.LatencyData.Measures.Length == 1); 62Assert.True(lc.LatencyData.Tags.Length == 1); 91Assert.True(lc.LatencyData.Checkpoints.Length == 1); 92Assert.True(lc.LatencyData.Measures.Length == 1); 93Assert.True(lc.LatencyData.Tags.Length == 1);
Latency\Internal\TagCollectionTests.cs (1)
104for (int i = 0; i < tags.Length; i++)
Microsoft.Gen.Logging (2)
src\Generators\Shared\RoslynExtensions.cs (2)
109switch (span.Length) 122var builder = ImmutableArray.CreateBuilder<T>(span.Length);
Microsoft.Gen.Metrics (2)
src\Generators\Shared\RoslynExtensions.cs (2)
109switch (span.Length) 122var builder = ImmutableArray.CreateBuilder<T>(span.Length);
Microsoft.Interop.ComInterfaceGenerator (4)
ComInterfaceGenerator.cs (2)
865var literals = new CollectionElementSyntax[bytes.Length]; 867for (int i = 0; i < bytes.Length; i++)
src\libraries\Common\src\Roslyn\GetBestTypeByMetadataName.cs (2)
162switch (span.Length) 170var builder = ImmutableArray.CreateBuilder<T>(span.Length);
Microsoft.Interop.LibraryImportGenerator (2)
src\libraries\Common\src\Roslyn\GetBestTypeByMetadataName.cs (2)
162switch (span.Length) 170var builder = ImmutableArray.CreateBuilder<T>(span.Length);
Microsoft.Interop.LibraryImportGenerator.Downlevel (2)
src\libraries\Common\src\Roslyn\GetBestTypeByMetadataName.cs (2)
162switch (span.Length) 170var builder = ImmutableArray.CreateBuilder<T>(span.Length);
Microsoft.Interop.SourceGeneration (2)
src\libraries\Common\src\Roslyn\GetBestTypeByMetadataName.cs (2)
162switch (span.Length) 170var builder = ImmutableArray.CreateBuilder<T>(span.Length);
Microsoft.JSInterop (2)
src\Components\Shared\src\ArrayBuilder.cs (2)
87var requiredCapacity = _itemsInUse + source.Length; 101_itemsInUse += source.Length;
Microsoft.Maui (1)
Debugger\DebuggerDisplayHelpers.cs (1)
37 var size = values.Length;
Microsoft.Maui.Essentials (2)
Types\Shared\WebUtils.shared.cs (2)
61 var chars = new char[span.Length]; 63 for (int i = 0; i < span.Length; i++)
Microsoft.Maui.Graphics (14)
Color.cs (14)
353 if (colorAsHex.Length == 6 || colorAsHex.Length == 3) 359 else if (colorAsHex.Length == 4) 375 else if (colorAsHex.Length == 8) 403 if (colorAsHex.Length == 6) 410 else if (colorAsHex.Length == 3) 423 else if (colorAsHex.Length == 4) 439 else if (colorAsHex.Length == 8) 758 Span<char> loweredValue = value.Length <= 128 ? stackalloc char[value.Length] : new char[value.Length]; 761 Debug.Assert(charsWritten == value.Length); 1000 if (!elem.IsEmpty && elem[elem.Length - 1] == '%' && acceptPercent) 1003 elem = elem.Slice(0, elem.Length - 1);
Microsoft.ML.Core (183)
Data\AnnotationUtils.cs (1)
400for (int i = 0; i < catIndicesValues.Length; i += 2)
Data\ReadOnlyMemoryUtils.cs (3)
221for (j = min; j < span.Length; j++) 231Contracts.Assert(j == span.Length); 252sb.Append(valueChars, span.Length);
Utilities\ArrayUtils.cs (1)
51Debug.Assert(0 <= min && min <= lim && lim <= input.Length);
Utilities\BigArray.cs (6)
329LongLimToMajorMaxMinorLim(_length + src.Length, out maMax, out miLim); 337Contracts.Assert(miLim - miMin == src.Length); 343Contracts.Assert((BlockSize - miMin) + miLim == src.Length); 366Contracts.Assert(srcSoFar < src.Length); 369Contracts.Assert(src.Length - srcSoFar == miLim); 375_length += src.Length;
Utilities\DoubleParser.cs (30)
113if (ich >= span.Length) 127if (span.Length - ich == 1) 143if (!DoubleParser.TryParse(span.Slice(ich, span.Length - ich), out value, out ichEnd, flags)) 150while (ichEnd < span.Length) 165if (ich >= span.Length) 179if (span.Length - ich == 1) 195if (!DoubleParser.TryParse(span.Slice(ich, span.Length - ich), out value, out ichEnd, flags)) 202while (ichEnd < span.Length) 494if (ich < span.Length) 505if (ich + 3 <= span.Length && span[ich + 1] == 'a' && span[ich + 2] == 'N') 514if (ich + 8 <= span.Length && span[ich + 1] == 'n' && span[ich + 2] == 'f' && span[ich + 3] == 'i' && span[ich + 4] == 'n' && span[ich + 5] == 'i' && span[ich + 6] == 't' && span[ich + 7] == 'y') 523if (ich + 2 <= span.Length && span[ich + 1] == InfinitySymbol) 530if (ich + 9 <= span.Length && span[ich + 1] == 'I' && span[ich + 2] == 'n' && span[ich + 3] == 'f' && span[ich + 4] == 'i' && span[ich + 5] == 'n' && span[ich + 6] == 'i' && span[ich + 7] == 't' && span[ich + 8] == 'y') 551Contracts.Assert(0 <= ich && ich <= span.Length); 562if (ich >= span.Length) 579if (++i >= span.Length) 585if (++i >= span.Length) 616Contracts.Assert(i < span.Length); 626if (++i >= span.Length) 632Contracts.Assert(i < span.Length); 638Contracts.Assert(i < span.Length); 644if (++i >= span.Length) 651Contracts.Assert(i < span.Length); 664Contracts.Assert(i < span.Length); 679if (++i >= span.Length) 686Contracts.Assert(i < span.Length); 690if (++i >= span.Length) 695if (++i >= span.Length) 711Contracts.Assert(i < span.Length); 718if (++i >= span.Length)
Utilities\FloatUtils.cs (2)
447for (int i = 0; i < values.Length; i++) 460for (int i = 0; i < values.Length; i++)
Utilities\Hashing.cs (2)
126for (int ich = 0; ich < span.Length; ich++) 192for (int ich = 0; ich < span.Length; ich++)
Utilities\LineParser.cs (3)
27for (int i = 0; i <= valuesToParse.Length; i++) 29if (i == valuesToParse.Length || valuesToParse[i] == ' ' || valuesToParse[i] == '\t') 61for (int i = 0; i < valuesToParse.Length; i++)
Utilities\MathUtils.cs (7)
150for (int i = a.Length - 1; i >= 0; i--) 179for (int i = a.Length - 1; i >= 0; i--) 207for (int i = 0; i < inputs.Length; i++) 219if (inputs.Length == 1) 225for (int i = 0; i < inputs.Length; i++) 739Contracts.Assert(aIdx >= 0 && aIdx <= a.Length - len); 740Contracts.Assert(bIdx >= 0 && bIdx <= b.Length - len);
Utilities\Stream.cs (19)
70writer.Write(values.Length); 71for (int i = 0; i < values.Length; i++) 82for (int i = 0; i < values.Length; i++) 93writer.Write(values.Length); 94for (int i = 0; i < values.Length; i++) 105for (int i = 0; i < values.Length; i++) 136writer.Write(values.Length); 138for (int i = 0; i < values.Length; i++) 174writer.Write(values.Length); 175for (int i = 0; i < values.Length; i++) 205for (int i = 0; i < values.Length; i++) 216writer.Write(values.Length); 217for (int i = 0; i < values.Length; i++) 228for (int i = 0; i < values.Length; i++) 239writer.Write(values.Length); 240for (int i = 0; i < values.Length; i++) 251for (int i = 0; i < values.Length; i++) 262writer.Write(values.Length); 263for (int i = 0; i < values.Length; i++)
Utilities\Utils.cs (5)
678if (values.Length < 1) 684for (int i = 1; i < values.Length; i++) 700Contracts.Check(values.Length >= len); 1272for (int i = 0; i < source.Length; i++) 1284for (int i = 0; i < source.Length; i++)
Utilities\VBufferUtils.cs (104)
26for (int i = 0; i < values.Length; i++) 37for (int i = 0; i < values.Length; i++) 48for (int i = 0; i < values.Length; i++) 59for (int i = 0; i < values.Length; i++) 92for (int i = 0; i < aValues.Length; i++) 98for (int i = 0; i < aValues.Length; i++) 128for (int i = 0; i < aValues.Length; i++) 134for (int i = 0; i < bValues.Length; i++) 144while (aI < aValues.Length && bI < bValues.Length) 182T aVal = (aI < aValues.Length && i == aIndices[aI]) ? aValues[aI++] : default(T); 192T bVal = (bI < bValues.Length && i == bIndices[bI]) ? bValues[bI++] : default(T); 203while (aI < aValues.Length && bI < bValues.Length) 224while (aI < aValues.Length) 230while (bI < bValues.Length) 368for (int i = values.Length; --i >= 0;) 373if (values.Length == 0) 378for (int ii = 0; ii < values.Length; ++ii) 389for (int i = 0; i < values.Length; ++i) 404if (dst.IsDense || denseCount == 0 || (dstValues.Length >= denseCount && dstIndices[denseCount - 1] == denseCount - 1)) 422int lim = Utils.FindIndexSorted(dstIndices, 0, dstValues.Length, denseCount); 424int newLen = dstValues.Length + denseCount - lim; 432int sliceLength = dstValues.Length - lim; 624if (srcValues.Length == 0) 636for (int i = 0; i < dstValues.Length; i++) 652for (int i = 0; i < srcValues.Length; i++) 670sIndex = ++sI == srcValues.Length ? src.Length : srcIndices[sI]; 678for (int i = 0; i < srcValues.Length; i++) 684if (dstValues.Length == 0) 690srcValues.Length, 693for (int i = 0; i < srcValues.Length; i++) 701int newCount = dstValues.Length; 703for (int sI = 0; sI < srcValues.Length; sI++) 706while (dI < dstValues.Length && dstIndices[dI] < sIndex) 708if (dI == dstValues.Length) 710newCount += srcValues.Length - sI; 719Contracts.Assert(0 < srcValues.Length && srcValues.Length <= newCount); 720Contracts.Assert(0 < dstValues.Length && dstValues.Length <= newCount); 739if (newCount != srcValues.Length && newCount != dstValues.Length) 752int sI = srcValues.Length - 1; 753dI = dstValues.Length - 1; 792if (newCount == dstValues.Length) 794if (newCount == srcValues.Length) 797Contracts.Assert(srcValues.Length == dstValues.Length); 798for (int i = 0; i < srcValues.Length; i++) 806Contracts.Assert(newCount > srcValues.Length); 812for (int i = 0; i < dstValues.Length; ++i) 817sIndex = ++sI == srcValues.Length ? src.Length : srcIndices[sI]; 825for (int sI = 0; sI < srcValues.Length; sI++) 837if (newCount == srcValues.Length) 843editor = VBufferEditor.Create(ref dst, newCount, dstValues.Length); 845for (dI = 0; dI < dstValues.Length; ++dI) 861for (sI = 0; sI < srcValues.Length; sI++) 886if (dstValues.Length == 0) 888if (srcValues.Length == 0) 894Contracts.Assert(srcValues.Length == src.Length); 903int count = srcValues.Length; 920if (srcValues.Length == 0) 938Contracts.Assert(srcValues.Length == src.Length); 946int count = srcValues.Length; 986int dstCount = dstValues.Length; 989if (srcValues.Length == 0) 1032Contracts.Assert(srcValues.Length > 0); 1037for (int ii = 0, jj = 0; ii < srcValues.Length; ii++) 1040while (jj < dstValues.Length && dstIndices[jj] < i) 1042if (jj == dstValues.Length) 1044resCount += srcValues.Length - ii; 1054Contracts.Assert(resCount <= srcValues.Length + dstCount); 1055Contracts.Assert(srcValues.Length <= resCount); 1083i = ++ii == srcValues.Length ? length : srcIndices[ii]; 1091i = ++ii == srcValues.Length ? length : srcIndices[ii]; 1107Contracts.Assert(ii == srcValues.Length && jj == dstCount); 1133if (srcValues.Length == 0) 1140srcValues.Length, 1153for (int i = 0; i < srcValues.Length; ++i) 1185if (aValues.Length == 0 && bValues.Length == 0) 1207TSrc1 aVal = (aI < aIndices.Length && i == aIndices[aI]) ? aValues[aI++] : default(TSrc1); 1217TSrc2 bVal = (bI < bIndices.Length && i == bIndices[bI]) ? bValues[bI++] : default(TSrc2); 1235while (aI < aIndices.Length && bI < bIndices.Length) 1245if (aI < aIndices.Length) 1246newCount += aIndices.Length - aI; 1247if (bI < bIndices.Length) 1248newCount += bIndices.Length - bI; 1256if (newCount == bValues.Length) 1258if (newCount == aValues.Length) 1262for (aI = 0; aI < aValues.Length; aI++) 1273for (bI = 0; aI < aValues.Length && bI < bValues.Length; bI++) 1279for (; bI < bValues.Length; bI++) 1283else if (newCount == aValues.Length) 1288for (aI = 0; bI < bValues.Length && aI < aValues.Length; aI++) 1294for (; aI < aValues.Length; aI++) 1303while (aI < aIndices.Length && bI < bIndices.Length) 1331for (; aI < aIndices.Length; aI++) 1338for (; bI < bIndices.Length; bI++)
Microsoft.ML.Core.Tests (39)
UnitTests\TestEntryPoints.cs (5)
4505Assert.Equal(5, treeValues.GetValues().Length); 4507Assert.Equal(5, leafIndicators.GetValues().Length); 4551Assert.Equal(150, feat.GetValues().Length); 5411for (int i = 0; i < slotNameValues.Length; i++) 6113for (int i = 0; i < avgValues.Length; i++)
UnitTests\TestVBuffer.cs (34)
38Assert.Equal(4, buffer.GetValues().Length); 101float infNorm = a.GetValues().Length == 0 ? 0 : a.Items().Max(iv => Math.Abs(iv.Value)); 471List<int> indices = new List<int>(a.GetIndices().Length); 472TDst[] values = new TDst[a.GetValues().Length]; 546if (a.GetValues().Length == 0 || c == 0) 554var editor = VBufferEditor.Create(ref aa, b.Length, aa.GetValues().Length, requireIndicesOnDense: true); 908while (index < a.GetValues().Length) 928Assert.True(expectedIndices.Count <= a.GetValues().Length); 1014var editor = VBufferEditor.Create(ref dst, src.Length, src.GetValues().Length); 1030Assert.Equal(expected.GetValues().Length, actual.GetValues().Length); 1034for (int i = 0; i < expected.GetIndices().Length; ++i) 1037for (int i = 0; i < expected.GetValues().Length; ++i) 1118GenerateVBuffer(rgen, len, a.GetValues().Length, out b); 1120for (int i = 0; i < a.GetIndices().Length; ++i) 1127GenerateVBuffer(rgen, a.GetValues().Length, rgen.Next(a.GetValues().Length), out b); 1128bEditor = VBufferEditor.Create(ref b, len, b.GetValues().Length); 1141int boundary = rgen.Next(a.GetValues().Length + 1); 1142GenerateVBuffer(rgen, len, a.GetValues().Length - boundary, out b); 1143if (a.GetValues().Length != 0 && b.GetValues().Length != 0 && a.GetValues().Length != b.GetValues().Length) 1189int j = actual.GetValues().Length == 0 ? length : actual.GetIndices()[jj]; 1195j = ++jj == actual.GetValues().Length ? length : actual.GetIndices()[jj]; 1205int i = expected.GetValues().Length == 0 ? length : expected.GetIndices()[ii]; 1211i = ++ii == expected.GetValues().Length ? length : expected.GetIndices()[ii]; 1222int i = expected.GetValues().Length == 0 ? length : expected.GetIndices()[ii]; 1223int j = actual.GetValues().Length == 0 ? length : actual.GetIndices()[jj]; 1231i = ++ii == expected.GetValues().Length ? length : expected.GetIndices()[ii]; 1232j = ++jj == actual.GetValues().Length ? length : actual.GetIndices()[jj]; 1237i = ++ii == expected.GetValues().Length ? length : expected.GetIndices()[ii]; 1243j = ++jj == actual.GetValues().Length ? length : actual.GetIndices()[jj];
Microsoft.ML.CpuMath (85)
AlignedArray.cs (5)
128Contracts.Assert(src.Length <= _size); 134Contracts.Assert(0 <= start && start <= _size - src.Length); 144Contracts.Assert(rgposSrc.Length <= valuesSrc.Length); 145Contracts.Assert(0 <= iposMin && iposMin <= iposLim && iposLim <= rgposSrc.Length);
AvxIntrinsics.cs (25)
570Contracts.Assert(count <= src.Length); 665Contracts.Assert(count <= src.Length); 719Contracts.Assert(count <= src.Length); 720Contracts.Assert(count <= dst.Length); 776Contracts.Assert(count <= src.Length); 778Contracts.Assert(count <= idx.Length); 827Contracts.Assert(count <= src.Length); 876Contracts.Assert(count <= src.Length); 878Contracts.Assert(count <= idx.Length); 924Contracts.Assert(count <= src1.Length); 925Contracts.Assert(count <= src2.Length); 981int length = src.Length; 1066float* pSrcEnd = psrc + src.Length; 1110float* pSrcEnd = psrc + src.Length; 1158float* pSrcEnd = psrc + src.Length; 1202float* pSrcEnd = psrc + src.Length; 1251float* pSrcEnd = psrc + src.Length; 1295float* pSrcEnd = psrc + src.Length; 1342Contracts.Assert(count <= src.Length); 1343Contracts.Assert(count <= dst.Length); 1396Contracts.Assert(count <= src.Length); 1397Contracts.Assert(count <= dst.Length); 1398Contracts.Assert(count <= idx.Length); 1453Contracts.Assert(count <= src.Length); 1454Contracts.Assert(count <= dst.Length);
CpuMathUtils.cs (9)
53Contracts.Assert(count <= source.Length); 72Contracts.Assert(count <= source.Length); 93Contracts.Assert(count <= source.Length); 94Contracts.Assert(count <= destination.Length); 112Contracts.Assert(count <= source.Length); 132Contracts.Assert(count <= left.Length); 133Contracts.Assert(count <= right.Length); 191Contracts.Assert(left.Length >= count); 192Contracts.Assert(right.Length >= count);
CpuMathUtils.netcoreapp.cs (21)
119Contracts.Assert(iposLimit <= rgposSrc.Length); 203Contracts.Assert(count <= source.Length); 204Contracts.Assert(count <= indices.Length); 239Contracts.Assert(count <= source.Length); 240Contracts.Assert(count <= indices.Length); 272if (source.Length < MinInputSize || !Sse.IsSupported) 275for (int i = 0; i < source.Length; i++) 302if (source.Length < MinInputSize || !Sse.IsSupported) 305for (int i = 0; i < source.Length; i++) 331if (source.Length < MinInputSize || !Sse.IsSupported) 334for (int i = 0; i < source.Length; i++) 365if (source.Length < MinInputSize || !Sse.IsSupported) 368for (int i = 0; i < source.Length; i++) 403Contracts.Assert(count < left.Length); 404Contracts.Assert(count <= right.Length); 405Contracts.Assert(count <= indices.Length); 440Contracts.Assert(count <= left.Length); 441Contracts.Assert(count <= right.Length); 535Contracts.Assert(count <= source.Length); 576Contracts.Assert(count <= source.Length); 577Contracts.Assert(count <= indices.Length);
SseIntrinsics.cs (25)
489Contracts.Assert(count <= src.Length); 559Contracts.Assert(count <= src.Length); 600Contracts.Assert(count <= src.Length); 601Contracts.Assert(count <= dst.Length); 644Contracts.Assert(count <= src.Length); 646Contracts.Assert(count <= idx.Length); 683Contracts.Assert(count <= src.Length); 720Contracts.Assert(count <= src.Length); 722Contracts.Assert(count <= idx.Length); 756Contracts.Assert(count <= src1.Length); 757Contracts.Assert(count <= src2.Length); 801int length = src.Length; 883float* pSrcEnd = psrc + src.Length; 914float* pSrcEnd = psrc + src.Length; 948float* pSrcEnd = psrc + src.Length; 979float* pSrcEnd = psrc + src.Length; 1013float* pSrcEnd = psrc + src.Length; 1044float* pSrcEnd = psrc + src.Length; 1076Contracts.Assert(count <= src.Length); 1077Contracts.Assert(count <= dst.Length); 1117Contracts.Assert(count <= src.Length); 1118Contracts.Assert(count <= dst.Length); 1119Contracts.Assert(count <= idx.Length); 1161Contracts.Assert(count <= src.Length); 1162Contracts.Assert(count <= dst.Length);
Microsoft.ML.Data (229)
Commands\ShowSchemaCommand.cs (1)
280itw.Write(": Length={0}, Count={0}", value.Length, value.GetValues().Length);
Data\BufferBuilder.cs (1)
398int count = values.Length;
Data\Conversion.cs (10)
771private bool HasNA(in VBuffer<R4> src) { var srcValues = src.GetValues(); for (int i = 0; i < srcValues.Length; i++) { if (R4.IsNaN(srcValues[i])) return true; } return false; } 772private bool HasNA(in VBuffer<R8> src) { var srcValues = src.GetValues(); for (int i = 0; i < srcValues.Length; i++) { if (R8.IsNaN(srcValues[i])) return true; } return false; } 795private bool HasZero(in VBuffer<U1> src) { if (!src.IsDense) return true; var srcValues = src.GetValues(); for (int i = 0; i < srcValues.Length; i++) { if (srcValues[i] == 0) return true; } return false; } 796private bool HasZero(in VBuffer<U2> src) { if (!src.IsDense) return true; var srcValues = src.GetValues(); for (int i = 0; i < srcValues.Length; i++) { if (srcValues[i] == 0) return true; } return false; } 797private bool HasZero(in VBuffer<U4> src) { if (!src.IsDense) return true; var srcValues = src.GetValues(); for (int i = 0; i < srcValues.Length; i++) { if (srcValues[i] == 0) return true; } return false; } 798private bool HasZero(in VBuffer<U8> src) { if (!src.IsDense) return true; var srcValues = src.GetValues(); for (int i = 0; i < srcValues.Length; i++) { if (srcValues[i] == 0) return true; } return false; } 1106switch (span.Length) 1187while (ich < span.Length) 1295while (ich < span.Length) 1341if (span.Length == 1 || !TryParseCore(span.Slice(1), out val) || (val > ((ulong)max + 1)))
Data\RowCursorUtils.cs (1)
279int count = srcValues.Length;
DataLoadSave\Binary\Codecs.cs (5)
53for (int i = 0; i < values.Length; ++i) 204int count = values.Length; 926_counts.Add(valueValues.Length); 927if (valueValues.Length > 0) 930for (int i = 0; i < valueIndices.Length; i++)
DataLoadSave\Text\TextSaver.cs (5)
182for (int i = 0; i < srcValues.Length; i++) 191for (int i = 0; i < srcValues.Length; i++) 204if (slotNamesValues.Length == 0) 208for (int i = 0; i < slotNamesValues.Length; i++) 814int ichLim = span.Length;
DataView\Transposer.cs (6)
585if (ii < rbuffIndices.Length && rbuffIndices[ii] == s) 609if (rbuff.GetValues().Length > 0) 629if (++ii < rbuffValues.Length) // Still more stuff. Add another followup item to the heap. 643countSum += _rbuff[irbuff].GetValues().Length; 1233if (indices.Length == 0) 1248while (ii < indices.Length && indices[ii] < lim)
Deprecated\Instances\HeaderSchema.cs (4)
170for (int i = 0; i < nameValues.Length; i++) 176ctx.Writer.Write(nameValues.Length); 177for (int ii = 0; ii < nameIndices.Length; ii++) 179for (int ii = 0; ii < nameValues.Length; ii++)
Deprecated\Vector\VBufferMathUtils.cs (39)
22if (aValues.Length == 0) 51if (aValues.Length == 0) 63if (aValues.Length == 0) 74if (aValues.Length == 0) 86if (c == 1 || dst.GetValues().Length == 0) 104int count = srcValues.Length; 144if (srcValues.Length == 0) 153CpuMathUtils.Add(srcValues, src.GetIndices(), editor.Values, srcValues.Length); 172if (srcValues.Length == 0 || c == 0) 181CpuMathUtils.AddScale(c, srcValues, src.GetIndices(), editor.Values, srcValues.Length); 198if (srcValues.Length == 0 || c == 0) 226if (c == 0 || b.GetValues().Length == 0) 228else if (a.GetValues().Length == 0) 246if (srcValues.Length == 0 || c == 0) 256CpuMathUtils.AddScale(c, srcValues, values, srcValues.Length); 258CpuMathUtils.AddScale(c, srcValues, src.GetIndices(), values, srcValues.Length); 268int dMin = dstIndices.Length == 0 ? 0 : dstIndices.FindIndexSorted(0, dstIndices.Length, offset); 269int dLim = dstIndices.Length == 0 ? 0 : dstIndices.FindIndexSorted(dMin, dstIndices.Length, offset + src.Length); 277gapCount = srcValues.Length; 279for (int iS = 0, iD = dMin; iS < srcIndices.Length && iD < dLim;) 298dstValues.Length + gapCount, 306if (dstValues.Length != dLim) 308Contracts.Assert(dLim < dstValues.Length); 309indices.Slice(dLim, dstValues.Length - dLim) 311values.Slice(dLim, dstValues.Length - dLim) 340int iS = srcIndices.Length - 1; 387else if (src.GetValues().Length == 0 || c == 0) 413if (srcValues.Length == 0) 418Contracts.Assert(-1 <= ind && ind < srcValues.Length); 437while (ind < srcIndices.Length && srcIndices[ind] == ind) 439Contracts.Assert(ind <= srcIndices.Length); 440Contracts.Assert(ind == srcIndices.Length || ind < srcIndices[ind]); 449if (srcValues.Length == 0) 454Contracts.Assert(-1 <= ind && ind < srcValues.Length); 473while (ind < srcIndices.Length && srcIndices[ind] == ind) 475Contracts.Assert(ind <= srcIndices.Length); 476Contracts.Assert(ind == srcIndices.Length || ind < srcIndices[ind]);
Deprecated\Vector\VectorUtils.cs (36)
34if (bValues.Length == 0) 38return CpuMathUtils.DotProductSparse(a, bValues, b.GetIndices(), bValues.Length); 47if (aValues.Length == 0 || bValues.Length == 0) 54return CpuMathUtils.DotProductSparse(aValues, bValues, b.GetIndices(), bValues.Length); 58return CpuMathUtils.DotProductSparse(bValues, aValues, a.GetIndices(), aValues.Length); 59return DotProductSparse(aValues, a.GetIndices(), 0, aValues.Length, bValues, b.GetIndices(), 0, bValues.Length); 83for (int i = 0; i < aValues.Length; i++) 175Contracts.Assert(valuesA.Length == indicesA.Length); 176Contracts.Assert(valuesB.Length == indicesB.Length); 182while (ia < indicesA.Length && ib < indicesB.Length) 205while (ia < indicesA.Length) 212while (ib < indicesB.Length) 225if (valuesB.Length == 0) 228var dotP = CpuMathUtils.DotProductSparse(valuesA, valuesB, indicesB, valuesB.Length); 235Contracts.Assert(0 <= length && length <= valuesA.Length); 236Contracts.Assert(0 <= length && length <= valuesB.Length); 258if (aValues.Length == 0 || bValues.Length == 0) 264return CpuMathUtils.DotProductSparse(aValues.Slice(offset), bValues, b.GetIndices(), bValues.Length); 270int aMin = Utils.FindIndexSorted(aIndices, 0, aIndices.Length, offset); 271int aLim = Utils.FindIndexSorted(aIndices, 0, aIndices.Length, offset + b.Length); 279for (int iA = aMin, iB = 0; iA < aLim && iB < bIndices.Length;) 309if (bValues.Length == 0) 314return CpuMathUtils.DotProductSparse(a.AsSpan(offset), bValues, b.GetIndices(), bValues.Length); 323Contracts.Assert(0 <= ia && ia < iaLim && iaLim <= aIndices.Length); 324Contracts.Assert(0 <= ib && ib < ibLim && ibLim <= bIndices.Length); 447if (srcValues.Length == 0 || c == 0) 451CpuMathUtils.AddScale(c, srcValues, dst, srcValues.Length); 455for (int i = 0; i < srcValues.Length; i++) 475if (srcValues.Length == 0 || c == 0) 486for (int i = 0; i < srcValues.Length; i++)
Evaluators\EvaluatorUtils.cs (3)
698srcValues.Length); 712for (int j = 0; j < srcValues.Length; j++) 1452for (int i = 0; i < values.Length; i++)
Evaluators\MultiOutputRegressionEvaluator.cs (2)
251Contracts.Assert(score.Length >= length); 252Contracts.Assert(label.Length >= length);
Evaluators\QuantileRegressionEvaluator.cs (5)
149for (int i = 0; i < scoreValues.Length; i++) 161for (int i = 0; i < scoreValues.Length; i++) 180for (int i = 0; i < lossValues.Length; i++) 187for (int i = 0; i < lossValues.Length; i++) 199for (int i = 0; i < srcValues.Length; i++)
Transforms\ColumnConcatenatingTransformer.cs (4)
723dstCount = checked(dstCount + tmpBufs[i].GetValues().Length); 746Contracts.Assert(bufferValues.Length <= dstCount - count); 750for (int i = 0; i < bufferValues.Length; i++) 759for (int i = 0; i < bufferValues.Length; i++)
Transforms\Hashing.cs (29)
1043if (srcValues.Length == 0) 1048var editor = VBufferEditor.Create(ref dst, src.Length, srcValues.Length); 1050for (int i = 0; i < srcValues.Length; ++i) 1067for (int i = 0; i < srcValues.Length; ++i) 1080for (int i = 0; i < srcValues.Length; ++i) 1097if (srcValues.Length == 0) 1102var editor = VBufferEditor.Create(ref dst, src.Length, srcValues.Length); 1104for (int i = 0; i < srcValues.Length; ++i) 1121for (int i = 0; i < srcValues.Length; ++i) 1134for (int i = 0; i < srcValues.Length; ++i) 1161if (srcValues.Length == 0) 1166var editor = VBufferEditor.Create(ref dst, src.Length, srcValues.Length); 1170for (int i = 0; i < srcValues.Length; ++i) 1176for (int i = 0; i < srcValues.Length; ++i) 1193for (int i = 0; i < srcValues.Length; ++i) 1203if (srcIndices.Length <= j || srcIndices[j] > i) 1225if (srcValues.Length == 0) 1230var editor = VBufferEditor.Create(ref dst, src.Length, srcValues.Length); 1234for (int i = 0; i < srcValues.Length; ++i) 1240for (int i = 0; i < srcValues.Length; ++i) 1257for (int i = 0; i < srcValues.Length; ++i) 1267if (srcIndices.Length <= j || srcIndices[j] > i) 1682Contracts.Assert(valueValues.Length == hashValues.Length); 1684for (int i = 0; i < valueValues.Length; ++i) 1727Contracts.Assert(valueValues.Length == hashValues.Length); 1730for (int i = 0; i < valueValues.Length; ++i) 1736for (int i = 0; i < valueValues.Length; ++i)
Transforms\InvertHashUtils.cs (1)
419writer.WriteLine("# Number of terms = {0} of length {1}", v.GetValues().Length, v.Length);
Transforms\KeyToValue.cs (3)
348if (0 < uintSrc && uintSrc <= values.Length) 390int srcCount = srcValues.Length; 479for (int i = 0; i < keyValues.Length; ++i)
Transforms\KeyToVector.cs (2)
531int count = values.Length; 576int cntSrc = values.Length;
Transforms\NormalizeColumn.cs (1)
944for (int i = 0; i < values.Length; i++)
Transforms\NormalizeColumnDbl.cs (52)
359Contracts.Assert(0 <= values.Length && values.Length <= size); 360if (values.Length == 0) 363if (values.Length == size) 365for (int j = 0; j < values.Length; j++) 375for (int k = 0; k < values.Length; k++) 470Contracts.Assert(0 <= values.Length && values.Length <= size); 471if (values.Length == 0) 474if (values.Length == size) 476for (int j = 0; j < values.Length; j++) 485for (int k = 0; k < values.Length; k++) 828Contracts.Assert(0 <= values.Length && values.Length <= size); 832if (values.Length == 0) 835if (values.Length >= size) 844for (int ii = 0; ii < values.Length; ii++) 858Contracts.Assert(0 <= values.Length && values.Length <= size); 863if (values.Length == 0) 870if (values.Length >= size) 888ivSrc = ++ii < values.Length ? indices[ii] : size; 889Contracts.Assert(ii == values.Length || ivSrc < size); 903Contracts.Assert(0 <= values.Length && values.Length <= size); 908if (values.Length == 0) 915if (values.Length >= size) 932Contracts.Assert(ii < values.Length && ivSrc == indices[ii] || ii == values.Length && ivSrc == size); 946ivSrc = ++ii < values.Length ? indices[ii] : size; 947Contracts.Assert((ii == values.Length) == (ivSrc >= size)); 956ivSrc = ++ii < values.Length ? indices[ii] : size; 957Contracts.Assert((ii == values.Length) == (ivSrc >= size)); 962Contracts.Assert(ii == values.Length); 1102Contracts.Assert(0 <= values.Length && values.Length <= size); 1107if (values.Length == 0) 1110if (values.Length >= size) 1127for (int ii = 0; ii < values.Length; ii++) 1313Contracts.Assert(0 <= values.Length && values.Length <= size); 1317if (values.Length == 0) 1323if (values.Length >= size) 1354ivSrc = ++ii < values.Length ? indices[ii] : size; 1355Contracts.Assert(ii == values.Length || ivSrc < size); 1365for (int ii = 0; ii < values.Length; ii++) 1937Host.Assert(0 <= values.Length && values.Length <= size); 1938if (values.Length == 0) 1941if (values.Length == size) 1943for (int j = 0; j < values.Length; j++) 1949for (int k = 0; k < values.Length; k++)
Transforms\NormalizeColumnSng.cs (9)
359var count = values.Length; 471var count = values.Length; 985int count = values.Length; 1016int count = values.Length; 1062int count = values.Length; 1262int count = values.Length; 1288for (int ii = 0; ii < indices.Length; ii++) 1474int count = values.Length; 2100int count = values.Length;
Transforms\ValueMapping.cs (1)
924for (int ich = 0; ich < values.Length; ich++)
Transforms\ValueToKeyMappingTransformerImpl.cs (7)
401for (int i = 0; i < values.Length; ++i) 419for (int i = 0; i < values.Length; ++i) 793for (int i = 0; i < srcValues.Length; ++i) 965int count = values.Length; 1014int nextExplicitSlot = indices.Length == 0 ? src.Length : indices[0]; 1021_host.Assert(islot < values.Length); 1025nextExplicitSlot = ++islot == indices.Length ? src.Length : indices[islot];
Utilities\SlotDropper.cs (2)
153var newCount = Math.Min(srcValues.Length, newLength); 173while (iiSrc < srcValues.Length)
Microsoft.ML.DataView (5)
src\Microsoft.ML.Core\Utilities\ArrayUtils.cs (1)
51Debug.Assert(0 <= min && min <= lim && lim <= input.Length);
VBuffer.cs (4)
53/// Note that if this vector <see cref="IsDense"/>, then this will be the same as the <see cref="ReadOnlySpan{T}.Length"/> 55/// this is a sparse representation, then that <see cref="ReadOnlySpan{T}.Length"/> will be somewhat shorter, as this 61/// The explicitly represented values. When this <see cref="IsDense"/>, the <see cref="ReadOnlySpan{T}.Length"/> 364/// items, which is to say, the <see cref="ReadOnlySpan{Int32}.Length"/> of the return value of <see cref="GetIndices"/>.
Microsoft.ML.Ensemble (3)
EnsembleUtils.cs (3)
60for (int i = 0; i < srcValues.Length; i++) 69for (int i = 0; i < srcValues.Length; i++) 90for (int i = 0; i < srcValues.Length; i++)
Microsoft.ML.EntryPoints (1)
FeatureCombiner.cs (1)
133for (int i = 0; i < metadataValues.Length; i++)
Microsoft.ML.FastTree (23)
BinFile\BinFinder.cs (2)
57var explicitValuesCount = explicitValues.Length; 232var valuesCount = values.GetValues().Length;
FastTree.cs (12)
1010Contracts.Assert(values.Length == indices.Length); 1013for (int i = 0; i < values.Length; ++i) 1210else if (!values.IsDense && zeroBin == 0 && valuesValues.Length < (1 - sparsifyThreshold) * values.Length) 1231for (int i = 0; i < valuesValues.Length; ++i) 1237firstBinCount += values.Length - valuesValues.Length; 1241for (int i = 0; i < valuesValues.Length; i++) 1311var editor = VBufferEditor.Create(ref dst, src.Length, srcValues.Length); 1312if (srcValues.Length > 0) 1318for (int i = 0; i < srcValues.Length; ++i) 1508for (int index = 0; index < doubleTempValues.Length; ++index) 1591for (int i = 0; i < tempValues.Length; ++i)
GamModelParameters.cs (4)
211for (int i = 0; i < featuresValues.Length; ++i) 222for (int i = 0; i < featuresValues.Length; ++i) 242for (int i = 0; i < featuresValues.Length; ++i) 256for (int i = 0; i < featuresValues.Length; ++i)
TreeEnsemble\InternalRegressionTree.cs (3)
918Contracts.Assert(featIndices.Length == featValues.Length); 922int count = featValues.Length;
Utils\LinqExtensions.cs (2)
28if (span.Length == 0) 31for (int i = 1; i < span.Length; i++)
Microsoft.ML.ImageAnalytics (2)
MLImage.cs (1)
98if (imagePixelData.Length != width * height * 4)
VectorToImageTransform.cs (1)
359if (src.GetValues().Length == 0)
Microsoft.ML.KMeansClustering (3)
KMeansModelParameters.cs (3)
189for (int j = 0; j < values.Length; j++) 196else if (values.Length > 0) 245writer.Write(values.Length);
Microsoft.ML.Mkl.Components (5)
OlsLinearRegression.cs (2)
916for (int i = 0; i < coeffs.Length; i++) 931for (int i = 0; i < coeffs.Length; i++)
SymSgdClassificationTrainer.cs (1)
426var instArrayLength = instArray.Length;
VectorWhitening.cs (2)
683int count = values.Length; 711Contracts.Assert(count <= indices.Length);
Microsoft.ML.OnnxTransformer (2)
OnnxUtils.cs (2)
563string[] stringData = new string[data.Length]; 564for (int i = 0; i < data.Length; i++)
Microsoft.ML.PCA (1)
PcaTransformer.cs (1)
439if (FloatUtils.IsFinite(weight) && weight >= 0 && (featureValues.Length == 0 || FloatUtils.IsFinite(featureValues)))
Microsoft.ML.Predictor.Tests (1)
TestTransposer.cs (1)
47for (int i = 0; i < tempValues.Length; ++i)
Microsoft.ML.Samples (3)
Dynamic\Transforms\Conversion\Hash.cs (1)
86for (int i = 0; i < indices.Length; i++)
Dynamic\Transforms\Conversion\HashWithOptions.cs (1)
100for (int i = 0; i < indices.Length; i++)
Dynamic\Transforms\ImageAnalytics\ConvertToGrayScaleInMemory.cs (1)
60for (int i = 0; i < imageData.Length; i += pixelSize)
Microsoft.ML.StandardTrainers (32)
Optimizer\SgdOptimizer.cs (9)
408for (int i = 0; i < xValues.Length; i++) 418for (int ii = 0; ii < xValues.Length; ii++) 431while (j < xprevValues.Length) 441for (int jj = 0; jj < xprevValues.Length; jj++) 454while (i < xValues.Length) 467while (ii < xValues.Length && jj < xprevValues.Length) 488while (ii < xValues.Length) 494while (jj < xprevValues.Length)
Standard\LinearPredictorUtils.cs (2)
53if (featureNames.GetValues().Length > 0) 120inputBuilder.AppendLine("Name=" + (featureNames.GetValues().Length == 0 ? "Feature_" + idx : name.IsEmpty ? $"f{idx}" : name.ToString()));
Standard\LogisticRegression\LbfgsPredictorBase.cs (1)
777for (int i = BiasCount; i < values.Length; i++)
Standard\LogisticRegression\LogisticRegression.cs (1)
293for (int i = 1; i < currentWeightsValues.Length; i++)
Standard\LogisticRegression\MulticlassLogisticRegression.cs (5)
698for (int i = 0; i < fwValues.Length; i++) 711count += fwIndices.Length; 726for (int i = 0; i < fwValues.Length; i++) 738count += fwValues.Length; 759for (int i = 0; i < values.Length; i++)
Standard\ModelStatistics.cs (1)
320Env.Assert(coeffStdErrorValues.Length == ParametersCount);
Standard\MulticlassClassification\MulticlassNaiveBayesTrainer.cs (2)
614for (int iFeature = 0; iFeature < srcValues.Length; iFeature += 1) 622for (int iFeature = 0; iFeature < srcValues.Length; iFeature += 1)
Standard\Online\LinearSvm.cs (2)
193if (_weightsUpdate.GetValues().Length == 0) 206Contracts.Assert(_weightsUpdate.GetValues().Length == 0);
Standard\SdcaBinary.cs (3)
880CpuMathUtils.SdcaL1UpdateDense(primalUpdate, featureValues.Length, featureValues, l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values); 881else if (featureValues.Length > 0) 882CpuMathUtils.SdcaL1UpdateSparse(primalUpdate, featureValues.Length, featureValues, features.GetIndices(), l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values);
Standard\SdcaMulticlass.cs (6)
298CpuMathUtils.SdcaL1UpdateDense(-primalUpdate, featureValues.Length, featureValues, l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values); 299else if (featureValues.Length > 0) 300CpuMathUtils.SdcaL1UpdateSparse(-primalUpdate, featureValues.Length, featureValues, features.GetIndices(), l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values); 329CpuMathUtils.SdcaL1UpdateDense(labelPrimalUpdate, featureValues.Length, featureValues, l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values); 330else if (featureValues.Length > 0) 331CpuMathUtils.SdcaL1UpdateSparse(labelPrimalUpdate, featureValues.Length, featureValues, features.GetIndices(), l1Threshold, l1IntermediateWeightsEditor.Values, weightsEditor.Values);
Microsoft.ML.TensorFlow.Tests (16)
TensorflowTests.cs (16)
320Assert.Equal(sample.OneDim.Length, oneDimValues.Length); 324Assert.Equal(sample.TwoDim.Length, twoDimValues.Length); 328Assert.Equal(sample.ThreeDim.Length, threeDimValues.Length); 332Assert.Equal(sample.FourDim.Length, fourDimValues.Length); 336Assert.Equal(sample.FourDimKnown.Length, fourDimKnownValues.Length); 461Assert.Equal(2, f64Values.Length); 464Assert.Equal(2, f32Values.Length); 467Assert.Equal(2, i64Values.Length); 470Assert.Equal(2, i32Values.Length); 473Assert.Equal(2, i16Values.Length); 476Assert.Equal(2, i8Values.Length); 479Assert.Equal(2, u64Values.Length); 482Assert.Equal(2, u32Values.Length); 485Assert.Equal(2, u16Values.Length); 488Assert.Equal(2, u8Values.Length); 491Assert.Equal(2, bValues.Length);
Microsoft.ML.TestFramework (3)
DataPipe\TestDataPipe.cs (1)
930TestCommon.CompareVec(in buffer, in expected[index++], buffer.GetValues().Length, (s1, s2) => s1.Span.SequenceEqual(s2.Span));
TestSparseDataView.cs (2)
60Assert.True(value.GetValues().Length == 3); 100Assert.True(value.GetValues().Length == 3);
Microsoft.ML.TestFrameworkCommon (2)
TestCommon.cs (2)
164int iv1 = v1.IsDense ? iiv1 : iiv1 < v1Indices.Length ? v1Indices[iiv1] : v1.Length; 165int iv2 = v2.IsDense ? iiv2 : iiv2 < v2Indices.Length ? v2Indices[iiv2] : v2.Length;
Microsoft.ML.Tests (16)
ImagesTests.cs (13)
219for (int i = 0; i < imageData.Length; i += pixelSize) 269for (int i = 0; i < imageData.Length; i += pixelSize) 292for (int i = 0; i < imageData1.Length; i += pixelSize1) 393for (int i = 0; i < restoredImageData.Length; i += pixelSize) 468for (int i = 0; i < restoredImageData.Length; i += pixelSize) 544for (int i = 0; i < restoredImageData.Length; i += pixelSize) 619for (int i = 0; i < restoredImageData.Length; i += pixelSize) 694for (int i = 0; i < restoredImageData.Length; i += pixelSize) 770for (int i = 0; i < restoredImageData.Length; i += pixelSize) 845for (int i = 0; i < restoredImageData.Length; i += pixelSize) 921for (int i = 0; i < restoredImageData.Length; i += pixelSize) 995for (int i = 0; i < restoredImageData.Length; i += pixelSize) 1245Assert.Equal(image1.Width * image1.Height * (image1.BitsPerPixel / 8), image1.Pixels.Length);
SvmLightTests.cs (2)
334Assert.True(features.GetValues().Length == 1); 335Assert.True(features.GetIndices().Length == 1);
TermEstimatorTests.cs (1)
149Assert.True(names1.GetValues().Length > 0);
Microsoft.ML.TimeSeries (2)
AdaptiveSingularSpectrumSequenceModeler.cs (2)
1507var horizon = meanForecast.Length; 1509Contracts.Check(sdForecast.Length >= horizon, "The forecast standard deviation values are not available.");
Microsoft.ML.Tokenizers (243)
Model\BPETokenizer.cs (41)
856span = span.Slice(0, span.Length - EndOfWordSuffix.Length); 953sSpan = sSpan.Slice(0, sSpan.Length - EndOfWordSuffix!.Length); 960if (sSpan.Length > buffer.Length) 967charsWritten += sSpan.Length; 968buffer = buffer.Slice(sSpan.Length); 1013if (specialTokenSpan.Length > buffer.Length) 1019buffer = buffer.Slice(specialTokenSpan.Length); 1020charsWritten += specialTokenSpan.Length; 1032span = span.Slice(0, span.Length - EndOfWordSuffix.Length); 1042if (current.Length < span.Length) 1047for (int i = 0; i < span.Length; i++) 1052current = utf8bytes.Slice(incompleteUtf8BytesInBufferIndex, incompleteUtf8BytesInBuffer + span.Length); 1188Word word = Word.WithCapacity(w.Length); 1195while (i < w.Length) 1199if (Char.IsHighSurrogate(w[i]) && i < w.Length - 1 && Char.IsLowSurrogate(w[i + 1])) 1213if (ContinuingSubwordPrefix.Length + s.Length <= buffer.Length) 1217s = buffer.Slice(0, ContinuingSubwordPrefix.Length + s.Length); 1231if (i + length >= w.Length && EndOfWordSuffix is not null) 1233if (s.Length + EndOfWordSuffix.Length <= buffer.Length) 1236EndOfWordSuffix.AsSpan().CopyTo(buffer.Slice(s.Length)); 1237s = buffer.Slice(0, s.Length + EndOfWordSuffix.Length); 1307tokens.Add(new EncodedToken(value.specialTokenId, value.specialToken, new Range(offset, offset + text.Length))); 1319int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(text.Length); 1350if (textSpan.Length <= MaxWordLengthToCache) 1417charsConsumed = text.Length; 1432int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(text.Length); 1455int res = WordToIds(ref hit, accumulatedIds, out charsConsumed, textSpan.Length, maxTokens); 1458charsConsumed = charsConsumed >= textSpan.Length ? text.Length : mapping[charsConsumed]; 1466if (textSpan.Length <= MaxWordLengthToCache) 1476int result = WordToIds(ref word, accumulatedIds, out charsConsumed, textSpan.Length, maxTokens); 1479charsConsumed = charsConsumed >= textSpan.Length ? text.Length : mapping[charsConsumed]; 1512int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(text.Length); 1535int res = WordToIdsFromEnd(ref hit, accumulatedIds, out textIndex, textSpan.Length, maxTokens); 1539textIndex = textIndex >= textSpan.Length ? text.Length : mapping[textIndex]; 1547if (textSpan.Length <= MaxWordLengthToCache) 1557int result = WordToIdsFromEnd(ref word, accumulatedIds, out textIndex, textSpan.Length, maxTokens); 1561textIndex = textIndex >= textSpan.Length ? text.Length : mapping[textIndex];
Model\CodeGenTokenizer.cs (40)
345if (span.Length + 1 > BufferLength) 347mutatedInputText = ArrayPool<char>.Shared.Rent(span.Length + 1); 352span = mutatedInputSpan.Slice(0, span.Length + 1); 385PriorityQueue<SymbolPair> agenda = new(textSpanToEncode.Length); 401int index = addPrefixSpace ? Math.Max(0, textSpanToEncode.Length - 1) : textSpanToEncode.Length; 405return new EncodeResults<EncodedToken> { Tokens = tokens, NormalizedText = normalizedText, CharsConsumed = textSpanToEncode.Length }; 435tokens.Add(new EncodedToken(value.specialTokenId, value.specialToken, new Range(index, index + ((addPrefixSpace && offset == 0) ? textSpan.Length - 1 : textSpan.Length)))); 452int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(textSpan.Length); 466if (textSpan.Length <= MaxTokenLengthToCache) 602if (span.Length + 1 > BufferLength) 604mutatedInputText = ArrayPool<char>.Shared.Rent(span.Length + 1); 609span = mutatedInputSpan.Slice(0, span.Length + 1); 625PriorityQueue<SymbolPair> agenda = new(textSpanToEncode.Length); 821if (span.Length + 1 > BufferLength) 823mutatedInputText = ArrayPool<char>.Shared.Rent(span.Length + 1); 828span = mutatedInputSpan.Slice(0, span.Length + 1); 837PriorityQueue<SymbolPair> agenda = new(textSpanToEncode.Length); 958if (span.Length + 1 > BufferLength) 960mutatedInputText = ArrayPool<char>.Shared.Rent(span.Length + 1); 965span = mutatedInputSpan.Slice(0, span.Length + 1); 974PriorityQueue<SymbolPair> agenda = new(textSpanToEncode.Length); 1119charsConsumed = textSpan.Length; 1125return EncodeToIdsResult(hit, accumulatedIds, maxTokens, textSpan.Length, out charsConsumed); 1135int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(textSpan.Length); 1149int length = text is not null ? text.Length : textSpan.Length; 1155return EncodeToIdsResult(result, accumulatedIds, maxTokens, textSpan.Length, out charsConsumed); 1172textIndex = textSpan.Length; 1189return EncodeToIdsFromEndResult(hit, accumulatedIds, maxTokens, textSpan.Length, out textIndex); 1199int destinationMaxSize = Encoding.UTF8.GetMaxByteCount(textSpan.Length); 1213int length = text is not null ? text.Length : textSpan.Length; 1219return EncodeToIdsFromEndResult(result, accumulatedIds, maxTokens, textSpan.Length, out textIndex); 1452if (specialTokenSpan.Length > buffer.Length) 1458buffer = buffer.Slice(specialTokenSpan.Length); 1459charsWritten += specialTokenSpan.Length; 1472if (current.Length < span.Length) 1477for (int i = 0; i < span.Length; i++) 1482current = utf8bytes.Slice(incompleteUtf8BytesInBufferIndex, incompleteUtf8BytesInBuffer + span.Length); 1682int endIndex = index + length < mapping.Length ? mapping[index + length] : originalText.Length;
Model\EnglishRobertaTokenizer.cs (15)
363char[] token = ArrayPool<char>.Shared.Rent(text.Length); 364int[] indexMapping = ArrayPool<int>.Shared.Rent(text.Length); 369for (int i = 0; i < text.Length; i++) 672return EncodeToIdsResult(hit, accumulatedIds, maxTokens, text.Length, out charsConsumed); 675char[] token = ArrayPool<char>.Shared.Rent(text.Length); 676int[] indexMapping = ArrayPool<int>.Shared.Rent(text.Length); 681for (int i = 0; i < text.Length; i++) 695charsConsumed = text.Length; 704return EncodeToIdsResult(result, accumulatedIds, maxTokens, text.Length, out charsConsumed); 711textIndex = text.Length; 717return EncodeToIdsFromEndResult(hit, accumulatedIds, maxTokens, text.Length, out textIndex); 720char[] token = ArrayPool<char>.Shared.Rent(text.Length); 721int[] indexMapping = ArrayPool<int>.Shared.Rent(text.Length); 726for (int i = 0; i < text.Length; i++) 749return EncodeToIdsFromEndResult(result, accumulatedIds, maxTokens, text.Length, out textIndex);
Model\SentencePieceBaseModel.cs (8)
678if (tokenSpan.Length > buffer.Length) 692buffer = buffer.Slice(tokenSpan.Length); 693charsConsumed += tokenSpan.Length; 700if (tokenSpan[tokenSpan.Length - 1] == prefixSuffixChar) 702suffixIndex = charsConsumed + tokenSpan.Length - 1; 705if (tokenSpan.Length > buffer.Length) 719charsConsumed += tokenSpan.Length; 741charsConsumed += tokenSpan.Length;
Model\SentencePieceBpeModel.cs (34)
86if (textToEncode.Length == 0) 131if (currentOffset < text.Length) 138tokens.Add(new EncodedToken(EndOfSentenceId, EndOfSentenceToken, new Range(text.Length, text.Length))); 152BpeSymbol[] symbols = ArrayPool<BpeSymbol>.Shared.Rent(text.Length); 203tokens.Add(new EncodedToken(EndOfSentenceId, EndOfSentenceToken, new Range(text.Length, text.Length))); 211for (int i = 0; i < text.Length; i++) 228int len = Encoding.UTF8.GetMaxByteCount(text.Length - i); 237int length = text.Length - i; 393if (currentOffset < text.Length && idsCount < maxTokens) 435BpeSymbol[] symbols = ArrayPool<BpeSymbol>.Shared.Rent(text.Length); 507for (int i = 0; i < text.Length; i++) 528int len = Encoding.UTF8.GetMaxByteCount(text.Length - i); 546charsConsumed += text.Length - i; 669if (currentOffset < text.Length && idsCount < maxTokens) 703BpeSymbol[] symbols = ArrayPool<BpeSymbol>.Shared.Rent(text.Length); 771for (int i = 0; i < text.Length; i++) 791int len = Encoding.UTF8.GetMaxByteCount(text.Length - i); 805charsConsumed += text.Length - i; 897Debug.Assert(text.Length > 0); 899textIndex = text.Length; 919if (current.Offset + current.Length < text.Length) 923textIndex -= splitText.Length - splitTextIndex; 941textIndex -= splitText.Length - splitTextIndex; 964textIndex = text.Length; 972BpeSymbol[] symbols = ArrayPool<BpeSymbol>.Shared.Rent(text.Length); 1047for (int i = text.Length - 1; i >= 0; i--) 1067int len = Encoding.UTF8.GetMaxByteCount(text.Length - i); 1131Debug.Assert(text.Length > 0); 1132Debug.Assert(symbols.Length >= text.Length); 1137while (spanIndex < text.Length) 1139int len = (Char.IsHighSurrogate(text[spanIndex]) && spanIndex < text.Length - 1 && Char.IsLowSurrogate(text[spanIndex + 1])) ? 2 : 1; 1143next: spanIndex + len >= text.Length ? -1 : symbolIndex + 1,
Model\SentencePieceTokenizer.cs (1)
125CharsConsumed = normalizedText?.Length ?? text?.Length ?? textSpan.Length
Model\SentencePieceUnigramModel.cs (27)
112int[] buffer = ArrayPool<int>.Shared.Rent(textToEncode.Length * 3); 115char[] normalizedString = ArrayPool<char>.Shared.Rent(textToEncode.Length + 2); 147if (text.Length > remainingLength) 155text.CopyTo(normalizedString.AsSpan(normalizedString.Length - normalizedStringCountFromEnd - text.Length)); 156normalizedStringCountFromEnd += text.Length; 174Debug.Assert(bytesConsumed == utf8Bytes.Length); 183if (text.Length > utf16NormalizedString.Length) 190normalizedStringIndex += text.Length; 196if (Encoding.UTF8.GetMaxCharCount(normalizationSpan.Length) > normalizedUtf16Span.Length) 246if (currentOffset < text.Length) 294Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) * 3 <= buffer.Length * sizeof(int)); 473Debug.Assert(normalized.Length > 0); 475int size = normalized.Length; 584int[] buffer = ArrayPool<int>.Shared.Rent(textToEncode.Length * 3); 587char[]? normalizedString = maxTokenCount == int.MaxValue ? null : ArrayPool<char>.Shared.Rent(textToEncode.Length + 2); 686if (currentOffset < text.Length) 853charsConsumed += text.Length; 891if (index + utf8UnknownBytes.Length > maxTokenCount) 896addedTokensCount += utf8UnknownBytes.Length - 1; 974int[] buffer = ArrayPool<int>.Shared.Rent(textToEncode.Length * 3); 977char[]? normalizedString = maxTokenCount == int.MaxValue ? null : ArrayPool<char>.Shared.Rent(textToEncode.Length + 2); 1056if (currentOffset < text.Length && tokenCount < maxTokenCount) 1226return textToEncode.Length; 1236return textToEncode.Length; 1241int[] buffer = ArrayPool<int>.Shared.Rent(textToEncode.Length * 3); 1244char[]? normalizedString = maxTokenCount == int.MaxValue ? null : ArrayPool<char>.Shared.Rent(textToEncode.Length + 2); 1295if (current.Offset + current.Length < text.Length)
Model\TiktokenTokenizer.cs (20)
323int utf8Length = Encoding.UTF8.GetMaxByteCount(text.Length); 329indexMappingSpan[encodedLength] = text.Length; 341if (text.Length <= MaxWordLengthToCache) 430return EncodeToIdsResult(value, accumulatedIds, maxTokenCount, text.Length, out charsConsumed); 435charsConsumed = text.Length; 440int utf8Length = Encoding.UTF8.GetMaxByteCount(text.Length); 446indexMappingSpan[encodedLength] = text.Length; 455if (text.Length <= MaxWordLengthToCache) 461return EncodeToIdsResult(encodedTokens, accumulatedIds, maxTokenCount, text.Length, out charsConsumed); 596return EncodeToIdsResult(value, accumulatedIds: null, maxTokens, text.Length, out charsConsumed); 601charsConsumed = text.Length; 605int utf8Length = Encoding.UTF8.GetMaxByteCount(text.Length); 611indexMappingSpan[encodedLength] = text.Length; 620if (text.Length <= MaxWordLengthToCache) 626return EncodeToIdsResult(encodedTokens, accumulatedIds: null, maxTokens, text.Length, out charsConsumed); 722return EncodeToIdsFromEndResult(value, accumulatedIds: null, maxTokens, text.Length, out textIndex); 731int utf8Length = Encoding.UTF8.GetMaxByteCount(text.Length); 737indexMappingSpan[encodedLength] = text.Length; 746if (text.Length <= MaxWordLengthToCache) 752return EncodeToIdsFromEndResult(encodedTokens, accumulatedIds: null, maxTokens, text.Length, out textIndex);
Model\WordPieceTokenizer.cs (12)
317if (text.Length > MaxInputCharsPerWord) 319tokens.Add(new EncodedToken(UnknownTokenId, UnknownToken, new Range(offset, offset + text.Length))); 329int textLength = text.Length; 346subStr = buffer.Slice(0, ContinuingSubwordPrefix.Length + subStr.Length); 456if (text.Length > MaxInputCharsPerWord) 459charsConsumed = text.Length; 469int textLength = text.Length; 487subStr = buffer.Slice(0, ContinuingSubwordPrefix.Length + subStr.Length); 632if (charsConsumed != textSpanToEncode.Length) 635return fromEnd ? textSpanToEncode.Length : 0; 638return fromEnd ? 0 : textSpanToEncode.Length; 663return fromEnd ? 0 : textSpanToEncode.Length;
Normalizer\LowerCaseNormalizer.cs (2)
45char[] arrayPoolArray = ArrayPool<char>.Shared.Rent(original.Length); 48Debug.Assert(length == original.Length);
Normalizer\SentencePieceNormalizer.cs (6)
107int endIndex = original.Length - 1; 392while (isPrevSpace && sp.Length > 0 && sp[0] == (byte)' ') 399for (int n = 0; n < sp.Length; ++n) 426isPrevSpace = sp[sp.Length - 1] == (byte)' '; 490if (blob.Length <= sizeof(uint)) 505if (trieBlobSize >= blob.Length)
Normalizer\UpperCaseNormalizer.cs (2)
45char[] arrayPoolArray = ArrayPool<char>.Shared.Rent(original.Length); 48Debug.Assert(length == original.Length);
PreTokenizer\CompositePreTokenizer.cs (2)
149char[] buffer = ArrayPool<char>.Shared.Rent(text.Length); 152IEnumerable<(int Offset, int Length)> result = PreTokenize(buffer, text.Length);
PreTokenizer\PreTokenizer.cs (2)
136char[] buffer = ArrayPool<char>.Shared.Rent(text.Length); 138return SplitText(buffer, regex, text.Length);
PreTokenizer\RegexPreTokenizer.cs (2)
104char[] buffer = ArrayPool<char>.Shared.Rent(text.Length); 106return SplitText(buffer, _regex, _specialTokensRegex, text.Length);
Tokenizer.cs (2)
257return tokens.NormalizedText?.Length ?? textSpan.Length; 456fullTextLength = textSpan.Length;
Utils\BytePairEncoder.cs (1)
102while (finalEndIndex < indexMappingSpan.Length && indexMappingSpan[finalEndIndex] == mappedEndIndex)
Utils\DoubleArrayTrie.cs (1)
1072for (int i = 0; i < key.Length; ++i)
Utils\Helpers.cs (16)
57while (utf8Bytes.Length > 0) 61utf8Bytes = utf8Bytes.Slice(Math.Min(bytesLength, utf8Bytes.Length)); 70Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length); 75for (int i = 0; i < text.Length; i++) 96if (i < text.Length - 1 && char.IsSurrogatePair((char)c, text[i + 1])) 141if (text.Length > 1 && char.IsSurrogatePair((char)c, text[1])) 162Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length); 168for (int i = 0; i < text.Length; i++) 189if (i < text.Length - 1 && char.IsSurrogatePair((char)c, text[i + 1])) 217for (int i = 0; i < text.Length; i++) 244while (byteIndex < utf8Bytes.Length) 283if (byteIndex + additionalBytes >= utf8Bytes.Length) 321Debug.Assert(input.Length > 0); 328else if (input.Length >= 2 && (input[0] & 0xE0) == 0xC0) 337else if (input.Length >= 3 && (input[0] & 0xF0) == 0xE0) 346else if (input.Length >= 4 && (input[0] & 0xf8) == 0xF0)
Utils\Helpers.netcoreapp.cs (1)
81Debug.Assert(textIndex < text.Length);
Utils\LruCache.cs (1)
78if (_cache.TryGetValue(new StringSpanOrdinalKey(ptr, key.Length), out LinkedListNode<KeyValuePair<string, TValue>>? cached))
Utils\StringSpanOrdinalKey.cs (4)
103return _map.TryGetValue(new StringSpanOrdinalKey(ptr, key.Length), out value!); 181return map.TryGetValue(new StringSpanOrdinalKey(ptr, key.Length), out value!); 193return map.TryGetValue(new StringSpanOrdinalKeyPair(ptr1, key1.Length, ptr2, key2.Length), out value!);
Utils\ValueStringBuilder.cs (3)
352if (pos > _chars.Length - value.Length) 354Grow(value.Length); 358_pos += value.Length;
Microsoft.ML.Tokenizers.Tests (24)
NormalizerTests.cs (3)
95StringBuilder sb = new StringBuilder(original.Length); 110if (start >= original.Length) 118for (int i = start; i < original.Length; i++)
PreTokenizerTests.cs (3)
90while (index < text.Length && char.IsWhiteSpace(text[index])) 96while (end < text.Length && !char.IsWhiteSpace(text[end])) 101if (index < text.Length)
src\Microsoft.ML.Tokenizers\Utils\DoubleArrayTrie.cs (1)
1072for (int i = 0; i < key.Length; ++i)
src\Microsoft.ML.Tokenizers\Utils\Helpers.cs (16)
57while (utf8Bytes.Length > 0) 61utf8Bytes = utf8Bytes.Slice(Math.Min(bytesLength, utf8Bytes.Length)); 70Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length); 75for (int i = 0; i < text.Length; i++) 96if (i < text.Length - 1 && char.IsSurrogatePair((char)c, text[i + 1])) 141if (text.Length > 1 && char.IsSurrogatePair((char)c, text[1])) 162Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length); 168for (int i = 0; i < text.Length; i++) 189if (i < text.Length - 1 && char.IsSurrogatePair((char)c, text[i + 1])) 217for (int i = 0; i < text.Length; i++) 244while (byteIndex < utf8Bytes.Length) 283if (byteIndex + additionalBytes >= utf8Bytes.Length) 321Debug.Assert(input.Length > 0); 328else if (input.Length >= 2 && (input[0] & 0xE0) == 0xC0) 337else if (input.Length >= 3 && (input[0] & 0xF0) == 0xE0) 346else if (input.Length >= 4 && (input[0] & 0xf8) == 0xF0)
src\Microsoft.ML.Tokenizers\Utils\Helpers.netcoreapp.cs (1)
81Debug.Assert(textIndex < text.Length);
Microsoft.ML.TorchSharp (16)
AutoFormerV2\ObjectDetectionTrainer.cs (2)
398Contracts.Assert(boxValues.Length == labelValues.Length * 4, "Must have 4 coordinates for each label");
Utils\DataUtils.cs (14)
79var array = new T[s1.Length + s2.Length]; 81s2.CopyTo(array.AsSpan(s1.Length)); 87var array = new T[s1.Length + s2.Length + s3.Length]; 89s2.CopyTo(array.AsSpan(s1.Length)); 90s3.CopyTo(array.AsSpan(s1.Length + s2.Length)); 96var array = new T[s1.Length + 1]; 98array.AsSpan(s1.Length)[0] = s2; 104var array = new T[s1.Length + 2]; 106array.AsSpan(s1.Length)[0] = s2; 107array.AsSpan(s1.Length + 1)[0] = s3;
Microsoft.ML.Transforms (100)
Dracula\CountTableTransformer.cs (2)
291for (int i = 0; i < indices.Length; i++) 722for (int i = 0; i < srcIndices.Length; i++)
ExpressionTransformer.cs (6)
620int count = src0.GetValues().Length; 647int count = src0.GetValues().Length; 694int count = src0.GetValues().Length; 757int count = src0.GetValues().Length; 823int count = src0.GetValues().Length; 892int count = src0.GetValues().Length;
GcnTransform.cs (15)
476int count = srcValues.Length; 529Contracts.Assert(0 <= values.Length && values.Length <= length); 530if (values.Length == 0) 535if (values.Length != length && tmpMean != 0) 539sumSq = (length - values.Length) * meanSq; 551Contracts.Assert(0 <= values.Length && values.Length <= length); 552if (values.Length == 0) 555if (values.Length != length && mean != 0) 559sumSq = (length - values.Length) * meanSq; 571if (values.Length == 0) 582if (values.Length == 0) 593if (values.Length == 0) 600if (length == 0 || src.Length == 0)
LearnerFeatureSelection.cs (8)
128if (scoresValues.Length == 0) 145for (int i = 0; i < scoresValues.Length; i++) 161while (++i < scoresValues.Length) 192Contracts.Assert(max < scoresValues.Length); 195range.max = max == scoresIndices.Length - 1 ? scores.Length - 1 : scoresIndices[max + 1] - 1; 211for (; ii <= scoresIndices.Length; ii++) 214var gapMax = ii == scoresIndices.Length ? scores.Length - 1 : scoresIndices[ii] - 1; 236for (int i = 0; i < scores.Length; i++)
MissingValueDroppingTransformer.cs (13)
259for (int i = 0; i < srcValues.Length; i++) 264Host.Assert(newCount <= srcValues.Length); 272if (newCount == srcValues.Length) 277Host.Assert(dst.GetValues().Length == newCount); 287for (int i = 0; i < srcValues.Length; i++) 303for (int i = 0; i < srcValues.Length; i++) 308Host.Assert(newCount <= srcValues.Length); 312VBufferUtils.Resize(ref dst, src.Length - srcValues.Length, 0); 316if (newCount == srcValues.Length) 326for (int i = 0; i < srcValues.Length; i++) 339var newLength = src.Length - srcValues.Length - newCount; 344for (int i = 0; i < srcValues.Length; i++) 356Host.Assert(offset == srcValues.Length - newCount);
MissingValueIndicatorTransform.cs (4)
300var editor = VBufferEditor.Create(ref buffer, size * 2, values.Length); 306for (int ivSrc = 0; ivSrc < values.Length; ivSrc++) 331for (int iivSrc = 0; iivSrc < values.Length; iivSrc++) 354ectx.Assert(0 <= iivDst && iivDst <= values.Length);
MissingValueIndicatorTransformer.cs (1)
307var srcCount = srcValues.Length;
MissingValueReplacing.cs (3)
261for (int slot = 0; slot < srcValues.Length; slot++) 714int srcCount = srcValues.Length; 788int srcCount = srcValues.Length;
MissingValueReplacingUtils.cs (2)
221var srcCount = srcValues.Length; 245var srcCount = srcValues.Length;
MutualInformationFeatureSelection.cs (12)
733for (int i = 0; i < labelsValues.Length; i++) 746for (int i = 0; i < labelsValues.Length; i++) 750if (ii == featureIndices.Length || i < featureIndices[ii]) 761Contracts.Assert(ii == featureIndices.Length); 800var bounds = _binFinder.FindBins(numBins, _singles, input.Length - input.GetValues().Length); 819for (int i = 0; i < inputValues.Length; i++) 826var bounds = _binFinder.FindBins(numBins, _singles, input.Length - inputValues.Length); 845for (int i = 0; i < inputValues.Length; i++) 852var bounds = _binFinder.FindBins(numBins, _doubles, input.Length - inputValues.Length); 894var editor = VBufferEditor.Create(ref output, input.Length, inputValues.Length); 895for (int i = 0; i < inputValues.Length; i++) 901if (!input.IsDense && inputValues.Length > 0)
RandomFourierFeaturizing.cs (2)
578featuresAligned.CopyFrom(srcIndices, srcValues, 0, 0, srcValues.Length, zeroItems: false); 580srcValues.Length, productAligned, transformInfo.NewDim);
SvmLight\SvmLightLoader.cs (2)
307for (int i = 0; i < inputValues.Length; i++) 692for (int i = 0; i < values.Length; ++i)
Text\LdaSingleBox.cs (14)
199Contracts.Check(termID.Length >= termNum); 200Contracts.Check(termVal.Length >= termNum); 203int[] pVal = new int[termVal.Length]; 204for (int i = 0; i < termVal.Length; i++) 215Contracts.Check(termVal.Length >= termNum); 218int[] pVal = new int[termVal.Length]; 219for (int i = 0; i < termVal.Length; i++) 264Contracts.Check(termVal.Length >= termNum); 265Contracts.Check(termID.Length >= termNum); 268int[] pVal = new int[termVal.Length]; 269for (int i = 0; i < termVal.Length; i++) 296Contracts.Check(termVal.Length >= termNum); 297int[] pVal = new int[termVal.Length]; 298for (int i = 0; i < termVal.Length; i++)
Text\LdaTransform.cs (4)
426for (int i = 0; i < inputValues.Length; i++) 484if (srcValues.Length == 0) 494for (int i = 0; i < srcValues.Length; i++) 884for (int termID = 0; termID < srcValues.Length; termID++)
Text\NgramUtils.cs (1)
100if (iindex < srcIndices.Length && i == srcIndices[iindex])
Text\StopWordsRemovingTransformer.cs (2)
426for (int i = 0; i < srcValues.Length; i++) 1114for (int i = 0; i < srcValues.Length; i++)
Text\TextNormalizing.cs (1)
372for (int i = 0; i < srcValues.Length; i++)
Text\TokenizingByCharacters.cs (4)
520for (int i = 0; i < srcValues.Length; i++) 534for (int i = 0; i < srcValues.Length; i++) 559for (int i = 0; i < srcValues.Length; i++) 587for (int i = 0; i < srcValues.Length; i++)
Text\WordEmbeddingsExtractor.cs (1)
579for (int word = 0; word < srcValues.Length; word++)
Text\WordTokenizing.cs (1)
293for (int i = 0; i < srcValues.Length; i++)
UngroupTransform.cs (2)
662while (cachedIndex < rowIndices.Length && _pivotColPosition > rowIndices[cachedIndex]) 665if (cachedIndex < rowIndices.Length && _pivotColPosition == rowIndices[cachedIndex])
Microsoft.Net.Http.Headers (11)
ContentDispositionHeaderValue.cs (9)
546var requiredLength = MimePrefix.Length + 548MimeSuffix.Length; 556var bufferContent = buffer.Slice(MimePrefix.Length); 563var result = Encoding.UTF8.GetString(buffer.Slice(0, MimePrefix.Length + base64ContentLength + MimeSuffix.Length)); 622while (remaining.Length > 0) 627length = remaining.Length; 632if (remaining.Length == 0) 640length = remaining.Length;
SetCookieHeaderValue.cs (1)
326span = span.Slice(other.Length);
src\Shared\HttpRuleParser.cs (1)
65return (firstNonTokenCharIdx == -1) ? subspan.Length : firstNonTokenCharIdx;
Microsoft.NET.StringTools (18)
InternableString.cs (9)
68if (newCharIndex < _string._inlineSpan.Length) 124Length = span.Length; 188if (_inlineSpan.SequenceCompareTo(other.AsSpan(0, _inlineSpan.Length)) != 0) 195int otherStart = _inlineSpan.Length; 221if (_inlineSpan.Length == Length) 249Unsafe.CopyBlockUnaligned(destPtr, sourcePtr, 2 * (uint)_inlineSpan.Length); 251destPtr += _inlineSpan.Length; 288if (_inlineSpan.Length == Length) 327hash = GetHashCodeHelper(charPtr, _inlineSpan.Length, hash, ref hashedOddNumberOfCharacters);
SpanBasedStringBuilder.cs (9)
172if (_spans.Count == 0 || other.IsEmpty || Length != other.Length) 272while (i < span.Length && char.IsWhiteSpace(span[i])) 294while (i < span.Length && span[i] == c) 318int i = span.Length - 1; 323if (i + 1 < span.Length) 326Length -= span.Length - (i + 1); 340int i = span.Length - 1; 345if (i + 1 < span.Length) 348Length -= span.Length - (i + 1);
PresentationBuildTasks (11)
MS\Internal\MarkupCompiler\PathInternal.cs (6)
196int pathLength = path.Length; 290path.Length >= DevicePrefixLength 303return path.Length >= UncExtendedPrefixLength 328return path.Length >= DevicePrefixLength 339=> path.Length > 0 && PathInternal.IsDirectorySeparator(path[path.Length - 1]);
src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\ReflectionUtils.cs (5)
66fullName = fullName.Slice(0, fullName.Length - nameSlice.Length + commaIndex); 108int tokenLength = tokenEnding == 0 ? assemblyName.Slice(versionIndex).Length : tokenEnding; 118int tokenLength = tokenEnding == 0 ? assemblyName.Slice(tokenIndex).Length : tokenEnding; 123if (assemblyToken.Length != 16)
PresentationCore (6)
MS\Internal\Ink\InkSerializedFormat\AlgoModule.cs (1)
48int i = DefaultFirstSquareRoot.Length - 2;
MS\Internal\Ink\InkSerializedFormat\InkSerializer.cs (3)
88int isfBase64PrefixLength = Base64HeaderBytes.Length; 2091if (data.Length < Base64HeaderBytes.Length) 2096for (int x = 0; x < Base64HeaderBytes.Length; x++)
System\Windows\Input\TextCompositionManager.cs (1)
407ptrMultiByte, multiByte.Length, ptrOutputChars, outputChars.Length);
System\Windows\PresentationSource.cs (1)
577for (int i = 1; i < visuals.Length; i++)
PresentationFramework (45)
MS\Internal\AppModel\ResourceContainer.cs (12)
199int totalLength = assemblyName.Length + assemblyVersion.Length + assemblyToken.Length; 210UpdateCachedRMW(key.Slice(0, assemblyName.Length), assembly); 215assemblyVersion.CopyTo(key.Slice(assemblyName.Length)); 216UpdateCachedRMW(key.Slice(0, assemblyName.Length + assemblyVersion.Length), assembly); 224assemblyToken.CopyTo(key.Slice(assemblyName.Length + assemblyVersion.Length)); 229assemblyToken.CopyTo(key.Slice(assemblyName.Length)); 230UpdateCachedRMW(key.Slice(0, assemblyName.Length + assemblyToken.Length), assembly);
MS\Internal\Commands\CommandHelpers.cs (1)
104for (int i = 0; i < inputGestures.Length; i++)
MS\Internal\Globalization\BamlResourceContent.cs (6)
103StringBuilder stringBuilder = new(contentSpan.Length); 106for (int i = firstEscapeToken; i < contentSpan.Length; i++) 110if (contentSpan.Length > i + 1) // Check whether we're at the end 131if (contentSpan.Length > 5 && contentSpan[5] == ';') 146else if (contentSpan.Length > 4 && contentSpan[4] == ';') 155else if (contentSpan.Length > 3 && contentSpan[3] == ';')
MS\Internal\Ink\LassoHelper.cs (2)
167int marginCount = (points.Length * percentIntersect) / 100; 169if ((0 == marginCount) || (50 <= ((points.Length * percentIntersect) % 100)))
MS\Internal\PtsHost\ListMarkerSourceInfo.cs (2)
249for (int i = 0; i < RomanNumericSizeIncrements.Length; i++) 261if (i < RomanNumericSizeIncrements.Length - 1)
MS\Internal\TraceData.cs (1)
92for (int i = 0; i < parameters.Length; i++)
System\Windows\Controls\DataGridLengthConverter.cs (2)
242if (valueSpan.Length == strLenUnit) 258ReadOnlySpan<char> valueString = valueSpan.Slice(0, valueSpan.Length - strLenUnit);
System\Windows\Controls\DocumentViewer.cs (3)
1137(_zoomLevelIndex < ZoomLevelCollection.Length - 1)) 2223if ((_zoomLevelIndex < 0) || (_zoomLevelIndex >= ZoomLevelCollection.Length)) 2245for (loopIndex = 0; loopIndex < ZoomLevelCollection.Length - 1; loopIndex++)
System\Windows\Controls\VirtualizingStackPanel.cs (1)
12253return args.IsEmpty ? string.Empty : string.Format(CultureInfo.InvariantCulture, s_format[args.Length], args);
System\Windows\Documents\TextStore.cs (1)
4838return args.IsEmpty ? string.Empty : string.Format(CultureInfo.InvariantCulture, s_format[args.Length], args);
System\Windows\Documents\XamlToRtfWriter.cs (6)
3545if (s.Length == 0) 3551int n = s.Length - 1; 3558if (n < s.Length - 1) 3814while (s < thickness.Length) 3818while (e < thickness.Length && thickness[e] != ',') 3824if (onenum.Length > 0)
System\Windows\LengthConverter.cs (1)
204valueSpan = valueSpan.Slice(0, valueSpan.Length - pixelUnit.Name.Length);
System\Windows\Markup\Primitives\ExtensionSimplifierMarkupObject.cs (2)
357if (value.Length > 1 && value[1] == '}') 371for (int i = 0; i < value.Length; i++)
System\Windows\Markup\Primitives\MarkupWriter.cs (1)
1640for (int i = 0; i < ns.Length; i++)
System\Windows\Markup\XamlFigureLengthSerializer.cs (2)
229if (valueSpan.Length == strLenUnit && unit != FigureUnitType.Pixel) 240ReadOnlySpan<char> valueString = valueSpan.Slice(0, valueSpan.Length - strLenUnit);
System\Windows\Markup\XamlGridLengthSerializer.cs (2)
229if (valueSpan.Length == strLenUnit 240ReadOnlySpan<char> valueString = valueSpan.Slice(0, valueSpan.Length - strLenUnit);
PresentationUI (3)
MS\Internal\Documents\DocumentApplicationDocumentViewer.cs (3)
1860if ((!culture.IsNeutralCulture) && (zoomString.Length > 0)) 1868if (zoomString.Length - 1 == zoomString.LastIndexOf( 1872zoomString = zoomString.Slice(0, zoomString.Length - 1);
Roslyn.Diagnostics.Analyzers (47)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (1)
126if (remaining[index] == '\r' && remaining.Length > index + 1 && remaining[index + 1] == '\n')
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Roslyn.Diagnostics.CSharp.Analyzers (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ExpressionGenerator.cs (1)
302for (var i = 0; i < names.Length; i++)
Shared (13)
JsonSchemaExporter\JsonSchemaExporter.cs (1)
561for (int i = 0; i < path.Length; i++)
ServerSentEvents\Helpers.cs (4)
52Span<byte> buffer = writer.GetSpan(value.Length); 53Debug.Assert(value.Length <= buffer.Length); 55writer.Advance(value.Length); 65int maxByteCount = Encoding.UTF8.GetMaxByteCount(value.Length);
ServerSentEvents\SseFormatter.cs (1)
156if (data[i++] == '\r' && i < data.Length && data[i] == '\n')
ServerSentEvents\SseParser_1.cs (7)
125while (FillLineBuffer() != 0 && _lineLength < Utf8Bom.Length); 205while (await FillLineBufferAsync(cancellationToken).ConfigureAwait(false) != 0 && _lineLength < Utf8Bom.Length) ; 392ReadOnlySpan<byte> remainder = _lineBuffer.AsSpan(_newlineIndex + newlineLength, _lineLength - line.Length - newlineLength); 394(remainder[0] is LF || (remainder[0] is CR && remainder.Length > 1))) 396advance = line.Length + newlineLength + (remainder.StartsWith(CRLF) ? 2 : 1); 420_dataLength += fieldValue.Length; 462advance = line.Length + GetNewLineLength();
System.Collections (3)
src\libraries\Common\src\System\Collections\Generic\BitHelper.cs (1)
45bitArrayIndex < (uint)span.Length &&
System\Collections\Generic\PriorityQueue.cs (2)
892for (int i = 0; i < nodes.Length; i++) 902for (int i = 0; i < nodes.Length; i++)
System.Collections.Immutable (45)
System\Collections\Frozen\FrozenDictionary.cs (1)
54Dictionary<TKey, TValue> d = new(source.Length, comparer);
System\Collections\Frozen\FrozenHashTable.cs (9)
148Debug.Assert(hashCodes.Length != 0); 149Debug.Assert(!hashCodesAreUnique || new HashSet<int>(hashCodes.ToArray()).Count == hashCodes.Length); 158int uniqueCodesCount = hashCodes.Length; 163new HashSet<int>(hashCodes.Length); 184while ((uint)minPrimeIndexInclusive < (uint)primes.Length && minNumBuckets > primes[minPrimeIndexInclusive]) 189if (minPrimeIndexInclusive >= primes.Length) 202while ((uint)maxPrimeIndexExclusive < (uint)primes.Length && maxNumBuckets > primes[maxPrimeIndexExclusive]) 207if (maxPrimeIndexExclusive < primes.Length) 232if (codes is not null && uniqueCodesCount != hashCodes.Length)
System\Collections\Frozen\FrozenSet.cs (2)
31if (source.Length == 0) 40new(source.Length, equalityComparer); // we assume there are few-to-no duplicates when using this API
System\Collections\Frozen\String\Hashing.cs (2)
24int length = s.Length; 88int length = s.Length;
System\Collections\Frozen\String\KeyAnalyzer.cs (2)
54int acceptableNonUniqueCount = uniqueStrings.Length / 20; 68uniqueStrings.Length,
System\Collections\Frozen\String\LengthBucketsFrozenDictionary.AlternateLookup.cs (1)
32int bucketIndex = (key.Length - _minLength) * LengthBuckets.MaxPerLength;
System\Collections\Frozen\String\LengthBucketsFrozenSet.AlternateLookup.cs (1)
32int bucketIndex = (item.Length - _minLength) * LengthBuckets.MaxPerLength;
System\Collections\Frozen\String\OrdinalStringFrozenDictionary.AlternateLookup.cs (2)
36if ((uint)(key.Length - _minimumLength) <= (uint)_maximumLengthDiff) 38if (CheckLengthQuick((uint)key.Length))
System\Collections\Frozen\String\OrdinalStringFrozenDictionary_RightJustifiedCaseInsensitiveAsciiSubstring.cs (1)
28private protected override int GetHashCode(ReadOnlySpan<char> s) => Hashing.GetHashCodeOrdinalIgnoreCaseAscii(s.Slice(s.Length + HashIndex, HashCount));
System\Collections\Frozen\String\OrdinalStringFrozenDictionary_RightJustifiedCaseInsensitiveSubstring.cs (1)
28private protected override int GetHashCode(ReadOnlySpan<char> s) => Hashing.GetHashCodeOrdinalIgnoreCase(s.Slice(s.Length + HashIndex, HashCount));
System\Collections\Frozen\String\OrdinalStringFrozenDictionary_RightJustifiedSingleChar.cs (1)
27private protected override int GetHashCode(ReadOnlySpan<char> s) => s[s.Length + HashIndex];
System\Collections\Frozen\String\OrdinalStringFrozenDictionary_RightJustifiedSubstring.cs (1)
28private protected override int GetHashCode(ReadOnlySpan<char> s) => Hashing.GetHashCodeOrdinal(s.Slice(s.Length + HashIndex, HashCount));
System\Collections\Frozen\String\OrdinalStringFrozenSet.AlternateLookup.cs (2)
36if ((uint)(item.Length - _minimumLength) <= (uint)_maximumLengthDiff) 38if (CheckLengthQuick((uint)item.Length))
System\Collections\Frozen\String\OrdinalStringFrozenSet_RightJustifiedCaseInsensitiveAsciiSubstring.cs (1)
27private protected override int GetHashCode(ReadOnlySpan<char> s) => Hashing.GetHashCodeOrdinalIgnoreCaseAscii(s.Slice(s.Length + HashIndex, HashCount));
System\Collections\Frozen\String\OrdinalStringFrozenSet_RightJustifiedCaseInsensitiveSubstring.cs (1)
27private protected override int GetHashCode(ReadOnlySpan<char> s) => Hashing.GetHashCodeOrdinalIgnoreCase(s.Slice(s.Length + HashIndex, HashCount));
System\Collections\Frozen\String\OrdinalStringFrozenSet_RightJustifiedSingleChar.cs (1)
24private protected override int GetHashCode(ReadOnlySpan<char> s) => s[s.Length + HashIndex];
System\Collections\Frozen\String\OrdinalStringFrozenSet_RightJustifiedSubstring.cs (1)
25private protected override int GetHashCode(ReadOnlySpan<char> s) => Hashing.GetHashCodeOrdinal(s.Slice(s.Length + HashIndex, HashCount));
System\Collections\Immutable\ImmutableArray_1.Builder.cs (5)
436this.Count += items.Length; 438items.CopyTo(new Span<T>(_elements, offset, items.Length)); 449this.Count += items.Length; 451var elements = new Span<T>(_elements, offset, items.Length); 452for (int i = 0; i < items.Length; i++)
System\Collections\Immutable\ImmutableArray_1.cs (4)
990if (items.Length == 1) 1514var tmp = new T[Length + items.Length]; 1519items.CopyTo(new Span<T>(tmp, index, items.Length)); 1522Array.Copy(array!, index, tmp, index + items.Length, Length - index);
System\Collections\Immutable\ImmutableList_1.Node.cs (2)
273int rightCount = (items.Length - 1) / 2; 274int leftCount = (items.Length - 1) - rightCount;
System\Collections\Immutable\ImmutableQueue.cs (1)
95for (int i = items.Length - 1; i >= 0; i--)
System\Collections\Immutable\ImmutableSortedSet_1.cs (3)
332if (this.IsEmpty || (this.Count + other.Length) * RefillOverIncrementalThreshold > this.Count) 1184list = new List<T>(addedItems.Length); 1191list = new List<T>(this.Count + addedItems.Length);
System.Collections.Specialized (1)
System\Collections\Specialized\BitVector32.cs (1)
169dst = dst.Slice(prefix.Length, 32);
System.ComponentModel.Annotations (1)
System\ComponentModel\DataAnnotations\PhoneAttribute.cs (1)
110if (potentialExtension.Length == 0)
System.ComponentModel.TypeConverter (4)
System\Drawing\PointConverter.cs (1)
30if (text.Length == 0)
System\Drawing\RectangleConverter.cs (1)
30if (text.Length == 0)
System\Drawing\SizeConverter.cs (1)
30if (text.Length == 0)
System\Drawing\SizeFConverter.cs (1)
30if (text.Length == 0)
System.Data.Common (12)
System\Data\Filter\Operators.cs (1)
142return (uint)op < (uint)priorities.Length ? priorities[op] : PriMax;
System\Data\SQLTypes\SQLBytes.cs (7)
331return span.Length; 352if (buffer.Length > _rgbBuf.Length - offset) 420if (buffer.Length != 0) 422Span<byte> span = _rgbBuf.AsSpan((int)offset, buffer.Length); 427if (_lCurLen < offset + buffer.Length) 428_lCurLen = offset + buffer.Length; 763_lPosition += buffer.Length;
System\Data\SQLTypes\SQLDecimal.cs (4)
786Debug.Assert(rglData.Length >= 4); 2464Debug.Assert(rgulS.Length >= ciulS, "rgulS.Length >= ciulS", "Invalid array length"); 2605Debug.Assert(rgulU.Length == s_cNumeMax); 3025Debug.Assert(rguiData.Length == 4);
System.Diagnostics.DiagnosticSource (41)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
System\Diagnostics\Activity.cs (8)
1901if (idData.Length != 16) 1914if (idData.Length != 32 || !ActivityTraceId.IsLowerCaseHexAndNotAllZeros(idData)) 1962if (idData.Length != 32) 2025Debug.Assert(outBytes.Length * 2 == charData.Length); 2046for (; i < idData.Length; i++) 2094if (idData.Length != 8) 2107if (idData.Length != 16 || !ActivityTraceId.IsLowerCaseHexAndNotAllZeros(idData)) 2152if (idData.Length != 16)
System\Diagnostics\DsesFilterAndTransform.cs (3)
239if (suffixPart.Length > 0) 303if (eventName.Length > 0) 334if (activityName.Length > 0 && activitySourceName.Length == 1 && activitySourceName[0] == '*')
System\Diagnostics\Metrics\AggregatorStore.cs (5)
336int expectedLabels = labels.Length; 343if (l.Length != expectedLabels) 398LabelInstruction[] valueFetches = new LabelInstruction[labels.Length]; 399for (int i = 0; i < labels.Length; i++) 438if (labels.Length != _expectedLabelCount)
System\Diagnostics\Metrics\RuntimeMetrics.cs (1)
21private static readonly int s_maxGenerations = Math.Min(GC.GetGCMemoryInfo().GenerationInfo.Length, s_genNames.Length);
System\Diagnostics\Metrics\TagList.netcore.cs (3)
40_tagsCount = tagList.Length; 280for (int i = 0; i < tags.Length; i++) 290for (int i = 0; i < tags.Length; i++)
System\Diagnostics\W3CPropagator.cs (12)
103if (keyValueSeparator <= 0 || keyValueSeparator >= currentEntry.Length - 1) 118} while (baggageSpan.Length > 0); 152int delta = entry.Length + (commaIndex >= 0 ? 1 : 0); // +1 for the comma 160if (equalIndex <= 0 || equalIndex >= entry.Length - 1) 267for (int i = 0; i < valueSpan.Length; i++) 296if (i + 5 >= valueSpan.Length || valueSpan[i + 3] != Percent || !TryDecodeEscapedByte(valueSpan.Slice(i + 3), out byte b1) || (b1 & 0xC0) != 0x80) 312if (i + 8 >= valueSpan.Length || 333if (i + 11 >= valueSpan.Length || 378Debug.Assert(span.Length > 0 && span[0] == Percent); 380if (span.Length < 3 || !TryDecodeHexDigit(span[1], out byte byte1) || !TryDecodeHexDigit(span[2], out byte byte2)) 523for (int i = 0; i < value.Length; i++) 549if (i < value.Length - 1 && char.IsSurrogatePair((char)c, value[i + 1]))
System.Drawing.Common (78)
System\Drawing\Drawing2D\GraphicsPath.cs (22)
43if (pts.Length != types.Length) 52PInvokeGdiPlus.GdipCreatePath2((GdiPlus.PointF*)p, t, types.Length, (GdiPlus.FillMode)fillMode, &path).ThrowIfFailed(); 79if (pts.Length != types.Length) 88PInvokeGdiPlus.GdipCreatePath2I((GdiPlus.Point*)p, t, types.Length, (GdiPlus.FillMode)fillMode, &path).ThrowIfFailed(); 334if (points.Length == 0) 341PInvokeGdiPlus.GdipAddPathLine2(_nativePath, (GdiPlus.PointF*)p, points.Length).ThrowIfFailed(); 361if (points.Length == 0) 368PInvokeGdiPlus.GdipAddPathLine2I(_nativePath, (GdiPlus.Point*)p, points.Length).ThrowIfFailed(); 413PInvokeGdiPlus.GdipAddPathBeziers(_nativePath, (GdiPlus.PointF*)p, points.Length).ThrowIfFailed(); 435if (points.Length == 0) 440PInvokeGdiPlus.GdipAddPathBeziersI(_nativePath, (GdiPlus.Point*)p, points.Length).ThrowIfFailed(); 499points.Length, 547points.Length, 575PInvokeGdiPlus.GdipAddPathClosedCurve2(_nativePath, (GdiPlus.PointF*)p, points.Length, tension).ThrowIfFailed(); 605PInvokeGdiPlus.GdipAddPathClosedCurve2I(_nativePath, (GdiPlus.Point*)p, points.Length, tension).ThrowIfFailed(); 634PInvokeGdiPlus.GdipAddPathRectangles(_nativePath, (RectF*)r, rects.Length).ThrowIfFailed(); 654PInvokeGdiPlus.GdipAddPathRectanglesI(_nativePath, (Rect*)r, rects.Length).ThrowIfFailed(); 743PInvokeGdiPlus.GdipAddPathPolygon(_nativePath, (GdiPlus.PointF*)p, points.Length).ThrowIfFailed(); 764PInvokeGdiPlus.GdipAddPathPolygonI(_nativePath, (GdiPlus.Point*)p, points.Length).ThrowIfFailed(); 915destPoints.Length,
System\Drawing\Drawing2D\Matrix.cs (4)
277pts.Length).ThrowIfFailed(); 306pts.Length).ThrowIfFailed(); 335pts.Length).ThrowIfFailed(); 369pts.Length).ThrowIfFailed();
System\Drawing\Drawing2D\PathGradientBrush.cs (4)
40if (points.Length < 2) 48points.Length, 81if (points.Length < 2) 89points.Length,
System\Drawing\Font.cs (1)
502if (name.Length > 1 && name[0] == '@')
System\Drawing\FontFamily.cs (1)
95Debug.Assert(n is null || n[name.Length] == '\0', "Expected null-terminated string.");
System\Drawing\Graphics.cs (31)
770CheckErrorStatus(PInvokeGdiPlus.GdipDrawRectangles(NativeGraphics, pen.NativePen, (RectF*)r, rects.Length)); 795CheckErrorStatus(PInvokeGdiPlus.GdipDrawRectanglesI(NativeGraphics, pen.NativePen, (Rect*)r, rects.Length)); 869CheckErrorStatus(PInvokeGdiPlus.GdipDrawPolygon(NativeGraphics, pen.NativePen, (GdiPlus.PointF*)p, points.Length)); 894CheckErrorStatus(PInvokeGdiPlus.GdipDrawPolygonI(NativeGraphics, pen.NativePen, (GdiPlus.Point*)p, points.Length)); 929CheckErrorStatus(PInvokeGdiPlus.GdipDrawCurve(NativeGraphics, pen.NativePen, (GdiPlus.PointF*)p, points.Length)); 954(GdiPlus.PointF*)p, points.Length, 990(GdiPlus.PointF*)p, points.Length, 1014CheckErrorStatus(PInvokeGdiPlus.GdipDrawCurveI(NativeGraphics, pen.NativePen, (GdiPlus.Point*)p, points.Length)); 1039(GdiPlus.Point*)p, points.Length, 1072(GdiPlus.Point*)p, points.Length, 1100(GdiPlus.PointF*)p, points.Length)); 1131(GdiPlus.PointF*)p, points.Length, 1156(GdiPlus.Point*)p, points.Length)); 1182(GdiPlus.Point*)p, points.Length, 1266CheckErrorStatus(PInvokeGdiPlus.GdipFillRectangles(NativeGraphics, brush.NativeBrush, (RectF*)r, rects.Length)); 1288CheckErrorStatus(PInvokeGdiPlus.GdipFillRectanglesI(NativeGraphics, brush.NativeBrush, (Rect*)r, rects.Length)); 1321(GdiPlus.PointF*)p, points.Length, 1360(GdiPlus.Point*)p, points.Length, 1463(GdiPlus.PointF*)p, points.Length)); 1504(GdiPlus.PointF*)p, points.Length, 1531(GdiPlus.Point*)p, points.Length)); 1567(GdiPlus.Point*)p, points.Length, 1749c, s.Length, 1811text.Length, 1979text.Length, 2377CheckErrorStatus(PInvokeGdiPlus.GdipDrawLines(NativeGraphics, pen.NativePen, (GdiPlus.PointF*)p, points.Length)); 2424CheckErrorStatus(PInvokeGdiPlus.GdipDrawLinesI(NativeGraphics, pen.NativePen, (GdiPlus.Point*)p, points.Length)); 2606pts.Length)); 2632pts.Length)); 2807(GdiPlus.PointF*)p, points.Length)); 2839points.Length));
System\Drawing\Icon.cs (2)
551_handle = PInvoke.CreateIconFromResourceEx(b, (uint)bestImage.Length, fIcon: true, 0x00030000, 0, 0, 0); 558_handle = PInvoke.CreateIconFromResourceEx(b, (uint)bestImage.Length, fIcon: true, 0x00030000, 0, 0, 0);
System\Drawing\Imaging\ColorMatrix.cs (1)
340ArgumentOutOfRangeException.ThrowIfNotEqual(newColorMatrix.Length, 25, nameof(newColorMatrix));
System\Drawing\Imaging\Effects\ColorLookupTableEffect.cs (4)
41ArgumentOutOfRangeException.ThrowIfGreaterThan(redLookupTable.Length, 256, nameof(redLookupTable)); 42ArgumentOutOfRangeException.ThrowIfGreaterThan(greenLookupTable.Length, 256, nameof(greenLookupTable)); 43ArgumentOutOfRangeException.ThrowIfGreaterThan(blueLookupTable.Length, 256, nameof(blueLookupTable)); 44ArgumentOutOfRangeException.ThrowIfGreaterThan(alphaLookupTable.Length, 256, nameof(alphaLookupTable));
System\Drawing\Imaging\ImageAttributes.cs (6)
361using BufferScope<(ARGB, ARGB)> buffer = new(stackBuffer, map.Length); 363for (int i = 0; i < map.Length; i++) 374(uint)map.Length, 386using BufferScope<(ARGB, ARGB)> buffer = new(stackBuffer, map.Length); 388for (int i = 0; i < map.Length; i++) 399(uint)map.Length,
System\Drawing\Imaging\ImageCodecInfo.cs (2)
83ImageCodecInfo[] codecs = new ImageCodecInfo[codecInfo.Length]; 85for (int i = 0; i < codecInfo.Length; i++)
System.Drawing.Primitives (3)
System\Drawing\KnownColorTable.cs (3)
478Debug.Assert(ColorValueTable.Length == ColorKindTable.Length); 481for (int index = 1; index < colorValueTable.Length; ++index)
System.Formats.Asn1 (127)
System\Formats\Asn1\Asn1Tag.cs (1)
184if (source.Length <= bytesConsumed)
System\Formats\Asn1\AsnCharacterStringEncodings.cs (11)
47return encoding.GetByteCount(strPtr, str.Length); 71return encoding.GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length); 261for (int i = 0; i < chars.Length; i++) 279return chars.Length; 289for (int i = 0; i < bytes.Length; i++) 309return bytes.Length; 330for (int i = 0; i < chars.Length; i++) 363if (bytes.Length % 2 != 0) 366bytes.Slice(bytes.Length - 1).ToArray(), 367bytes.Length - 1); 375for (int i = 0; i < bytes.Length; i += 2)
System\Formats\Asn1\AsnDecoder.BitString.cs (17)
82if (localValue.Length == 0 || normalizedLastByte == localValue[localValue.Length - 1]) 189if (value.Length > destination.Length) 199bytesWritten = value.Length; 295if (localValue.Length > 0) 340if (ruleSet == AsnEncodingRules.CER && source.Length > MaxCERSegmentSize) 346if (source.Length == 0) 359if (source.Length == 1) 378byte lastByte = source[source.Length - 1]; 404if (value.Length == 0) 411destination[value.Length - 1] = normalizedLastByte; 502int localLen = headerLength + encodedValue.Length; 506totalLength += contents.Length; 507lastSegmentLength = encodedValue.Length; 512curDest = curDest.Slice(contents.Length); 552readerStack.Push((curOffset, cur.Length, isIndefinite, bytesRead)); 672bytesConsumed = headerLength + encodedValue.Length;
System\Formats\Asn1\AsnDecoder.Boolean.cs (1)
59if (contents.Length != 1)
System\Formats\Asn1\AsnDecoder.cs (10)
205bytesConsumed = headerLength + ret.Length; 374if (lengthLength + 1 > source.Length) 513if (totalLength > source.Length) 611cur = cur.Slice(tlv.Length); 612totalLen += tlv.Length; 631consumed == data.Length) 641int len = Math.Min(longestPermitted, source.Length); 649if (length < 0 || source.Length - offset < length) 668if (lengthVal < 0 || source.Length - offset < lengthVal) 685return bigger.Slice(offset, smaller.Length);
System\Formats\Asn1\AsnDecoder.GeneralizedTime.cs (6)
74CryptoPool.Return(rented, contents.Length); 117if (strict && contentOctets.Length < 15) 122else if (contentOctets.Length < 10) 165while (state == HmsState && contents.Length != 0) 251if (contents.Length != 0) 303if (contents.Length != 0)
System\Formats\Asn1\AsnDecoder.Integer.cs (5)
443if (contents.Length > sizeLimit) 453for (int i = 0; i < contents.Length; i++) 492if (contents.Length > 1 && contents[0] == 0) 497if (contents.Length > sizeLimit) 506for (int i = 0; i < contents.Length; i++)
System\Formats\Asn1\AsnDecoder.NamedBitList.cs (2)
368Debug.Assert(valueSpan.Length <= sizeof(long)); 373for (int byteIdx = 0; byteIdx < valueSpan.Length; byteIdx++)
System\Formats\Asn1\AsnDecoder.Null.cs (1)
56if (contents.Length != 0)
System\Formats\Asn1\AsnDecoder.OctetString.cs (10)
86if (contents.Length > destination.Length) 94bytesWritten = contents.Length; 177CryptoPool.Return(rented, contents.Length); 214if (ruleSet == AsnEncodingRules.CER && encodedValue.Length > MaxCERSegmentSize) 220bytesConsumed = headerLength + encodedValue.Length; 361int localLen = headerLength + contents.Length; 365totalLength += contents.Length; 366lastSegmentLength = contents.Length; 377curDest = curDest.Slice(contents.Length); 417readerStack.Push((curOffset, cur.Length, isIndefinite, bytesRead));
System\Formats\Asn1\AsnDecoder.Oid.cs (4)
85Debug.Assert(source.Length > 0); 127for (idx = 0; idx < source.Length; idx++) 234if (contents.Length < 1) 250StringBuilder builder = new StringBuilder(((byte)contents.Length) * 4);
System\Formats\Asn1\AsnDecoder.Sequence.cs (1)
78if (length.Value > source.Length - headerLength)
System\Formats\Asn1\AsnDecoder.SetOf.cs (2)
125contentLength = contents.Length; 126bytesConsumed = headerLength + contents.Length + suffix;
System\Formats\Asn1\AsnDecoder.Text.cs (6)
354if (contents.Length > destination.Length) 362bytesWritten = contents.Length; 449if (contents.Length == 0) 461str = encoding.GetString(bytePtr, contents.Length); 473CryptoPool.Return(rented, contents.Length); 509CryptoPool.Return(rented, contents.Length);
System\Formats\Asn1\AsnDecoder.UtcTime.cs (12)
99Debug.Fail($"UtcTime did not fit in tmpSpace ({contents.Length} total)"); 100CryptoPool.Return(rented, contents.Length); 134if (contentOctets.Length != HasSecondsZulu) 142if (contentOctets.Length < NoSecondsZulu || 143contentOctets.Length > HasSecondsOffset || 144(contentOctets.Length & 1) != 1) 161if (contentOctets.Length == HasSecondsOffset || 162contentOctets.Length == HasSecondsZulu) 167if (contentOctets.Length == NoSecondsZulu || 168contentOctets.Length == HasSecondsZulu) 178contentOctets.Length == NoSecondsOffset || 179contentOctets.Length == HasSecondsOffset);
System\Formats\Asn1\AsnWriter.BitString.cs (10)
57if (bitString.Length == 0 && unusedBitCount != 0) 62byte lastByte = bitString.IsEmpty ? (byte)0 : bitString[bitString.Length - 1]; 80if (bitString.Length >= AsnReader.MaxCERSegmentSize) 90WriteLength(bitString.Length + 1); 94_offset += bitString.Length; 147Debug.Assert(payload.Length > MaxCERContentSize); 149int expectedSize = DetermineCerBitStringTotalLength(tag, payload.Length); 164while (remainingData.Length > MaxCERContentSize) 181WriteLength(remainingData.Length + 1); 188_offset += remainingData.Length;
System\Formats\Asn1\AsnWriter.cs (3)
581if (!read || consumed != value.Length) 588EnsureWriteCapacity(value.Length); 590_offset += value.Length;
System\Formats\Asn1\AsnWriter.Integer.cs (6)
227if (value.Length > 1 && value[0] == 0 && value[1] < 0x80) 237WriteLength(checked(value.Length + 1)); 243WriteLength(value.Length); 247_offset += value.Length; 272WriteLength(value.Length); 275_offset += value.Length;
System\Formats\Asn1\AsnWriter.OctetString.cs (8)
88if (octetString.Length > AsnReader.MaxCERSegmentSize) 97WriteLength(octetString.Length); 99_offset += octetString.Length; 106Debug.Assert(payload.Length > MaxCERSegmentSize); 111int fullSegments = Math.DivRem(payload.Length, MaxCERSegmentSize, out int lastSegmentSize); 144while (remainingData.Length > MaxCERSegmentSize) 158WriteLength(remainingData.Length); 161_offset += remainingData.Length;
System\Formats\Asn1\AsnWriter.Oid.cs (7)
65WriteLength(wellKnownContents.Length); 67_offset += wellKnownContents.Length; 81if (oidValue.Length < 3) 89byte[] tmp = CryptoPool.Rent(oidValue.Length / 2); 153endIndex = oidValue.Length; 155else if (endIndex == 0 || endIndex == oidValue.Length - 1) 173oidValue = oidValue.Slice(Math.Min(oidValue.Length, endIndex + 1));
System\Formats\Asn1\SetOfValueComparer.cs (4)
17int min = Math.Min(x.Length, y.Length); 51diff = x.Length - y.Length;
System.Formats.Cbor (24)
System\Formats\Cbor\CborConformanceLevel.cs (8)
242if (left.Length != right.Length) 244return left.Length - right.Length; 261if (left.Length != right.Length) 263return left.Length - right.Length;
System\Formats\Cbor\Reader\CborReader.cs (1)
283if (buffer.Length < requiredLength)
System\Formats\Cbor\Reader\CborReader.Integer.cs (1)
148if (length > (ulong)(data.Length - bytesRead))
System\Formats\Cbor\Reader\CborReader.Map.cs (1)
52if (2 * (ulong)mapSize > (ulong)(buffer.Length - bytesRead))
System\Formats\Cbor\Writer\CborWriter.cs (7)
134EnsureWriteCapacity(encodedValue.Length); 148_offset += encodedValue.Length; 157using var manager = new PointerMemoryManager<byte>(ptr, encodedValue.Length); 192if (encoding.Length > destination.Length) 198return encoding.Length; 210if (encoding.Length > destination.Length) 217bytesWritten = encoding.Length;
System\Formats\Cbor\Writer\CborWriter.Map.cs (1)
169s = s.Slice(keyValuePairEncoding.Length);
System\Formats\Cbor\Writer\CborWriter.String.cs (5)
41WriteUnsignedInteger(CborMajorType.ByteString, (ulong)value.Length); 42EnsureWriteCapacity(value.Length); 50_currentIndefiniteLengthStringRanges.Add((_offset, value.Length)); 54_offset += value.Length; 144_currentIndefiniteLengthStringRanges.Add((_offset, value.Length));
System.Formats.Nrbf (3)
System\Formats\Nrbf\NrbfDecoder.cs (3)
42=> bytes.Length >= SerializedStreamHeaderRecord.Size 44&& bytes.Slice(SerializedStreamHeaderRecord.Size - HeaderSuffix.Length, HeaderSuffix.Length).SequenceEqual(HeaderSuffix);
System.Formats.Tar (29)
src\libraries\Common\src\System\IO\Archiving.Utils.Unix.cs (1)
18nonSlash = path.Length;
src\libraries\Common\src\System\IO\PathInternal.cs (11)
16internal static bool StartsWithDirectorySeparator(ReadOnlySpan<char> path) => path.Length > 0 && IsDirectorySeparator(path[0]); 22=> path.Length == GetRootLength(path); 142for (int i = skip; i < path.Length; i++) 146if (IsDirectorySeparator(c) && i + 1 < path.Length) 157if ((i + 2 == path.Length || IsDirectorySeparator(path[i + 2])) && 166if (i + 2 < path.Length && 167(i + 3 == path.Length || IsDirectorySeparator(path[i + 3])) && 176sb.Length = (i + 3 >= path.Length && s == skip) ? s + 1 : s; // to avoid removing the complete "\tmp\" segment in cases like \\?\C:\tmp\..\, C:\tmp\.. 201if (!flippedSeparator && sb.Length == path.Length) 235path.Slice(0, path.Length - 1) : 242path.Length > 0 && IsDirectorySeparator(path[^1]);
src\libraries\Common\src\System\IO\PathInternal.Unix.cs (1)
24return path.Length > 0 && IsDirectorySeparator(path[0]) ? 1 : 0;
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
System\Formats\Tar\TarHeader.Write.cs (10)
596if (pathNameBytes.Length <= FieldLengths.Name) 618while (prefix.Length - name.Length > FieldLengths.Prefix) 630if (prefix.Length <= FieldLengths.Prefix && name.Length <= FieldLengths.Name) 632Debug.Assert(prefix.Length != 1 || !PathInternal.Utf8DirectorySeparators.Contains(prefix[0])); 1062int numToCopy = Math.Min(bytesToWrite.Length, destination.Length); 1079int numToCopy = Math.Min(bytesToWrite.Length, destination.Length - 1); 1081int copyPos = destination.Length - 1 - bytesToWrite.Length; 1221string.Concat("/tmp", result.AsSpan(tmp.Length)) :
System\Formats\Tar\TarHelpers.cs (3)
246if (buffer.Length == 0) 281int trimmedLength = buffer.Length; 293while (newStart < buffer.Length && buffer[newStart] is 0 or 32)
System.IO.Compression.ZipFile (1)
src\libraries\Common\src\System\IO\Archiving.Utils.Unix.cs (1)
18nonSlash = path.Length;
System.IO.FileSystem.Watcher (16)
src\libraries\Common\src\System\IO\PathInternal.cs (11)
16internal static bool StartsWithDirectorySeparator(ReadOnlySpan<char> path) => path.Length > 0 && IsDirectorySeparator(path[0]); 22=> path.Length == GetRootLength(path); 142for (int i = skip; i < path.Length; i++) 146if (IsDirectorySeparator(c) && i + 1 < path.Length) 157if ((i + 2 == path.Length || IsDirectorySeparator(path[i + 2])) && 166if (i + 2 < path.Length && 167(i + 3 == path.Length || IsDirectorySeparator(path[i + 3])) && 176sb.Length = (i + 3 >= path.Length && s == skip) ? s + 1 : s; // to avoid removing the complete "\tmp\" segment in cases like \\?\C:\tmp\..\, C:\tmp\.. 201if (!flippedSeparator && sb.Length == path.Length) 235path.Slice(0, path.Length - 1) : 242path.Length > 0 && IsDirectorySeparator(path[^1]);
src\libraries\Common\src\System\IO\PathInternal.Unix.cs (1)
24return path.Length > 0 && IsDirectorySeparator(path[0]) ? 1 : 0;
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
System\IO\FileSystemWatcher.cs (1)
377if (name.Length == 0)
System.IO.Hashing (47)
System\IO\Hashing\Crc32.Arm.cs (6)
18if (source.Length >= sizeof(ulong)) 21int longLength = source.Length & ~0x7; // Exclude trailing bytes not a multiple of 8 33for (int i = 0; i < source.Length; i++) 46if (source.Length >= sizeof(uint)) 49int intLength = source.Length & ~0x3; // Exclude trailing bytes not a multiple of 4 61for (int i = 0; i < source.Length; i++)
System\IO\Hashing\Crc32.cs (1)
206for (int i = 0; i < source.Length; i++)
System\IO\Hashing\Crc32.Vectorized.cs (2)
23&& source.Length >= Vector128<byte>.Count * (System.Runtime.Intrinsics.Arm.Crc32.IsSupported ? 8 : 1); 39int length = source.Length;
System\IO\Hashing\Crc64.cs (1)
190for (int i = 0; i < source.Length; i++)
System\IO\Hashing\Crc64.Vectorized.cs (2)
37private static bool CanBeVectorized(ReadOnlySpan<byte> source) => VectorHelper.IsSupported && source.Length >= Vector128<byte>.Count; 53int length = source.Length;
System\IO\Hashing\XxHash128.cs (1)
131uint length = (uint)source.Length;
System\IO\Hashing\XxHash3.cs (1)
129uint length = (uint)source.Length;
System\IO\Hashing\XxHash32.cs (7)
97if (source.Length >= remain) 108_length += source.Length; 113while (source.Length >= StripeSize) 120if (source.Length > 0) 124_length += source.Length; 254int totalLength = source.Length; 257while (source.Length >= StripeSize)
System\IO\Hashing\XxHash32.State.cs (3)
39Debug.Assert(source.Length >= StripeSize); 75while (remaining.Length >= sizeof(uint)) 85for (int i = 0; i < remaining.Length; i++)
System\IO\Hashing\XxHash64.cs (7)
97if (source.Length >= remain) 108_length += source.Length; 113while (source.Length >= StripeSize) 120if (source.Length > 0) 124_length += source.Length; 254int totalLength = source.Length; 257while (source.Length >= StripeSize)
System\IO\Hashing\XxHash64.State.cs (4)
50Debug.Assert(source.Length >= StripeSize); 110while (remaining.Length >= sizeof(ulong)) 122if (remaining.Length >= sizeof(uint)) 133for (int i = 0; i < remaining.Length; i++)
System\IO\Hashing\XxHashShared.cs (12)
244state.TotalLength += (uint)source.Length; 249if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 251source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 252state.BufferedCount += (uint)source.Length; 272Debug.Assert(sourceIndex < source.Length); 275if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 277ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 301Debug.Assert(sourceIndex < source.Length); // at least some bytes left 307else if (source.Length - sourceIndex > InternalBufferLengthBytes) 315while (source.Length - sourceIndex > InternalBufferLengthBytes); 322Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 323Debug.Assert(sourceIndex < source.Length);
System.IO.Packaging (9)
System\IO\Packaging\ContentType.cs (4)
315if (parameterAndValue.Length == 1) 327if (equalSignIndex <= 0 || equalSignIndex == (parameterAndValue.Length - 1)) 370length = s.Length; 460for (int i = 0; i < quotedText.Length; i++)
System\IO\Packaging\InterleavedZipPackagePartStream.cs (5)
309if (buffer.Length == 0) 331while (totalBytesWritten < buffer.Length) 334int numBytesToWriteInCurrentPiece = buffer.Length - totalBytesWritten; 364if (!_dir.IsLastPiece(pieceNumber) && totalBytesWritten < buffer.Length) 384Debug.Assert(totalBytesWritten == buffer.Length);
System.IO.Pipelines (2)
System\IO\Pipelines\Pipe.cs (2)
1104int writable = Math.Min(destination.Length, source.Length); 1109if (source.Length == 0)
System.IO.Ports (1)
System\IO\Ports\SerialStream.Unix.cs (1)
818int numBytes = Interop.Serial.Write(_handle, bufPtr, buff.Length);
System.Linq (43)
System\Linq\Aggregate.cs (1)
31for (int i = 1; i < span.Length; i++)
System\Linq\Average.cs (5)
32if (Vector.IsHardwareAccelerated && span.Length >= Vector<int>.Count) 42while (i <= span.Length - Vector<int>.Count); 46for (; (uint)i < (uint)span.Length; i++) 51return (double)sum / span.Length; 101return TResult.CreateChecked(Sum<TSource, TAccumulator>(span)) / TResult.CreateChecked(span.Length);
System\Linq\Max.cs (4)
113for (i = 0; i < span.Length && T.IsNaN(span[i]); i++) ; 115if (i == span.Length) 120for (value = span[i]; (uint)i < (uint)span.Length; i++) 233for (int i = 1; (uint)i < (uint)span.Length; i++)
System\Linq\MaxMin.cs (7)
40if (!Vector128.IsHardwareAccelerated || !Vector128<T>.IsSupported || span.Length < Vector128<T>.Count) 43for (int i = 1; i < span.Length; i++) 51else if (!Vector256.IsHardwareAccelerated || !Vector256<T>.IsSupported || span.Length < Vector256<T>.Count) 54ref T lastVectorStart = ref Unsafe.Add(ref current, span.Length - Vector128<T>.Count); 75else if (!Vector512.IsHardwareAccelerated || !Vector512<T>.IsSupported || span.Length < Vector512<T>.Count) 78ref T lastVectorStart = ref Unsafe.Add(ref current, span.Length - Vector256<T>.Count); 102ref T lastVectorStart = ref Unsafe.Add(ref current, span.Length - Vector512<T>.Count);
System\Linq\Min.cs (2)
95for (int i = 1; (uint)i < (uint)span.Length; i++) 213for (int i = 1; (uint)i < (uint)span.Length; i++)
System\Linq\OrderedEnumerable.SpeedOpt.cs (1)
390if (span.Length != 0)
System\Linq\SegmentedArrayBuilder.cs (8)
85for (int i = 0; i < segments.Length; i++) 145ReadOnlySpan<T> sourceSlice = sourceSpan.Slice(0, Math.Min(availableSpaceInCurrentSpan, sourceSpan.Length)); 147_countInCurrentSegment += sourceSlice.Length; 148sourceSlice = sourceSpan.Slice(sourceSlice.Length); 152Expand(sourceSlice.Length); 154_countInCurrentSegment = sourceSlice.Length; 312destination = destination.Slice(firstSegment.Length); 322destination = destination.Slice(segment.Length);
System\Linq\Select.SpeedOpt.cs (4)
399if (source.Length == 0) 404var results = new TResult[source.Length]; 414var results = new List<TResult>(source.Length); 415Fill(source, SetCountAndGetSpan(results, source.Length), _selector);
System\Linq\Single.cs (2)
120for (int i = 0; i < span.Length; i++) 125for (i++; (uint)i < (uint)span.Length; i++)
System\Linq\SkipTake.SpeedOpt.cs (2)
170if (minInclusive < span.Length) 172return span.Slice(minInclusive, GetAdjustedCount(minInclusive, _maxIndexInclusive, span.Length)).IndexOf(item);
System\Linq\Sum.cs (3)
55&& span.Length >= Vector<T>.Count * 4) 83Debug.Assert(span.Length >= Vector<T>.Count * 4); 88nuint length = (nuint)span.Length;
System\Linq\ToCollection.cs (2)
181Dictionary<TKey, TSource> d = new Dictionary<TKey, TSource>(source.Length, comparer); 239Dictionary<TKey, TElement> d = new Dictionary<TKey, TElement>(source.Length, comparer);
System\Linq\Where.SpeedOpt.cs (2)
344for (int i = source.Length - 1; i >= 0; i--) 492for (int i = source.Length - 1; i >= 0; i--)
System.Memory (58)
System\Buffers\BuffersExtensions.cs (6)
68if (span.Length > destination.Length) 90destination = destination.Slice(span.Length); 121if (value.Length <= destination.Length) 124writer.Advance(value.Length); 137int writeSize = Math.Min(destination.Length, input.Length); 141if (input.Length > 0)
System\Buffers\ReadOnlySequence.Helpers.cs (1)
688return MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<char, T>(ref MemoryMarshal.GetReference(spanOfChar)), spanOfChar.Length);
System\Buffers\SequenceReader.cs (12)
30_moreData = first.Length > 0; 151if ((CurrentSpanIndex + offset) <= CurrentSpan.Length - 1) 160long remainingOffset = offset - (CurrentSpan.Length - CurrentSpanIndex); 204if (CurrentSpanIndex >= CurrentSpan.Length) 317if ((count & TooBigOrNegative) == 0 && CurrentSpan.Length - CurrentSpanIndex > (int)count) 339if (CurrentSpanIndex >= CurrentSpan.Length) 355Debug.Assert(CurrentSpanIndex < CurrentSpan.Length); 368int remaining = CurrentSpan.Length - CurrentSpanIndex; 417if (firstSpan.Length >= destination.Length) 434Debug.Assert(firstSpan.Length < destination.Length); 436int copied = firstSpan.Length; 444int toCopy = Math.Min(nextSpan.Length, destination.Length - copied);
System\Buffers\SequenceReader.Search.cs (33)
35if (!TryReadToInternal(out ReadOnlySequence<T> sequence, delimiter, advancePastDelimiter, CurrentSpan.Length - CurrentSpanIndex)) 148int i = remaining.Length - 2; 155escapeCount += remaining.Length - 2 - i; 168AdvanceCurrentSpan(remaining.Length); 220AdvanceCurrentSpan(remaining.Length); 300for (int i = remaining.Length; i > 0 && remaining[i - 1].Equals(delimiterEscape); i--, escapeCount++) 302if (priorEscape && escapeCount == remaining.Length) 310Advance(remaining.Length); 331int index = delimiters.Length == 2 347if (!TryReadToAnyInternal(out ReadOnlySequence<T> sequence, delimiters, advancePastDelimiter, CurrentSpan.Length - CurrentSpanIndex)) 378int index = delimiters.Length == 2 398Advance(remaining.Length); 423AdvanceCurrentSpan(index + (advancePastDelimiter ? delimiter.Length : 0)); 453if (delimiter.Length == 0) 470if (delimiter.Length == 1) 489Advance(delimiter.Length); 581for (i = CurrentSpanIndex; i < CurrentSpan.Length && CurrentSpan[i].Equals(value); i++) 613for (i = CurrentSpanIndex; i < CurrentSpan.Length && values.IndexOf(CurrentSpan[i]) != -1; i++) 645for (i = CurrentSpanIndex; i < CurrentSpan.Length; i++) 682for (i = CurrentSpanIndex; i < CurrentSpan.Length; i++) 719for (i = CurrentSpanIndex; i < CurrentSpan.Length; i++) 795AdvanceCurrentSpan(next.Length); 801return unread.Length < next.Length && IsNextSlow(next, advancePast); 809Debug.Assert(currentSpan.Length < next.Length); 811int fullLength = next.Length; 816if (next.Length == currentSpan.Length) 837next = next.Slice(currentSpan.Length); 839if (currentSpan.Length > next.Length) 841currentSpan = currentSpan.Slice(0, next.Length);
System\Buffers\SequenceReaderExtensions.Binary.cs (2)
29if (span.Length < sizeof(T)) 39Debug.Assert(reader.UnreadSpan.Length < sizeof(T));
System\Text\EncodingExtensions.cs (4)
39if (chars.Length <= MaxInputElementsPerIteration) 230if (bytes.Length <= MaxInputElementsPerIteration) 432int byteCountForThisSlice = (chars.Length <= MaxInputElementsPerIteration) 525int charCountForThisSlice = (bytes.Length <= MaxInputElementsPerIteration)
System.Memory.Data (3)
src\libraries\Common\src\System\IO\ReadOnlyMemoryStream.cs (1)
89return _position < s.Length ? s[_position++] : -1;
System\BinaryData.cs (2)
430return Encoding.UTF8.GetString(ptr, span.Length); 481if (span.Length > 2 && span[0] == 0xEF && span[1] == 0xBB && span[2] == 0xBF)
System.Net.HttpListener (9)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Net\Logging\NetEventSource.Common.DumpBuffer.cs (1)
35Log.DumpBuffer(IdOf(thisOrContextObject), memberName, buffer.Slice(0, Math.Min(buffer.Length, MaxDumpSize)).ToArray());
System\Net\Managed\HttpListenerRequest.Managed.cs (1)
96if (version.Length != 8 || !version.StartsWith("HTTP/", StringComparison.Ordinal))
System\Net\Managed\HttpListenerResponse.Managed.cs (1)
279int preamble = encoding.Preamble.Length;
System.Net.Mail (31)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
System\Net\Base64Stream.cs (1)
229if (written < buffer.Length)
System\Net\BufferBuilder.cs (2)
46EnsureBuffer(value.Length); 48_offset += value.Length;
System\Net\BufferedReadStream.cs (2)
92if (buffer.Length == 0) 95int count = buffer.Length;
System\Net\Mail\MailBnfHelper.cs (1)
241i = span.Length;
System\Net\Mail\SmtpReplyReaderFactory.cs (2)
86if (buffer.Length == 0) 97byte* end = ptr + buffer.Length;
System\Net\Mime\Base64Encoder.cs (1)
47return LineBreakNeeded(bytes.Length);
System\Net\Mime\ByteEncoder.cs (1)
25for (; cur < buffer.Length; cur++)
System\Net\Mime\EightBitStream.cs (2)
100for (int i = 0; i < buffer.Length; i++) 105if ((buffer[i] == '\r') && ((i + 1) < buffer.Length) && (buffer[i + 1] == '\n'))
System\Net\Mime\QEncodedStream.cs (1)
235if (written < buffer.Length)
System\Net\Mime\QEncoder.cs (2)
49if (bytes.Length == 1 || IsCRLF(bytes)) // preserve same behavior as in EncodeBytes 54int numberOfCharsToAppend = bytes.Length * SizeOfQEncodedChar;
System\Net\Mime\QuotedPrintableStream.cs (4)
207for (; processed < buffer.Length; processed++) 228if (buffer[processed] == '\r' && processed + 1 < buffer.Length && buffer[processed + 1] == '\n') 272(processed + 1 >= buffer.Length)) 349if (written < buffer.Length)
System\Net\Mime\WriteStateInfoBase.cs (3)
82EnsureSpaceInBuffer(bytes.Length); 84_currentLineLength += bytes.Length; 85_currentBufferUsed += bytes.Length;
System.Net.Ping (8)
src\libraries\Common\src\System\Net\IPEndPointExtensions.cs (1)
66if (socketAddressBuffer.Length >= SocketAddress.GetMaximumAddressSize(endPoint.AddressFamily) &&
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (4)
66err = Interop.Sys.GetAddressFamily(rawAddress, buffer.Length, (int*)&family); 94err = Interop.Sys.GetPort(rawAddress, buffer.Length, &port); 118err = Interop.Sys.GetIPv4Address(rawAddress, buffer.Length, &ipAddress); 132err = Interop.Sys.GetIPv6Address(rawAddress, buffer.Length, ipAddress, address.Length, &localScope);
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (1)
26int maxSize = checked(Encoding.UTF8.GetMaxByteCount(value.Length) + 1);
System\Net\NetworkInformation\Ping.RawSocket.cs (2)
486for (int i = 0; i < buffer.Length; i += 2) 490ushort element1 = (i + 1 < buffer.Length)
System.Net.Security (1)
System\Security\Authentication\ExtendedProtection\ServiceNameCollection.cs (1)
225host.Length == hostPortAndDistinguisher.Length ?
System.Net.ServerSentEvents (12)
System\Net\ServerSentEvents\Helpers.cs (4)
35Span<byte> buffer = writer.GetSpan(value.Length); 36Debug.Assert(value.Length <= buffer.Length); 38writer.Advance(value.Length); 48int maxByteCount = Encoding.UTF8.GetMaxByteCount(value.Length);
System\Net\ServerSentEvents\SseFormatter.cs (1)
153if (data[i++] == '\r' && i < data.Length && data[i] == '\n')
System\Net\ServerSentEvents\SseParser_1.cs (7)
109while (FillLineBuffer() != 0 && _lineLength < Utf8Bom.Length) ; 189while (await FillLineBufferAsync(cancellationToken).ConfigureAwait(false) != 0 && _lineLength < Utf8Bom.Length) ; 375ReadOnlySpan<byte> remainder = _lineBuffer.AsSpan(_newlineIndex + newlineLength, _lineLength - line.Length - newlineLength); 377(remainder[0] is LF || (remainder[0] is CR && remainder.Length > 1))) 379advance = line.Length + newlineLength + (remainder.StartsWith(CRLF) ? 2 : 1); 402_dataLength += fieldValue.Length; 444advance = line.Length + GetNewLineLength();
System.Net.WebClient (10)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\IO\ChunkedMemoryStream.cs (2)
50int toCopy = Math.Min(remaining, buffer.Length); 59AppendChunk(buffer.Length);
System\Net\WebClient.cs (2)
1144bomLengthInData = preamble.Length; 1157bomLengthInData = data.AsSpan().StartsWith(preamble) ? preamble.Length : 0;
System.Net.WebHeaderCollection (1)
System\Net\HeaderInfoTable.cs (1)
74equalsPos = lastElement.Length;
System.Net.WebSockets.Client (2)
System\Net\WebSockets\WebSocketHandle.Managed.cs (2)
319if (value.Length > 0) 490Span<byte> bytes = stackalloc byte[24 /* Base64 guid length */ + wsServerGuidBytes.Length];
System.Numerics.Tensors (376)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IAggregationOperator.cs (4)
70nuint remainder = (uint)x.Length; 1176if (x.Length != y.Length) 1189nuint remainder = (uint)x.Length;
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IBinaryOperator.cs (6)
61if (x.Length != y.Length) 66if (x.Length > destination.Length) 83nuint remainder = (uint)x.Length; 1400if (x.Length > destination.Length) 1415nuint remainder = (uint)x.Length;
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IBooleanUnaryOperator.cs (51)
103oneVectorFromEnd = x.Length - Vector512<T>.Count; 119if (i != x.Length && 120TAnyAll.ShouldEarlyExit(TOperator.Invoke(Vector512.LoadUnsafe(ref xRef, (uint)(x.Length - Vector512<T>.Count))))) 131oneVectorFromEnd = x.Length - Vector256<T>.Count; 147if (i != x.Length && 148TAnyAll.ShouldEarlyExit(TOperator.Invoke(Vector256.LoadUnsafe(ref xRef, (uint)(x.Length - Vector256<T>.Count))))) 159oneVectorFromEnd = x.Length - Vector128<T>.Count; 175if (i != x.Length && 176TAnyAll.ShouldEarlyExit(TOperator.Invoke(Vector128.LoadUnsafe(ref xRef, (uint)(x.Length - Vector128<T>.Count))))) 185while (i < x.Length) 205if (x.Length > destination.Length) 237int vectorFromEnd = x.Length - Vector512<T>.Count; 249if (i != x.Length) 251i = x.Length - Vector512<T>.Count; 268int vectorFromEnd = x.Length - Vector256<T>.Count; 280if (i != x.Length) 282i = x.Length - Vector256<T>.Count; 299int vectorFromEnd = x.Length - Vector128<T>.Count; 311if (i != x.Length) 313i = x.Length - Vector128<T>.Count; 328while (i < x.Length) 345int vectorsFromEnd = x.Length - (Vector512<T>.Count * sizeof(T)); 357if (i != x.Length) 359i = x.Length - (Vector512<T>.Count * sizeof(T)); 379int vectorsFromEnd = x.Length - (Vector256<T>.Count * sizeof(T)); 391if (i != x.Length) 393i = x.Length - (Vector256<T>.Count * sizeof(T)); 413int vectorsFromEnd = x.Length - (Vector128<T>.Count * sizeof(T)); 425if (i != x.Length) 427i = x.Length - (Vector128<T>.Count * sizeof(T)); 445while (i < x.Length) 462int vectorsFromEnd = x.Length - (Vector512<T>.Count * sizeof(T)); 474if (i != x.Length) 476i = x.Length - (Vector512<T>.Count * sizeof(T)); 500int vectorsFromEnd = x.Length - (Vector256<T>.Count * sizeof(T)); 512if (i != x.Length) 514i = x.Length - (Vector256<T>.Count * sizeof(T)); 538int vectorsFromEnd = x.Length - (Vector128<T>.Count * sizeof(T)); 550if (i != x.Length) 552i = x.Length - (Vector128<T>.Count * sizeof(T)); 574while (i < x.Length) 591int vectorsFromEnd = x.Length - (Vector512<T>.Count * sizeof(T)); 603if (i != x.Length) 605i = x.Length - (Vector512<T>.Count * sizeof(T)); 639int vectorsFromEnd = x.Length - (Vector256<T>.Count * sizeof(T)); 651if (i != x.Length) 653i = x.Length - (Vector256<T>.Count * sizeof(T)); 687int vectorsFromEnd = x.Length - (Vector128<T>.Count * sizeof(T)); 699if (i != x.Length) 701i = x.Length - (Vector128<T>.Count * sizeof(T)); 731while (i < x.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IStatefulUnaryOperator.cs (2)
34if (x.Length > destination.Length) 49nuint remainder = (uint)x.Length;
System\Numerics\Tensors\netcore\Common\TensorPrimitives.ITernaryOperator.cs (12)
46if (x.Length != y.Length || x.Length != z.Length) 51if (x.Length > destination.Length) 70nuint remainder = (uint)x.Length; 1523if (x.Length != y.Length) 1528if (x.Length > destination.Length) 1545nuint remainder = (uint)x.Length; 3016if (x.Length > destination.Length) 3031nuint remainder = (uint)x.Length;
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryInputBinaryOutput.cs (47)
52if (x.Length > destination1.Length) 57if (x.Length > destination2.Length) 64ValidateOutputSpansNonOverlapping(x.Length, destination1, destination2); 73oneVectorFromEnd = x.Length - Vector512<T>.Count; 88if (i != x.Length) 90i = x.Length - Vector512<T>.Count; 103oneVectorFromEnd = x.Length - Vector256<T>.Count; 118if (i != x.Length) 120i = x.Length - Vector256<T>.Count; 133oneVectorFromEnd = x.Length - Vector128<T>.Count; 148if (i != x.Length) 150i = x.Length - Vector128<T>.Count; 161while (i < x.Length) 179if (x.Length != y.Length) 184if (x.Length > destination1.Length) 189if (x.Length > destination2.Length) 198ValidateOutputSpansNonOverlapping(x.Length, destination1, destination2); 208oneVectorFromEnd = x.Length - Vector512<T>.Count; 223if (i != x.Length) 225Vector512<T> mask = Vector512.Equals(CreateRemainderMaskVector512<T>(x.Length - i), Vector512<T>.Zero); 227i = x.Length - Vector512<T>.Count; 256oneVectorFromEnd = x.Length - Vector256<T>.Count; 271if (i != x.Length) 273Vector256<T> mask = Vector256.Equals(CreateRemainderMaskVector256<T>(x.Length - i), Vector256<T>.Zero); 275i = x.Length - Vector256<T>.Count; 304oneVectorFromEnd = x.Length - Vector128<T>.Count; 319if (i != x.Length) 321Vector128<T> mask = Vector128.Equals(CreateRemainderMaskVector128<T>(x.Length - i), Vector128<T>.Zero); 323i = x.Length - Vector128<T>.Count; 350while (i < x.Length) 368if (x.Length > destination1.Length) 373if (x.Length > destination2.Length) 380ValidateOutputSpansNonOverlapping(x.Length, destination1, destination2); 389oneVectorFromEnd = x.Length - Vector512<T>.Count; 406if (i != x.Length) 408Vector512<T> mask = Vector512.Equals(CreateRemainderMaskVector512<T>(x.Length - i), Vector512<T>.Zero); 410i = x.Length - Vector512<T>.Count; 439oneVectorFromEnd = x.Length - Vector256<T>.Count; 456if (i != x.Length) 458Vector256<T> mask = Vector256.Equals(CreateRemainderMaskVector256<T>(x.Length - i), Vector256<T>.Zero); 460i = x.Length - Vector256<T>.Count; 489oneVectorFromEnd = x.Length - Vector128<T>.Count; 506if (i != x.Length) 508Vector128<T> mask = Vector128.Equals(CreateRemainderMaskVector128<T>(x.Length - i), Vector128<T>.Zero); 510i = x.Length - Vector128<T>.Count; 537while (i < x.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryOneToFourOperator.cs (11)
35if (x.Length > destination.Length) 49oneVectorFromEnd = x.Length - Vector512<TInput>.Count; 66if (i != x.Length) 68i = x.Length - Vector512<TInput>.Count; 86oneVectorFromEnd = x.Length - Vector256<TInput>.Count; 103if (i != x.Length) 105i = x.Length - Vector256<TInput>.Count; 123oneVectorFromEnd = x.Length - Vector128<TInput>.Count; 140if (i != x.Length) 142i = x.Length - Vector128<TInput>.Count; 155while (i < x.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryOneToTwoOperator.cs (11)
35if (x.Length > destination.Length) 49oneVectorFromEnd = x.Length - Vector512<TInput>.Count; 64if (i != x.Length) 66i = x.Length - Vector512<TInput>.Count; 82oneVectorFromEnd = x.Length - Vector256<TInput>.Count; 97if (i != x.Length) 99i = x.Length - Vector256<TInput>.Count; 115oneVectorFromEnd = x.Length - Vector128<TInput>.Count; 130if (i != x.Length) 132i = x.Length - Vector128<TInput>.Count; 143while (i < x.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryOperator.cs (2)
70if (x.Length > destination.Length) 89nuint remainder = (uint)x.Length;
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryTwoToOneOperator.cs (11)
35if (x.Length > destination.Length) 49twoVectorsFromEnd = x.Length - (Vector512<TInput>.Count * 2); 64if (i != x.Length) 66i = x.Length - (Vector512<TInput>.Count * 2); 82twoVectorsFromEnd = x.Length - (Vector256<TInput>.Count * 2); 97if (i != x.Length) 99i = x.Length - (Vector256<TInput>.Count * 2); 115twoVectorsFromEnd = x.Length - (Vector128<TInput>.Count * 2); 130if (i != x.Length) 132i = x.Length - (Vector128<TInput>.Count * 2); 143while (i < x.Length)
System\Numerics\Tensors\netcore\ReadOnlyTensorSpan_1.cs (3)
114_shape = TensorShape.Create(ref reference, span.Length, pinned: false); 144_shape = TensorShape.Create(ref reference, span.Length, lengths, strides, pinned: false); 291public int Rank => Lengths.Length;
System\Numerics\Tensors\netcore\Tensor.cs (35)
129if (tensors.Length < 2) 141for (int i = 1; i < tensors.Length; i++) 168for (int i = 0; i < tensors.Length; i++) 202if (tensors.Length < 2) 210for (int i = 0; i < tensors.Length; i++) 218for (int i = 1; i < tensors.Length; i++) 245for (int i = 0; i < tensors.Length; i++) 266for (int i = 0; i < tensors.Length; i++) 286for (int i = startingAxis; i < lengths.Length; i++) 1364if (!dimensions.IsEmpty && dimensions.Length != tensor.Lengths.Length) 1382for (int i = 0; i < dimensions.Length; i++) 1384if (dimensions[i] >= tensor.Lengths.Length || dimensions[i] < 0) 1428for (int i = 0; i < lengths.Length; i++) 1500for (int i = 0; i < lengths.Length; i++) 1577for (int i = 0; i < lengths.Length; i++) 1642if (newSize >= span.Length) 1682if (ospan.Length >= span.Length) 1901for (int i = 0, index = 0; i < tensor.Lengths.Length; i++) 1968for (int i = 0, index = 0; i < tensor.Lengths.Length; i++) 2035for (int i = 0, index = 0; i < tensor.Lengths.Length; i++) 2091if (tensors.Length < 2) 2094for (int i = 1; i < tensors.Length; i++) 2105Tensor<T>[] outputs = new Tensor<T>[tensors.Length]; 2106for (int i = 0; i < tensors.Length; i++) 2131if (tensors.Length < 2) 2134for (int i = 1; i < tensors.Length; i++) 2145Tensor<T>[] outputs = new Tensor<T>[tensors.Length]; 2146for (int i = 0; i < tensors.Length; i++) 2172if (maximumLengths.Length != tensor.Rank) 2184Debug.Assert(maximumLengths.Length != tensor.Rank); 2256if (tensor.Lengths.Length < 2) 2330if (dimension > tensor.Lengths.Length) 2367if (dimension > tensor.Lengths.Length) 2404if (dimension > tensor.Lengths.Length)
System\Numerics\Tensors\netcore\TensorOperation.cs (6)
1906for (int i = 0; i < x.Length; i++) 1924for (int i = 0; i < x.Length; i++) 2009for (int i = 0; i < x.Length; i++) 2022for (int i = 0; i < x.Length; i++) 2173for (int i = 0; i < x.Length; i++) 2192for (int i = 0; i < x.Length; i++)
System\Numerics\Tensors\netcore\TensorPrimitives.Average.cs (1)
28return Sum(x) / T.CreateChecked(x.Length);
System\Numerics\Tensors\netcore\TensorPrimitives.ConvertHelpers.cs (1)
21if (source.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.CosineSimilarity.cs (42)
52if (x.Length != y.Length) 61if (Vector512.IsHardwareAccelerated && Vector512<T>.IsSupported && x.Length >= Vector512<T>.Count) 71int oneVectorFromEnd = x.Length - Vector512<T>.Count; 85if (i != x.Length) 87Vector512<T> remainderMask = CreateRemainderMaskVector512<T>(x.Length - i); 90Vector512.LoadUnsafe(ref xRef, (uint)(x.Length - Vector512<T>.Count)) & remainderMask, 91Vector512.LoadUnsafe(ref yRef, (uint)(x.Length - Vector512<T>.Count)) & remainderMask, 98if (Vector256.IsHardwareAccelerated && Vector256<T>.IsSupported && x.Length >= Vector256<T>.Count) 108int oneVectorFromEnd = x.Length - Vector256<T>.Count; 122if (i != x.Length) 124Vector256<T> remainderMask = CreateRemainderMaskVector256<T>(x.Length - i); 127Vector256.LoadUnsafe(ref xRef, (uint)(x.Length - Vector256<T>.Count)) & remainderMask, 128Vector256.LoadUnsafe(ref yRef, (uint)(x.Length - Vector256<T>.Count)) & remainderMask, 135if (Vector128.IsHardwareAccelerated && Vector128<T>.IsSupported && x.Length >= Vector128<T>.Count) 145int oneVectorFromEnd = x.Length - Vector128<T>.Count; 159if (i != x.Length) 161Vector128<T> remainderMask = CreateRemainderMaskVector128<T>(x.Length - i); 164Vector128.LoadUnsafe(ref xRef, (uint)(x.Length - Vector128<T>.Count)) & remainderMask, 165Vector128.LoadUnsafe(ref yRef, (uint)(x.Length - Vector128<T>.Count)) & remainderMask, 175for (int i = 0; i < x.Length; i++) 191if (x.Length != y.Length) 201if (Vector512.IsHardwareAccelerated && x.Length >= Vector512<short>.Count) 212int oneVectorFromEnd = x.Length - Vector512<short>.Count; 227if (i != x.Length) 229Vector512<short> remainderMask = CreateRemainderMaskVector512<short>(x.Length - i); 232Vector512.LoadUnsafe(ref xRef, (uint)(x.Length - Vector512<short>.Count)) & remainderMask); 234Vector512.LoadUnsafe(ref yRef, (uint)(x.Length - Vector512<short>.Count)) & remainderMask); 243if (Vector256.IsHardwareAccelerated && x.Length >= Vector256<short>.Count) 254int oneVectorFromEnd = x.Length - Vector256<short>.Count; 269if (i != x.Length) 271Vector256<short> remainderMask = CreateRemainderMaskVector256<short>(x.Length - i); 274Vector256.LoadUnsafe(ref xRef, (uint)(x.Length - Vector256<short>.Count)) & remainderMask); 276Vector256.LoadUnsafe(ref yRef, (uint)(x.Length - Vector256<short>.Count)) & remainderMask); 285if (Vector128.IsHardwareAccelerated && x.Length >= Vector128<short>.Count) 296int oneVectorFromEnd = x.Length - Vector128<short>.Count; 311if (i != x.Length) 313Vector128<short> remainderMask = CreateRemainderMaskVector128<short>(x.Length - i); 316Vector128.LoadUnsafe(ref xRef, (uint)(x.Length - Vector128<short>.Count)) & remainderMask); 318Vector128.LoadUnsafe(ref yRef, (uint)(x.Length - Vector128<short>.Count)) & remainderMask); 330for (int i = 0; i < x.Length; i++)
System\Numerics\Tensors\netcore\TensorPrimitives.Half.cs (1)
307source.Length >= Vector128<short>.Count;
System\Numerics\Tensors\netcore\TensorPrimitives.HammingDistance.cs (29)
22if (x.Length != y.Length) 28for (int i = 0; i < x.Length; i++) 55MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(x)), x.Length), 56MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<T, ushort>(ref MemoryMarshal.GetReference(y)), y.Length)); 65if (x.Length != y.Length) 75if (Vector128.IsHardwareAccelerated && Vector128<T>.IsSupported && x.Length >= Vector128<T>.Count) 77if (Vector256.IsHardwareAccelerated && Vector256<T>.IsSupported && x.Length >= Vector256<T>.Count) 79if (Vector512.IsHardwareAccelerated && Vector512<T>.IsSupported && x.Length >= Vector512<T>.Count) 84int oneVectorFromEnd = x.Length - Vector512<T>.Count; 98if (i != x.Length) 100Vector512<T> xVec = Vector512.LoadUnsafe(ref xRef, (uint)(x.Length - Vector512<T>.Count)); 101Vector512<T> yVec = Vector512.LoadUnsafe(ref yRef, (uint)(x.Length - Vector512<T>.Count)); 103Vector512<T> remainderMask = CreateRemainderMaskVector512<T>(x.Length - i); 116int oneVectorFromEnd = x.Length - Vector256<T>.Count; 130if (i != x.Length) 132Vector256<T> xVec = Vector256.LoadUnsafe(ref xRef, (uint)(x.Length - Vector256<T>.Count)); 133Vector256<T> yVec = Vector256.LoadUnsafe(ref yRef, (uint)(x.Length - Vector256<T>.Count)); 135Vector256<T> remainderMask = CreateRemainderMaskVector256<T>(x.Length - i); 149int oneVectorFromEnd = x.Length - Vector128<T>.Count; 163if (i != x.Length) 165Vector128<T> xVec = Vector128.LoadUnsafe(ref xRef, (uint)(x.Length - Vector128<T>.Count)); 166Vector128<T> yVec = Vector128.LoadUnsafe(ref yRef, (uint)(x.Length - Vector128<T>.Count)); 168Vector128<T> remainderMask = CreateRemainderMaskVector128<T>(x.Length - i); 178for (int i = 0; i < x.Length; i++) 189for (int i = 0; i < x.Length; i++) 198Debug.Assert(count >= 0 && count <= x.Length, $"Expected count to be in the range [0, {x.Length}], got {count}.");
System\Numerics\Tensors\netcore\TensorPrimitives.IndexOfMax.cs (16)
148if (Vector512.IsHardwareAccelerated && Vector512<T>.IsSupported && x.Length >= Vector512<T>.Count) 190int oneVectorFromEnd = x.Length - Vector512<T>.Count; 215if (i != x.Length) 217current = Vector512.LoadUnsafe(ref xRef, (uint)(x.Length - Vector512<T>.Count)); 218currentIndex += CreateVector512T(x.Length - i); 239if (Vector256.IsHardwareAccelerated && Vector256<T>.IsSupported && x.Length >= Vector256<T>.Count) 281int oneVectorFromEnd = x.Length - Vector256<T>.Count; 306if (i != x.Length) 308current = Vector256.LoadUnsafe(ref xRef, (uint)(x.Length - Vector256<T>.Count)); 309currentIndex += CreateVector256T(x.Length - i); 330if (Vector128.IsHardwareAccelerated && Vector128<T>.IsSupported && x.Length >= Vector128<T>.Count) 372int oneVectorFromEnd = x.Length - Vector128<T>.Count; 397if (i != x.Length) 399current = Vector128.LoadUnsafe(ref xRef, (uint)(x.Length - Vector128<T>.Count)); 400currentIndex += CreateVector128T(x.Length - i); 429for (int i = 1; i < x.Length; i++)
System\Numerics\Tensors\netcore\TensorPrimitives.IsCanonical.cs (2)
27if (x.Length > destination.Length) 32destination.Slice(0, x.Length).Fill(true);
System\Numerics\Tensors\netcore\TensorPrimitives.IsComplexNumber.cs (2)
27if (x.Length > destination.Length) 32destination.Slice(0, x.Length).Clear();
System\Numerics\Tensors\netcore\TensorPrimitives.IsFinite.cs (2)
27if (x.Length > destination.Length) 32destination.Slice(0, x.Length).Fill(true);
System\Numerics\Tensors\netcore\TensorPrimitives.IsImaginaryNumber.cs (2)
27if (x.Length > destination.Length) 32destination.Slice(0, x.Length).Clear();
System\Numerics\Tensors\netcore\TensorPrimitives.IsInteger.cs (2)
26if (x.Length > destination.Length) 31destination.Slice(0, x.Length).Fill(true);
System\Numerics\Tensors\netcore\TensorPrimitives.IsNaN.cs (2)
27if (x.Length > destination.Length) 32destination.Slice(0, x.Length).Clear();
System\Numerics\Tensors\netcore\TensorPrimitives.IsNegative.cs (2)
26if (x.Length > destination.Length) 31destination.Slice(0, x.Length).Clear();
System\Numerics\Tensors\netcore\TensorPrimitives.IsRealNumber.cs (2)
27if (x.Length > destination.Length) 32destination.Slice(0, x.Length).Fill(true);
System\Numerics\Tensors\netcore\TensorPrimitives.Max.cs (13)
409if (Vector512.IsHardwareAccelerated && Vector512<T>.IsSupported && x.Length >= Vector512<T>.Count) 429int oneVectorFromEnd = x.Length - Vector512<T>.Count; 453if (i != x.Length) 455current = Vector512.LoadUnsafe(ref xRef, (uint)(x.Length - Vector512<T>.Count)); 474if (Vector256.IsHardwareAccelerated && Vector256<T>.IsSupported && x.Length >= Vector256<T>.Count) 494int oneVectorFromEnd = x.Length - Vector256<T>.Count; 518if (i != x.Length) 520current = Vector256.LoadUnsafe(ref xRef, (uint)(x.Length - Vector256<T>.Count)); 540if (Vector128.IsHardwareAccelerated && Vector128<T>.IsSupported && x.Length >= Vector128<T>.Count) 560int oneVectorFromEnd = x.Length - Vector128<T>.Count; 584if (i != x.Length) 586current = Vector128.LoadUnsafe(ref xRef, (uint)(x.Length - Vector128<T>.Count)); 612for (int i = 1; i < x.Length; i++)
System\Numerics\Tensors\netcore\TensorPrimitives.PopCount.cs (1)
20for (int i = 0; i < x.Length; i++)
System\Numerics\Tensors\netcore\TensorPrimitives.Round.cs (1)
140if ((uint)digits >= (uint)roundPower10.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.SoftMax.cs (1)
32if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.StdDev.cs (1)
30T variance = sumSquaredDiff / T.CreateChecked(x.Length);
System\Numerics\Tensors\netcore\TensorShape.cs (50)
75int rank = lengths.Length; 108if (strides.Length == 0) 142else if (strides.Length != lengths.Length) 273Debug.Assert((flattenedLength == minimumLinearLength) || (strides.Length != 0)); 286int rank = lengths.Length; 287Debug.Assert(strides.Length == rank); 422for (int i = 0; i < strides.Length; i++) 424int rankIndex = lengths.Length - (i + 1); 425int destinationRankIndex = destinationShape.Lengths.Length - (i + 1); 453for (int i = strides.Length; i < destinationLengths.Length; i++) 455int rankIndex = destinationLengths.Length - (i + 1); 487for (int i = 0; i < strides.Length; i++) 489int rankIndex = lengths.Length - (i + 1); 490int destinationRankIndex = destinationShape.Lengths.Length - (i + 1); 518for (int i = destinationLengths.Length - 1; i >= strides.Length; i--) 520int rankIndex = destinationLengths.Length - (i + 1); 601for (int i = 0; i < lengths1.Length; i++) 631for (int i = 0; i < strides1.Length; i++) 648int rankDelta = shape1Lengths.Length - shape2.Rank; 672for (int i = 0; i < lengths1.Length; i++) 757if ((start.Length != 0) && (start.Length != rank)) 764if (lengths.Length == 0) 789if (start.Length != 0) 802for (int i = 0; i < start.Length; i++) 804int index = start.Length - (i + 1); 837else if (start.Length != 0) 842if ((lengths.Length != 0) || (strides.Length != 0)) 879if ((lengths.Length != 0) || (strides.Length != 0)) 905if ((lengths.Length != 0) || (strides.Length != 0)) 946if ((lengths.Length != 0) || (strides.Length != 0)) 992if ((state.Length != lengths.Length) || 993(state.Length != strides.Length)) 1000for (int i = 0; i < state.Length; i++) 1014if ((uint)dimension > (uint)lengths.Length) 1067if ((state.Length != previousLengths.Length) || 1068(state.Length != previousStrides.Length)) 1177for (int i = 0; i < strides.Length; i++) 1179int index = strides.Length - (i + 1);
System\Numerics\Tensors\netcore\TensorSpan_1.cs (1)
192public int Rank => Lengths.Length;
System\Numerics\Tensors\TensorPrimitives.Single.cs (1)
855if (x.Length > destination.Length)
System.Private.CoreLib (2057)
src\Internal\VersionResilientHashCode.CoreCLR.cs (1)
70for (int i = 0; i < instantiation.Length; i++)
src\libraries\Common\src\Interop\Interop.ICU.cs (1)
20InitICUFunctions(icuuc, icuin, version.ToString(), suffix.Length > 0 ? suffix.ToString() : null);
src\libraries\Common\src\Interop\Linux\os-release\Interop.OSReleaseFile.cs (2)
65ReadOnlySpan<char> fieldValue = line.Slice(prefix.Length); 68if (fieldValue.Length >= 2 &&
src\libraries\Common\src\Interop\Linux\procfs\Interop.ProcMountInfo.cs (6)
32if (mount.MountPoint.Length < currentBestLength) 42if (mount.MountPoint.Length == path.Length) 48if (mount.MountPoint.Length > 1 && path[mount.MountPoint.Length] != '/') 53currentBestLength = mount.MountPoint.Length; 58if (currentFormat.Length > 0)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadDir.cs (1)
41Debug.Assert(nameBytes.Length > 0, "we shouldn't have gotten a garbage value from the OS");
src\libraries\Common\src\Interop\Windows\Kernel32\Interop.FormatMessage.cs (1)
79int length = buffer.Length;
src\libraries\Common\src\System\Collections\Generic\BitHelper.cs (1)
45bitArrayIndex < (uint)span.Length &&
src\libraries\Common\src\System\HexConverter.cs (17)
116Debug.Assert(bytes.Length >= Vector128<int>.Count); 132nuint lengthSubVector128 = (nuint)bytes.Length - (nuint)Vector128<int>.Count; 150if (pos == (nuint)bytes.Length) 167Debug.Assert(chars.Length >= bytes.Length * 2); 170if ((AdvSimd.Arm64.IsSupported || Ssse3.IsSupported) && bytes.Length >= 4) 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 248chars.Length >= Vector128<ushort>.Count * 2) 263Debug.Assert(chars.Length <= bytes.Length * 2); 264Debug.Assert(chars.Length % 2 == 0); 265Debug.Assert(chars.Length >= Vector128<ushort>.Count * 2); 268nuint lengthSubTwoVector128 = (nuint)chars.Length - ((nuint)Vector128<ushort>.Count * 2); 337if (offset == (nuint)chars.Length) 339charsProcessed = chars.Length; 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\IO\PathInternal.cs (11)
16internal static bool StartsWithDirectorySeparator(ReadOnlySpan<char> path) => path.Length > 0 && IsDirectorySeparator(path[0]); 22=> path.Length == GetRootLength(path); 142for (int i = skip; i < path.Length; i++) 146if (IsDirectorySeparator(c) && i + 1 < path.Length) 157if ((i + 2 == path.Length || IsDirectorySeparator(path[i + 2])) && 166if (i + 2 < path.Length && 167(i + 3 == path.Length || IsDirectorySeparator(path[i + 3])) && 176sb.Length = (i + 3 >= path.Length && s == skip) ? s + 1 : s; // to avoid removing the complete "\tmp\" segment in cases like \\?\C:\tmp\..\, C:\tmp\.. 201if (!flippedSeparator && sb.Length == path.Length) 235path.Slice(0, path.Length - 1) : 242path.Length > 0 && IsDirectorySeparator(path[^1]);
src\libraries\Common\src\System\IO\PathInternal.Unix.cs (1)
24return path.Length > 0 && IsDirectorySeparator(path[0]) ? 1 : 0;
src\libraries\Common\src\System\Memory\FixedBufferExtensions.cs (3)
27return length < 0 ? span.Length : length; 36if (value == null || value.Length > span.Length) 49return i == span.Length || span[i] == '\0';
src\libraries\Common\src\System\Number.Formatting.Common.cs (29)
58if (format.Length > 0) 66if (format.Length == 1) 72if (format.Length == 2) 82else if (format.Length == 3) 98while ((uint)i < (uint)format.Length && char.IsAsciiDigit(format[i])) 110if ((uint)i >= (uint)format.Length || format[i] == '\0') 120return format.Length == 0 || c == '\0' ? // For compat, treat '\0' as the end of the specifier, even if the specifier extends beyond it. 330while (src < format.Length && (ch = pFormat[src++]) != 0 && ch != ';') 381while (src < format.Length && pFormat[src] != 0 && pFormat[src++] != ch) ; 385if (src < format.Length && pFormat[src] != 0) 393if ((src < format.Length && pFormat[src] == '0') || 394(src + 1 < format.Length && (pFormat[src] == '+' || pFormat[src] == '-') && pFormat[src + 1] == '0')) 396while (++src < format.Length && pFormat[src] == '0') ; 531while (src < format.Length && (ch = pFormat[src++]) != 0 && ch != ';') 622while (src < format.Length && pFormat[src] != 0 && pFormat[src] != ch) 627if (src < format.Length && pFormat[src] != 0) 634if (src < format.Length && pFormat[src] != 0) 647if (src < format.Length && pFormat[src] == '0') 652else if (src + 1 < format.Length && pFormat[src] == '+' && pFormat[src + 1] == '0') 657else if (src + 1 < format.Length && pFormat[src] == '-' && pFormat[src + 1] == '0') 668while (++src < format.Length && pFormat[src] == '0') 685if (src < format.Length) 692while (src < format.Length && pFormat[src] == '0') 776bufferSize += sGroup.Length; 805for (int j = sGroup.Length - 1; j >= 0; j--) 1140if (src >= format.Length) 1149while (src < format.Length && pFormat[src] != 0 && pFormat[src++] != ch) ; 1153if (src < format.Length && pFormat[src] != 0) 1165if (src < format.Length && pFormat[src] != 0 && pFormat[src] != ';')
src\libraries\Common\src\System\Number.Parsing.Common.cs (2)
289if (!TryParseNumber(ref p, p + value.Length, styles, ref number, info) 290|| ((int)(p - stringPointer) < value.Length && !TrailingZeros(value, (int)(p - stringPointer))))
src\libraries\Common\src\System\Reflection\AssemblyNameFormatter.cs (1)
108if (s.Length != span.Trim().Length || span.IndexOfAny('\"', '\'') >= 0)
src\libraries\Common\src\System\Reflection\AssemblyNameParser.cs (2)
63if (input.Length == 0) 348if (_index < _input.Length)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (1)
26int maxSize = checked(Encoding.UTF8.GetMaxByteCount(value.Length) + 1);
src\libraries\System.Private.CoreLib\src\System\AppDomain.cs (1)
143parameters: entry.GetParametersAsSpan().Length > 0 ? [args] : null,
src\libraries\System.Private.CoreLib\src\System\Array.cs (3)
737Debug.Assert(indices.Length == Rank); 743for (int i = 0; i < indices.Length; i++) 745int index = indices[i] - Unsafe.Add(ref bounds, indices.Length + i);
src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (14)
414if (value.Length < sizeof(char)) 449if (value.Length < sizeof(short)) 487if (value.Length < sizeof(int)) 525if (value.Length < sizeof(long)) 563if (value.Length < Int128.Size) 590if (value.Length < sizeof(ushort)) 620if (value.Length < sizeof(uint)) 650if (value.Length < sizeof(ulong)) 690if (value.Length < UInt128.Size) 715if (value.Length < sizeof(Half)) 743if (value.Length < sizeof(float)) 771if (value.Length < sizeof(double)) 823while (i < src.Length) 897if (value.Length < sizeof(byte))
src\libraries\System.Private.CoreLib\src\System\Boolean.cs (4)
269int originalLength = value.Length; 273if (value.Length != originalLength) 295while (start < value.Length) 304int end = value.Length - 1;
src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.ReverseEndianness.cs (8)
289if (destination.Length < source.Length) 310while (i <= source.Length - Vector256<T>.Count) 319while (i <= source.Length - Vector128<T>.Count) 326while (i < source.Length) 338int i = source.Length; 381if (destination.Length < source.Length) 391for (int i = 0; i < source.Length; i++) 399for (int i = source.Length - 1; i >= 0; i--)
src\libraries\System.Private.CoreLib\src\System\Buffers\SharedArrayPool.cs (1)
530if (!value.IsEmpty && value.Length <= 10)
src\libraries\System.Private.CoreLib\src\System\Buffers\StandardFormat.cs (3)
99if (format.Length == 0) 104if (format.Length == 1) 111for (int srcIndex = 1; srcIndex < format.Length; srcIndex++)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Helper\Base64DecoderHelper.cs (10)
32int srcLength = decoder.SrcLength(isFinalBlock, source.Length); 155if (src == srcBytes + source.Length) 233if (srcLength != source.Length) 244if (srcLength != source.Length && isFinalBlock) 279bytesConsumed += source.Length; 462for (; encodedIdx < source.Length && (uint)bufferIdx < (uint)buffer.Length; ++encodedIdx) 487hasAnotherBlock = source.Length >= BlockSize; 491hasAnotherBlock = source.Length > 1; 524for (int i = 0; i < source.Length; ++i) 1453for (int i = 0; i < span.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Helper\Base64EncoderHelper.cs (1)
31int srcLength = source.Length;
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Helper\Base64ValidatorHelper.cs (3)
23if ((uint)index >= (uint)base64Text.Length) 25length += base64Text.Length; 26lastChar = base64Text[base64Text.Length - 1];
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Url\Base64UrlDecoder.cs (7)
164int upperBound = GetMaxDecodedLength(source.Length); 219for (; encodedIdx < source.Length && (uint)bufferIdx < (uint)buffer.Length; ++encodedIdx) 244hasAnotherBlock = source.Length >= BlockSize; 248hasAnotherBlock = source.Length > 1; 281for (int i = 0; i < source.Length; ++i) 380int upperBound = GetMaxDecodedLength(source.Length); 841for (int i = 0; i < span.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Url\Base64UrlEncoder.cs (4)
88byte[] destination = new byte[GetEncodedLength(source.Length)]; 139char[] destination = new char[GetEncodedLength(source.Length)]; 155int encodedLength = GetEncodedLength(source.Length); 161Debug.Assert(buffer.Length == charsWritten, $"The source length: {source.Length}, bytes written: {charsWritten}");
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\FormattingHelpers.CountDigits.cs (3)
25Debug.Assert(log2ToPow10.Length == 64); 54Debug.Assert((elementOffset + 1) <= powersOf10.Length); 102Debug.Assert(table.Length == 32, "Every result of uint.Log2(value) needs a long entry in the table.");
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Boolean.cs (2)
32if (source.Length >= 4) 42if (source.Length > 4)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Date.Default.cs (1)
18if (source.Length < 26)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Date.G.cs (1)
17if (source.Length < 19)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Date.O.cs (3)
21if (source.Length < 27) 196byte offsetChar = (source.Length <= 27) ? default : source[27]; 228if (source.Length < 33)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Date.R.cs (1)
17if (source.Length < 29)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Float.cs (1)
116int remaining = source.Length;
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Guid.cs (2)
56if (text.Length < 32) 109if (source.Length < expectedCodingUnits)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Integer.Signed.D.cs (34)
10if (source.Length < 1) 20if ((uint)index >= (uint)source.Length) 27if ((uint)index >= (uint)source.Length) 41if ((uint)index >= (uint)source.Length) 52if ((uint)index >= (uint)source.Length) 61if ((uint)index >= (uint)source.Length) 73if ((uint)index >= (uint)source.Length) 95if (source.Length < 1) 105if ((uint)index >= (uint)source.Length) 112if ((uint)index >= (uint)source.Length) 126if ((uint)index >= (uint)source.Length) 137if ((uint)index >= (uint)source.Length) 145if ((uint)index >= (uint)source.Length) 153if ((uint)index >= (uint)source.Length) 162if ((uint)index >= (uint)source.Length) 174if ((uint)index >= (uint)source.Length) 196if (source.Length < 1) 206if ((uint)index >= (uint)source.Length) 213if ((uint)index >= (uint)source.Length) 227if ((uint)index >= (uint)source.Length) 238if ((uint)index >= (uint)source.Length) 246if ((uint)index >= (uint)source.Length) 254if ((uint)index >= (uint)source.Length) 262if ((uint)index >= (uint)source.Length) 270if ((uint)index >= (uint)source.Length) 278if ((uint)index >= (uint)source.Length) 286if ((uint)index >= (uint)source.Length) 294if ((uint)index >= (uint)source.Length) 303if ((uint)index >= (uint)source.Length) 317if ((uint)index >= (uint)source.Length) 348if ((uint)idx >= (uint)source.Length) { goto FalseExit; } 382if (source.Length < overflowLength) 390if ((uint)idx >= (uint)source.Length) { break; } // EOF 401if ((uint)idx >= (uint)source.Length) { break; } // EOF
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Integer.Signed.N.cs (24)
10if (source.Length < 1) 20if ((uint)index >= (uint)source.Length) 27if ((uint)index >= (uint)source.Length) 46if ((uint)index >= (uint)source.Length) 70if ((uint)index >= (uint)source.Length) 79if ((uint)index >= (uint)source.Length) 102if (source.Length < 1) 112if ((uint)index >= (uint)source.Length) 119if ((uint)index >= (uint)source.Length) 138if ((uint)index >= (uint)source.Length) 162if ((uint)index >= (uint)source.Length) 171if ((uint)index >= (uint)source.Length) 194if (source.Length < 1) 204if ((uint)index >= (uint)source.Length) 211if ((uint)index >= (uint)source.Length) 230if ((uint)index >= (uint)source.Length) 257if ((uint)index >= (uint)source.Length) 266if ((uint)index >= (uint)source.Length) 289if (source.Length < 1) 299if ((uint)index >= (uint)source.Length) 306if ((uint)index >= (uint)source.Length) 325if ((uint)index >= (uint)source.Length) 352if ((uint)index >= (uint)source.Length) 361if ((uint)index >= (uint)source.Length)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Integer.Unsigned.D.cs (27)
10if (source.Length < 1) 24if ((uint)index >= (uint)source.Length) 35if ((uint)index >= (uint)source.Length) 44if ((uint)index >= (uint)source.Length) 54if ((uint)index >= (uint)source.Length) 76if (source.Length < 1) 90if ((uint)index >= (uint)source.Length) 101if ((uint)index >= (uint)source.Length) 109if ((uint)index >= (uint)source.Length) 117if ((uint)index >= (uint)source.Length) 126if ((uint)index >= (uint)source.Length) 136if ((uint)index >= (uint)source.Length) 158if (source.Length < 1) 172if ((uint)index >= (uint)source.Length) 183if ((uint)index >= (uint)source.Length) 191if ((uint)index >= (uint)source.Length) 199if ((uint)index >= (uint)source.Length) 207if ((uint)index >= (uint)source.Length) 215if ((uint)index >= (uint)source.Length) 223if ((uint)index >= (uint)source.Length) 231if ((uint)index >= (uint)source.Length) 239if ((uint)index >= (uint)source.Length) 248if ((uint)index >= (uint)source.Length) 258if ((uint)index >= (uint)source.Length) 298if (source.Length < ParserHelpers.UInt64OverflowLength) 306if ((uint)idx >= (uint)source.Length) { break; } // EOF 317if ((uint)idx >= (uint)source.Length) { break; } // EOF
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Integer.Unsigned.N.cs (20)
13if (source.Length < 1) 21if ((uint)index >= (uint)source.Length) 40if ((uint)index >= (uint)source.Length) 62if ((uint)index >= (uint)source.Length) 71if ((uint)index >= (uint)source.Length) 94if (source.Length < 1) 102if ((uint)index >= (uint)source.Length) 121if ((uint)index >= (uint)source.Length) 143if ((uint)index >= (uint)source.Length) 152if ((uint)index >= (uint)source.Length) 175if (source.Length < 1) 183if ((uint)index >= (uint)source.Length) 202if ((uint)index >= (uint)source.Length) 224if ((uint)index >= (uint)source.Length) 233if ((uint)index >= (uint)source.Length) 256if (source.Length < 1) 264if ((uint)index >= (uint)source.Length) 283if ((uint)index >= (uint)source.Length) 305if ((uint)index >= (uint)source.Length) 314if ((uint)index >= (uint)source.Length)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Integer.Unsigned.X.cs (20)
10if (source.Length < 1) 32if (source.Length <= ParserHelpers.ByteOverflowLengthHex) 35for (int index = 1; index < source.Length; index++) 64for (int index = ParserHelpers.ByteOverflowLengthHex; index < source.Length; index++) 85bytesConsumed = source.Length; 92if (source.Length < 1) 114if (source.Length <= ParserHelpers.Int16OverflowLengthHex) 117for (int index = 1; index < source.Length; index++) 146for (int index = ParserHelpers.Int16OverflowLengthHex; index < source.Length; index++) 167bytesConsumed = source.Length; 174if (source.Length < 1) 196if (source.Length <= ParserHelpers.Int32OverflowLengthHex) 199for (int index = 1; index < source.Length; index++) 228for (int index = ParserHelpers.Int32OverflowLengthHex; index < source.Length; index++) 249bytesConsumed = source.Length; 256if (source.Length < 1) 278if (source.Length <= ParserHelpers.Int64OverflowLengthHex) 281for (int index = 1; index < source.Length; index++) 310for (int index = ParserHelpers.Int64OverflowLengthHex; index < source.Length; index++) 331bytesConsumed = source.Length;
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Number.cs (11)
26if (source.Length == 0) 47if (srcIndex >= source.Length) 64while (srcIndex < source.Length) 72if (srcIndex == source.Length) 82while (srcIndex < source.Length) 118if (srcIndex == source.Length) 137while (srcIndex < source.Length) 182if (srcIndex == source.Length) 226if (srcIndex == source.Length) 242if (srcIndex == source.Length) 271while (srcIndex < source.Length)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.TimeSpan.BigG.cs (8)
12while (srcIndex < source.Length) 20if (srcIndex == source.Length) 32if (srcIndex == source.Length) 48if (srcIndex == source.Length || source[srcIndex++] != Utf8Constants.Colon) 63if (srcIndex == source.Length || source[srcIndex++] != Utf8Constants.Colon) 78if (srcIndex == source.Length || source[srcIndex++] != Utf8Constants.Colon) 93if (srcIndex == source.Length || source[srcIndex++] != Utf8Constants.Period) 120if (srcIndex != source.Length && (source[srcIndex] == Utf8Constants.Period || source[srcIndex] == Utf8Constants.Colon))
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.TimeSpan.cs (2)
47if (srcIndex == source.Length) 66while (srcIndex < source.Length)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.TimeSpanSplitter.cs (5)
41while (srcIndex < source.Length) 49if (srcIndex == source.Length) 60if (srcIndex == source.Length) 166if (srcIndex != source.Length && (source[srcIndex] == Utf8Constants.Period || source[srcIndex] == Utf8Constants.Colon)) 181if (srcIndex == source.Length)
src\libraries\System.Private.CoreLib\src\System\Byte.cs (5)
301if (source.Length != 0) 312if ((source.Length > sizeof(byte)) && (source[..^sizeof(byte)].ContainsAnyExcept((byte)0x00))) 322result = Unsafe.Add(ref MemoryMarshal.GetReference(source), source.Length - sizeof(byte)); 334if (source.Length != 0) 345if ((source.Length > sizeof(byte)) && (source[sizeof(byte)..].ContainsAnyExcept((byte)0x00)))
src\libraries\System.Private.CoreLib\src\System\Char.cs (12)
81private static bool IsLatin1(char c) => (uint)c < (uint)Latin1CharInfo.Length; 205if (s.Length != 1) 224if (s.Length != 1) 238bytesConsumed != utf8Text.Length) 255bytesConsumed != utf8Text.Length || 1215if (source.Length != 0) 1226if ((source.Length > sizeof(char)) && (source[..^sizeof(char)].ContainsAnyExcept((byte)0x00))) 1237if (source.Length >= sizeof(char)) 1239sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(char)); 1265if (source.Length != 0) 1276if ((source.Length > sizeof(char)) && (source[sizeof(char)..].ContainsAnyExcept((byte)0x00))) 1287if (source.Length >= sizeof(char))
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\CollectionExtensions.cs (7)
105if (list._items.Length - list._size < source.Length) 107list.Grow(checked(list._size + source.Length)); 111list._size += source.Length; 137if (list._items.Length - list._size < source.Length) 139list.GrowForInsertion(index, source.Length); 146Array.Copy(list._items, index, list._items, index + source.Length, list._size - index); 153list._size += source.Length;
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\RandomizedStringEqualityComparer.cs (2)
91(uint)alternate.Length * 2, 136alternate.Length,
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (8)
69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 89_pos += source.Length; 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 98Grow(source.Length); 101_span.Slice(0, _pos).CopyTo(_span.Slice(source.Length)); 103_pos += source.Length;
src\libraries\System.Private.CoreLib\src\System\Convert.Base64.cs (3)
36int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 42if (utf16.Length == 0) 142if (srcLength != utf16.Length)
src\libraries\System.Private.CoreLib\src\System\Convert.cs (35)
2350if (bytes.Length == 0) 2356int outputLength = ToBase64_CalculateAndValidateOutputLength(bytes.Length, insertLineBreaks); 2360if (Vector128.IsHardwareAccelerated && !insertLineBreaks && bytes.Length >= Base64VectorizationLengthThreshold) 2371int charsWritten = ConvertToBase64Array(charsPtr, bytesPtr, 0, bytes.Length, insertLineBreaks); 2436if (bytes.Length == 0) 2444int charLengthRequired = ToBase64_CalculateAndValidateOutputLength(bytes.Length, insertLineBreaks); 2451if (Vector128.IsHardwareAccelerated && !insertLineBreaks && bytes.Length >= Base64VectorizationLengthThreshold) 2460int converted = ConvertToBase64Array(outChars, inData, 0, bytes.Length, insertLineBreaks); 2477Debug.Assert(bytes.Length >= Base64VectorizationLengthThreshold); 2677while (chars.Length != 0) 2688Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 2696if (indexOfFirstNonSpace == chars.Length) 2705if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 2717Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 2745for (int i = 0; i < chars.Length; i++) 2768for (int i = 0; i < chars.Length; i++) 2781consumed = chars.Length; 2945if (chars.Length == 0) 2947if ((uint)chars.Length % 2 != 0) 2950byte[] result = GC.AllocateUninitializedArray<byte>(chars.Length >> 1); 2992(int quotient, int remainder) = Math.DivRem(source.Length, 2); 3014source = source.Slice(0, source.Length - 1); 3032charsConsumed = source.Length; 3081if (bytes.Length == 0) 3083ArgumentOutOfRangeException.ThrowIfGreaterThan(bytes.Length, int.MaxValue / 2, nameof(bytes)); 3097if (source.Length == 0) 3102else if (source.Length > int.MaxValue / 2 || destination.Length < source.Length * 2) 3109charsWritten = source.Length * 2; 3158if (bytes.Length == 0) 3160ArgumentOutOfRangeException.ThrowIfGreaterThan(bytes.Length, int.MaxValue / 2, nameof(bytes)); 3174if (source.Length == 0) 3179else if (source.Length > int.MaxValue / 2 || destination.Length < source.Length * 2) 3186charsWritten = source.Length * 2;
src\libraries\System.Private.CoreLib\src\System\DateOnly.cs (3)
495if (format.Length == 1) 794if (format.Length == 0) 799if (format.Length == 1)
src\libraries\System.Private.CoreLib\src\System\Decimal.cs (2)
293if (bits.Length == 4) 640Debug.Assert(span.Length >= 16);
src\libraries\System.Private.CoreLib\src\System\DefaultBinder.cs (46)
58paramOrder[i] = new int[(par.Length > args.Length) ? par.Length : args.Length]; 63for (j = 0; j < par.Length; j++) 110if (par.Length == 0) 126else if (par.Length > args.Length) 131for (j = args.Length; j < par.Length - 1; j++) 137if (j != par.Length - 1) 152else if (par.Length < args.Length) 156int lastArgPos = par.Length - 1; 173int lastArgPos = par.Length - 1; 187int argsToCheck = (paramArrayType != null) ? par.Length - 1 : args.Length; 252if (paramArrayType != null && j == par.Length - 1) 311if (parms.Length == args.Length) 315object[] objs = new object[parms.Length]; 316int lastPos = parms.Length - 1; 323else if (parms.Length > args.Length) 325object?[] objs = new object[parms.Length]; 327for (i = 0; i < parms.Length; i++) 336if (i == parms.Length - 1 && paramArrayTypes[0] != null) 353object[] objs = new object[parms.Length]; 354int paramArrayPos = parms.Length - 1; 401if (parameters.Length == args.Length) 405object[] objs = new object[parameters.Length]; 406int lastPos = parameters.Length - 1; 413else if (parameters.Length > args.Length) 415object?[] objs = new object[parameters.Length]; 420for (; i < parameters.Length - 1; i++) 438object[] objs = new object[parameters.Length]; 439int paramArrayPos = parameters.Length - 1; 566if (par.Length != types.Length) 801if (par.Length == 0) 894if (paramArrayType1 != null && paramOrder1[i] >= p1.Length - 1) 899if (paramArrayType2 != null && paramOrder2[i] >= p2.Length - 1) 923if (p1.Length > p2.Length) 927else if (p2.Length > p1.Length) 1102if (params1.Length != params2.Length) 1105int numParams = params1.Length; 1186bool[] used = new bool[pars.Length]; 1189for (int i = 0; i < pars.Length; i++) 1195for (j = 0; j < pars.Length; j++) 1206if (j == pars.Length) 1212for (int i = 0; i < pars.Length; i++) 1216for (; pos < pars.Length; pos++)
src\libraries\System.Private.CoreLib\src\System\Delegate.cs (1)
45for (int i = 1; i < delegates.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Diagnostics\StackTrace.cs (1)
305for (int j = 0; j < pi.Length; j++)
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventPipePayloadDecoder.cs (2)
24if (payload.Length <= 0) 109for (int j = 1; j < payload.Length; j += 2)
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\TraceLoggingEventSource.cs (4)
441descriptors[0].SetMetadata(pMetadata0, providerMetadata.Length, 2); 548descriptors[0].SetMetadata(pMetadata0, providerMetadata.Length, 2); 619descriptors[0].SetMetadata(pMetadata0, providerMetadata.Length, 2); 735bool hasProviderMetadata = ProviderMetadata.Length > 0;
src\libraries\System.Private.CoreLib\src\System\Enum.cs (6)
1055while (value.Length > 0) 1066else if (endIndex != value.Length - 1) 1899if (format.Length == 1) 2109Debug.Assert(foundItems.Length >= 2, $"{nameof(foundItems)} == {foundItems.Length}"); 2111for (int i = foundItems.Length - 1; i != 0; i--)
src\libraries\System.Private.CoreLib\src\System\Environment.Variables.Windows.cs (1)
122currentPtr += variable.Length + 1;
src\libraries\System.Private.CoreLib\src\System\Globalization\CalendricalCalculationsHelper.cs (1)
128for (int i = 1; i < coefficients.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.cs (12)
141if (text.Length == 0) 291InvariantModeCasing.CompareStringIgnoreCase(ref MemoryMarshal.GetReference(string1), string1.Length, ref MemoryMarshal.GetReference(string2), string2.Length) : 438return Ordinal.CompareStringIgnoreCase(ref MemoryMarshal.GetReference(string1), string1.Length, ref MemoryMarshal.GetReference(string2), string2.Length); 452return Ordinal.CompareStringIgnoreCase(ref MemoryMarshal.GetReference(string1), string1.Length, ref MemoryMarshal.GetReference(string2), string2.Length); 611matchLength = (matched) ? prefix.Length : 0; 754matchLength = (matched) ? suffix.Length : 0; 1064return (fromBeginning) ? 0 : source.Length; 1106*matchLengthPtr = value.Length; 1329return source.Length; // Empty target string trivially occurs at the last index of every search space.
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Icu.cs (89)
62return Interop.Globalization.CompareString(_sortHandle, pString1, string1.Length, pString2, string2.Length, options); 70Debug.Assert(target.Length != 0); 92return Interop.Globalization.IndexOf(_sortHandle, pTarget, target.Length, pSource, source.Length, options, matchLengthPtr); 94return Interop.Globalization.LastIndexOf(_sortHandle, pTarget, target.Length, pSource, source.Length, options, matchLengthPtr); 122if (target.Length > source.Length) 138endIndex = source.Length - target.Length + 1; 145startIndex = source.Length - target.Length; 155for (; targetIndex < target.Length; targetIndex++, sourceIndex++) 180if (sourceIndex < source.Length - 1 && *(a + sourceIndex + 1) >= 0x80) 186if (sourceIndex < source.Length && *(a + sourceIndex) >= 0x80) 189*matchLengthPtr = target.Length; 213return Interop.Globalization.IndexOf(_sortHandle, b, target.Length, a, source.Length, options, matchLengthPtr); 215return Interop.Globalization.LastIndexOf(_sortHandle, b, target.Length, a, source.Length, options, matchLengthPtr); 237if (target.Length > source.Length) 253endIndex = source.Length - target.Length + 1; 260startIndex = source.Length - target.Length; 270for (; targetIndex < target.Length; targetIndex++, sourceIndex++) 284if (sourceIndex < source.Length - 1 && *(a + sourceIndex + 1) >= 0x80) 290if (sourceIndex < source.Length && *(a + sourceIndex) >= 0x80) 293*matchLengthPtr = target.Length; 307return Interop.Globalization.IndexOf(_sortHandle, b, target.Length, a, source.Length, options, matchLengthPtr); 309return Interop.Globalization.LastIndexOf(_sortHandle, b, target.Length, a, source.Length, options, matchLengthPtr); 338return Interop.Globalization.StartsWith(_sortHandle, pPrefix, prefix.Length, pSource, source.Length, options, matchLengthPtr); 350int length = Math.Min(source.Length, prefix.Length); 385if (a < ap + source.Length - 1 && *(a + 1) >= 0x80) 387if (b < bp + prefix.Length - 1 && *(b + 1) >= 0x80) 394if (source.Length < prefix.Length) 403if (source.Length > prefix.Length) 412*matchLengthPtr = prefix.Length; // non-linguistic match doesn't change UTF-16 length 421return Interop.Globalization.StartsWith(_sortHandle, bp, prefix.Length, ap, source.Length, options, matchLengthPtr); 432int length = Math.Min(source.Length, prefix.Length); 456if (a < ap + source.Length - 1 && *(a + 1) >= 0x80) 458if (b < bp + prefix.Length - 1 && *(b + 1) >= 0x80) 465if (source.Length < prefix.Length) 474if (source.Length > prefix.Length) 484*matchLengthPtr = prefix.Length; // non-linguistic match doesn't change UTF-16 length 493return Interop.Globalization.StartsWith(_sortHandle, bp, prefix.Length, ap, source.Length, options, matchLengthPtr); 522return Interop.Globalization.EndsWith(_sortHandle, pSuffix, suffix.Length, pSource, source.Length, options, matchLengthPtr); 534int length = Math.Min(source.Length, suffix.Length); 539char* a = ap + source.Length - 1; 540char* b = bp + suffix.Length - 1; 578if (source.Length < suffix.Length) 587if (source.Length > suffix.Length) 597*matchLengthPtr = suffix.Length; // non-linguistic match doesn't change UTF-16 length 606return Interop.Globalization.EndsWith(_sortHandle, bp, suffix.Length, ap, source.Length, options, matchLengthPtr); 617int length = Math.Min(source.Length, suffix.Length); 622char* a = ap + source.Length - 1; 623char* b = bp + suffix.Length - 1; 650if (source.Length < suffix.Length) 659if (source.Length > suffix.Length) 669*matchLengthPtr = suffix.Length; // non-linguistic match doesn't change UTF-16 length 678return Interop.Globalization.EndsWith(_sortHandle, bp, suffix.Length, ap, source.Length, options, matchLengthPtr); 769actualSortKeyLength = Interop.Globalization.GetSortKey(_sortHandle, pSource, source.Length, pDest, destination.Length, options); 815return Interop.Globalization.GetSortKey(_sortHandle, pSource, source.Length, null, 0, options); 863int sortKeyLength = checked((source.Length > 1024 * 1024 / 4) ? 0 : 4 * source.Length); 882sortKeyLength = Interop.Globalization.GetSortKey(_sortHandle, pSource, source.Length, pSortKey, sortKey.Length, options); 905sortKeyLength = Interop.Globalization.GetSortKey(_sortHandle, pSource, source.Length, pSortKey, sortKey.Length, options);
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Invariant.cs (8)
46Debug.Assert(sortKey.Length >= source.Length * sizeof(char)); 48for (int i = 0; i < source.Length; i++) 58Debug.Assert(sortKey.Length >= source.Length * sizeof(char)); 60for (int i = 0; i < source.Length; i++) 63if (char.IsHighSurrogate(c) && i < source.Length - 1) 93if ((uint)destination.Length < (uint)source.Length * sizeof(char)) 107return source.Length * sizeof(char); 119int byteLength = source.Length * sizeof(char);
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Nls.cs (16)
63source.Length, 65value.Length, 68Debug.Assert(ret >= -1 && ret <= source.Length); 82Debug.Assert(source.Length != 0); 83Debug.Assert(value.Length != 0); 129int sourceLength = source.Length; 241string1.Length, 243string2.Length, 275int lpStringSourceLength = lpStringSource.Length; 294lpStringValue.Length, 300Debug.Assert(result >= -1 && result <= lpStringSource.Length); 314Debug.Assert(target.Length != 0); 354*matchLengthPtr = source.Length - idx; // all chars from idx to the end of the string are consumed 455int sourceLength = source.Length; 534int sourceLength = source.Length; 574return Interop.Kernel32.IsNLSDefinedString(Interop.Kernel32.COMPARE_STRING, 0, IntPtr.Zero, pText, text.Length);
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Utf8.cs (2)
83int sourceMaxCharCount = Encoding.UTF8.GetMaxCharCount(source.Length); 114int prefixMaxCharCount = Encoding.UTF8.GetMaxCharCount(prefix.Length);
src\libraries\System.Private.CoreLib\src\System\Globalization\CultureData.Icu.cs (5)
72bufferIndex += extension.Length; 367Debug.Assert(icuFormatString.Length < ICU_ULOC_FULLNAME_CAPACITY); 373for (int i = 0; i < icuFormatString.Length; i++) 386if (i + 1 < icuFormatString.Length && icuFormatString[i + 1] == '\'') 402for (; i < icuFormatString.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeFormat.cs (15)
200while ((uint)index < (uint)format.Length && format[index] == patternChar) 289int formatLen = format.Length; 346if ((uint)(pos + 1) >= (uint)format.Length) 401for (i = index + tokenLen; i < format.Length && format[i] != patternToMatch; i++) { /* Do nothing here */ } 403if (i < format.Length) 407while (++i < format.Length && format[i] == patternToMatch) 442while (i < format.Length) 628((i + tokenLen < format.Length && format[i + tokenLen] == DateTimeFormatInfoScanner.CJKYearSuff) || 629(i + tokenLen < format.Length - 1 && format[i + tokenLen] == '\'' && format[i + tokenLen + 1] == DateTimeFormatInfoScanner.CJKYearSuff))) 1074else if (format.Length == 1) 1180while (i < format.Length) 1185if (i == format.Length - 1) 1201while (i < format.Length && format[i] != quoteChar) 1206if (i >= format.Length) 1249int length = format.Length;
src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeFormatInfo.cs (2)
2254} while (i < str.Value.Length && (state != HebrewNumberParsingState.FoundEndOfHebrewNumber)); 2306Debug.Assert(str.Index < str.Value.Length, "DateTimeFormatInfo.Tokenize(): start < value.Length");
src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeParse.cs (32)
85if (s.Length == 0) 91if (format.Length == 0) 178if (s.Length == 0) 411if (target.Length > (str.Value.Length - str.Index)) 423if (nextCharIndex < str.Value.Length) 2491if (s.Length == 0) 3301for (int i = 0; i < format.Length; i++) 3322while (i + 1 < format.Length && format[i + 1] == 'd') 3355if (span.Length >= 3) 3456if (span.Length >= 3) 3557if (span.Length >= 3) 3624if (span.Length >= 3) 4397for (int i = 0; i < quotedSpan.Length; i++) 4432if (format.Index >= format.Value.Length - 1 || format.Value[format.Index + 1] == '%') 4526while ((uint)pos < (uint)format.Length) 4541if ((uint)pos < (uint)format.Length) 4599if (formatParam.Length == 1) 4669if (str.Index < str.Value.Length - 1) 4794if (source.Length != 29) 4991if (source.Length < 27 || 5112if (source.Length > 27) 5118if (source.Length != 28) 5130if (source.Length == 33) 5143else if (source.Length == 32) // special-case allowed for compat: only one offset hour digit 5341for (int i = 0; i < str.Length; i++) 5392internal int Length => Value.Length; 5585int valueRemaining = Value.Length - Index; 5603if (thisPosition >= Value.Length - segmentLength) 5631while (thisPosition < Value.Length && char.IsWhiteSpace(Value[thisPosition])) 5649if (thisPosition > Value.Length - segmentLength) 5663if (nextCharIndex < Value.Length) 5898Span<char> result = new char[Value.Length - i];
src\libraries\System.Private.CoreLib\src\System\Globalization\GlobalizationMode.cs (1)
74version = icuSuffixAndVersion.AsSpan(icuSuffix.Length + 1);
src\libraries\System.Private.CoreLib\src\System\Globalization\GlobalizationMode.Unix.cs (1)
65string extension = version.Length > 0 ? "so." : "so";
src\libraries\System.Private.CoreLib\src\System\Globalization\IcuLocaleData.cs (7)
37045 => (LcidSortPrefix5Index, indices.Length), 3711int hi = indices.Length / 4 - 1; 3779Debug.Assert(CulturesCount == (ThreeLetterWindowsLanguageName.Length / 3)); 3821Debug.Assert(CulturesCount * 2 == LocalesNamesIndexes.Length); 3863string result = string.FastAllocateString(buffer.Length); 3864var s = new Span<char>(ref result.GetRawStringData(), buffer.Length); 3865for (int i = 0; i < buffer.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Globalization\InvariantModeCasing.cs (18)
114Debug.Assert(source.Length <= destination.Length); 116for (int i = 0; i < source.Length; i++) 119if (char.IsHighSurrogate(c) && i < source.Length - 1) 140Debug.Assert(source.Length <= destination.Length); 142for (int i = 0; i < source.Length; i++) 145if (char.IsHighSurrogate(c) && i < source.Length - 1) 226Debug.Assert(value.Length > 0); 227Debug.Assert(value.Length <= source.Length); 233char* pSourceLimit = pSource + (source.Length - value.Length); 234char* pValueLimit = pValue + value.Length - 1; 288Debug.Assert(value.Length > 0); 289Debug.Assert(value.Length <= source.Length); 295char* pValueLimit = pValue + value.Length - 1; 296char* pCurrentSource = pSource + (source.Length - value.Length);
src\libraries\System.Private.CoreLib\src\System\Globalization\Normalization.cs (2)
53charsWritten = source.Length; 74return source.Length;
src\libraries\System.Private.CoreLib\src\System\Globalization\Normalization.Icu.cs (5)
35ret = Interop.Globalization.IsNormalized(normalizationForm, pInput, source.Length); 149realLen = Interop.Globalization.NormalizeString(normalizationForm, pInput, source.Length, pDest, destination.Length); 188realLen = Interop.Globalization.NormalizeString(normalizationForm, pInput, source.Length, null, 0); 227for (; (uint)i < (uint)s.Length; i++) 249if ((uint)(i + 1) >= (uint)s.Length || !char.IsLowSurrogate(s[i + 1]))
src\libraries\System.Private.CoreLib\src\System\Globalization\Normalization.Nls.cs (3)
24result = Interop.Normaliz.IsNormalizedString(normalizationForm, pInput, source.Length); 136realLength = Interop.Normaliz.NormalizeString(normalizationForm, pInput, source.Length, pDest, destination.Length); 179realLength = Interop.Normaliz.NormalizeString(normalizationForm, pInput, source.Length, null, 0);
src\libraries\System.Private.CoreLib\src\System\Globalization\Ordinal.cs (17)
331if (value.Length == 0) 336if (value.Length > source.Length) 363int valueTailLength = value.Length - 1; 364int searchSpaceMinusValueTailLength = source.Length - valueTailLength; 465Debug.Assert(offset + ch1ch2Distance + Vector256<ushort>.Count <= source.Length); 507if (EqualsIgnoreCase(ref Unsafe.Add(ref searchSpace, offset + charPos), ref valueRef, value.Length)) 531Debug.Assert(offset + ch1ch2Distance + Vector128<ushort>.Count <= source.Length); 573if (EqualsIgnoreCase(ref Unsafe.Add(ref searchSpace, offset + charPos), ref valueRef, value.Length)) 659if (value.Length == 0) 661return source.Length; 664if (value.Length > source.Length) 692if (destination.Length < source.Length) 698return source.Length; 704return source.Length; 708return source.Length;
src\libraries\System.Private.CoreLib\src\System\Globalization\Ordinal.Utf8.cs (3)
100while ((spanA.Length | spanB.Length) != 0); 410while (spanB.Length != 0);
src\libraries\System.Private.CoreLib\src\System\Globalization\OrdinalCasing.Icu.cs (17)
150for (int i = 0; i < source.Length; i++) 161for (int i = 0; i < source.Length; i++) 170if (char.IsHighSurrogate(c) && i < source.Length - 1) 290Debug.Assert(value.Length > 0); 291Debug.Assert(value.Length <= source.Length); 299char* pSourceLimit = pSource + (source.Length - value.Length); 300char* pValueLimit = pValue + value.Length - 1; 354Debug.Assert(value.Length > 0); 355Debug.Assert(value.Length <= source.Length); 363char* pValueLimit = pValue + value.Length - 1; 364char* pCurrentSource = pSource + (source.Length - value.Length); 417ushort[]?[] table = new ushort[]?[s_casingTableInit.Length * 8]; 418for (int i = 0; i < s_casingTableInit.Length * 8; ++i)
src\libraries\System.Private.CoreLib\src\System\Globalization\StringInfo.cs (1)
220builder.Append(str.Length - remaining.Length); // a new extended grapheme cluster begins at this offset
src\libraries\System.Private.CoreLib\src\System\Globalization\TextInfo.cs (3)
213Debug.Assert(destination.Length >= source.Length); 220Debug.Assert(destination.Length >= source.Length); 254ChangeCaseCore(pSource + charsConsumed, source.Length - charsConsumed, pDestination + charsConsumed, destination.Length - charsConsumed, toUpper);
src\libraries\System.Private.CoreLib\src\System\Globalization\TimeSpanFormat.cs (9)
55if (format.Length == 0) 60if (format.Length == 1) 162requiredOutputLength += decimalSeparator.Length; 172requiredOutputLength += decimalSeparator.Length; 275else if (decimalSeparator.Length == 1) 281decimalSeparator.CopyTo(new Span<TChar>(p, decimalSeparator.Length)); 282p += decimalSeparator.Length; 318while (i < format.Length) 513for (int i = 0; i < format.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Globalization\TimeSpanParse.cs (15)
188if ((uint)pos >= (uint)value.Length) 205if ((uint)++pos >= (uint)value.Length || (uint)(digit = value[pos] - '0') > 9) 225while ((uint)++pos < (uint)value.Length) 248while ((uint)++pos < (uint)value.Length && !char.IsAsciiDigit(value[pos])) 258internal bool EOL => _pos >= (_value.Length - 1); 268return (uint)pos < (uint)_value.Length ? 591Debug.Assert(powersOfTen.Length == MaxFractionDigits + 1); 1230if (format.Length == 0) 1235if (format.Length == 1) 1269while ((uint)i < (uint)format.Length) 1451for (int i = 0; i < span.Length; i++) 1479if (_pos < str.Length) 1485_ch = (uint)pos < (uint)str.Length ? 1559if (_pos < _str.Length) 1669if (input.Length == 0)
src\libraries\System.Private.CoreLib\src\System\Globalization\UmAlQuraCalendar.cs (1)
230DateMapping[] mapping = new DateMapping[rawData.Length / 4];
src\libraries\System.Private.CoreLib\src\System\Guid.cs (31)
67if (b.Length != 16) 84if (b.Length != 16) 408if (format.Length != 1) 443if (format.Length != 1 || input.Length < 32) // Minimal length we can parse ('N' format) 477if (guidString.Length < 32) // Minimal length we can parse ('N' format) 499if (guidString.Length != 38 || guidString[0] != TChar.CastFrom('{') || guidString[37] != TChar.CastFrom('}')) 512if (guidString.Length != 36 || guidString[8] != TChar.CastFrom('-') || guidString[13] != TChar.CastFrom('-') || guidString[18] != TChar.CastFrom('-') || guidString[23] != TChar.CastFrom('-')) 514result.SetFailure(guidString.Length != 36 ? ParseFailure.Format_GuidInvLen : ParseFailure.Format_GuidDashes); 598if (guidString.Length != 32) 641if (guidString.Length != 38 || guidString[0] != TChar.CastFrom('(') || guidString[37] != TChar.CastFrom(')')) 668if (guidString.Length == 0 || guidString[0] != TChar.CastFrom('{')) 742if ((uint)guidString.Length <= (uint)(numStart + numLen + 1) || guidString[numStart + numLen + 1] != TChar.CastFrom('{')) 799if (numStart + numLen + 1 >= guidString.Length || guidString[numStart + numLen + 1] != TChar.CastFrom('}')) 806if (numStart + numLen + 1 != guidString.Length - 1) 819Debug.Assert(lookup.Length == 256); 847if (guidString.Length > 0) 854if (guidString.Length > 1 && guidString[0] == TChar.CastFrom('0') && (guidString[1] | TChar.CastFrom(0x20)) == TChar.CastFrom('x')) 862for (; i < guidString.Length && guidString[i] == TChar.CastFrom('0'); i++) ; 866for (; i < guidString.Length; i++) 892for (i = 0; i < charSpan.Length && !char.IsWhiteSpace(charSpan[i]); i++) ; 893if (i == charSpan.Length) 899var chArr = new char[charSpan.Length]; 908for (; i < charSpan.Length; i++) 928while (i < srcUtf8Span.Length) 944if (i == srcUtf8Span.Length) 950Span<byte> destUtf8Span = new byte[srcUtf8Span.Length]; 959while (i < srcUtf8Span.Length) 982i + 1 < str.Length && 1271if (format.Length == 0) 1277if (format.Length != 1)
src\libraries\System.Private.CoreLib\src\System\HashCode.cs (2)
321ref byte end = ref Unsafe.Add(ref pos, value.Length); 323if (value.Length < (sizeof(int) * 4))
src\libraries\System.Private.CoreLib\src\System\Int128.cs (14)
756if (source.Length != 0) 766if (isUnsigned && sbyte.IsNegative(sign) && (source.Length >= Size)) 775if (source.Length > Size) 798if (source.Length >= Size) 800sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - Size); 816for (int i = 0; i < source.Length; i++) 824result |= ((One << ((Size * 8) - 1)) >> (((Size - source.Length) * 8) - 1)); 838if (source.Length != 0) 848if (isUnsigned && sbyte.IsNegative(sign) && (source.Length >= Size)) 857if (source.Length > Size) 880if (source.Length >= Size) 898for (int i = 0; i < source.Length; i++) 904result <<= ((Size - source.Length) * 8); 909result |= ((One << ((Size * 8) - 1)) >> (((Size - source.Length) * 8) - 1));
src\libraries\System.Private.CoreLib\src\System\Int16.cs (9)
304if (source.Length != 0) 314if (isUnsigned && sbyte.IsNegative(sign) && (source.Length >= sizeof(short))) 323if (source.Length > sizeof(short)) 346if (source.Length >= sizeof(short)) 348sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(short)); 379if (source.Length != 0) 389if (isUnsigned && sbyte.IsNegative(sign) && (source.Length >= sizeof(short))) 398if (source.Length > sizeof(short)) 421if (source.Length >= sizeof(short))
src\libraries\System.Private.CoreLib\src\System\Int32.cs (14)
324if (source.Length != 0) 334if (isUnsigned && sbyte.IsNegative(sign) && (source.Length >= sizeof(int))) 343if (source.Length > sizeof(int)) 366if (source.Length >= sizeof(int)) 368sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(int)); 384for (int i = 0; i < source.Length; i++) 392result |= ((1 << ((sizeof(int) * 8) - 1)) >> (((sizeof(int) - source.Length) * 8) - 1)); 406if (source.Length != 0) 416if (isUnsigned && sbyte.IsNegative(sign) && (source.Length >= sizeof(int))) 425if (source.Length > sizeof(int)) 448if (source.Length >= sizeof(int)) 466for (int i = 0; i < source.Length; i++) 472result <<= ((sizeof(int) - source.Length) * 8); 477result |= ((1 << ((sizeof(int) * 8) - 1)) >> (((sizeof(int) - source.Length) * 8) - 1));
src\libraries\System.Private.CoreLib\src\System\Int64.cs (14)
321if (source.Length != 0) 331if (isUnsigned && sbyte.IsNegative(sign) && (source.Length >= sizeof(long))) 340if (source.Length > sizeof(long)) 363if (source.Length >= sizeof(long)) 365sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(long)); 381for (int i = 0; i < source.Length; i++) 389result |= ((1L << ((sizeof(long) * 8) - 1)) >> (((sizeof(long) - source.Length) * 8) - 1)); 403if (source.Length != 0) 413if (isUnsigned && sbyte.IsNegative(sign) && (source.Length >= sizeof(long))) 422if (source.Length > sizeof(long)) 445if (source.Length >= sizeof(long)) 463for (int i = 0; i < source.Length; i++) 469result <<= ((sizeof(long) - source.Length) * 8); 474result |= ((1L << ((sizeof(long) * 8) - 1)) >> (((sizeof(long) - source.Length) * 8) - 1));
src\libraries\System.Private.CoreLib\src\System\IntPtr.cs (14)
326if (source.Length != 0) 336if (isUnsigned && sbyte.IsNegative(sign) && (source.Length >= sizeof(nint_t))) 345if (source.Length > sizeof(nint_t)) 368if (source.Length >= sizeof(nint_t)) 370sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(nint_t)); 386for (int i = 0; i < source.Length; i++) 394result |= (((nint)1 << ((sizeof(nint_t) * 8) - 1)) >> (((sizeof(nint_t) - source.Length) * 8) - 1)); 408if (source.Length != 0) 418if (isUnsigned && sbyte.IsNegative(sign) && (source.Length >= sizeof(nint_t))) 427if (source.Length > sizeof(nint_t)) 450if (source.Length >= sizeof(nint_t)) 468for (int i = 0; i < source.Length; i++) 474result <<= ((sizeof(nint_t) - source.Length) * 8); 479result |= (((nint)1 << ((sizeof(nint_t) * 8) - 1)) >> (((sizeof(nint_t) - source.Length) * 8) - 1));
src\libraries\System.Private.CoreLib\src\System\IO\BinaryWriter.cs (4)
392byte[] array = ArrayPool<byte>.Shared.Rent(buffer.Length); 396Write(array, 0, buffer.Length); 422if (chars.Length <= MaxArrayPoolRentalSize) 427int maxByteCount = _encoding.GetMaxByteCount(chars.Length);
src\libraries\System.Private.CoreLib\src\System\IO\BufferedStream.cs (6)
783int bytesToWrite = Math.Min(_bufferSize - _writePos, buffer.Length); 940totalUserbytes = _writePos + buffer.Length; 942useBuffer = ((uint)totalUserbytes + buffer.Length < (_bufferSize + _bufferSize)); 952Debug.Assert(bytesWritten == buffer.Length); 966Debug.Assert(bytesWritten == buffer.Length); 982buffer.CopyTo(new Span<byte>(_buffer, _writePos, buffer.Length));
src\libraries\System.Private.CoreLib\src\System\IO\DirectoryInfo.cs (3)
91&& ((trimmedNewPath.Length == trimmedCurrentPath.Length) || PathInternal.IsDirectorySeparator(newPath[trimmedCurrentPath.Length])))
src\libraries\System.Private.CoreLib\src\System\IO\Enumeration\FileSystemEntry.cs (1)
38ReadOnlySpan<char> relativePath = Directory.Slice(RootDirectory.Length);
src\libraries\System.Private.CoreLib\src\System\IO\Enumeration\FileSystemEntry.Unix.cs (6)
84if (_fullPath.Length == 0) 86Debug.Assert(Directory.Length + FileName.Length < _pathBuffer.Length, 87$"directory ({Directory.Length} chars) & name ({Directory.Length} chars) too long for buffer ({_pathBuffer.Length} chars)"); 100if (_directoryEntry.NameLength != 0 && _fileName.Length == 0)
src\libraries\System.Private.CoreLib\src\System\IO\Enumeration\FileSystemEnumerableFactory.cs (2)
49if (directoryName.Length != 0) 53expression = expression.Substring(directoryName.Length + 1);
src\libraries\System.Private.CoreLib\src\System\IO\Enumeration\FileSystemName.cs (11)
148if (expression.Length == 0 || name.Length == 0) 154if (expression.Length == 1) 169if (name.Length < expressionEnd.Length) 193int maxState = expression.Length * 2; 219if (nameOffset < name.Length) 246while (expressionOffset < expression.Length) 280for (int offset = nameOffset; offset < name.Length; offset++) 338if (++expressionOffset == expression.Length) 374if (++expressionOffset == expression.Length)
src\libraries\System.Private.CoreLib\src\System\IO\File.cs (5)
1508int preambleSize = preamble.Length; 1523int bytesNeeded = checked(preambleSize + encoding.GetMaxByteCount(Math.Min(contents.Length, ChunkSize))); 1541ReadOnlySpan<char> toEncode = contents.Slice(0, Math.Min(contents.Length, ChunkSize)); 1542contents = contents.Slice(toEncode.Length); 1615if (contents.Length < ChunkSize)
src\libraries\System.Private.CoreLib\src\System\IO\FileStatus.Unix.cs (2)
195Debug.Assert(handle is not null || path.Length > 0); 500Debug.Assert(handle is not null || path.Length > 0);
src\libraries\System.Private.CoreLib\src\System\IO\FileSystem.Unix.cs (1)
353stackDir.Append(mkdirPath.Length);
src\libraries\System.Private.CoreLib\src\System\IO\MemoryStream.cs (2)
636int i = _position + buffer.Length; 658buffer.CopyTo(new Span<byte>(_buffer, _position, buffer.Length));
src\libraries\System.Private.CoreLib\src\System\IO\Path.cs (58)
161int end = path.Length; 197int length = path.Length; 227if (path.Length == result.Length) 238int root = GetPathRoot(path).Length; 257if (path.Length == result.Length) 331for (int i = path.Length - 1; i >= 0; i--) 336return i != path.Length - 1; 390for (int i = 0; i < paths.Length; i++) 417for (int i = firstComponent; i < paths.Length; i++) 448if (path1.Length == 0) 450if (path2.Length == 0) 458if (path1.Length == 0) 461if (path2.Length == 0) 464if (path3.Length == 0) 472if (path1.Length == 0) 475if (path2.Length == 0) 478if (path3.Length == 0) 481if (path4.Length == 0) 552maxSize += paths.Length - 1; 557for (int i = 0; i < paths.Length; i++) 586if (path1.Length == 0 && path2.Length == 0) 589if (path1.Length == 0 || path2.Length == 0) 591ref ReadOnlySpan<char> pathToUse = ref path1.Length == 0 ? ref path2 : ref path1; 592if (destination.Length < pathToUse.Length) 598charsWritten = pathToUse.Length; 603int charsNeeded = path1.Length + path2.Length + (needsSeparator ? 1 : 0); 609destination[path1.Length] = DirectorySeparatorChar; 611path2.CopyTo(destination.Slice(path1.Length + (needsSeparator ? 1 : 0))); 620if (path1.Length == 0 && path2.Length == 0 && path3.Length == 0) 623if (path1.Length == 0) 625if (path2.Length == 0) 627if (path3.Length == 0) 635int charsNeeded = path1.Length + path2.Length + path3.Length + neededSeparators; 646charsWritten += path3.Length; 705Debug.Assert(first.Length > 0 && second.Length > 0, "should have dealt with empty paths"); 716Debug.Assert(first.Length > 0 && second.Length > 0 && third.Length > 0, "should have dealt with empty paths"); 732Debug.Assert(first.Length > 0 && second.Length > 0 && third.Length > 0 && fourth.Length > 0, "should have dealt with empty paths"); 746first.Length + second.Length + third.Length + fourth.Length + state.NeedSeparator1 + state.NeedSeparator2 + state.NeedSeparator3, 752destination = destination.Slice(first.Length); 762destination = destination.Slice(second.Length); 772destination = destination.Slice(third.Length); 781Debug.Assert(fourth.Length == destination.Length);
src\libraries\System.Private.CoreLib\src\System\IO\Path.Unix.cs (1)
104int totalByteCount = checked(tempPathByteCount + fileTemplate.Length + 1);
src\libraries\System.Private.CoreLib\src\System\IO\RandomAccess.Unix.cs (2)
109int bytesToWrite = GetNumberOfBytesToWrite(buffer.Length); 134if (bytesWritten == buffer.Length)
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\BufferedFileStreamStrategy.cs (5)
499if (numBytes >= source.Length) 502_writePos += source.Length; 522if (source.Length >= _bufferSize) 541else if (source.Length == 0) 549_writePos = source.Length;
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\OSFileStreamStrategy.cs (1)
245_filePosition += buffer.Length;
src\libraries\System.Private.CoreLib\src\System\IO\Stream.cs (2)
914byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 918Write(sharedBuffer, 0, buffer.Length);
src\libraries\System.Private.CoreLib\src\System\IO\StreamReader.cs (10)
174int preambleLength = encoding.Preamble.Length; 551Debug.Assert(_bytePos < preamble.Length, "_compressPreamble was called with the current bytePos greater than the preamble buffer length. Are two threads using this StreamReader at the same time?"); 552int len = Math.Min(_byteLen, preamble.Length); 565Debug.Assert(_bytePos <= preamble.Length, "possible bug in _compressPreamble. Are two threads using this StreamReader at the same time?"); 567if (_bytePos == preamble.Length) 570CompressBuffer(preamble.Length); 596Debug.Assert(_bytePos <= _encoding.Preamble.Length, "possible bug in _compressPreamble. Are two threads using this StreamReader at the same time?"); 700Debug.Assert(_bytePos <= _encoding.Preamble.Length, "possible bug in _compressPreamble. Are two threads using this StreamReader at the same time?"); 1138Debug.Assert(_bytePos <= _encoding.Preamble.Length, "possible bug in _compressPreamble. Are two threads using this StreamReader at the same time?"); 1333Debug.Assert(_bytePos <= _encoding.Preamble.Length, "possible bug in _compressPreamble. Are two threads using this StreamReader at the same time?");
src\libraries\System.Private.CoreLib\src\System\IO\StreamWriter.cs (6)
292if (preamble.Length > 0) 403if (buffer.Length <= 4 && // Threshold of 4 chosen based on perf experimentation 404buffer.Length <= _charLen - _charPos) 408for (int i = 0; i < buffer.Length; i++) 428int count = buffer.Length; 503int estimatedLength = checked((format?.Length ?? 0) + args.Length * 8);
src\libraries\System.Private.CoreLib\src\System\IO\TextWriter.cs (4)
162char[] array = ArrayPool<char>.Shared.Rent(buffer.Length); 167Write(array, 0, buffer.Length); 366char[] array = ArrayPool<char>.Shared.Rent(buffer.Length); 371WriteLine(array, 0, buffer.Length);
src\libraries\System.Private.CoreLib\src\System\IO\UnmanagedMemoryStream.cs (4)
632long n = pos + buffer.Length; 663if (bytesLeft < buffer.Length) 672SpanHelpers.Memmove(ref *(pointer + pos + _offset), ref MemoryMarshal.GetReference(buffer), (nuint)buffer.Length); 684SpanHelpers.Memmove(ref *(_mem + pos), ref MemoryMarshal.GetReference(buffer), (nuint)buffer.Length);
src\libraries\System.Private.CoreLib\src\System\Marvin.cs (1)
23public static int ComputeHash32(ReadOnlySpan<byte> data, ulong seed) => ComputeHash32(ref MemoryMarshal.GetReference(data), (uint)data.Length, (uint)seed, (uint)(seed >> 32));
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.cs (310)
337span.Length); 344span.Length); 351span.Length); 358span.Length); 362return SpanHelpers.Contains(ref MemoryMarshal.GetReference(span), value, span.Length); 816span.Length); 823span.Length); 830span.Length); 837span.Length); 841return SpanHelpers.IndexOfAnyExcept(ref MemoryMarshal.GetReference(span), value, span.Length); 865span.Length); 872span.Length); 879span.Length); 886span.Length); 893for (int i = 0; i < span.Length; i++) 911for (int i = 0; i < span.Length; i++) 944span.Length); 952span.Length); 956return SpanHelpers.IndexOfAnyExcept(ref MemoryMarshal.GetReference(span), value0, value1, span.Length); 982span.Length); 990span.Length); 997for (int i = 0; i < span.Length; i++) 1016for (int i = 0; i < span.Length; i++) 1052span.Length); 1061span.Length); 1065return SpanHelpers.IndexOfAnyExcept(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length); 1093span.Length); 1102span.Length); 1109for (int i = 0; i < span.Length; i++) 1128for (int i = 0; i < span.Length; i++) 1156span.Length); 1166span.Length); 1170return SpanHelpers.IndexOfAnyExcept(ref MemoryMarshal.GetReference(span), value0, value1, value2, value3, span.Length); 1183switch (values.Length) 1206if (sizeof(T) == sizeof(byte) && values.Length == 5) 1217span.Length); 1219else if (sizeof(T) == sizeof(short) && values.Length == 5) 1230span.Length); 1238span.Length, 1240values.Length); 1243for (int i = 0; i < span.Length; i++) 1266switch (values.Length) 1281for (int i = 0; i < span.Length; i++) 1394span.Length); 1401span.Length); 1408span.Length); 1415span.Length); 1419return SpanHelpers.LastIndexOfAnyExcept(ref MemoryMarshal.GetReference(span), value, span.Length); 1443span.Length); 1450span.Length); 1457span.Length); 1464span.Length); 1471for (int i = span.Length - 1; i >= 0; i--) 1489for (int i = span.Length - 1; i >= 0; i--) 1522span.Length); 1530span.Length); 1534return SpanHelpers.LastIndexOfAnyExcept(ref MemoryMarshal.GetReference(span), value0, value1, span.Length); 1560span.Length); 1568span.Length); 1575for (int i = span.Length - 1; i >= 0; i--) 1594for (int i = span.Length - 1; i >= 0; i--) 1630span.Length); 1639span.Length); 1643return SpanHelpers.LastIndexOfAnyExcept(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length); 1671span.Length); 1680span.Length); 1687for (int i = span.Length - 1; i >= 0; i--) 1707for (int i = span.Length - 1; i >= 0; i--) 1735span.Length); 1745span.Length); 1749return SpanHelpers.LastIndexOfAnyExcept(ref MemoryMarshal.GetReference(span), value0, value1, value2, value3, span.Length); 1762switch (values.Length) 1769return span.Length - 1; 1786if (sizeof(T) == sizeof(byte) && values.Length == 5) 1797span.Length); 1799else if (sizeof(T) == sizeof(short) && values.Length == 5) 1810span.Length); 1818span.Length, 1820values.Length); 1823for (int i = span.Length - 1; i >= 0; i--) 1846switch (values.Length) 1849return span.Length - 1; 1861for (int i = span.Length - 1; i >= 0; i--) 1923span.Length); 1932span.Length); 1941span.Length); 1950span.Length); 1954return SpanHelpers.IndexOfAnyInRange(ref MemoryMarshal.GetReference(span), lowInclusive, highInclusive, span.Length); 1988span.Length); 1997span.Length); 2006span.Length); 2015span.Length); 2019return SpanHelpers.IndexOfAnyExceptInRange(ref MemoryMarshal.GetReference(span), lowInclusive, highInclusive, span.Length); 2053span.Length); 2062span.Length); 2071span.Length); 2080span.Length); 2084return SpanHelpers.LastIndexOfAnyInRange(ref MemoryMarshal.GetReference(span), lowInclusive, highInclusive, span.Length); 2118span.Length); 2127span.Length); 2136span.Length); 2145span.Length); 2149return SpanHelpers.LastIndexOfAnyExceptInRange(ref MemoryMarshal.GetReference(span), lowInclusive, highInclusive, span.Length); 2190span.Length); 2196span.Length); 2202span.Length); 2208span.Length); 2211return SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), value, span.Length); 2231span.Length); 2237span.Length); 2243span.Length); 2249span.Length); 2255for (int i = 0; i < span.Length; i++) 2272for (int i = 0; i < span.Length; i++) 2298span.Length, 2300value.Length); 2305span.Length, 2307value.Length); 2310return SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length); 2327span.Length, 2329value.Length); 2334span.Length, 2336value.Length); 2342if (value.Length == 0) 2386span.Length); 2393span.Length); 2400span.Length); 2407span.Length); 2411return SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), value, span.Length); 2432span.Length); 2439span.Length); 2446span.Length); 2453span.Length); 2460for (int i = span.Length - 1; i >= 0; i--) 2478for (int i = span.Length - 1; i >= 0; i--) 2505span.Length, 2507value.Length); 2513span.Length, 2515value.Length); 2519return SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length); 2537span.Length, 2539value.Length); 2545span.Length, 2547value.Length); 2554if (value.Length == 0) 2556return span.Length; 2561int pos = span.Length; 2650span.Length); 2658span.Length); 2662return SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length); 2685span.Length); 2693span.Length); 2700for (int i = 0; i < span.Length; i++) 2718for (int i = 0; i < span.Length; i++) 2751span.Length); 2760span.Length); 2764return SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length); 2789span.Length); 2798span.Length); 2805for (int i = 0; i < span.Length; i++) 2824for (int i = 0; i < span.Length; i++) 2853switch (values.Length) 2859return SpanHelpers.IndexOfValueType(ref spanRef, valueRef, span.Length); 2866span.Length); 2874span.Length); 2883span.Length); 2893span.Length); 2901return values.Length switch 29041 => SpanHelpers.IndexOfValueType(ref spanRef, valueRef, span.Length), 2909span.Length), 2915span.Length), 2922span.Length), 2930span.Length), 2931_ => ProbabilisticMap.IndexOfAny(ref Unsafe.As<short, char>(ref spanRef), span.Length, ref Unsafe.As<short, char>(ref valueRef), values.Length), 2936return SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length); 2947switch (values.Length) 2964for (int i = 0; i < span.Length; i++) 3070span.Length); 3078span.Length); 3082return SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length); 3105span.Length); 3113span.Length); 3120for (int i = span.Length - 1; i >= 0; i--) 3139for (int i = span.Length - 1; i >= 0; i--) 3172span.Length); 3181span.Length); 3185return SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length); 3210span.Length); 3219span.Length); 3226for (int i = span.Length - 1; i >= 0; i--) 3246for (int i = span.Length - 1; i >= 0; i--) 3275switch (values.Length) 3281return SpanHelpers.LastIndexOfValueType(ref spanRef, valueRef, span.Length); 3288span.Length); 3296span.Length); 3305span.Length); 3315span.Length); 3323return values.Length switch 33261 => SpanHelpers.LastIndexOfValueType(ref spanRef, valueRef, span.Length), 3331span.Length), 3337span.Length), 3344span.Length), 3352span.Length), 3353_ => ProbabilisticMap.LastIndexOfAny(ref Unsafe.As<short, char>(ref spanRef), span.Length, ref Unsafe.As<short, char>(ref valueRef), values.Length), 3358return SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length); 3369switch (values.Length) 3386for (int i = span.Length - 1; i >= 0; i--) 3421int length = span.Length; 3422int otherLength = other.Length; 3457if (span.Length != other.Length) 3472((uint)span.Length) * (nuint)sizeof(T)); // If this multiplication overflows, the Span we got overflows the entire address range. There's no happy outcome for this API in such a case so we choose not to take the overhead of checking. 3476for (int i = 0; i < span.Length; i++) 3490for (int i = 0; i < span.Length; i++) 3513span.Length, 3515other.Length); 3520span.Length, 3522other.Length); 3524return SpanHelpers.SequenceCompareTo(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(other), other.Length); 3532int minLength = Math.Min(span.Length, other.Length); 3544return span.Length.CompareTo(other.Length); 3563int valueLength = value.Length; 3566return valueLength <= span.Length && 3573return valueLength <= span.Length && SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(value), valueLength); 3584value.Length <= span.Length && 3585SequenceEqual(span.Slice(0, value.Length), value, comparer); 3603int spanLength = span.Length; 3604int valueLength = value.Length; 3629value.Length <= span.Length && 3630SequenceEqual(span.Slice(span.Length - value.Length), value, comparer); 3641span.Length != 0 && (span[0]?.Equals(value) ?? (object?)value is null); 3653span.Length != 0 && 3665span.Length != 0 && (span[^1]?.Equals(value) ?? (object?)value is null); 3677span.Length != 0 && 4101return (nuint)byteOffset < (nuint)((nint)span.Length * sizeof(T)) || 4102(nuint)byteOffset > (nuint)(-((nint)other.Length * sizeof(T))); 4120if ((nuint)byteOffset < (nuint)((nint)span.Length * sizeof(T)) || 4121(nuint)byteOffset > (nuint)(-((nint)other.Length * sizeof(T)))) 4217/// no larger element, the bitwise complement of <see cref="ReadOnlySpan{T}.Length"/>. 4239/// no larger element, the bitwise complement of <see cref="ReadOnlySpan{T}.Length"/>. 4265/// no larger element, the bitwise complement of <see cref="ReadOnlySpan{T}.Length"/>. 4582nuint length = (uint)source.Length; 4598((nuint)byteOffset < (nuint)((nint)source.Length * sizeof(T)) || 4666nuint length = (uint)source.Length; 4682((nuint)byteOffset < (nuint)((nint)source.Length * sizeof(T)) || 4738for (int i = 0; i < source.Length; i++) 4750for (int i = 0; i < source.Length; i++) 4774if (source.Length > destination.Length) 4786ReplaceAny(destination.Slice(0, source.Length), values, newValue); 4824if (source.Length > destination.Length) 4836ReplaceAnyExcept(destination.Slice(0, source.Length), values, newValue); 4885nuint length = Math.Min((nuint)(uint)span.Length, (nuint)(uint)other.Length); 4912for (int i = 0; i < span.Length; i++) 4920return span.Length; 4944for (int i = 0; i < span.Length; i++) 4952return span.Length; 4959if (other.Length > span.Length) 4961other = other.Slice(0, span.Length); 4963else if (span.Length > other.Length) 4965span = span.Slice(0, other.Length); 4967Debug.Assert(span.Length == other.Length); 5097int startInclusive = 0, endExclusive = source.Length; 5150if (separators.IsEmpty && destination.Length > source.Length) 5191if (separators.IsEmpty && destination.Length > source.Length) 5224if (source.Length == 0) 5240endExclusive = source.Length; 5274separatorLength = separatorOrSeparators.Length; 5327endExclusive = source.Length; 5384span.Length); 5391span.Length); 5398span.Length); 5405span.Length); 5412span.Length); 5433span.Length); 5440span.Length); 5447span.Length); 5454span.Length); 5462for (int i = 0; i < span.Length; i++) 5481for (int i = 0; i < span.Length; i++) 5510switch (value.Length) 5524span = span.Slice(pos + value.Length); 5540switch (value.Length) 5554span = span.Slice(pos + value.Length); 5759format.ValidateNumberOfArgs(args.Length); 5760return args.Length switch 5876if (typeof(T) == typeof(char) && separators.Length == 0) 5896_splitMode = separator.Length == 0 ? 5934separatorLength = _separatorBuffer.Length; 5957_startNext = _endCurrent = _source.Length; 6245_pos += value.Length; 6265int paddingRequired = alignment - value.Length; 6274Debug.Assert(alignment > value.Length); 6280_pos += value.Length; 6289_pos += value.Length;
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.Globalization.cs (34)
19for (int i = 0; i < span.Length; i++) 72if (span.Length != value.Length) 74if (value.Length == 0) // span.Length == value.Length == 0 82if (span.Length != value.Length) 84if (value.Length == 0) // span.Length == value.Length == 0 86return Ordinal.EqualsIgnoreCase(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(value), span.Length); 111if (span.Length == 0 || other.Length == 0) 112return span.Length - other.Length; 117return Ordinal.CompareStringIgnoreCase(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(other), other.Length); 133return SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length); 166span.Length, 168value.Length); 205if (destination.Length < source.Length) 212return source.Length; 229if (destination.Length < source.Length) 236return source.Length; 257if (destination.Length < source.Length) 264return source.Length; 281if (destination.Length < source.Length) 288return source.Length; 323=> value.Length <= span.Length 325ref Unsafe.Add(ref MemoryMarshal.GetReference(span), span.Length - value.Length), 327value.Length); 361=> value.Length <= span.Length 362&& Ordinal.EqualsIgnoreCase(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(value), value.Length);
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.Globalization.Utf8.cs (8)
19if ((span.Length | value.Length) == 0) // span.Length == value.Length == 0 24return Ordinal.EqualsIgnoreCaseUtf8(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length); 70if ((span.Length | value.Length) == 0) // span.Length == value.Length == 0 75return Ordinal.StartsWithIgnoreCaseUtf8(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length);
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.Trim.cs (47)
136for (; start < span.Length; start++) 146for (; start < span.Length; start++) 167Debug.Assert((uint)start <= span.Length); 169int end = span.Length - 1; 204if (trimElements.Length > 1) 212if (trimElements.Length == 1) 229if (trimElements.Length > 1) 234if (trimElements.Length == 1) 251if (trimElements.Length > 1) 256if (trimElements.Length == 1) 273if (trimElements.Length > 1) 281if (trimElements.Length == 1) 298if (trimElements.Length > 1) 303if (trimElements.Length == 1) 320if (trimElements.Length > 1) 325if (trimElements.Length == 1) 342if (trimElements.Length > 1) 349if (trimElements.Length == 1) 366if (trimElements.Length > 1) 371if (trimElements.Length == 1) 388if (trimElements.Length > 1) 393if (trimElements.Length == 1) 410if (trimElements.Length > 1) 417if (trimElements.Length == 1) 434if (trimElements.Length > 1) 439if (trimElements.Length == 1) 456if (trimElements.Length > 1) 461if (trimElements.Length == 1) 478for (; start < span.Length; start++) 499Debug.Assert((uint)start <= span.Length); 501int end = span.Length - 1; 573if (span.Length == 0 || 584for (; start < span.Length; start++) 592int end = span.Length - 1; 611for (; start < span.Length; start++) 628int end = span.Length - 1; 648for (; start < span.Length; start++) 656int end = span.Length - 1; 676for (; start < span.Length; start++) 694int end = span.Length - 1; 731for (; start < span.Length; start++) 733for (int i = 0; i < trimChars.Length; i++) 763int end = span.Length - 1; 766for (int i = 0; i < trimChars.Length; i++) 843for (; start < span.Length; start++) 862Debug.Assert((uint)start <= span.Length); 864int end = span.Length - 1;
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.Trim.Utf8.cs (3)
22if (span.Length == 0) 48while (span.Length != 0) 60while (span.Length != 0)
src\libraries\System.Private.CoreLib\src\System\Net\WebUtility.cs (17)
38ValueStringBuilder sb = valueSpan.Length < 80 ? 40new ValueStringBuilder(valueSpan.Length + 200); 67ValueStringBuilder sb = valueSpan.Length < 80 ? 69new ValueStringBuilder(valueSpan.Length + 200); 80for (int i = 0; i < input.Length; i++) 118if ((uint)(i + 1) < (uint)input.Length && 167ValueStringBuilder sb = valueSpan.Length <= 256 ? 169new ValueStringBuilder(valueSpan.Length); 192ValueStringBuilder sb = valueSpan.Length <= 256 ? 194new ValueStringBuilder(valueSpan.Length); 205for (int i = 0; i < input.Length; i++) 280for (int i = input.IndexOfAnyExcept(s_htmlAsciiNonEncodingChars); (uint)i < (uint)input.Length; i++) 388for (int i = source.IndexOfAnyExcept(s_safeUrlBytes); (uint)i < (uint)source.Length; i++) 945var dictionary = new Dictionary<ulong, char>(tableData.Length / (sizeof(ulong) + sizeof(char))); 963if (entity.Length <= 8) 978Debug.Assert(entity.Length <= 8); 981for (int i = 0; i < entity.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Number.BigInteger.cs (1)
912Debug.Assert((Pow10BigNumTableIndices[^1] + MaxBlockCount + 2) == Pow10BigNumTable.Length);
src\libraries\System.Private.CoreLib\src\System\Number.Formatting.cs (15)
702if (format.Length == 0) 818if (format.Length == 0) 934if (format.Length == 0) 1050if (format.Length == 0) 1167if (format.Length == 0) 1285if (format.Length == 0) 1410int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits((uint)(-value))) + sNegative.Length; 1421Debug.Assert(p == buffer + sNegative.Length); 1423for (int i = sNegative.Length - 1; i >= 0; i--) 1843int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits((ulong)(-value))) + sNegative.Length; 1854Debug.Assert(p == buffer + sNegative.Length); 1856for (int i = sNegative.Length - 1; i >= 0; i--) 2273int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(absValue)) + sNegative.Length; 2284Debug.Assert(p == buffer + sNegative.Length); 2286for (int i = sNegative.Length - 1; i >= 0; i--)
src\libraries\System.Private.CoreLib\src\System\Number.Grisu3.cs (6)
476Debug.Assert((uint)(exponentGuess) < SmallPowersOfTen.Length); 820Debug.Assert(CachedPowersSignificand.Length == CachedPowersBinaryExponent.Length); 821Debug.Assert(CachedPowersSignificand.Length == CachedPowersDecimalExponent.Length); 826Debug.Assert((uint)(index) < CachedPowersSignificand.Length);
src\libraries\System.Private.CoreLib\src\System\Number.Parsing.cs (24)
255if ((uint)index >= (uint)value.Length) 275if ((uint)index >= (uint)value.Length) 285if ((uint)index >= (uint)value.Length) 297if ((uint)index >= (uint)value.Length) 313index += positiveSign.Length; 315if ((uint)index >= (uint)value.Length) 324index += negativeSign.Length; 326if ((uint)index >= (uint)value.Length) 347if ((uint)index >= (uint)value.Length) 370if ((uint)index >= (uint)value.Length) 394if ((uint)index >= (uint)value.Length) 432if ((uint)index >= (uint)value.Length) 446if ((uint)index >= (uint)value.Length) 495for (index++; index < value.Length; index++) 504if ((uint)index >= (uint)value.Length) 576if ((uint)index >= (uint)value.Length) 597if ((uint)index >= (uint)value.Length) 616if ((uint)index >= (uint)value.Length) 635if ((uint)index >= (uint)value.Length) 653if ((uint)index >= (uint)value.Length) 697for (index++; index < value.Length; index++) 707if ((uint)index >= (uint)value.Length) 988valueTrim = valueTrim.Slice(positiveSign.Length); 1009if (SpanEqualsOrdinalIgnoreCase(valueTrim.Slice(negativeSign.Length), nanSymbol))
src\libraries\System.Private.CoreLib\src\System\Numerics\INumberBase.cs (4)
310int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length); 444int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length); 546int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length); 593int textMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Text.Length);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector.cs (1)
755if (values.Length < Vector<T>.Count)
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector_1.cs (2)
92if (values.Length < Count) 110if (values.Length < Vector<byte>.Count)
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector2.cs (1)
407if (values.Length < ElementCount)
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector3.cs (1)
442if (values.Length < ElementCount)
src\libraries\System.Private.CoreLib\src\System\ParseNumbers.cs (7)
35int length = s.Length; 123int length = s.Length; 208for (; localIndex < s.Length && char.IsWhiteSpace(s[localIndex]); localIndex++) ; 223while (i < s.Length && IsDigit(s[i], radix, out int value)) 250while (i < s.Length && IsDigit(s[i], radix, out int value)) 284while (i < s.Length && IsDigit(s[i], radix, out int value)) 309while (i < s.Length && IsDigit(s[i], radix, out int value))
src\libraries\System.Private.CoreLib\src\System\Random.cs (6)
209choices.Length <= 256) 215if (BitOperations.IsPow2(choices.Length)) 221int mask = choices.Length - 1; 247int mask = (int)BitOperations.RoundUpToPowerOf2((uint)choices.Length) - 1; 270if (masked < (uint)choices.Length) 286destination[i] = choices[Next(choices.Length)];
src\libraries\System.Private.CoreLib\src\System\ReadOnlySpan.cs (2)
227return new ReadOnlySpan<T>(ref Unsafe.As<TDerived, T>(ref items._reference), items.Length); 255if (index < _span.Length)
src\libraries\System.Private.CoreLib\src\System\Reflection\AssemblyName.cs (1)
363charsToCopy = stringToEscape.Length;
src\libraries\System.Private.CoreLib\src\System\Reflection\EventInfo.cs (1)
50for (int i = 0; i < p.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Reflection\InvokerEmitUtil.cs (3)
50for (int i = 0; i < parameters.Length; i++) 118for (int i = 0; i < parameters.Length; i++) 175for (int i = 0; i < parameters.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Reflection\MethodBase.cs (3)
129if (paramInfo.Length == 0) 134Type[] parameterTypes = new Type[paramInfo.Length]; 135for (int i = 0; i < paramInfo.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Reflection\MethodBaseInvoker.cs (1)
354for (int i = 0; i < parameters.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Reflection\NullabilityInfoContext.cs (2)
119for (int i = 0; i < parameters.Length; i++) 214ParameterInfo parameter = parameters[parameters.Length - 1];
src\libraries\System.Private.CoreLib\src\System\Reflection\ParameterInfo.cs (2)
84if (PositionImpl < args.Length) 93if (PositionImpl > -1 && PositionImpl < args.Length)
src\libraries\System.Private.CoreLib\src\System\Reflection\TypeNameResolver.cs (2)
109Type[] genericTypes = new Type[genericArgs.Length]; 110for (int i = 0; i < genericArgs.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\DefaultInterpolatedStringHandler.cs (7)
409_pos += value.Length; 430int paddingRequired = alignment - value.Length; 440EnsureCapacityForAdditionalChars(value.Length + paddingRequired); 444_pos += value.Length; 453_pos += value.Length; 616Grow(value.Length); 618_pos += value.Length;
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\RuntimeHelpers.cs (1)
139if ((int)srcET >= primitiveWidenTable.Length)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Java\JavaMarshal.cs (1)
72(nuint)unreachableObjectHandles.Length,
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\ReadOnlySpanMarshaller.cs (5)
50numElements = managed.Length; 114if (managed.Length <= buffer.Length) 116_span = buffer[0..managed.Length]; 120int bufferSize = checked(managed.Length * sizeof(TUnmanagedElement)); 122_span = new Span<TUnmanagedElement>(_allocatedMemory, managed.Length);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\MemoryMarshal.cs (6)
61checked(span.Length * sizeof(T))); 100internal static unsafe ref T GetNonNullPinnableReference<T>(ReadOnlySpan<T> span) => ref (span.Length != 0) ? ref Unsafe.AsRef(in span._reference) : ref Unsafe.AsRef<T>((void*)1); 182uint fromLength = (uint)span.Length; 475if (sizeof(T) > source.Length) 494if (sizeof(T) > (uint)source.Length) 578if (sizeof(T) > (uint)span.Length)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeBuffer.cs (2)
328SpaceCheck(ptr, checked((nuint)(alignedSizeofT * data.Length))); 336for (int i = 0; i < data.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\TypeMapLazyDictionary.cs (2)
112int needed = (utf8TypeName.Length < 1024) 113? Encoding.UTF8.GetMaxCharCount(utf8TypeName.Length)
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\ISimdVector_2.cs (1)
253if (values.Length < TSelf.ElementCount)
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector128.cs (1)
936if (values.Length < Vector128<T>.Count)
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector256.cs (1)
952if (values.Length < Vector256<T>.Count)
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector512.cs (1)
853if (values.Length < Vector512<T>.Count)
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector64.cs (1)
925if (values.Length < Vector64<T>.Count)
src\libraries\System.Private.CoreLib\src\System\Runtime\Versioning\FrameworkName.cs (2)
163if (value.Length > 0 && (value[0] == VersionValuePrefix || value[0] == 'V')) 181if (value.Length > 0)
src\libraries\System.Private.CoreLib\src\System\RuntimeType.cs (1)
659finalist.GetParametersAsSpan().Length == 0 &&
src\libraries\System.Private.CoreLib\src\System\SByte.cs (5)
307if (source.Length != 0) 326if (source.Length > sizeof(sbyte)) 348result = (sbyte)Unsafe.Add(ref MemoryMarshal.GetReference(source), source.Length - sizeof(sbyte)); 360if (source.Length != 0) 379if (source.Length > sizeof(sbyte))
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any1CharPackedIgnoreCaseSearchValues.cs (2)
37PackedSpanHelpers.IndexOfAnyIgnoreCase(ref MemoryMarshal.GetReference(span), _lowerCase, span.Length); 42PackedSpanHelpers.IndexOfAnyExceptIgnoreCase(ref MemoryMarshal.GetReference(span), _lowerCase, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any1CharPackedSearchValues.cs (2)
27PackedSpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), _e0, span.Length); 32PackedSpanHelpers.IndexOfAnyExcept(ref MemoryMarshal.GetReference(span), _e0, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any1SearchValues.cs (5)
20Debug.Assert(values.Length == 1); 36SpanHelpers.NonPackedIndexOfValueType<TImpl, SpanHelpers.DontNegate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, span.Length); 40SpanHelpers.NonPackedIndexOfValueType<TImpl, SpanHelpers.Negate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, span.Length); 44SpanHelpers.LastIndexOfValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, span.Length); 48SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any2CharPackedIgnoreCaseSearchValues.cs (4)
44PackedSpanHelpers.IndexOfAnyIgnoreCase(ref MemoryMarshal.GetReference(span), _e0, _e1, span.Length); 49PackedSpanHelpers.IndexOfAnyExceptIgnoreCase(ref MemoryMarshal.GetReference(span), _e0, _e1, span.Length); 57ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 65ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any2CharPackedSearchValues.cs (2)
27PackedSpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), _e0, _e1, span.Length); 32PackedSpanHelpers.IndexOfAnyExcept(ref MemoryMarshal.GetReference(span), _e0, _e1, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any2SearchValues.cs (5)
20Debug.Assert(values.Length == 2); 36SpanHelpers.NonPackedIndexOfAnyValueType<TImpl, SpanHelpers.DontNegate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, span.Length); 40SpanHelpers.NonPackedIndexOfAnyValueType<TImpl, SpanHelpers.Negate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, span.Length); 44SpanHelpers.LastIndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, span.Length); 48SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any3CharPackedSearchValues.cs (2)
27PackedSpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), _e0, _e1, _e2, span.Length); 32PackedSpanHelpers.IndexOfAnyExcept(ref MemoryMarshal.GetReference(span), _e0, _e1, _e2, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any3SearchValues.cs (5)
20Debug.Assert(values.Length == 3); 36SpanHelpers.NonPackedIndexOfAnyValueType<TImpl, SpanHelpers.DontNegate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, span.Length); 40SpanHelpers.NonPackedIndexOfAnyValueType<TImpl, SpanHelpers.Negate<TImpl>>(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, span.Length); 44SpanHelpers.LastIndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, span.Length); 48SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any4SearchValues.cs (5)
20Debug.Assert(values.Length == 4); 39SpanHelpers.IndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, span.Length); 43SpanHelpers.IndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, span.Length); 47SpanHelpers.LastIndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, span.Length); 51SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Any5SearchValues.cs (5)
20Debug.Assert(values.Length == 5); 40SpanHelpers.IndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, _e4, span.Length); 44SpanHelpers.IndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, _e4, span.Length); 48SpanHelpers.LastIndexOfAnyValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, _e4, span.Length); 52SpanHelpers.LastIndexOfAnyExceptValueType(ref Unsafe.As<T, TImpl>(ref MemoryMarshal.GetReference(span)), _e0, _e1, _e2, _e3, _e4, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\AnyByteSearchValues.cs (6)
32ref MemoryMarshal.GetReference(span), span.Length, ref _state); 40ref MemoryMarshal.GetReference(span), span.Length, ref _state); 48ref MemoryMarshal.GetReference(span), span.Length, ref _state); 56ref MemoryMarshal.GetReference(span), span.Length, ref _state); 64ref MemoryMarshal.GetReference(span), span.Length, ref _state); 72ref MemoryMarshal.GetReference(span), span.Length, ref _state);
src\libraries\System.Private.CoreLib\src\System\SearchValues\AsciiByteSearchValues.cs (6)
48ref MemoryMarshal.GetReference(span), span.Length, ref _state); 56ref MemoryMarshal.GetReference(span), span.Length, ref _state); 64ref MemoryMarshal.GetReference(span), span.Length, ref _state); 72ref MemoryMarshal.GetReference(span), span.Length, ref _state); 80ref MemoryMarshal.GetReference(span), span.Length, ref _state); 88ref MemoryMarshal.GetReference(span), span.Length, ref _state);
src\libraries\System.Private.CoreLib\src\System\SearchValues\AsciiCharSearchValues.cs (6)
49ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 57ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 65ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 73ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 81ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state); 89ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(span)), span.Length, ref _state);
src\libraries\System.Private.CoreLib\src\System\SearchValues\BitmapCharSearchValues.cs (4)
56IndexOfAny<IndexOfAnyAsciiSearcher.DontNegate>(ref MemoryMarshal.GetReference(span), span.Length); 60IndexOfAny<IndexOfAnyAsciiSearcher.Negate>(ref MemoryMarshal.GetReference(span), span.Length); 64LastIndexOfAny<IndexOfAnyAsciiSearcher.DontNegate>(ref MemoryMarshal.GetReference(span), span.Length); 68LastIndexOfAny<IndexOfAnyAsciiSearcher.Negate>(ref MemoryMarshal.GetReference(span), span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\EmptySearchValues.cs (1)
25span.Length - 1;
src\libraries\System.Private.CoreLib\src\System\SearchValues\IndexOfAnyAsciiSearcher.cs (1)
103if (!IsVectorizationSupported || values.Length > 16)
src\libraries\System.Private.CoreLib\src\System\SearchValues\ProbabilisticCharSearchValues.cs (4)
26ProbabilisticMap.IndexOfAny<SearchValues.TrueConst>(ref MemoryMarshal.GetReference(span), span.Length, ref _map); 29ProbabilisticMapState.IndexOfAnySimpleLoop<SearchValues.TrueConst, IndexOfAnyAsciiSearcher.Negate>(ref MemoryMarshal.GetReference(span), span.Length, ref _map); 32ProbabilisticMap.LastIndexOfAny<SearchValues.TrueConst>(ref MemoryMarshal.GetReference(span), span.Length, ref _map); 35ProbabilisticMapState.LastIndexOfAnySimpleLoop<SearchValues.TrueConst, IndexOfAnyAsciiSearcher.Negate>(ref MemoryMarshal.GetReference(span), span.Length, ref _map);
src\libraries\System.Private.CoreLib\src\System\SearchValues\ProbabilisticMap.cs (2)
49for (int i = 0; i < values.Length; ++i) 110values.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\ProbabilisticMapState.cs (3)
133int modulus = HashHelpers.GetPrime(values.Length); 150modulus = HashHelpers.GetPrime(values.Length); 196if (unique.Count == values.Length)
src\libraries\System.Private.CoreLib\src\System\SearchValues\ProbabilisticWithAsciiCharSearchValues.cs (18)
44if (IndexOfAnyAsciiSearcher.IsVectorizationSupported && span.Length >= Vector128<short>.Count && char.IsAscii(span[0])) 61span.Length, 71span.Length, 76if ((uint)offset >= (uint)span.Length || char.IsAscii(span[offset])) 87span.Length, 105if (IndexOfAnyAsciiSearcher.IsVectorizationSupported && span.Length >= Vector128<short>.Count && char.IsAscii(span[0])) 110span.Length, 114if ((uint)offset >= (uint)span.Length || char.IsAscii(span[offset])) 125span.Length, 141if (IndexOfAnyAsciiSearcher.IsVectorizationSupported && span.Length >= Vector128<short>.Count && char.IsAscii(span[^1])) 160span.Length, 170span.Length, 175if ((uint)offset >= (uint)span.Length || char.IsAscii(span[offset])) 186span.Length, 194if (IndexOfAnyAsciiSearcher.IsVectorizationSupported && span.Length >= Vector128<short>.Count && char.IsAscii(span[^1])) 199span.Length, 203if ((uint)offset >= (uint)span.Length || char.IsAscii(span[offset])) 214span.Length,
src\libraries\System.Private.CoreLib\src\System\SearchValues\RangeCharSearchValues.cs (4)
43? PackedSpanHelpers.IndexOfAnyInRange(ref MemoryMarshal.GetReference(span), _lowInclusive, _rangeInclusive, span.Length) 48span.Length); 53? PackedSpanHelpers.IndexOfAnyExceptInRange(ref MemoryMarshal.GetReference(span), _lowInclusive, _rangeInclusive, span.Length) 58span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\SearchValues.cs (13)
35if (values.Length == 1) 48if (values.Length >= 4 && IndexOfAnyAsciiSearcher.CanUseUniqueLowNibbleSearch(values, maxInclusive)) 53if (values.Length <= 5) 55Debug.Assert(values.Length is 2 or 3 or 4 or 5); 56return values.Length switch 88if (values.Length == 1) 105if (values.Length == 2) 123if (values.Length == 3) 138maxInclusive < 128 && values.Length == 4 && minInclusive > 0) 169if (values.Length == 4) 174if (values.Length == 5) 189if (ShouldUseProbabilisticMap(values.Length, maxInclusive)) 260if (range > values.Length)
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\AsciiStringSearchValuesTeddyBase.cs (19)
157if (Vector512.IsHardwareAccelerated && Avx512Vbmi.IsSupported && span.Length >= CharsPerIterationAvx512 + MatchStartOffsetN2) 162if (Avx2.IsSupported && span.Length >= CharsPerIterationAvx2 + MatchStartOffsetN2) 177if (Vector512.IsHardwareAccelerated && Avx512Vbmi.IsSupported && span.Length >= CharsPerIterationAvx512 + MatchStartOffsetN3) 182if (Avx2.IsSupported && span.Length >= CharsPerIterationAvx2 + MatchStartOffsetN3) 197if (span.Length < CharsPerIterationVector128 + MatchStartOffsetN2) 203ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationVector128); 252Debug.Assert(span.Length >= CharsPerIterationAvx2 + MatchStartOffsetN2); 255ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationAvx2); 304Debug.Assert(span.Length >= CharsPerIterationAvx512 + MatchStartOffsetN2); 307ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationAvx512); 356if (span.Length < CharsPerIterationVector128 + MatchStartOffsetN3) 362ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationVector128); 429Debug.Assert(span.Length >= CharsPerIterationAvx2 + MatchStartOffsetN3); 432ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationAvx2); 484Debug.Assert(span.Length >= CharsPerIterationAvx512 + MatchStartOffsetN3); 487ref char lastSearchSpaceStart = ref Unsafe.Add(ref searchSpace, span.Length - CharsPerIterationAvx512); 548int lengthRemaining = span.Length - offsetFromStart; 595int lengthRemaining = span.Length - offsetFromStart; 640int lengthRemaining = span.Length - offsetFromStart;
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\AhoCorasick.cs (8)
92int remainingLength = span.Length - i; 115if ((uint)i >= (uint)span.Length) 122Debug.Assert((uint)i < (uint)span.Length); 204int remainingLength = span.Length - i; 224if ((uint)i >= (uint)span.Length) 231Debug.Assert((uint)i < (uint)span.Length); 246(uint)(i + 1) < (uint)span.Length && 268Ordinal.ToUpperOrdinal(span.Slice(i, i + 1 == span.Length ? 1 : 2), destination);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\AhoCorasickBuilder.cs (1)
29for (int i = 1; i < values.Length; i++)
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\CharacterFrequencyHelper.cs (1)
89for (int i = 1; i < span.Length; i++)
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\RabinKarp.cs (8)
42Debug.Assert(values.Length <= MaxValues); 112Debug.Assert(span.Length <= MaxInputLength, "Teddy should have handled short inputs."); 118if (span.Length >= hashLength) 120ref char end = ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (uint)(span.Length - hashLength)); 139if (StartsWith<TCaseSensitivity>(ref current, span.Length - startOffset, bucket)) 164Debug.Assert(span.Length <= MaxInputLength, "Teddy should have handled long inputs."); 166if (_hashLength > span.Length) 172Span<char> upperCase = stackalloc char[MaxInputLength].Slice(0, span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\StringSearchValuesHelper.cs (1)
35int availableLength = span.Length - currentOffset;
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\TeddyBucketizer.cs (6)
17Debug.Assert(values.Length <= 8); 22for (int i = 0; i < values.Length; i++) 78Debug.Assert(values.Length > bucketCount, "Should be using a non-bucketized implementation."); 79Debug.Assert(values.Length <= RabinKarp.MaxValues); 83Span<int> bucketIndexes = stackalloc int[RabinKarp.MaxValues].Slice(0, values.Length); 90for (int i = 0; i < values.Length; i++)
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\MultiStringIgnoreCaseSearchValuesFallback.cs (1)
26for (int i = 0; i < span.Length; i++)
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\SingleStringSearchValuesThreeChars.cs (1)
75IndexOf(ref MemoryMarshal.GetReference(span), span.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\StringSearchValues.cs (10)
28if (values.Length == 0) 33if (values.Length == 1) 44var uniqueValues = new HashSet<string>(values.Length, ignoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal); 124if (values.Length == 1) 189if (values.Length > RabinKarp.MaxValues) 259values.Length < TeddyBucketCount && 293Debug.Assert(values.Length > 1); 296if (values.Length > TeddyBucketCount) 318Debug.Assert(values.Length < maxValues); 340Debug.Assert(newValuesCount > values.Length, "Shouldn't have been called if there were no letters present");
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\StringSearchValuesBase.cs (2)
57for (int i = 0; i < span.Length; i++) 71for (int i = span.Length - 1; i >= 0; i--)
src\libraries\System.Private.CoreLib\src\System\Security\SecureString.cs (2)
37_buffer = UnmanagedBuffer.Allocate(GetAlignedByteSize(value.Length)); 38_decryptedLength = value.Length;
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.BinarySearch.cs (1)
20return BinarySearch(ref MemoryMarshal.GetReference(span), span.Length, comparable);
src\libraries\System.Private.CoreLib\src\System\StartupHookProvider.cs (2)
111for (int j = 0; j < disallowedSimpleAssemblyNameChars.Length; j++) 209initializeMethod.GetParametersAsSpan().Length == 0);
src\libraries\System.Private.CoreLib\src\System\String.Comparison.cs (8)
456=> SpanHelpers.SequenceCompareTo(ref MemoryMarshal.GetReference(strA), strA.Length, ref MemoryMarshal.GetReference(strB), strB.Length); 779return Marvin.ComputeHash32(ref Unsafe.As<char, byte>(ref MemoryMarshal.GetReference(value)), (uint)value.Length * 2 /* in bytes, not chars */, (uint)seed, (uint)(seed >> 32)); 812return Marvin.ComputeHash32OrdinalIgnoreCase(ref MemoryMarshal.GetReference(value), value.Length /* in chars, not bytes */, (uint)seed, (uint)(seed >> 32)); 865int length = span.Length; 975int length = span.Length; 1052return GetNonRandomizedHashCodeOrdinalIgnoreCaseSlow(hash1, hash2, span.Slice(span.Length - length)); 1057int length = str.Length;
src\libraries\System.Private.CoreLib\src\System\String.cs (5)
313if (value.Length == 0) 316string result = FastAllocateString(value.Length); 317Buffer.Memmove(ref result._firstChar, ref MemoryMarshal.GetReference(value), (uint)value.Length); 774if (s.Length > MaxLength) 783if (s.Length <= MaxLength)
src\libraries\System.Private.CoreLib\src\System\String.Manipulation.cs (75)
90if (args.Length <= 1) 106var strings = new string[args.Length]; 110for (int i = 0; i < args.Length; i++) 289int length = checked(str0.Length + str1.Length); 299str1.CopyTo(resultSpan.Slice(str0.Length)); 306int length = checked(str0.Length + str1.Length + str2.Length); 316resultSpan = resultSpan.Slice(str0.Length); 319resultSpan = resultSpan.Slice(str1.Length); 328int length = checked(str0.Length + str1.Length + str2.Length + str3.Length); 338resultSpan = resultSpan.Slice(str0.Length); 341resultSpan = resultSpan.Slice(str1.Length); 344resultSpan = resultSpan.Slice(str2.Length); 353int length = checked(str0.Length + str1.Length + str2.Length + str3.Length + str4.Length); 363resultSpan = resultSpan.Slice(str0.Length); 366resultSpan = resultSpan.Slice(str1.Length); 369resultSpan = resultSpan.Slice(str2.Length); 372resultSpan = resultSpan.Slice(str3.Length); 392if (values.Length <= 1) 408for (int i = 0; i < values.Length; i++) 431for (int i = 0; i < values.Length; i++) 542sb.EnsureCapacity(format.Length + args.Length * 8); 638format.ValidateNumberOfArgs(args.Length); 639return args.Length switch 888if (values.Length == 1) 897for (int i = 1; i < values.Length; i++) 1037if (values.Length <= 1) 1044long totalSeparatorsLength = (long)(values.Length - 1) * separator.Length; 1073for (int i = 0; i < values.Length; i++) 1095if (i < values.Length - 1) 1103if (separator.Length == 1) 1109separator.CopyTo(new Span<char>(ref dest, separator.Length)); 1112copiedLength += separator.Length; 1226result.EnsureCapacity(searchSpace.Length); 1413Debug.Assert(indices.Length > 0); 1415long dstLength = this.Length + ((long)(newValue.Length - oldValueLength)) * indices.Length; 1425for (int r = 0; r < indices.Length; r++) 1565if ((uint)idx >= (uint)text.Length) 1579if ((uint)nextCharIdx < (uint)text.Length && text[nextCharIdx] == '\n') 1623if ((uint)idx >= (uint)remaining.Length) break; // no more newline chars 1624stride = remaining[idx] == '\r' && (uint)(idx + 1) < (uint)remaining.Length && remaining[idx + 1] == '\n' ? 2 : 1; 1723if (sepList.Length == 0) 1801if (sepList.Length == 0) 1844if (sepList.Length == 0) 1868int numActualReplaces = (sepList.Length < count) ? sepList.Length : count; 1901int numReplaces = sepList.Length; 1979if (separators.Length == 0) 1981for (int i = 0; i < source.Length; i++) 1991else if (separators.Length <= 3) 1995sep1 = separators.Length > 1 ? separators[1] : sep0; 1996sep2 = separators.Length > 2 ? separators[2] : sep1; 1997if (Vector128.IsHardwareAccelerated && source.Length >= Vector128<ushort>.Count * 2) 2003for (int i = 0; i < source.Length; i++) 2020for (int i = 0; i < source.Length; i++) 2038Debug.Assert(sourceSpan.Length >= Vector128<ushort>.Count); 2039nuint lengthToExamine = (uint)sourceSpan.Length; 2164i += separator.Length; 2165source = source.Slice(index + separator.Length); 2180for (int i = 0; i < source.Length; i++) 2182for (int j = 0; j < separators.Length; j++) 2190if (source[i] == separator[0] && currentSepLength <= source.Length - i) 2378return TrimHelper(pTrimChars, trimChars.Length, TrimType.Both); 2419return TrimHelper(pTrimChars, trimChars.Length, TrimType.Head); 2460return TrimHelper(pTrimChars, trimChars.Length, TrimType.Tail);
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.CaseConversion.cs (2)
170if (source.Length <= destination.Length) 172numElementsToConvert = (uint)source.Length;
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.cs (2)
22IsValidCore(ref MemoryMarshal.GetReference(value), value.Length); 32IsValidCore(ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(value)), value.Length);
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.Equality.cs (18)
25=> left.Length == right.Length 26&& Equals<byte, byte, PlainLoader<byte>>(ref MemoryMarshal.GetReference(left), ref MemoryMarshal.GetReference(right), (uint)right.Length); 30=> left.Length == right.Length 31&& Equals<byte, ushort, WideningLoader>(ref MemoryMarshal.GetReference(left), ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(right)), (uint)right.Length); 39=> left.Length == right.Length 40&& Equals<ushort, ushort, PlainLoader<ushort>>(ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(left)), ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(right)), (uint)right.Length); 176=> left.Length == right.Length 177&& EqualsIgnoreCase<byte, byte, PlainLoader<byte>>(ref MemoryMarshal.GetReference(left), ref MemoryMarshal.GetReference(right), (uint)right.Length); 181=> left.Length == right.Length 182&& EqualsIgnoreCase<byte, ushort, WideningLoader>(ref MemoryMarshal.GetReference(left), ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(right)), (uint)right.Length); 190=> left.Length == right.Length 191&& EqualsIgnoreCase<ushort, ushort, PlainLoader<ushort>>(ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(left)), ref Unsafe.As<char, ushort>(ref MemoryMarshal.GetReference(right)), (uint)right.Length);
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.Transcoding.cs (4)
25if (source.Length <= destination.Length) 27numElementsToConvert = (uint)source.Length; 60if (source.Length <= destination.Length) 62numElementsToConvert = (uint)source.Length;
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.Trimming.cs (2)
57for (; start < value.Length; start++) 67int end = value.Length - 1;
src\libraries\System.Private.CoreLib\src\System\Text\ASCIIEncoding.cs (8)
146return GetByteCountCommon(charsPtr, chars.Length); 321return GetBytesCommon(charsPtr, chars.Length, bytesPtr, bytes.Length); 331int written = GetBytesCommon(charsPtr, chars.Length, bytesPtr, bytes.Length, throwForDestinationOverflow: false); 393int numElementsToConvert = Math.Min(chars.Length, bytes.Length); 488return GetCharCountCommon(bytesPtr, bytes.Length); 612return GetCharsCommon(bytesPtr, bytes.Length, charsPtr, chars.Length); 622int written = GetCharsCommon(bytesPtr, bytes.Length, charsPtr, chars.Length, throwForDestinationOverflow: false); 681int numElementsToConvert = Math.Min(bytes.Length, chars.Length);
src\libraries\System.Private.CoreLib\src\System\Text\CompositeFormat.cs (1)
343if ((uint)pos >= (uint)format.Length)
src\libraries\System.Private.CoreLib\src\System\Text\Decoder.cs (3)
114return GetCharCount(bytesPtr, bytes.Length, flush); 201return GetChars(bytesPtr, bytes.Length, charsPtr, chars.Length, flush); 307Convert(bytesPtr, bytes.Length, charsPtr, chars.Length, flush, out bytesUsed, out charsUsed, out completed);
src\libraries\System.Private.CoreLib\src\System\Text\DecoderFallback.cs (2)
210return (Fallback(remainingBytes.Slice(0, fallbackLength).ToArray(), index: _originalByteCount - remainingBytes.Length)) 217if (Fallback(remainingBytes.Slice(0, fallbackLength).ToArray(), index: _originalByteCount - remainingBytes.Length))
src\libraries\System.Private.CoreLib\src\System\Text\DecoderNLS.cs (3)
211_leftoverByteCount = bytes.Length; 380for (int i = 0; i < srcLeft.Length; i++) 392for (int i = 0; i < srcRight.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Text\Encoder.cs (3)
112return GetByteCount(charsPtr, chars.Length, flush); 198return GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length, flush); 306Convert(charsPtr, chars.Length, bytesPtr, bytes.Length, flush, out charsUsed, out bytesUsed, out completed);
src\libraries\System.Private.CoreLib\src\System\Text\EncoderFallback.cs (2)
137if (chars.Length > 1) 145int index = originalCharCount - chars.Length;
src\libraries\System.Private.CoreLib\src\System\Text\EncoderLatin1BestFitFallback.cs (3)
126int highBound = ArrayCharBestFit.Length; 142Debug.Assert(index + 1 < ArrayCharBestFit.Length, 163Debug.Assert(index + 1 < ArrayCharBestFit.Length,
src\libraries\System.Private.CoreLib\src\System\Text\Encoding.cs (5)
585return GetByteCount(charsPtr, chars.Length); 732return GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length); 787return GetCharCount(bytesPtr, bytes.Length); 881return GetChars(bytesPtr, bytes.Length, charsPtr, chars.Length); 917return string.CreateStringFromEncoding(bytesPtr, bytes.Length, this);
src\libraries\System.Private.CoreLib\src\System\Text\Encoding.Internal.cs (15)
273charsLength: chars.Length, 366charsLength: chars.Length, 550charsLength: chars.Length, 571encoder._charsUsed = originalCharCount - chars.Length; // total number of characters consumed up until now 608Debug.Assert(charsConsumedThisIteration == chars.Length, "If returning NeedMoreData, should out the entire buffer length as chars consumed."); 653charsLength: chars.Length, 697Debug.Assert(originalCharsLength >= chars.Length, "About to report a negative number of chars used?"); 698encoder._charsUsed = originalCharsLength - chars.Length; // number of chars consumed 873bytesLength: bytes.Length, 962bytesLength: bytes.Length, 1153bytesLength: bytes.Length, 1210Debug.Assert(bytesConsumedThisIteration == bytes.Length, "If returning NeedMoreData, should out the entire buffer length as bytes consumed."); 1253bytesLength: bytes.Length, 1294Debug.Assert(originalBytesLength >= bytes.Length, "About to report a negative number of bytes used?"); 1295decoder._bytesUsed = originalBytesLength - bytes.Length; // number of bytes consumed
src\libraries\System.Private.CoreLib\src\System\Text\EncodingTable.cs (10)
53int right = EncodingNameIndices.Length - 2; 57Debug.Assert(EncodingNameIndices.Length == CodePagesByName.Length + 1); 68Debug.Assert(index < EncodingNameIndices.Length - 1); 91Debug.Assert(left < EncodingNameIndices.Length - 1); 111EncodingInfo[] arrayEncodingInfo = new EncodingInfo[(LocalAppContextSwitches.EnableUnsafeUTF7Encoding) ? mappedCodePages.Length : (mappedCodePages.Length - 1)]; 116for (int i = 0; i < mappedCodePages.Length; i++) 142for (int i = 0; i < mappedCodePages.Length; i++) 180Interlocked.CompareExchange<CodePageDataItem?[]?>(ref s_codePageToCodePageData, new CodePageDataItem[MappedCodePages.Length], null);
src\libraries\System.Private.CoreLib\src\System\Text\Latin1Encoding.cs (7)
85return GetByteCountCommon(charsPtr, chars.Length); 233return GetBytesCommon(charsPtr, chars.Length, bytesPtr, bytes.Length); 243int written = GetBytesCommon(charsPtr, chars.Length, bytesPtr, bytes.Length, throwForDestinationOverflow: false); 380return bytes.Length; 528return GetCharsCommon(bytesPtr, bytes.Length, charsPtr, chars.Length); 535if (bytes.Length <= chars.Length) 540charsWritten = GetCharsCommon(bytesPtr, bytes.Length, charsPtr, chars.Length);
src\libraries\System.Private.CoreLib\src\System\Text\Rune.cs (16)
341if (source.Length > 1) 370charsConsumed = source.Length; 446if (source.Length <= 1) 500if (source.Length <= 2) 525if (source.Length <= 3) 577int index = source.Length - 1; 578if ((uint)index < (uint)source.Length) 597if ((uint)index < (uint)source.Length) 621charsConsumed = (int)((uint)(-source.Length) >> 31); // 0 -> 0, all other lengths -> 1 637int index = source.Length - 1; 638if ((uint)index < (uint)source.Length) 672if ((uint)index >= (uint)source.Length) 713if (tempBytesConsumed == source.Length) 839if (input.Length <= 1) 947if (bytesConsumed == utf8Text.Length) 961if (DecodeFromUtf8(utf8Text, out Rune result, out int bytesConsumed) != OperationStatus.Done || bytesConsumed != utf8Text.Length)
src\libraries\System.Private.CoreLib\src\System\Text\SpanLineEnumerator.cs (2)
57if ((uint)idx < (uint)remaining.Length) 61if (remaining[idx] == '\r' && (uint)(idx + 1) < (uint)remaining.Length && remaining[idx + 1] == '\n')
src\libraries\System.Private.CoreLib\src\System\Text\StringBuilder.cs (33)
952long insertingChars = (long)value.Length * count; 963ReplaceInPlaceAtChunk(ref chunk!, ref indexInChunk, ref MemoryMarshal.GetReference(value), value.Length); 1096Append(ref MemoryMarshal.GetReference(value), value.Length); 1279for (int i = 1; i < values.Length; i++) 1404if (value.Length != 0) 1406Insert(index, ref MemoryMarshal.GetReference(value), value.Length); 1699if ((uint)index >= (uint)args.Length) 1746if (itemFormatSpan.Length != 0) 1882format.ValidateNumberOfArgs(args.Length); 1883return args.Length switch 2025if (span.Length != Length) 2040if (!chunk.EqualsOrdinal(span.Slice(span.Length - offset, chunk_length))) 2091if (oldValue.Length == 0) 2110while (oldValue.Length <= remainingChunk.Length) 2121remainingChunk = remainingChunk.Slice(foundPos + oldValue.Length); 2122indexInChunk += oldValue.Length; 2123count -= foundPos + oldValue.Length; 2138int move = remainingChunk.Length - (oldValue.Length - 1); 2145Debug.Assert(oldValue.Length > Math.Min(count, chunk.m_ChunkLength - indexInChunk), 2146$"oldValue.Length = {oldValue.Length}, chunk.m_ChunkLength - indexInChunk = {chunk.m_ChunkLength - indexInChunk}, count == {count}"); 2154indexInChunk += oldValue.Length; 2155count -= oldValue.Length; 2176ReplaceAllInChunk(replacements.AsSpan(), chunk, oldValue.Length, newValue); 2177index += (newValue.Length - oldValue.Length) * replacements.Length; 2362long longDelta = (value.Length - removeCount) * (long)replacements.Length; 2383ReplaceInPlaceAtChunk(ref targetChunk!, ref targetIndexInChunk, ref MemoryMarshal.GetReference<char>(value), value.Length); 2386if ((uint)i >= replacements.Length) 2423for (int i = 0; i < value.Length; i++) 3080int paddingRequired = alignment - value.Length;
src\libraries\System.Private.CoreLib\src\System\Text\TranscodingStream.cs (1)
484int rentalLength = Math.Clamp(buffer.Length, MinWriteRentedArraySize, MaxWriteRentedArraySize);
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8.cs (4)
64inputLength: source.Length, 155inputLength: source.Length, 250inputLength: source.Length, 604_pos += utf8Value.Length;
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.cs (2)
32byte* pFirstInvalidByte = GetPointerToFirstInvalidByte(pUtf8Data, utf8Data.Length, out int utf16CodeUnitCountAdjustment, out _); 36return (index < utf8Data.Length) ? index : -1;
src\libraries\System.Private.CoreLib\src\System\Text\UTF8Encoding.cs (6)
196return GetByteCountCommon(charsPtr, chars.Length); 368return GetBytesCommon(charsPtr, chars.Length, bytesPtr, bytes.Length); 378int written = GetBytesCommon(charsPtr, chars.Length, bytesPtr, bytes.Length, throwForDestinationOverflow: false); 489return GetCharCountCommon(bytesPtr, bytes.Length); 563return GetCharsCommon(bytesPtr, bytes.Length, charsPtr, chars.Length); 573int written = GetCharsCommon(bytesPtr, bytes.Length, charsPtr, chars.Length, throwForDestinationOverflow: false);
src\libraries\System.Private.CoreLib\src\System\Text\ValueStringBuilder.AppendFormat.cs (2)
194if ((uint)index >= (uint)args.Length) 233if (itemFormatSpan.Length != 0)
src\libraries\System.Private.CoreLib\src\System\Threading\CancellationTokenSource.cs (3)
886return tokens.Length switch 954_linkingRegistrations = new CancellationTokenRegistration[tokens.Length]; 956for (int i = 0; i < tokens.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Task.cs (8)
4978for (int i = tasks.Length - 1; i >= 0; i--) 4995AddToList(task, ref waitedOnTaskList, initSize: tasks.Length); 5001if (!taskIsCompleted) AddToList(task, ref waitedOnTaskList, initSize: tasks.Length); 6028tasks.Length != 0 ? new WhenAllPromise(tasks) : CompletedTask; 6038Debug.Assert(tasks.Length != 0, "Expected a non-zero length task array"); 6065_remainingToComplete = tasks.Length; 6544if (tasks.Length == 2) 6944if (tasks.Length != 0)
src\libraries\System.Private.CoreLib\src\System\Threading\WaitHandle.cs (17)
242Debug.Assert(waitHandles.Length > 0); 243Debug.Assert(waitHandles.Length <= MaxWaitHandles); 249for (int i = 0; i < waitHandles.Length; ++i) 264for (int i = 0; i < waitHandles.Length; ++i) 299if (waitHandles.Length == 0) 303if (waitHandles.Length > MaxWaitHandles) 311SafeWaitHandle?[]? safeWaitHandles = RentSafeWaitHandleArray(waitHandles.Length); 319IntPtr[] unsafeWaitHandles = new IntPtr[waitHandles.Length]; 325Span<IntPtr> unsafeWaitHandles = stackalloc IntPtr[waitHandles.Length]; 330if (waitResult >= WaitAbandoned && waitResult < WaitAbandoned + waitHandles.Length) 347for (int i = 0; i < waitHandles.Length; ++i) 367Debug.Assert(safeWaitHandles.Length != 0); 368Debug.Assert(safeWaitHandles.Length <= MaxWaitHandles); 377IntPtr[] unsafeWaitHandles = new IntPtr[safeWaitHandles.Length]; 378for (int i = 0; i < safeWaitHandles.Length; ++i) 387Span<IntPtr> unsafeWaitHandles = stackalloc IntPtr[safeWaitHandles.Length]; 388for (int i = 0; i < safeWaitHandles.Length; ++i)
src\libraries\System.Private.CoreLib\src\System\TimeOnly.cs (3)
666if (format.Length == 1) 966if (format.Length == 0) 971if (format.Length == 1)
src\libraries\System.Private.CoreLib\src\System\TimeZoneInfo.Unix.cs (12)
775if (offset.Length > 0) 931if ((uint)index >= (uint)date.Length || !char.IsAsciiDigit(date[index])) 942} while ((uint)index < (uint)date.Length && char.IsAsciiDigit(date[index])); 946if (julianDay == 0 || julianDay > days[days.Length - 1]) 952while (i < days.Length && julianDay > days[i]) 957Debug.Assert(i > 0 && i < days.Length); 1023if (index < posixFormat.Length && posixFormat[index] == ',') 1028if (index < posixFormat.Length && posixFormat[index] == ',') 1041bool isBracketEnclosed = index < posixFormat.Length && posixFormat[index] == '<'; 1050if (index < posixFormat.Length && posixFormat[index] == '>') 1074if (index < posixFormat.Length && posixFormat[index] == '/') 1090for (; index < posixFormat.Length; index++)
src\libraries\System.Private.CoreLib\src\System\Type.Helpers.cs (1)
513str = str.Slice(0, str.Length - 1);
src\libraries\System.Private.CoreLib\src\System\UInt128.cs (13)
827if (source.Length != 0) 838if ((source.Length > Size) && (source[..^Size].ContainsAnyExcept((byte)0x00))) 849if (source.Length >= Size) 851sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - Size); 867for (int i = 0; i < source.Length; i++) 884if (source.Length != 0) 895if ((source.Length > Size) && (source[Size..].ContainsAnyExcept((byte)0x00))) 906if (source.Length >= Size) 924for (int i = 0; i < source.Length; i++) 1094Debug.Assert(left.Length >= right.Length); 1100for (int i = 0; i < right.Length; i++) 1264Debug.Assert(left.Length >= right.Length); 1272for (int i = 0; i < right.Length; i++)
src\libraries\System.Private.CoreLib\src\System\UInt16.cs (7)
298if (source.Length != 0) 309if ((source.Length > sizeof(ushort)) && (source[..^sizeof(ushort)].ContainsAnyExcept((byte)0x00))) 320if (source.Length >= sizeof(ushort)) 322sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(ushort)); 348if (source.Length != 0) 359if ((source.Length > sizeof(ushort)) && (source[sizeof(ushort)..].ContainsAnyExcept((byte)0x00))) 370if (source.Length >= sizeof(ushort))
src\libraries\System.Private.CoreLib\src\System\UInt32.cs (9)
319if (source.Length != 0) 330if ((source.Length > sizeof(uint)) && (source[..^sizeof(uint)].ContainsAnyExcept((byte)0x00))) 341if (source.Length >= sizeof(uint)) 343sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(uint)); 359for (int i = 0; i < source.Length; i++) 376if (source.Length != 0) 387if ((source.Length > sizeof(uint)) && (source[sizeof(uint)..].ContainsAnyExcept((byte)0x00))) 398if (source.Length >= sizeof(uint)) 416for (int i = 0; i < source.Length; i++)
src\libraries\System.Private.CoreLib\src\System\UInt64.cs (9)
318if (source.Length != 0) 329if ((source.Length > sizeof(ulong)) && (source[..^sizeof(ulong)].ContainsAnyExcept((byte)0x00))) 340if (source.Length >= sizeof(ulong)) 342sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(ulong)); 358for (int i = 0; i < source.Length; i++) 375if (source.Length != 0) 386if ((source.Length > sizeof(ulong)) && (source[sizeof(ulong)..].ContainsAnyExcept((byte)0x00))) 397if (source.Length >= sizeof(ulong)) 415for (int i = 0; i < source.Length; i++)
src\libraries\System.Private.CoreLib\src\System\UIntPtr.cs (9)
322if (source.Length != 0) 333if ((source.Length > sizeof(nuint_t)) && (source[..^sizeof(nuint_t)].ContainsAnyExcept((byte)0x00))) 344if (source.Length >= sizeof(nuint_t)) 346sourceRef = ref Unsafe.Add(ref sourceRef, source.Length - sizeof(nuint_t)); 362for (int i = 0; i < source.Length; i++) 379if (source.Length != 0) 390if ((source.Length > sizeof(nuint_t)) && (source[sizeof(nuint_t)..].ContainsAnyExcept((byte)0x00))) 401if (source.Length >= sizeof(nuint_t)) 419for (int i = 0; i < source.Length; i++)
src\libraries\System.Reflection.Metadata\src\System\Reflection\Metadata\TypeNameParser.cs (3)
57int errorIndex = typeName.Length - parser._inputString.Length; 255_inputString = _inputString.Slice(candidate.Length);
src\libraries\System.Reflection.Metadata\src\System\Reflection\Metadata\TypeNameParserHelpers.cs (5)
43return input.Length; // no type name end chars were found, the whole input is the type name 53isNestedType = offset > 0 && offset < input.Length && input[offset] == '+'; 59for (; offset < input.Length; offset++) 66if (offset == input.Length || // invalid name that ends with escape character 154for (; offset < input.Length; offset++)
src\System\Reflection\Emit\DynamicILGenerator.cs (4)
95stackchange -= meth.GetParametersAsSpan().Length; 412if (paramInfo.Length != 0) 414parameterTypes = new Type[paramInfo.Length]; 418for (int i = 0; i < paramInfo.Length; i++)
src\System\Reflection\Emit\RuntimeModuleBuilder.cs (2)
460Type[] parameterTypes = new Type[parameters.Length]; 464for (int i = 0; i < parameters.Length; i++)
src\System\Reflection\Emit\RuntimeTypeBuilder.cs (1)
95attr, attr.Length);
src\System\Reflection\Metadata\MetadataUpdater.cs (3)
50ApplyUpdate(new QCallAssembly(ref rtAsm), metadataDeltaPtr, metadataDelta.Length, ilDeltaPtr, ilDelta.Length, pdbDeltaPtr, pdbDelta.Length);
src\System\Reflection\RuntimeAssembly.cs (2)
215nestedTypeNames.Length, 223nestedTypeNames.Length,
src\System\Reflection\RuntimeCustomAttributeData.cs (5)
264if (parameters.Length != 0) 266m_ctorParams = new CustomAttributeCtorParameter[parameters.Length]; 267for (int i = 0; i < parameters.Length; i++) 405Debug.Assert(allCtors[0].GetParametersAsSpan().Length == 0); 930Debug.Assert(size <= (_blob.Length - _curr));
src\System\Reflection\RuntimeEventInfo.cs (1)
68(parameters = m_addMethod.GetParametersAsSpan()).Length == 0)
src\System\Reflection\RuntimePropertyInfo.cs (2)
286numParams = methParams.Length; 296numParams = methParams.Length - 1;
src\System\Reflection\TypeNameResolver.CoreCLR.cs (2)
146if (typeName.Length == 0) 321for (int i = 0; i < nestedTypeNames.Length; i++)
src\System\Runtime\CompilerServices\RuntimeHelpers.CoreCLR.cs (1)
215PrepareMethod(methodInfo.Value, pInstantiation, instantiationHandles.Length);
src\System\Runtime\Loader\AssemblyLoadContext.CoreCLR.cs (2)
78LoadFromStream(_nativeAssemblyLoadContext, new IntPtr(ptrAssembly), arrAssembly.Length, 79new IntPtr(ptrSymbols), arrSymbols.Length, ObjectHandleOnStack.Create(ref loadedAssembly));
src\System\RuntimeHandles.cs (6)
1846ResolveType(new QCallModule(ref module), typeToken, typeInstArgs, typeInstantiationContextHandles.Length, methodInstArgs, methodInstantiationContextHandles.Length, ObjectHandleOnStack.Create(ref type)); 1901return ResolveMethod(new QCallModule(ref module), methodToken, typeInstArgs, typeInstantiationContext.Length, methodInstArgs, methodInstantiationContext.Length); 1952ResolveField(new QCallModule(ref module), fieldToken, typeInstArgs, typeInstantiationContextHandles.Length, methodInstArgs, methodInstantiationContextHandles.Length, ObjectHandleOnStack.Create(ref field));
src\System\RuntimeType.CoreCLR.cs (6)
2281if (argumentTypes.Length != parameterInfos.Length) 2290bool excessSuppliedArguments = argumentTypes.Length > parameterInfos.Length; 2328if (parameterInfos.Length == 0) 2332bool shortByMoreThanOneSuppliedArgument = argumentTypes.Length < parameterInfos.Length - 1; 2358for (int i = 0; i < parameterInfos.Length; i++) 3920if (invokeMethod.GetParametersAsSpan().Length == 0)
src\System\StubHelpers.cs (1)
452int numChars = Math.Min(managed.Length, length - 1);
src\System\Text\StringBuilder.CoreCLR.cs (1)
44ArgumentOutOfRangeException.ThrowIfGreaterThan(source.Length, m_MaxCapacity, "capacity");
src\System\Threading\WaitHandle.CoreCLR.cs (1)
15=> WaitMultipleIgnoringSyncContext(waitHandles, waitHandles.Length, waitAll, millisecondsTimeout);
System.Private.CoreLib.Generators (10)
EventSourceGenerator.Parser.cs (2)
109byte[] combinedBytes = new byte[namespaceBytes.Length + bytes.Length]; 111bytes.CopyTo(combinedBytes, namespaceBytes.Length);
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (8)
69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 89_pos += source.Length; 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 98Grow(source.Length); 101_span.Slice(0, _pos).CopyTo(_span.Slice(source.Length)); 103_pos += source.Length;
System.Private.DataContractSerialization (35)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
System\Runtime\Serialization\Json\JsonEncodingStreamWrapper.cs (2)
264while (buffer.Length > 0) 266int size = Math.Min(_chars.Length, buffer.Length);
System\Xml\EncodingStreamWrapper.cs (1)
184if (bom.Length > 0)
System\Xml\XmlBinaryWriter.cs (19)
607if (chars.Length > 0) 611UnsafeWriteText(pch, chars.Length); 862WriteArray(XmlBinaryNodeType.BoolTextWithEndElement, items.Length, MemoryMarshal.AsBytes(items)); 869WriteArray(XmlBinaryNodeType.Int16TextWithEndElement, items.Length, MemoryMarshal.AsBytes(items)); 873WriteArrayInfo(XmlBinaryNodeType.Int16TextWithEndElement, items.Length); 885WriteArray(XmlBinaryNodeType.Int32TextWithEndElement, items.Length, MemoryMarshal.AsBytes(items)); 889WriteArrayInfo(XmlBinaryNodeType.Int32TextWithEndElement, items.Length); 901WriteArray(XmlBinaryNodeType.Int64TextWithEndElement, items.Length, MemoryMarshal.AsBytes(items)); 905WriteArrayInfo(XmlBinaryNodeType.Int64TextWithEndElement, items.Length); 917WriteArray(XmlBinaryNodeType.FloatTextWithEndElement, items.Length, MemoryMarshal.AsBytes(items)); 921WriteArrayInfo(XmlBinaryNodeType.FloatTextWithEndElement, items.Length); 935WriteArray(XmlBinaryNodeType.DoubleTextWithEndElement, items.Length, MemoryMarshal.AsBytes(items)); 939WriteArrayInfo(XmlBinaryNodeType.DoubleTextWithEndElement, items.Length); 953WriteArray(XmlBinaryNodeType.DecimalTextWithEndElement, items.Length, MemoryMarshal.AsBytes(items)); 958WriteArrayInfo(XmlBinaryNodeType.DecimalTextWithEndElement, items.Length); 976WriteArrayInfo(XmlBinaryNodeType.DateTimeTextWithEndElement, items.Length); 987WriteArray(XmlBinaryNodeType.GuidTextWithEndElement, items.Length, MemoryMarshal.AsBytes(items)); 992WriteArrayInfo(XmlBinaryNodeType.GuidTextWithEndElement, items.Length); 1004WriteArrayInfo(XmlBinaryNodeType.TimeSpanTextWithEndElement, items.Length);
System\Xml\XmlStreamNodeWriter.cs (7)
230if (bytes.Length < bufferLength) 232var buffer = GetBuffer(bytes.Length, out int offset).AsSpan(offset, bytes.Length); 234Advance(bytes.Length); 279if (value.Length < bufferLength) 281byte[] buffer = GetBuffer(value.Length, out int offset); 283Advance(value.Length);
System.Private.Uri (45)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Net\IPv6AddressHelper.Common.cs (7)
21for (int i = 0; i < numbers.Length; i++) 325for (int i = (address[0] == TChar.CreateTruncating('[') ? 1 : 0); i < address.Length && address[i] != TChar.CreateTruncating(']');) 341for (++i; i < address.Length && address[i] != TChar.CreateTruncating(']') && address[i] != TChar.CreateTruncating('/'); ++i) 347for (; i < address.Length && address[i] != TChar.CreateTruncating(']'); ++i) 372for (int j = i; j < address.Length && 388while (j < address.Length && (address[j] != TChar.CreateTruncating(']')) && (address[j] != TChar.CreateTruncating('/')) && (address[j] != TChar.CreateTruncating('%'))) 414for (++i; i < address.Length && address[i] != TChar.CreateTruncating(']'); i++)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
System\DomainNameHelper.cs (7)
121length = hostname.Length; 148int labelLength = dotIndex < 0 ? hostname.Length : dotIndex; 246string asciiForm = s_idnMapping.GetAscii(hostname, i, label.Length); 264dest.Append(s_idnMapping.GetUnicode(hostname, i, label.Length)); 276int charsWritten = label.ToLowerInvariant(dest.AppendSpan(label.Length)); 277Debug.Assert(charsWritten == label.Length); 281i += label.Length;
System\Uri.cs (5)
1632charsWritten = result.Length; 2771charsWritten = copied ? result.Length : 0; 3729switch (scheme.Length) 3769if (scheme.Length == 0 || 3777if (scheme.Length > c_MaxUriSchemeName)
System\UriExt.cs (5)
595Debug.Assert(backingString is null || backingString.Length == charsToUnescape.Length); 607vsb.EnsureCapacity(charsToUnescape.Length - indexOfFirstToUnescape); 633charsWritten = charsToUnescape.Length; 652vsb.EnsureCapacity(charsToUnescape.Length - indexOfFirstToUnescape); 666Debug.Assert(newLength <= charsToUnescape.Length);
System\UriHelper.cs (12)
16return string.Create(span.Length, span, static (buffer, span) => 137if (destination.Length < charsToEscape.Length) 148charsWritten = charsToEscape.Length; 161vsb.EnsureCapacity(charsToEscape.Length); 171Debug.Assert(newLength > charsToEscape.Length); 208Debug.Assert(backingString is null || backingString.Length == charsToEscape.Length); 222vsb.EnsureCapacity(charsToEscape.Length); 292if (stringToEscape.Length > 2 && char.IsAsciiHexDigit(stringToEscape[1]) && char.IsAsciiHexDigit(stringToEscape[2])) 311charsToCopy = stringToEscape.Length; 376UnescapeString(pStr, 0, input.Length, ref dest, rsvd1, rsvd2, rsvd3, unescapeMode, syntax, isQuery); 612Debug.Assert(backingString is null || strToClean.Length == backingString.Length); 646stripped = string.Create(strToClean.Length - charsToRemove, strToClean, static (buffer, strToClean) =>
System.Private.Windows.Core (30)
System\IO\Compression\RunLengthEncoder.cs (1)
44for (int i = 0; i < encoded.Length; i += 2)
System\SpanHelpers.cs (2)
17if (source.Length >= destination.Length) 25destination[source.Length] = '\0';
System\SpanReader.cs (14)
30readonly get => Span.Length - _unread.Length; 103if (count > _unread.Length) 140if (sizeof(TValue) > _unread.Length * sizeof(T)) 174if (sizeof(TValue) * count > _unread.Length * sizeof(T)) 205UnsafeAdvance(next.Length); 224count = _unread.Length; 245public void Rewind(int count) => _unread = Span[(Span.Length - _unread.Length - count)..]; 259Debug.Assert((uint)count <= (uint)_unread.Length); 260UncheckedSlice(ref _unread, count, _unread.Length - count); 269Debug.Assert((uint)length <= (uint)span.Length); 279Debug.Assert((uint)start <= (uint)span.Length && (uint)length <= (uint)(span.Length - start));
System\SpanWriter.cs (2)
49if (_unwritten.Length >= values.Length) 53UnsafeAdvance(values.Length);
System\Text\ValueStringBuilder.cs (3)
296if (pos > _chars.Length - value.Length) 298Grow(value.Length); 302_pos += value.Length;
System\TypeExtensions.cs (5)
254if (publicKey1.Length == publicKey2.Length) 259if (publicKey1.Length == 0 || publicKey2.Length == 0) 266return publicKey1.Length == PublicKeyTokenLength
Windows\Win32\Graphics\Gdi\ARGB.cs (3)
49Color[] colors = new Color[argbColors.Length]; 50for (int i = 0; i < argbColors.Length; i++) 61argbColors.Length));
System.Private.Windows.GdiPlus (3)
System\Drawing\CoreImageExtensions.cs (1)
21if (format == PInvokeCore.ImageFormatGIF && image.Data is { } rawData && rawData.Length > 0)
System\Drawing\ImageCodecInfoHelper.cs (2)
52s_encoders = new (Guid Format, Guid Encoder)[codecInfo.Length]; 54for (int i = 0; i < codecInfo.Length; i++)
System.Private.Xml (35)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
System\Xml\Base64Decoder.cs (5)
123while ((uint)iChar < (uint)chars.Length) 145if (ch >= mapBase64.Length || (digit = mapBase64[ch]) == Invalid) 166if ((uint)iChar < (uint)chars.Length && chars[iChar] == '=') 173} while ((uint)iChar < (uint)chars.Length && chars[iChar] == '='); 176while ((uint)iChar < (uint)chars.Length)
System\Xml\BinaryXml\XmlBinaryReader.cs (1)
3491Debug.Assert(data.Length % 2 == 0, "Data size should not be odd");
System\Xml\BinHexDecoder.cs (2)
107int len = chars.Length; 144for (; iChar < chars.Length; iChar++)
System\Xml\Core\ReadOnlyTernaryTree.cs (1)
194if (stringPos == stringToFind.Length)
System\Xml\Core\XmlEncodedRawTextWriter.cs (1)
170if (bom.Length != 0)
System\Xml\Core\XmlTextEncoder.cs (1)
252int len = text.Length;
System\Xml\Core\XmlTextReaderImpl.cs (4)
3199_ps.bytePos = preamble.Length; 9581for (int i = 0; i < chars.Length; i++) 9597if ((uint)nextIdx < (uint)chars.Length && chars[nextIdx] == '\n') 9607lineInfo.linePos = chars.Length - lastNewLinePos;
System\Xml\Core\XmlUtf8RawTextWriter.cs (3)
115if (bom.Length != 0) 118_bufPos += bom.Length; 119_textPos += bom.Length;
System\Xml\XmlCharType.cs (2)
149for (; (uint)i < (uint)str.Length; i++) 154if ((uint)(i + 1) >= (uint)str.Length || !char.IsSurrogatePair(c, str[i + 1]))
System\Xml\XmlConvert.cs (3)
1058if (value.Length != 0 && value[0] != '+') 1721charsWritten = valueSpan.Length; 1745charsWritten = valueSpan.Length;
System\Xml\XPath\Internal\XPathScanner.cs (2)
337for (i = 1; i < span.Length && XmlCharType.IsNCNameSingleChar(span[i]); i++); 339if ((uint)i < (uint)span.Length)
System\Xml\Xsl\Runtime\NumberFormatter.cs (1)
112for (int idx = RomanDigitValue.Length; idx-- != 0;)
System.Reflection.Emit (3)
System\Reflection\Emit\CustomAttributeWrapper.cs (2)
42if (binaryAttribute.Length < 2) 44throw new ArgumentException(SR.Format(SR.Argument_InvalidCustomAttributeLength, ctor.DeclaringType, binaryAttribute.Length), nameof(binaryAttribute));
System\Reflection\Emit\FieldBuilderImpl.cs (1)
59Debug.Assert(binaryAttribute.Length >= 6);
System.Reflection.Metadata (35)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Reflection\AssemblyNameFormatter.cs (1)
108if (s.Length != span.Trim().Length || span.IndexOfAny('\"', '\'') >= 0)
src\libraries\Common\src\System\Reflection\AssemblyNameParser.cs (2)
66Debug.Assert(input.Length > 0); 348if (_index < _input.Length)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
System\Reflection\Internal\Utilities\Hash.cs (1)
47for (int i = 0; i < data.Length; i++)
System\Reflection\Internal\Utilities\MemoryBlock.cs (1)
328numberOfBytesRead = length = span.Length;
System\Reflection\Metadata\BlobBuilder.cs (3)
674int bytesToCurrent = Math.Min(FreeBytes, buffer.Length); 683Expand(remaining.Length); 686AddLength(remaining.Length);
System\Reflection\Metadata\BlobContentId.cs (3)
49if (id.Length != Size) 56var reader = new BlobReader(ptr, id.Length); 88if (hashCode.Length < minHashSize)
System\Reflection\Metadata\BlobWriter.cs (1)
152int start = Advance(buffer.Length);
System\Reflection\Metadata\Ecma335\MetadataBuilder.Heaps.cs (2)
224_blobHeapSize += BlobWriterImpl.GetCompressedIntegerSize(value.Length) + value.Length;
System\Reflection\Metadata\TypeNameParser.cs (3)
57int errorIndex = typeName.Length - parser._inputString.Length; 255_inputString = _inputString.Slice(candidate.Length);
System\Reflection\Metadata\TypeNameParserHelpers.cs (5)
43return input.Length; // no type name end chars were found, the whole input is the type name 53isNestedType = offset > 0 && offset < input.Length && input[offset] == '+'; 59for (; offset < input.Length; offset++) 66if (offset == input.Length || // invalid name that ends with escape character 154for (; offset < input.Length; offset++)
System\Reflection\PortableExecutable\ManagedTextSection.cs (2)
113CorEntryPointName.Length + 117CorEntryPointDll.Length + 1 + sizeof(ushort);
System\Reflection\PortableExecutable\PEBuilder.cs (2)
157Debug.Assert(DosHeader.Length == DosHeaderSize); 160builder.WriteBytes(ptr, header.Length);
System.Reflection.MetadataLoadContext (1)
System\Reflection\TypeLoading\Modules\GetTypeCoreCache.cs (1)
50for (int i = 0; i < name.Length; i++)
System.Resources.Extensions (7)
System\Resources\Extensions\TypeNameComparer.cs (7)
80typeSpan1 = typeSpan1.Length > type1.Length ? typeSpan1.Slice(type1.Length + 1).TrimStart(s_whiteSpaceChars) : ReadOnlySpan<char>.Empty; 81typeSpan2 = typeSpan2.Length > type2.Length ? typeSpan2.Slice(type2.Length + 1).TrimStart(s_whiteSpaceChars) : ReadOnlySpan<char>.Empty; 127for (int i = 0; i < typeName.Length; i++)
System.Runtime.Numerics (436)
src\libraries\Common\src\System\Number.Formatting.Common.cs (29)
58if (format.Length > 0) 66if (format.Length == 1) 72if (format.Length == 2) 82else if (format.Length == 3) 98while ((uint)i < (uint)format.Length && char.IsAsciiDigit(format[i])) 110if ((uint)i >= (uint)format.Length || format[i] == '\0') 120return format.Length == 0 || c == '\0' ? // For compat, treat '\0' as the end of the specifier, even if the specifier extends beyond it. 330while (src < format.Length && (ch = pFormat[src++]) != 0 && ch != ';') 381while (src < format.Length && pFormat[src] != 0 && pFormat[src++] != ch) ; 385if (src < format.Length && pFormat[src] != 0) 393if ((src < format.Length && pFormat[src] == '0') || 394(src + 1 < format.Length && (pFormat[src] == '+' || pFormat[src] == '-') && pFormat[src + 1] == '0')) 396while (++src < format.Length && pFormat[src] == '0') ; 531while (src < format.Length && (ch = pFormat[src++]) != 0 && ch != ';') 622while (src < format.Length && pFormat[src] != 0 && pFormat[src] != ch) 627if (src < format.Length && pFormat[src] != 0) 634if (src < format.Length && pFormat[src] != 0) 647if (src < format.Length && pFormat[src] == '0') 652else if (src + 1 < format.Length && pFormat[src] == '+' && pFormat[src + 1] == '0') 657else if (src + 1 < format.Length && pFormat[src] == '-' && pFormat[src + 1] == '0') 668while (++src < format.Length && pFormat[src] == '0') 685if (src < format.Length) 692while (src < format.Length && pFormat[src] == '0') 776bufferSize += sGroup.Length; 805for (int j = sGroup.Length - 1; j >= 0; j--) 1140if (src >= format.Length) 1149while (src < format.Length && pFormat[src] != 0 && pFormat[src++] != ch) ; 1153if (src < format.Length && pFormat[src] != 0) 1165if (src < format.Length && pFormat[src] != 0 && pFormat[src] != ';')
src\libraries\Common\src\System\Number.Parsing.Common.cs (2)
289if (!TryParseNumber(ref p, p + value.Length, styles, ref number, info) 290|| ((int)(p - stringPointer) < value.Length && !TrailingZeros(value, (int)(p - stringPointer))))
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\FormattingHelpers.CountDigits.cs (3)
25Debug.Assert(log2ToPow10.Length == 64); 54Debug.Assert((elementOffset + 1) <= powersOf10.Length); 102Debug.Assert(table.Length == 32, "Every result of uint.Log2(value) needs a long entry in the table.");
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (8)
69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 89_pos += source.Length; 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 98Grow(source.Length); 101_span.Slice(0, _pos).CopyTo(_span.Slice(source.Length)); 103_pos += source.Length;
System\Number.BigInteger.cs (51)
85if (value.Length == 0) 90if (value.Length < 255) 92buffer = stackalloc byte[value.Length + 1 + 1]; 96buffer = arrayFromPool = ArrayPool<byte>.Shared.Rent(value.Length + 1 + 1); 149for (whiteIndex = 0; whiteIndex < value.Length; whiteIndex++) 161for (whiteIndex = value.Length - 1; whiteIndex >= 0; whiteIndex--) 180int leadingBitsCount = value.Length % TParser.DigitsPerBlock; 235int wholeBlockCount = value.Length / TParser.DigitsPerBlock; 331ReadOnlySpan<byte> fracDigitsSpan = number.Digits.Slice(intDigits.Length); 348int base1E9Length = (intDigits.Length + PowersOf1e9.MaxPartialDigits - 1) / PowersOf1e9.MaxPartialDigits; 355ReadOnlySpan<byte> leadingDigits = intDigits[..(intDigits.Length % PowersOf1e9.MaxPartialDigits)]; 356if (leadingDigits.Length != 0) 361intDigits = intDigits.Slice(leadingDigits.Length); 362Debug.Assert(intDigits.Length % PowersOf1e9.MaxPartialDigits == 0); 369Debug.Assert(intDigits.Length == 0); 404int valueDigits = (base1E9.Length - 1) * PowersOf1e9.MaxPartialDigits + FormattingHelpers.CountDigits(base1E9[^1]); 418int leadingLength = checked((int)(digitRatio * PowersOf1e9.MaxPartialDigits * base1E9.Length) + 3); 449if (base1E9.Length < BigIntegerParseNaiveThresholdInRecursive) 456while (base1E9.Length <= multiplier1E9Length) 463Debug.Assert(multiplier1E9Length < base1E9.Length && base1E9.Length <= multiplier1E9Length * 2); 476Span<uint> bitsUpper = bits.Slice(multiplierTrailingZeroCount, buffer2.Length + multiplier.Length); 477if (multiplier.Length < buffer2.Length) 494if (base1E9.Length == 0) 522if (base1E9.Length == 0) 527for (int i = base1E9.Length - 2; i >= 0; i--) 749Debug.Assert(formatString == null || formatString.Length == formatSpan.Length); 823int valueDigits = (base1E9Value.Length - 1) * MaxPartialDigits + FormattingHelpers.CountDigits(base1E9Value[^1]); 858strResult = string.Create(strLength, (digits, ptr: (IntPtr)ptr, base1E9Value.Length, sNegative), static (span, state) => 929for (int i = 0; i < base1E9Value.Length - 1; i++) 1056Debug.Assert(Indexes[6] == LeadingPowers1E9.Length); 1057if (pow1E9.Length <= LeadingPowers1E9.Length) 1062LeadingPowers1E9.CopyTo(pow1E9.Slice(0, LeadingPowers1E9.Length)); 1067for (int i = 6; i + 1 < Indexes.Length; i++) 1069Debug.Assert(2 * src.Length - (Indexes[i + 1] - Indexes[i]) is 0 or 1); 1070if (pow1E9.Length - toExclusive < (src.Length << 1)) 1072Span<uint> dst = pow1E9.Slice(toExclusive, src.Length << 1); 1087if ((uint)index < (uint)Indexes.Length) 1091maxIndex = Indexes.Length - 2; 1115if (trailingZeroCount < UInt32PowersOfTen.Length) 1117BigIntegerCalculator.Multiply(left, UInt32PowersOfTen[trailingZeroCount], bits.Slice(0, left.Length + 1)); 1136int curLength = first.Length; 1151Debug.Assert(fi + 1 < Indexes.Length); 1158Span<uint> dst = powersOfTen2.Slice(0, curLength += power.Length); 1160if (power.Length < src.Length) 1179Span<uint> bits2 = bits.Slice(omittedLength, curLength += left.Length); 1180if (left.Length < powersOfTen.Length) 1237Debug.Assert(destination.Length * TParser.DigitsPerBlock == input.Length); 1238ref TChar lastWholeBlockStart = ref Unsafe.Add(ref MemoryMarshal.GetReference(input), input.Length - TParser.DigitsPerBlock);
System\Numerics\BigInteger.cs (42)
278int byteCount = value.Length; 299byteCount = value.Length; 505if (value.Length > MaxLength) 510if (value.Length == 0) 514else if (value.Length == 1) 923if (rightBits.Length == 1) 928else if (rightBits.Length == 2) 930Span<uint> bits = (leftBits.Length <= BigIntegerCalculator.StackAllocThreshold 932: bitsFromPool = ArrayPool<uint>.Shared.Rent(leftBits.Length)).Slice(0, leftBits.Length); 943Span<uint> bits = (leftBits.Length <= BigIntegerCalculator.StackAllocThreshold 945: bitsFromPool = ArrayPool<uint>.Shared.Rent(leftBits.Length)).Slice(0, leftBits.Length); 1459curByte = length - srcBytes.Length; 1460Span<byte> destBytes = destination.Slice(curByte, srcBytes.Length); 1467curByte = srcBytes.Length; 1685int size = rightBits.Length + 1; 1697int size = leftBits.Length + 1; 1705else if (leftBits.Length < rightBits.Length) 1709int size = rightBits.Length + 1; 1721int size = leftBits.Length + 1; 1763int size = rightBits.Length; 1775int size = leftBits.Length; 1785int size = rightBits.Length; 1797int size = leftBits.Length; 2738int size = right.Length + 1; 2750int size = left.Length + 1; 2760int size = left.Length + right.Length; 2768else if (left.Length < right.Length) 2772int size = left.Length + right.Length; 2785int size = left.Length + right.Length; 3278int xl = bits.Length; 3279if (negx && (bits[^1] >= kuMaskHighBit) && ((bits[^1] != kuMaskHighBit) || bits.IndexOfAnyExcept(0u) != (bits.Length - 1))) 3433int xl = bits.Length; 3434if (negx && (bits[^1] >= kuMaskHighBit) && ((bits[^1] != kuMaskHighBit) || bits.IndexOfAnyExcept(0u) != (bits.Length - 1))) 5309int xl = bits.Length; 5310if (negx && (bits[^1] >= kuMaskHighBit) && ((bits[^1] != kuMaskHighBit) || bits.IndexOfAnyExcept(0u) != (bits.Length - 1)))
System\Numerics\BigIntegerCalculator.AddSub.cs (29)
21Debug.Assert(left.Length >= 1); 22Debug.Assert(bits.Length == left.Length + 1); 29Debug.Assert(right.Length >= 1); 30Debug.Assert(left.Length >= right.Length); 31Debug.Assert(bits.Length == left.Length + 1); 54} while (i < right.Length); 61Debug.Assert(left.Length >= right.Length); 74for (; i < right.Length; i++) 92Debug.Assert(left.Length >= 1); 93Debug.Assert(left[0] >= right || left.Length >= 2); 94Debug.Assert(bits.Length == left.Length); 101Debug.Assert(right.Length >= 1); 102Debug.Assert(left.Length >= right.Length); 104Debug.Assert(bits.Length == left.Length); 127} while (i < right.Length); 134Debug.Assert(left.Length >= right.Length); 150for (; i < right.Length; i++) 177if (left.Length <= CopyToThreshold) 179for (; i < left.Length; i++) 186Unsafe.Add(ref resultPtr, left.Length) = unchecked((uint)carry); 190for (; i < left.Length;) 205Unsafe.Add(ref resultPtr, left.Length) = unchecked((uint)carry); 207if (i < left.Length) 224if (left.Length <= CopyToThreshold) 226for (; i < left.Length; i++) 235for (; i < left.Length;) 250if (i < left.Length)
System\Numerics\BigIntegerCalculator.DivRem.cs (120)
36Debug.Assert(left.Length >= 1); 37Debug.Assert(quotient.Length == left.Length); 44for (int i = left.Length - 1; i >= 0; i--) 55Debug.Assert(left.Length >= 1); 59for (int i = left.Length - 1; i >= 0; i--) 70Debug.Assert(left.Length >= 1); 71Debug.Assert(right.Length >= 1); 72Debug.Assert(left.Length >= right.Length); 73Debug.Assert(quotient.Length == left.Length - right.Length + 1); 74Debug.Assert(remainder.Length == left.Length); 78if (right.Length < DivideBurnikelZieglerThreshold || left.Length - right.Length < DivideBurnikelZieglerThreshold) 91Debug.Assert(left.Length >= 1); 92Debug.Assert(right.Length >= 1); 93Debug.Assert(left.Length >= right.Length); 94Debug.Assert(quotient.Length == left.Length - right.Length + 1); 97if (right.Length < DivideBurnikelZieglerThreshold || left.Length - right.Length < DivideBurnikelZieglerThreshold) 105Span<uint> leftCopy = (left.Length <= StackAllocThreshold ? 107: leftCopyFromPool = ArrayPool<uint>.Shared.Rent(left.Length)).Slice(0, left.Length); 123Debug.Assert(left.Length >= 1); 124Debug.Assert(right.Length >= 1); 125Debug.Assert(left.Length >= right.Length); 126Debug.Assert(remainder.Length == left.Length); 129if (right.Length < DivideBurnikelZieglerThreshold || left.Length - right.Length < DivideBurnikelZieglerThreshold) 138int quotientLength = left.Length - right.Length + 1; 162Debug.Assert(right.Length >= 1); 163Debug.Assert(left.Length >= right.Length); 164Debug.Assert(quotient.Length == left.Length - right.Length + 1 168if (right.Length < DivideBurnikelZieglerThreshold || left.Length - right.Length < DivideBurnikelZieglerThreshold) 188int quotientLength = left.Length - right.Length + 1; 211Debug.Assert(right.Length >= 1); 212Debug.Assert(left.Length >= right.Length); 215|| quotient.Length == left.Length - right.Length + 1 216|| (CompareActual(left.Slice(left.Length - right.Length), right) < 0 && quotient.Length == left.Length - right.Length)); 223uint divHi = right[right.Length - 1]; 224uint divLo = right.Length > 1 ? right[right.Length - 2] : 0; 233uint divNx = right.Length > 2 ? right[right.Length - 3] : 0; 241for (int i = left.Length; i >= right.Length; i--) 243int n = i - right.Length; 295Debug.Assert(left.Length >= right.Length); 301for (int i = 0; i < right.Length; i++) 314Debug.Assert(left.Length >= right.Length); 322for (int i = 0; i < right.Length; i++) 357Debug.Assert(left.Length >= 1); 358Debug.Assert(right.Length >= 1); 359Debug.Assert(left.Length >= right.Length); 360Debug.Assert(quotient.Length == left.Length - right.Length + 1); 361Debug.Assert(remainder.Length == left.Length 373int m = (int)BitOperations.RoundUpToPowerOf2((uint)right.Length / (uint)DivideBurnikelZieglerThreshold + 1); 375int j = (right.Length + m - 1) / m; // Ceil(right.Length/m) 379int sigmaDigit = n - right.Length; 388int aLength = left.Length + sigmaDigit; 406Debug.Assert(src.Length + sigmaDigit <= bits.Length); 411dst.Slice(src.Length).Clear(); 523Debug.Assert(left.Length == 2 * right.Length); 524Debug.Assert(CompareActual(left.Slice(right.Length), right) < 0); 525Debug.Assert(quotient.Length == right.Length); 526Debug.Assert(remainder.Length >= right.Length + 1); 528Debug.Assert(right.Length < DivideBurnikelZieglerThreshold); 532if (left.Length < right.Length) 536remainder.Slice(left.Length).Clear(); 538else if (right.Length == 1) 542if (quotient.Length < left.Length) 544Debug.Assert(quotient.Length + 1 == left.Length); 553quotient.Slice(left.Length).Clear(); 566Span<uint> r1 = (left.Length <= StackAllocThreshold ? 568: r1FromPool = ArrayPool<uint>.Shared.Rent(left.Length)).Slice(0, left.Length); 571int quotientLength = Math.Min(left.Length - right.Length + 1, quotient.Length); 595Debug.Assert(left.Length == 2 * right.Length); 596Debug.Assert(CompareActual(left.Slice(right.Length), right) < 0); 597Debug.Assert(quotient.Length == right.Length); 598Debug.Assert(remainder.Length >= right.Length + 1); 601if ((right.Length & 1) != 0 || right.Length < DivideBurnikelZieglerThreshold) 607int halfN = right.Length >> 1; 610Span<uint> r1 = ((right.Length + 1) <= StackAllocThreshold ? 612: r1FromPool = ArrayPool<uint>.Shared.Rent(right.Length + 1)).Slice(0, right.Length + 1); 614BurnikelZieglerD3n2n(left.Slice(right.Length), left.Slice(halfN, halfN), right, quotient.Slice(halfN), r1); 615BurnikelZieglerD3n2n(r1.Slice(0, right.Length), left.Slice(0, halfN), right, quotient.Slice(0, halfN), remainder); 624Debug.Assert(right.Length % 2 == 0); 625Debug.Assert(left12.Length == right.Length); 626Debug.Assert(2 * left3.Length == right.Length); 627Debug.Assert(2 * quotient.Length == right.Length); 628Debug.Assert(remainder.Length >= right.Length + 1); 632int n = right.Length >> 1; 639Span<uint> d = (right.Length <= StackAllocThreshold ? 641: dFromPool = ArrayPool<uint>.Shared.Rent(right.Length)).Slice(0, right.Length); 685Debug.Assert(bits.Length == left.Length + right.Length); 689bits = bits.Slice(0, left.Length + right.Length); 691if (left.Length < right.Length)
System\Numerics\BigIntegerCalculator.FastReducer.cs (21)
26Debug.Assert(r.Length == modulus.Length * 2 + 1); 27Debug.Assert(mu.Length == r.Length - modulus.Length + 1); 28Debug.Assert(q1.Length == modulus.Length * 2 + 2); 29Debug.Assert(q2.Length == modulus.Length * 2 + 2); 46Debug.Assert(value.Length <= _modulus.Length * 2); 49if (value.Length < _modulus.Length) 54int l1 = DivMul(value, _mu, _q1, _modulus.Length - 1); 58int l2 = DivMul(_q1.Slice(0, l1), _modulus, _q2, _modulus.Length + 1); 61var length = SubMod(value, _q2.Slice(0, l2), _modulus, _modulus.Length + 1); 72Debug.Assert(bits.Length + k >= left.Length + right.Length); 79if (left.Length > k) 83if (left.Length < right.Length) 87bits.Slice(0, left.Length + right.Length)); 93bits.Slice(0, left.Length + right.Length)); 96return ActualLength(bits.Slice(0, left.Length + right.Length)); 111if (right.Length > k)
System\Numerics\BigIntegerCalculator.GcdInv.cs (22)
46Debug.Assert(left.Length >= 1); 59Debug.Assert(left.Length >= 2); 60Debug.Assert(right.Length >= 2); 62Debug.Assert(result.Length == left.Length); 67Span<uint> rightCopy = (right.Length <= StackAllocThreshold ? 69: rightCopyFromPool = ArrayPool<uint>.Shared.Rent(right.Length)).Slice(0, right.Length); 225Debug.Assert(xBuffer.Length >= 3); 226Debug.Assert(yBuffer.Length >= 3); 227Debug.Assert(xBuffer.Length >= yBuffer.Length); 232ulong xh = xBuffer[xBuffer.Length - 1]; 233ulong xm = xBuffer[xBuffer.Length - 2]; 234ulong xl = xBuffer[xBuffer.Length - 3]; 239switch (xBuffer.Length - yBuffer.Length) 242yh = yBuffer[yBuffer.Length - 1]; 243ym = yBuffer[yBuffer.Length - 2]; 244yl = yBuffer[yBuffer.Length - 3]; 249ym = yBuffer[yBuffer.Length - 1]; 250yl = yBuffer[yBuffer.Length - 2]; 256yl = yBuffer[yBuffer.Length - 1];
System\Numerics\BigIntegerCalculator.PowMod.cs (33)
23Debug.Assert(bits.Length == PowBound(power, value.Length)); 36valueCopy.Slice(value.Length).Clear(); 38Span<uint> result = PowCore(valueCopy, value.Length, temp, power, bits); 74int resultLength = leftLength + right.Length; 76if (leftLength >= right.Length) 170for (int i = 0; i < power.Length - 1; i++) 182return PowCore(value, power[power.Length - 1], modulus, result); 212Debug.Assert(bits.Length == modulus.Length + modulus.Length); 218int size = Math.Max(value.Length, bits.Length); 226valueCopy.Slice(value.Length).Clear(); 228if (value.Length > modulus.Length) 230Remainder(value, modulus, valueCopy.Slice(0, value.Length)); 261Debug.Assert(bits.Length == modulus.Length + modulus.Length); 266int size = Math.Max(value.Length, bits.Length); 275valueCopy.Slice(value.Length).Clear(); 277if (value.Length > modulus.Length) 279Remainder(value, modulus, valueCopy.Slice(0, value.Length)); 316if (modulus.Length < ReducerThreshold) 324int size = modulus.Length * 2 + 1; 331size = r.Length - modulus.Length + 1; 338size = modulus.Length * 2 + 2; 376if (modulus.Length < ReducerThreshold) 384int size = modulus.Length * 2 + 1; 391size = r.Length - modulus.Length + 1; 398size = modulus.Length * 2 + 2; 440for (int i = 0; i < power.Length - 1; i++) 456return PowCore(value, valueLength, power[power.Length - 1], modulus, result, resultLength, temp); 499for (int i = 0; i < power.Length - 1; i++) 515return PowCore(value, valueLength, power[power.Length - 1], reducer, result, resultLength, temp);
System\Numerics\BigIntegerCalculator.SquMul.cs (49)
23Debug.Assert(bits.Length == value.Length + value.Length); 34if (value.Length < SquareThreshold) 51for (int i = 0; i < value.Length; i++) 81int n = value.Length >> 1; 98int foldLength = valueHigh.Length + 1; 133Debug.Assert(bits.Length == left.Length + 1); 143for (; i < left.Length; i++) 161Debug.Assert(left.Length >= right.Length); 162Debug.Assert(bits.Length >= left.Length + right.Length); 175if (right.Length < MultiplyKaratsubaThreshold) 207int n = (left.Length + 1) >> 1; 209if (right.Length <= n) 214Debug.Assert(leftLow.Length >= leftHigh.Length); 217Span<uint> bitsLow = bits.Slice(0, n + right.Length); 223int carryLength = right.Length; 229Span<uint> carryOrig = bits.Slice(n, right.Length); 234if (leftHigh.Length < right.Length) 235MultiplyKaratsuba(right, leftHigh, bitsHigh.Slice(0, leftHigh.Length + right.Length), (right.Length + 1) >> 1); 237Multiply(leftHigh, right, bitsHigh.Slice(0, leftHigh.Length + right.Length)); 249Debug.Assert(left.Length >= right.Length); 250Debug.Assert(2 * n - left.Length is 0 or 1); 251Debug.Assert(right.Length > n); 252Debug.Assert(bits.Length >= left.Length + right.Length); 254if (right.Length < MultiplyKaratsubaThreshold) 272Debug.Assert(leftLow.Length >= leftHigh.Length); 273Debug.Assert(rightLow.Length >= rightHigh.Length); 277MultiplyKaratsuba(leftLow, rightLow, bitsLow, (leftLow.Length + 1) >> 1); 320Debug.Assert(ActualLength(core) <= left.Length + 1); 333Debug.Assert(right.Length < MultiplyKaratsubaThreshold); 346for (int i = 0; i < right.Length; i++) 350for (int j = 0; j < left.Length; j++) 357Unsafe.Add(ref resultPtr, i + left.Length) = (uint)carry; 364Debug.Assert(left.Length >= right.Length); 365Debug.Assert(core.Length >= left.Length); 382for (; i < right.Length; i++) 389for (; i < left.Length; i++)
System\Numerics\BigIntegerCalculator.Utils.cs (22)
20Debug.Assert(left.Length <= right.Length || left.Slice(right.Length).ContainsAnyExcept(0u)); 21Debug.Assert(left.Length >= right.Length || right.Slice(left.Length).ContainsAnyExcept(0u)); 23if (left.Length != right.Length) 24return left.Length < right.Length ? -1 : 1; 26int iv = left.Length; 36if (left.Length != right.Length) 38if (left.Length < right.Length) 40if (ActualLength(right.Slice(left.Length)) > 0) 42right = right.Slice(0, left.Length); 46if (ActualLength(left.Slice(right.Length)) > 0) 48left = left.Slice(0, right.Length); 59int length = value.Length; 70if (bits.Length >= modulus.Length) 74return ActualLength(bits.Slice(0, modulus.Length));
System\Numerics\Complex.cs (2)
2098if ((s.Length < 5) || (openBracket == -1) || (semicolon == -1) || (closeBracket == -1) || (openBracket > semicolon) || (openBracket > closeBracket) || (semicolon > closeBracket)) 2135if ((closeBracket != (s.Length - 1)) && (((style & NumberStyles.AllowTrailingWhite) == 0) || !s.Slice(closeBracket).IsWhiteSpace()))
System.Security.Cryptography.Cose (17)
System\Security\Cryptography\Cose\CoseMessage.cs (8)
112using (MemoryManager<byte> manager = new PointerMemoryManager<byte>(ptr, cborPayload.Length)) 197using (MemoryManager<byte> manager = new PointerMemoryManager<byte>(ptr, cborPayload.Length)) 424CoseHelpers.WriteByteStringLength(toBeSignedBuilder, (ulong)contentBytes.Length); 498Debug.Assert(signProtected.Length == 0); 509Debug.Assert(bytesWritten == ComputeToBeSignedEncodedSize(context, bodyProtected.Length, signProtected.Length, associatedData.Length, content.Length));
System\Security\Cryptography\Cose\CoseMultiSignMessage.cs (3)
211int expectedSize = ComputeEncodedSize(signer, protectedHeaders, unprotectedHeaders, content.Length, isDetached); 349int expectedSize = ComputeEncodedSize(signer, protectedHeaders, unprotectedHeaders, content.Length, isDetached); 775associatedData.Length,
System\Security\Cryptography\Cose\CoseSign1Message.cs (5)
169Debug.Assert(contentStream == null || (isDetached && contentBytes.Length == 0)); 173int expectedSize = ComputeEncodedSize(signer, contentBytes.Length, isDetached); 280int expectedSize = ComputeEncodedSize(signer, content.Length, isDetached); 773Debug.Assert(contentStream == null || contentBytes.Length == 0); 793associatedData.Length,
System\Security\Cryptography\Cose\CoseSignature.cs (1)
653associatedData.Length,
System.Security.Cryptography.Pkcs (134)
Internal\Cryptography\Pal\AnyOS\ManagedPal.Asn.cs (1)
18using (var manager = new PointerMemoryManager<byte>(pin, encodedMessage.Length))
Internal\Cryptography\Pal\AnyOS\ManagedPal.Decode.cs (1)
87using (var manager = new PointerMemoryManager<byte>(pin, encodedMessage.Length))
src\libraries\Common\src\Internal\Cryptography\PkcsHelpers.cs (6)
68consumed != source.Length) 105if (encodedOid.Length == 2 && encodedOid[0] == 0x06 && encodedOid[1] == 0x00) 118if (consumed != encodedOid.Length) 183if (consumed != input.Length) 190return encodedOctetString.Slice(offset, primitive.Length); 198if (consumed != input.Length)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Security\Cryptography\Asn1\AlgorithmIdentifierAsn.manual.cs (1)
49if (span.Length != 2)
src\libraries\Common\src\System\Security\Cryptography\Asn1\AlgorithmIdentifierAsn.xml.cs (1)
101decoded.Parameters = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\AttributeAsn.xml.cs (1)
111tmpItem = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\DigestInfoAsn.xml.cs (1)
81decoded.Digest = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\DirectoryStringAsn.xml.cs (1)
160decoded.UniversalString = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\EncryptedPrivateKeyInfoAsn.xml.cs (1)
81decoded.EncryptedData = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\GeneralNameAsn.xml.cs (3)
228decoded.X400Address = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray(); 234decoded.DirectoryName = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray(); 253decoded.IPAddress = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\OtherNameAsn.xml.cs (1)
98decoded.Value = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\PBEParameter.xml.cs (1)
80decoded.Salt = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pbkdf2SaltChoice.xml.cs (1)
105decoded.Specified = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs12\CertBagAsn.xml.cs (1)
98decoded.CertValue = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs12\MacData.xml.cs (1)
115decoded.MacSalt = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs12\SafeBagAsn.xml.cs (1)
114decoded.BagValue = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs12\SecretBagAsn.xml.cs (1)
98decoded.SecretValue = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs7\CertificateChoiceAsn.xml.cs (4)
200decoded.Certificate = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray(); 205decoded.ExtendedCertificate = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray(); 210decoded.AttributeCertificateV1 = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray(); 215decoded.AttributeCertificateV2 = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs7\ContentInfoAsn.xml.cs (1)
98decoded.Content = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs7\EncapsulatedContentInfoAsn.xml.cs (1)
105decoded.Content = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs7\EncryptedContentInfoAsn.xml.cs (1)
99decoded.EncryptedContent = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs7\IssuerAndSerialNumberAsn.xml.cs (2)
99decoded.Issuer = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray(); 101decoded.SerialNumber = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs7\OtherCertificateFormat.xml.cs (1)
93decoded.OtherCert = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs7\SignedDataAsn.xml.cs (1)
189tmpItem = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs7\SignerIdentifierAsn.xml.cs (1)
112decoded.SubjectKeyIdentifier = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Pkcs7\SignerInfoAsn.xml.cs (2)
134decoded.SignedAttributes = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray(); 141decoded.SignatureValue = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\PrivateKeyInfoAsn.xml.cs (1)
105decoded.PrivateKey = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\Rc2CbcParameters.xml.cs (1)
86decoded.Iv = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\SubjectPublicKeyInfoAsn.xml.cs (1)
81decoded.SubjectPublicKey = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1\X509ExtensionAsn.xml.cs (1)
128decoded.ExtnValue = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
src\libraries\Common\src\System\Security\Cryptography\Asn1Reader\AsnValueReader.cs (1)
58_span = _span.Slice(value.Length);
src\libraries\Common\src\System\Security\Cryptography\Helpers.cs (2)
95bytesWritten = source.Length; 209if (bytesRead != data.Length)
src\libraries\Common\src\System\Security\Cryptography\KeyFormatHelper.cs (6)
25using (MemoryManager<byte> manager = new PointerMemoryManager<byte>(ptr, source.Length)) 44read = reader.PeekEncodedValue().Length; 75read = reader.PeekEncodedValue().Length; 101using (MemoryManager<byte> manager = new PointerMemoryManager<byte>(ptr, source.Length)) 116int read = reader.PeekEncodedValue().Length; 143int read = reader.PeekEncodedValue().Length;
src\libraries\Common\src\System\Security\Cryptography\KeyFormatHelper.Encrypted.cs (6)
27using (MemoryManager<byte> manager = new PointerMemoryManager<byte>(ptr, source.Length)) 44using (MemoryManager<byte> manager = new PointerMemoryManager<byte>(ptr, source.Length)) 108read = reader.PeekEncodedValue().Length; 285using (PointerMemoryManager<byte> manager = new(pointer, source.Length)) 316using (PointerMemoryManager<byte> manager = new(pointer, source.Length)) 351localRead = reader.PeekEncodedValue().Length;
src\libraries\Common\src\System\Security\Cryptography\PasswordBasedEncryption.cs (23)
51if (passwordBytes.Length > 0 && password.Length == 0) 75Debug.Assert(destination.Length >= encryptedData.Length); 155if (password.IsEmpty && passwordBytes.Length > 0) 176if (passwordBytes.Length > 0 || password.Length == 0) 333if (passwordBytes.Length == 0 && password.Length > 0) 337else if (passwordBytes.Length == 0) 343pwdTmpBytes = new byte[passwordBytes.Length]; 353Debug.Assert(password.Length > 0 || passwordBytes.IsEmpty); 376if (passwordBytes.Length > 0) 378Debug.Assert(pwdTmpBytes!.Length == passwordBytes.Length); 381else if (password.Length > 0) 461if (passwordBytes.Length > 0 || password.Length == 0) 706if (!gotIv || bytesWritten != length || consumed != source.Length) 771byte[] tmpPassword = new byte[password.Length]; 922byte[] tmpKey = new byte[key.Length]; 923byte[] tmpIv = new byte[iv.Length]; 924byte[] rentedEncryptedData = CryptoPool.Rent(encryptedData.Length); 947encryptedData.Length, 970CryptoPool.Return(rentedEncryptedData, encryptedData.Length);
src\libraries\Common\src\System\Security\Cryptography\Pkcs\Pkcs8PrivateKeyInfo.cs (1)
79int localRead = reader.PeekEncodedValue().Length;
src\libraries\Common\src\System\Security\Cryptography\Pkcs12Kdf.cs (7)
115int SLen = ((salt.Length - 1 + vBytes) / vBytes) * vBytes; 118int passLen = checked((password.Length + 1) * 2); 238Debug.Assert(into.Length == addend.Length); 252Debug.Assert(bytes.Length > 0); 256if (destination.Length >= bytes.Length) 259destination = destination.Slice(bytes.Length); 271int fullCopyLen = password.Length * 2;
System\Security\Cryptography\Pkcs\Asn1\CadesIssuerSerial.xml.cs (1)
103decoded.SerialNumber = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\EssCertId.xml.cs (1)
85decoded.Hash = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\EssCertIdV2.xml.cs (1)
125decoded.Hash = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\KeyAgreeRecipientInfoAsn.xml.cs (1)
120decoded.Ukm = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\KeyTransRecipientInfoAsn.xml.cs (1)
92decoded.EncryptedKey = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\MessageImprint.xml.cs (1)
81decoded.HashedMessage = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\OriginatorIdentifierOrKeyAsn.xml.cs (1)
123decoded.SubjectKeyIdentifier = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\OriginatorInfoAsn.xml.cs (1)
144tmpItem = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\OriginatorPublicKeyAsn.xml.cs (1)
81decoded.PublicKey = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\OtherKeyAttributeAsn.xml.cs (1)
101decoded.KeyAttr = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\PkiStatusInfo.xml.cs (1)
115decoded.StatusString = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\PolicyQualifierInfo.xml.cs (1)
93decoded.Qualifier = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\RecipientEncryptedKeyAsn.xml.cs (1)
81decoded.EncryptedKey = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\RecipientIdentifierAsn.xml.cs (1)
112decoded.SubjectKeyIdentifier = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\RecipientKeyIdentifier.xml.cs (1)
92decoded.SubjectKeyIdentifier = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\Rfc3161TimeStampReq.xml.cs (1)
160decoded.Nonce = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\Rfc3161TimeStampResp.xml.cs (1)
94decoded.TimeStampToken = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\Asn1\Rfc3161TstInfo.xml.cs (2)
168decoded.SerialNumber = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray(); 194decoded.Nonce = rebindSpan.Overlaps(tmpSpan, out offset) ? rebind.Slice(offset, tmpSpan.Length) : tmpSpan.ToArray();
System\Security\Cryptography\Pkcs\CmsSignature.cs (11)
194if (val.Length > fieldSize && val[0] == 0) 199if (val.Length <= fieldSize) 201val.CopyTo(ieeeSignature.Slice(fieldSize - val.Length, val.Length)); 206if (val.Length > fieldSize && val[0] == 0) 211if (val.Length <= fieldSize) 213val.CopyTo(ieeeSignature.Slice(fieldSize + fieldSize - val.Length, val.Length)); 230int fieldSize = ieeeSignature.Length / 2; 233fieldSize * 2 == ieeeSignature.Length, 234$"ieeeSignature.Length ({ieeeSignature.Length}) must be even");
System\Security\Cryptography\Pkcs\CmsSignature.RSA.cs (1)
72valueHash.Length);
System\Security\Cryptography\Pkcs\Rfc3161TimestampRequest.cs (6)
88int localBytesRead = reader.PeekEncodedValue().Length; 270if (nonceSpan.Length == 0 || nonceSpan[0] >= 0x80) 272byte[] temp = new byte[nonceSpan.Length + 1]; 281while (slice < nonceSpan.Length && nonceSpan[slice] == 0) 287if (slice == nonceSpan.Length || nonceSpan[slice] >= 0x80) 367bytesConsumed = firstElement.Length;
System\Security\Cryptography\Pkcs\Rfc3161TimestampToken.cs (1)
298int bytesActuallyRead = reader.PeekEncodedValue().Length;
System\Security\Cryptography\Pkcs\SignedCms.cs (1)
217using (var manager = new PointerMemoryManager<byte>(pin, encodedMessage.Length))
System\Security\Cryptography\Pkcs\SubjectIdentifier.cs (1)
61for (int i = 0; i < serial.Length; i++)
System.Security.Cryptography.ProtectedData (3)
src\libraries\Common\src\Interop\Windows\Kernel32\Interop.FormatMessage.cs (1)
79int length = buffer.Length;
System\Security\Cryptography\ProtectedData.cs (2)
339DATA_BLOB userDataBlob = new DATA_BLOB((IntPtr)pInputData, (uint)(inputData.Length)); 343optionalEntropyBlob = new DATA_BLOB((IntPtr)pOptionalEntropy, (uint)(optionalEntropy.Length));
System.Security.Cryptography.Xml (6)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
System.ServiceModel.NetFramingBase (2)
System\ServiceModel\Channels\Connection.cs (2)
203byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 204Memory<byte> memBuffer = new Memory<byte>(sharedBuffer, 0, buffer.Length);
System.Text.Encoding.CodePages (11)
System\Text\EncodingTable.cs (10)
107int right = encodingNameIndices.Length - 2; 111Debug.Assert(encodingNameIndices.Length == CodePagesByName.Length + 1); 112Debug.Assert(encodingNameIndices[encodingNameIndices.Length - 1] == EncodingNames.Length); 122Debug.Assert(index < encodingNameIndices.Length - 1); 144Debug.Assert(left < encodingNameIndices.Length - 1); 185Debug.Assert(MappedCodePages.Length + 1 == indices.Length); 186Debug.Assert(indices[indices.Length - 1] == names.Length); 201Debug.Assert(i < indices.Length - 1);
System\Text\ISO2022Encoding.cs (1)
403if (bTrailByte < 0x21 || bTrailByte >= 0x21 + HalfToFullWidthKanaTable.Length)
System.Text.Encodings.Web (38)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
System\Text\Encodings\Web\AllowedBmpCodePointsBitmap.cs (1)
70Debug.Assert(definedCharsBitmapAsLittleEndian.Length == thisAllowedCharactersBitmap.Length * sizeof(uint));
System\Text\Encodings\Web\OptimizedInboxTextEncoder.cs (9)
142if ((uint)source.Length <= (uint)srcIdx) 190if ((uint)source.Length > (uint)srcIdxTemp) 261if ((uint)source.Length <= (uint)srcIdx) 368if ((uint)asciiBytesSkipped >= (uint)data.Length || UnicodeUtility.IsAsciiCodePoint(data[asciiBytesSkipped])) 375int dataOriginalLength = data.Length; 392return (data.IsEmpty) ? -1 : dataOriginalLength - data.Length; 402if (data.Length >= 8) 406if ((uint)asciiCharsSkipped >= (uint)data.Length || char.IsAscii(data[asciiCharsSkipped])) 416nuint lengthInChars = (uint)data.Length;
System\Text\Encodings\Web\TextEncoder.cs (19)
166Span<char> destBuffer = stringBuilder.AppendSpan(Math.Max(remainingInput.Length, minBufferBumpEachIteration)); 293if (utf8Destination.Length < utf8Source.Length) 301idxOfFirstByteToEncode = sourceSearchSpace.Length; 305if (idxOfFirstByteToEncode == utf8Source.Length) 307bytesConsumed = utf8Source.Length; 308bytesWritten = utf8Source.Length; 329int originalUtf8SourceLength = utf8Source.Length; 382bytesConsumed = originalUtf8SourceLength - utf8Source.Length; 423if (destination.Length < source.Length) 431idxOfFirstCharToEncode = sourceSearchSpace.Length; 435if (idxOfFirstCharToEncode == source.Length) 437charsConsumed = source.Length; 438charsWritten = source.Length; 454int originalSourceLength = source.Length; 498charsConsumed = originalSourceLength - source.Length; 521char[] rentedArray = ArrayPool<char>.Shared.Rent(Math.Max(value.Length, minBufferBumpEachIteration)); 545return FindFirstCharacterToEncode(pText, text.Length); 561int utf8TextOriginalLength = utf8Text.Length; 573return (utf8Text.IsEmpty) ? -1 : utf8TextOriginalLength - utf8Text.Length;
System.Text.Json (875)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
src\libraries\System.Private.CoreLib\src\System\Marvin.cs (1)
23public static int ComputeHash32(ReadOnlySpan<byte> data, ulong seed) => ComputeHash32(ref MemoryMarshal.GetReference(data), (uint)data.Length, (uint)seed, (uint)(seed >> 32));
src\libraries\System.Text.Json\Common\JsonSeparatorNamingPolicy.cs (3)
37int initialBufferLength = (int)(1.2 * chars.Length); 45for (int i = 0; i < chars.Length; i++) 75if (i + 1 < chars.Length && char.IsLower(chars[i + 1]))
System\Text\Json\Document\JsonDocument.cs (26)
311int length = checked(otherText.Length * JsonConstants.MaxExpansionFactorWhileTranscoding); 353if (otherUtf8Text.Length > segment.Length || (!shouldUnescape && otherUtf8Text.Length != segment.Length)) 360if (otherUtf8Text.Length < segment.Length / JsonConstants.MaxExpansionFactorWhileEscaping) 428consumed == segment.Length) 450consumed == segment.Length) 472consumed == segment.Length) 494consumed == segment.Length) 516consumed == segment.Length) 538consumed == segment.Length) 560consumed == segment.Length) 582consumed == segment.Length) 604segment.Length == bytesConsumed) 626segment.Length == bytesConsumed) 648segment.Length == bytesConsumed) 697if (segment.Length > JsonConstants.MaximumEscapedGuidLength) 711if (segment.Length == JsonConstants.MaximumFormatGuidLength 949database.Append(tokenType, tokenStart, reader.ValueSpan.Length); 996database.Append(tokenType, tokenStart, reader.ValueSpan.Length); 1012database.Append(tokenType, tokenStart + 1, reader.ValueSpan.Length); 1037database.Append(tokenType, tokenStart + 1, reader.ValueSpan.Length); 1046database.Append(tokenType, tokenStart, reader.ValueSpan.Length); 1053Debug.Assert(reader.BytesConsumed == utf8JsonSpan.Length);
System\Text\Json\Document\JsonDocument.Parse.cs (12)
177byte[] owned = new byte[utf8Json.Length]; 578int payloadLength = reader.ValueSpan.Length + 2; 603payloadLength += reader.ValueSpan.Length; 644int length = valueSpan.IsEmpty ? checked((int)valueSequence.Length) : valueSpan.Length; 812long expectedLength = Math.Max(utf8Bom.Length, stream.Length - stream.Position) + 1; 826Debug.Assert(rented.Length >= utf8Bom.Length); 831utf8Bom.Length - written); 834} while (lastRead > 0 && written < utf8Bom.Length); 837if (written == utf8Bom.Length && 838utf8Bom.SequenceEqual(rented.AsSpan(0, utf8Bom.Length))) 889int utf8BomLength = JsonConstants.Utf8Bom.Length; 909Debug.Assert(rented.Length >= JsonConstants.Utf8Bom.Length);
System\Text\Json\Document\JsonDocument.TryGetProperty.cs (6)
26int maxBytes = JsonReaderHelper.s_utf8Encoding.GetMaxByteCount(propertyName.Length); 50int minBytes = propertyName.Length; 172if (currentPropertyName.Length > propertyName.Length) 178if (propertyName.Length > idx && 181int remaining = currentPropertyName.Length - idx;
System\Text\Json\JsonEncodedText.cs (2)
68if (value.Length == 0) 115if (utf8Value.Length == 0)
System\Text\Json\JsonHelpers.cs (25)
231Span<char> charBuffer = utf8Key.Length <= JsonConstants.StackallocCharThreshold ? 233(rentedBuffer = ArrayPool<char>.Shared.Rent(utf8Key.Length)); 336Debug.Assert(left.Length > 0 && right.Length > 0); 353(nDigits = (leftIntegral.Length + leftFractional.Length)) != 354rightIntegral.Length + rightFractional.Length) 369int diff = leftIntegral.Length - rightIntegral.Length; 376int rightOffset = rightIntegral.Length + diff; 392int leftOffset = leftIntegral.Length - diff; 402Debug.Assert(leftFirst.Length == rightFirst.Length); 403Debug.Assert(leftMiddle.Length == rightMiddle.Length); 404Debug.Assert(leftLast.Length == rightLast.Length); 431Debug.Assert(span.Length > 0); 476Debug.Assert(span.Length >= 10); 491Debug.Assert(intg.Length == 1, "Leading zeros not permitted in JSON numbers."); 511exp += intg.Length - fz; 517exp -= frac.Length; 536return firstNonZero < 0 ? span.Length - 1 : firstNonZero - 1; 554return lastNonZero == span.Length - 1 ? -1 : lastNonZero + 1;
System\Text\Json\JsonHelpers.Date.cs (19)
146Debug.Assert(source.Length >= 10); 183if (source.Length == 10) 225if (source.Length < 16) 240Debug.Assert(source.Length >= 16); 241if (source.Length == 16) 254return sourceIndex == source.Length; 266if (source.Length < 19 273Debug.Assert(source.Length >= 19); 274if (source.Length == 19) 287return sourceIndex == source.Length; 300if (source.Length < 21) 308int fractionEnd = Math.Min(sourceIndex + JsonConstants.DateTimeParseNumFractionDigits, source.Length); 332Debug.Assert(sourceIndex <= source.Length); 333if (sourceIndex == source.Length) 345return sourceIndex == source.Length; 357if (offsetData.Length < 2 365if (offsetData.Length == 2) 372if (offsetData.Length != 5 386Debug.Assert(source.Length == 2);
System\Text\Json\JsonHelpers.Escaping.cs (7)
33Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 34Debug.Assert(firstEscapeIndexVal >= 0 && firstEscapeIndexVal < utf8Value.Length); 38int length = JsonWriterHelper.GetMaxEscapedLength(utf8Value.Length, firstEscapeIndexVal); 61Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 62Debug.Assert(firstEscapeIndexVal >= 0 && firstEscapeIndexVal < utf8Value.Length); 66int length = JsonWriterHelper.GetMaxEscapedLength(utf8Value.Length, firstEscapeIndexVal); 86int length = utf8Value.Length;
System\Text\Json\Nodes\JsonArray.cs (1)
163List<JsonNode?> list = new(items.Length);
System\Text\Json\Reader\JsonReaderHelper.cs (14)
84if (!JsonHelpers.IsValidDateTimeOffsetParseLength(segment.Length)) 110Debug.Assert(source.Length <= JsonConstants.MaximumEscapedDateTimeOffsetParseLength); 132if (!JsonHelpers.IsValidDateTimeOffsetParseLength(segment.Length)) 158Debug.Assert(source.Length <= JsonConstants.MaximumEscapedDateTimeOffsetParseLength); 180Debug.Assert(source.Length <= JsonConstants.MaximumEscapedGuidLength); 203if (span.Length == 3) 211else if (span.Length == 8) 219else if (span.Length == 9) 235if (span.Length == 3) 243else if (span.Length == 8) 251else if (span.Length == 9) 266if (span.Length == 3) 274else if (span.Length == 8) 282else if (span.Length == 9)
System\Text\Json\Reader\JsonReaderHelper.Unescaping.cs (29)
18Span<byte> utf8Unescaped = utf8Source.Length <= JsonConstants.StackallocByteThreshold ? 20(unescapedArray = ArrayPool<byte>.Shared.Rent(utf8Source.Length)); 45int length = utf8Source.Length; 72int length = utf8Source.Length; 96Debug.Assert(utf8Source.Length >= other.Length && utf8Source.Length / JsonConstants.MaxExpansionFactorWhileEscaping <= other.Length); 100Span<byte> utf8Unescaped = utf8Source.Length <= JsonConstants.StackallocByteThreshold ? 102(unescapedArray = ArrayPool<byte>.Shared.Rent(utf8Source.Length)); 124Debug.Assert(utf8Source.Length >= other.Length && utf8Source.Length / JsonConstants.MaxExpansionFactorWhileEscaping <= other.Length); 173Span<byte> utf8Unescaped1 = utf8Source1.Length <= JsonConstants.StackallocByteThreshold ? 175(unescapedArray1 = ArrayPool<byte>.Shared.Rent(utf8Source1.Length)); 177Span<byte> utf8Unescaped2 = utf8Source2.Length <= JsonConstants.StackallocByteThreshold ? 179(unescapedArray2 = ArrayPool<byte>.Shared.Rent(utf8Source2.Length)); 222Span<byte> byteSpan = utf8Unescaped.Length <= JsonConstants.StackallocByteThreshold ? 224(pooledArray = ArrayPool<byte>.Shared.Rent(utf8Unescaped.Length)); 240Debug.Assert(bytesConsumed == utf8Unescaped.Length); 446Debug.Assert(destination.Length >= source.Length); 457Debug.Assert(idx >= 0 && idx < source.Length); 459Debug.Assert(destination.Length >= source.Length); 481Debug.Assert(idx >= 0 && idx < source.Length); 532Debug.Assert(source.Length >= idx + 5); 550if (source.Length < idx + 7 || source[idx + 1] != '\\' || source[idx + 2] != 'u') 587if (++idx == source.Length) 598nextUnescapedSegmentLength = remaining.Length; 628Debug.Assert(idx == source.Length || source[idx] == JsonConstants.BackSlash); 630if (idx == source.Length)
System\Text\Json\Reader\Utf8JsonReader.cs (52)
55internal readonly int ValueLength => HasValueSequence ? checked((int)ValueSequence.Length) : ValueSpan.Length; 531if (MatchNotPossible(text.Length)) 540int length = checked(text.Length * JsonConstants.MaxExpansionFactorWhileTranscoding); 587if (localSequence.Length != other.Length) 600matchedSoFar += span.Length; 615if (localSpan.Length < other.Length || localSpan.Length / JsonConstants.MaxExpansionFactorWhileEscaping > other.Length) 641if (sequenceLength < other.Length || sequenceLength / JsonConstants.MaxExpansionFactorWhileEscaping > other.Length) 682matchedSoFar += span.Length; 703int sourceLength = ValueSpan.Length; 919if (_consumed >= (uint)_buffer.Length) 949if (_consumed >= (uint)_buffer.Length) 1011for (; _consumed < localBuffer.Length; _consumed++) 1094if (_consumed >= (uint)_buffer.Length) 1136Debug.Assert(span.Length > 0); 1144ValueSpan = span.Slice(0, literal.Length); 1146_consumed += literal.Length; 1147_bytePositionInLine += literal.Length; 1153Debug.Assert(span.Length > 0 && span[0] == literal[0]); 1157for (int i = 1; i < literal.Length; i++) 1159if (span.Length > i) 1174Debug.Assert(indexOfFirstMismatch > 0 && indexOfFirstMismatch < literal.Length); 1216if (_consumed >= (uint)_buffer.Length) 1230((_consumed < _buffer.Length) && 1233|| (_isNotPrimitive ^ (_consumed >= (uint)_buffer.Length))); 1281Debug.Assert(_buffer.Length >= _consumed + 1); 1314_bytePositionInLine += localBuffer.Length + 1; // Account for the start quote 1326Debug.Assert(idx >= 0 && idx < data.Length); 1336for (; idx < data.Length; idx++) 1370idx = data.Length; 1385if (idx >= data.Length) 1407for (int j = idx; j < data.Length; j++) 1428Debug.Assert(data.Length > 0); 1545if (i >= data.Length) 1570if (i < data.Length) 1607for (; i < data.Length; i++) 1615if (i >= data.Length) 1639if (i >= data.Length) 1661if (i >= data.Length) 1675if (i >= data.Length) 1760if (_consumed >= (uint)_buffer.Length) 1897if (_consumed >= (uint)_buffer.Length) 2229if (_consumed >= (uint)_buffer.Length) 2319if (localBuffer.Length > 0) 2358if (idx < localBuffer.Length - 1) 2381idx = localBuffer.Length; 2384_bytePositionInLine += 2 + localBuffer.Length; 2435if (localBuffer.Length < 2) 2496if (localBuffer.Length > 0)
System\Text\Json\Reader\Utf8JsonReader.MultiSegment.cs (65)
68bool firstSegmentIsEmpty = _buffer.Length == 0; 252if (_consumed >= (uint)_buffer.Length) 280if (_consumed >= (uint)_buffer.Length) 384if (_consumed < _buffer.Length) 461if (_consumed >= (uint)_buffer.Length) 513Debug.Assert(span.Length > 0); 516int consumed = literal.Length; 529ValueSpan = span.Slice(0, literal.Length); 540Debug.Assert(span.Length > 0 && span[0] == literal[0] && literal.Length <= JsonConstants.MaximumLiteralLength); 547if (span.Length >= literal.Length || IsLastSpan) 567ReadOnlySpan<byte> leftToMatch = literal.Slice(span.Length); 571int alreadyMatched = literal.Length - leftToMatch.Length; 588int amountToWrite = Math.Min(span.Length, readSoFar.Length - written); 598SequencePosition end = new SequencePosition(_currentPosition.GetObject(), _currentPosition.GetInteger() + leftToMatch.Length); 600consumed = leftToMatch.Length; 615leftToMatch = leftToMatch.Slice(span.Length); 616alreadyMatched = span.Length; 623readSoFar.Length - written, 624Math.Min(span.Length, (int)bytePositionInLine + 1)); 635Debug.Assert(span.Length > 0); 652Debug.Assert(indexOfFirstMismatch >= 0 && indexOfFirstMismatch < literal.Length); 688if (_consumed >= (uint)_buffer.Length) 702((_consumed < _buffer.Length) && 705|| (_isNotPrimitive ^ (_consumed >= (uint)_buffer.Length))); 753Debug.Assert(_buffer.Length >= _consumed + 1); 787_bytePositionInLine += localBuffer.Length + 1; // Account for the start quote 800int leftOver = _buffer.Length - _consumed; 841for (; idx < localBuffer.Length; idx++) 874for (; j < localBuffer.Length; j++) 905_totalConsumed += localBuffer.Length; 933_totalConsumed += localBuffer.Length; 947_totalConsumed += localBuffer.Length; 948_bytePositionInLine += localBuffer.Length; 962Debug.Assert(idx >= 0 && idx < data.Length); 970int leftOverFromConsumed = _buffer.Length - _consumed; 978for (; idx < data.Length; idx++) 1011for (; j < data.Length; j++) 1045_totalConsumed += data.Length; 1078_totalConsumed += data.Length; 1127Debug.Assert(data.Length > 0); 1266if (i >= data.Length) 1306if (i < data.Length) 1359for (; i < data.Length; i++) 1368if (i >= data.Length) 1397for (; i < data.Length; i++) 1406if (i >= data.Length) 1435if (i >= data.Length) 1469if (i >= data.Length) 1497if (i >= data.Length) 1599if (_consumed >= (uint)_buffer.Length) 1745if (_consumed >= (uint)_buffer.Length) 2092if (_consumed >= (uint)_buffer.Length) 2245if (localBuffer.Length == 0) 2278if (localBuffer.Length == 0) 2359if (idx < localBuffer.Length - 1) 2375_consumed += localBuffer.Length; 2376_bytePositionInLine += localBuffer.Length; 2427Debug.Assert(dangerousLineSeparatorBytesConsumed >= 1 && dangerousLineSeparatorBytesConsumed <= 2 && localBuffer.Length <= 1); 2458Debug.Assert(localBuffer.Length < 2); 2521Debug.Assert(localBuffer.Length > 0); 2576_consumed += localBuffer.Length; 2577_bytePositionInLine += localBuffer.Length;
System\Text\Json\Reader\Utf8JsonReader.TryGet.cs (21)
106bytesWritten = valueSpan.Length; 188new Span<byte>(rentedBuffer, 0, unescapedSource.Length).Clear(); 224new Span<byte>(rentedBuffer, 0, source.Length).Clear(); 228Debug.Assert(bytesWritten < source.Length, "source buffer must contain at least one escape sequence"); 262Debug.Assert((HasValueSequence ? ValueSequence.ToArray() : ValueSpan).Length == 4); 271Debug.Assert((HasValueSequence ? ValueSequence.ToArray() : ValueSpan).Length == 5); 607&& span.Length == bytesConsumed 664&& span.Length == bytesConsumed 870&& span.Length == bytesConsumed) 906&& span.Length == bytesConsumed) 941&& span.Length == bytesConsumed) 976&& span.Length == bytesConsumed) 1011&& span.Length == bytesConsumed) 1047&& span.Length == bytesConsumed) 1083&& span.Length == bytesConsumed) 1119&& span.Length == bytesConsumed) 1149&& span.Length == bytesConsumed) 1179&& span.Length == bytesConsumed) 1214&& span.Length == bytesConsumed) 1354if (ValueSpan.Length > JsonConstants.MaximumEscapedGuidLength) 1370if (span.Length == JsonConstants.MaximumFormatGuidLength
System\Text\Json\Schema\JsonSchemaExporter.cs (1)
473using ValueStringBuilder sb = new(initialCapacity: path.Length * 10);
System\Text\Json\Serialization\Converters\Collection\ReadOnlyMemoryConverter.cs (2)
61for (; index < value.Length; index++) 68for (; index < value.Length; index++)
System\Text\Json\Serialization\Converters\Object\ObjectDefaultConverter.cs (2)
387while (state.Current.EnumeratorIndex < propertyCache.Length) 416if (state.Current.EnumeratorIndex == propertyCache.Length)
System\Text\Json\Serialization\Converters\Object\ObjectWithParameterizedConstructorConverter.cs (3)
366ArrayPool<FoundProperty>.Shared.Rent(Math.Max(1, state.Current.JsonTypeInfo.PropertyCache.Length)); 562argumentState.FoundPropertiesAsync = ArrayPool<FoundPropertyAsync>.Shared.Rent(Math.Max(1, state.Current.JsonTypeInfo.PropertyCache.Length)); 595if (jsonTypeInfo.ParameterCount != jsonTypeInfo.ParameterCache.Length)
System\Text\Json\Serialization\Converters\Object\ObjectWithParameterizedConstructorConverter.Large.cs (1)
56object?[] arguments = ArrayPool<object>.Shared.Rent(typeInfo.ParameterCache.Length);
System\Text\Json\Serialization\Converters\Value\BooleanConverter.cs (1)
28&& propertyName.Length == bytesConsumed))
System\Text\Json\Serialization\Converters\Value\TimeOnlyConverter.cs (1)
70if (!result || source.Length != bytesConsumed)
System\Text\Json\Serialization\Converters\Value\TimeSpanConverter.cs (1)
69if (!result || source.Length != bytesConsumed)
System\Text\Json\Serialization\JsonSerializer.Read.HandleMetadata.cs (3)
316(propertyName.Length > 0 && propertyName[0] == '$') || 322if (propertyName.Length > 0 && propertyName[0] == '$') 324switch (propertyName.Length)
System\Text\Json\Serialization\JsonSerializer.Read.Span.cs (2)
148Debug.Assert(reader.BytesConsumed == (actualByteCount ?? utf8Json.Length) || reader.CurrentState.Options.AllowMultipleValues); 165Debug.Assert(reader.BytesConsumed == (actualByteCount ?? utf8Json.Length) || reader.CurrentState.Options.AllowMultipleValues);
System\Text\Json\Serialization\JsonSerializer.Read.String.cs (6)
389json.Length <= (JsonConstants.StackallocByteThreshold / JsonConstants.MaxExpansionFactorWhileTranscoding) ? stackalloc byte[JsonConstants.StackallocByteThreshold] : 391json.Length <= (JsonConstants.ArrayPoolMaxSizeBeforeUsingNormalAlloc / JsonConstants.MaxExpansionFactorWhileTranscoding) ? tempArray = ArrayPool<byte>.Shared.Rent(json.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) : 420json.Length <= (JsonConstants.StackallocByteThreshold / JsonConstants.MaxExpansionFactorWhileTranscoding) ? stackalloc byte[JsonConstants.StackallocByteThreshold] : 422json.Length <= (JsonConstants.ArrayPoolMaxSizeBeforeUsingNormalAlloc / JsonConstants.MaxExpansionFactorWhileTranscoding) ? tempArray = ArrayPool<byte>.Shared.Rent(json.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) :
System\Text\Json\Serialization\JsonSerializer.Read.Utf8JsonReader.cs (2)
401int payloadLength = reader.ValueSpan.Length + 2; 420: reader.ValueSpan.Length + 2;
System\Text\Json\Serialization\Metadata\JsonTypeInfo.Cache.cs (1)
96int count = utf8PropertyCacheSpan.Length;
System\Text\Json\Serialization\Metadata\JsonTypeInfoOfT.ReadHelper.cs (2)
120Debug.Assert(reader.BytesConsumed <= bufferState.Bytes.Length); 121Debug.Assert(!bufferState.IsFinalBlock || reader.AllowMultipleValues || reader.BytesConsumed == bufferState.Bytes.Length,
System\Text\Json\Serialization\Metadata\PropertyRef.cs (10)
45return key == Key && (propertyName.Length <= PropertyNameKeyLength || propertyName.SequenceEqual(Utf8PropertyName)); 55int length = name.Length; 77(name.Length < 1 || name[0] == ((key & ((ulong)0xFF << BitsInByte * 0)) >> BitsInByte * 0)) && 78(name.Length < 2 || name[1] == ((key & ((ulong)0xFF << BitsInByte * 1)) >> BitsInByte * 1)) && 79(name.Length < 3 || name[2] == ((key & ((ulong)0xFF << BitsInByte * 2)) >> BitsInByte * 2)) && 80(name.Length < 4 || name[3] == ((key & ((ulong)0xFF << BitsInByte * 3)) >> BitsInByte * 3)) && 81(name.Length < 5 || name[4] == ((key & ((ulong)0xFF << BitsInByte * 4)) >> BitsInByte * 4)) && 82(name.Length < 6 || name[5] == ((key & ((ulong)0xFF << BitsInByte * 5)) >> BitsInByte * 5)) && 83(name.Length < 7 || name[6] == ((key & ((ulong)0xFF << BitsInByte * 6)) >> BitsInByte * 6)) && 85(key & ((ulong)0xFF << BitsInByte * 7)) >> BitsInByte * 7 == (byte)name.Length,
System\Text\Json\Serialization\ReadBufferState.cs (4)
46_buffer = ArrayPool<byte>.Shared.Rent(Math.Max(initialBufferSize, JsonConstants.Utf8Bom.Length)); 169Debug.Assert(_buffer.Length >= JsonConstants.Utf8Bom.Length); 172_offset = (byte)JsonConstants.Utf8Bom.Length; 173_count -= JsonConstants.Utf8Bom.Length;
System\Text\Json\ThrowHelper.cs (22)
142if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize) 144ThrowArgumentException(SR.Format(SR.PropertyNameTooLarge, propertyName.Length)); 148Debug.Assert(value.Length > JsonConstants.MaxUnescapedTokenSize); 149ThrowArgumentException(SR.Format(SR.ValueTooLarge, value.Length)); 156if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize) 158ThrowArgumentException(SR.Format(SR.PropertyNameTooLarge, propertyName.Length)); 162Debug.Assert(value.Length > JsonConstants.MaxCharacterTokenSize); 163ThrowArgumentException(SR.Format(SR.ValueTooLarge, value.Length)); 170if (propertyName.Length > JsonConstants.MaxCharacterTokenSize) 172ThrowArgumentException(SR.Format(SR.PropertyNameTooLarge, propertyName.Length)); 176Debug.Assert(value.Length > JsonConstants.MaxUnescapedTokenSize); 177ThrowArgumentException(SR.Format(SR.ValueTooLarge, value.Length)); 184if (propertyName.Length > JsonConstants.MaxCharacterTokenSize) 186ThrowArgumentException(SR.Format(SR.PropertyNameTooLarge, propertyName.Length)); 190Debug.Assert(value.Length > JsonConstants.MaxCharacterTokenSize); 191ThrowArgumentException(SR.Format(SR.ValueTooLarge, value.Length)); 205Debug.Assert(propertyName.Length > JsonConstants.MaxCharacterTokenSize); 206ThrowArgumentException(SR.Format(SR.PropertyNameTooLarge, propertyName.Length)); 258Debug.Assert(propertyName.Length > JsonConstants.MaxCharacterTokenSize); 259ThrowArgumentException(SR.Format(SR.PropertyNameTooLarge, propertyName.Length)); 534int printFirst10 = Math.Min(value.Length, 10); 549if (printFirst10 < value.Length)
System\Text\Json\ThrowHelper.Node.cs (2)
58Debug.Assert(supportedTypeNames.Length > 0); 59string concatenatedNames = supportedTypeNames.Length == 1 ? supportedTypeNames[0] : string.Join(", ", supportedTypeNames.ToArray());
System\Text\Json\ThrowHelper.Serialization.cs (1)
355if (str.Length <= MaxLength)
System\Text\Json\Writer\JsonWriterHelper.cs (32)
66if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize) 67ThrowHelper.ThrowArgumentException_PropertyNameTooLarge(propertyName.Length); 73if (value.Length > JsonConstants.MaxUnescapedTokenSize) 74ThrowHelper.ThrowArgumentException_ValueTooLarge(value.Length); 98if (propertyName.Length > JsonConstants.MaxCharacterTokenSize) 99ThrowHelper.ThrowArgumentException_PropertyNameTooLarge(propertyName.Length); 105if (value.Length > JsonConstants.MaxCharacterTokenSize) 106ThrowHelper.ThrowArgumentException_ValueTooLarge(value.Length); 112if (propertyName.Length > JsonConstants.MaxCharacterTokenSize || value.Length > JsonConstants.MaxUnescapedTokenSize) 119if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize || value.Length > JsonConstants.MaxCharacterTokenSize) 126if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize || value.Length > JsonConstants.MaxUnescapedTokenSize) 133if (propertyName.Length > JsonConstants.MaxCharacterTokenSize || value.Length > JsonConstants.MaxCharacterTokenSize) 140if (propertyName.Length > JsonConstants.MaxCharacterTokenSize) 141ThrowHelper.ThrowPropertyNameTooLargeArgumentException(propertyName.Length); 147if (propertyName.Length > JsonConstants.MaxUnescapedTokenSize) 148ThrowHelper.ThrowPropertyNameTooLargeArgumentException(propertyName.Length); 166if (utf8FormattedNumber.Length <= i) 178while (i < utf8FormattedNumber.Length && JsonHelpers.IsDigit(utf8FormattedNumber[i])) 184if (i == utf8FormattedNumber.Length) 196if (utf8FormattedNumber.Length <= i) 201while (i < utf8FormattedNumber.Length && JsonHelpers.IsDigit(utf8FormattedNumber[i])) 206if (i == utf8FormattedNumber.Length) 211Debug.Assert(i < utf8FormattedNumber.Length); 219if (utf8FormattedNumber.Length <= i) 238if (utf8FormattedNumber.Length <= i) 243while (i < utf8FormattedNumber.Length && JsonHelpers.IsDigit(utf8FormattedNumber[i])) 248if (i != utf8FormattedNumber.Length) 295Debug.Assert(charsRead == source.Length || status is not OperationStatus.Done);
System\Text\Json\Writer\JsonWriterHelper.Escaping.cs (7)
75return (encoder ?? JavaScriptEncoder.Default).FindFirstCharacterToEncode(ptr, value.Length); 101Debug.Assert(encoderBytesConsumed == value.Length || (result == OperationStatus.NeedMoreData && !isFinalBlock)); 112Debug.Assert(indexOfFirstByteToEscape >= 0 && indexOfFirstByteToEscape < value.Length); 128while (indexOfFirstByteToEscape < value.Length) 219Debug.Assert(encoderBytesConsumed == value.Length || (result == OperationStatus.NeedMoreData && !isFinalBlock)); 230Debug.Assert(indexOfFirstByteToEscape >= 0 && indexOfFirstByteToEscape < value.Length); 246while (indexOfFirstByteToEscape < value.Length)
System\Text\Json\Writer\Utf8JsonWriter.cs (18)
128Debug.Assert(partialStringDataBytes.Length == 3); 138Debug.Assert(value.Length <= 3); 143_partialStringDataLength = (byte)value.Length; 157Debug.Assert(partialStringDataBytes.Length == 3); 166Debug.Assert(value.Length <= 1); 171_partialStringDataLength = (byte)(2 * value.Length); 185Debug.Assert(partialStringDataBytes.Length == 3); 194Debug.Assert(value.Length < 3); 199_partialStringDataLength = (byte)value.Length; 722Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 786Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 814Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 815Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 819int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 935Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 963Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 964Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 968int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Bytes.cs (23)
23Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 106Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 122Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 136Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 137Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 141int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 159Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 160Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 164int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 208int encodedLength = Base64.GetMaxEncodedToUtf8Length(bytes.Length); 210Debug.Assert(escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding < int.MaxValue - encodedLength - 6); 214int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + encodedLength + 6; 243int encodedLength = Base64.GetMaxEncodedToUtf8Length(bytes.Length); 245Debug.Assert(escapedPropertyName.Length < int.MaxValue - encodedLength - 6); 249int maxRequired = escapedPropertyName.Length + encodedLength + 6; 265BytesPending += escapedPropertyName.Length; 282int encodedLength = Base64.GetMaxEncodedToUtf8Length(bytes.Length); 284Debug.Assert(escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding < int.MaxValue - indent - encodedLength - 7 - _newLineLength); 288int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + encodedLength + 7 + _newLineLength; 332int encodedLength = Base64.GetMaxEncodedToUtf8Length(bytes.Length); 334Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - encodedLength - 7 - _newLineLength); 338int maxRequired = indent + escapedPropertyName.Length + encodedLength + 7 + _newLineLength; 365BytesPending += escapedPropertyName.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.DateTime.cs (19)
27Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 113Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 129Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 143Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 144Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 148int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 166Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 167Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 171int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 215Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatDateTimeOffsetLength - 6); 219int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDateTimeOffsetLength + 6; 249Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatDateTimeOffsetLength - 6); 251int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatDateTimeOffsetLength + 5; // 2 quotes for property name, 2 quotes for date, and 1 colon 268BytesPending += escapedPropertyName.Length; 286Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatDateTimeOffsetLength - 7 - _newLineLength); 290int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDateTimeOffsetLength + 7 + _newLineLength; 335Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatDateTimeOffsetLength - 7 - _newLineLength); 337int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatDateTimeOffsetLength + 6; // 2 quotes for property name, 2 quotes for date, 1 colon, and 1 space 365BytesPending += escapedPropertyName.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.DateTimeOffset.cs (19)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 112Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 128Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 142Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 143Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 147int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 165Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 166Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 170int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 214Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatDateTimeOffsetLength - 6); 218int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDateTimeOffsetLength + 6; 248Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatDateTimeOffsetLength - 6); 250int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatDateTimeOffsetLength + 5; // 2 quotes for property name, 2 quotes for date, and 1 colon 267BytesPending += escapedPropertyName.Length; 285Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatDateTimeOffsetLength - 7 - _newLineLength); 289int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDateTimeOffsetLength + 7 + _newLineLength; 334Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatDateTimeOffsetLength - 7 - _newLineLength); 336int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatDateTimeOffsetLength + 6; // 2 quotes for property name, 2 quotes for date, 1 colon, and 1 space 364BytesPending += escapedPropertyName.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Decimal.cs (19)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 112Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 128Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 142Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 143Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 147int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 165Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 166Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 170int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 214Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatDecimalLength - 4); 218int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDecimalLength + 4; 245Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatDecimalLength - 4); 247int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatDecimalLength + 3; // 2 quotes for property name, and 1 colon 264BytesPending += escapedPropertyName.Length; 279Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatDecimalLength - 5 - _newLineLength); 283int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDecimalLength + 5 + _newLineLength; 325Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatDecimalLength - 5 - _newLineLength); 327int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatDecimalLength + 4; // 2 quotes for property name, 1 colon, and 1 space 355BytesPending += escapedPropertyName.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Double.cs (19)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 116Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 132Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 146Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 147Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 151int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 169Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 170Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 174int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 218Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatDoubleLength - 4); 222int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDoubleLength + 4; 249Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatDoubleLength - 4); 251int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatDoubleLength + 3; // 2 quotes for property name, and 1 colon 268BytesPending += escapedPropertyName.Length; 283Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatDoubleLength - 5 - _newLineLength); 287int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatDoubleLength + 5 + _newLineLength; 329Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatDoubleLength - 5 - _newLineLength); 331int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatDoubleLength + 4; // 2 quotes for property name, 1 colon, and 1 space 359BytesPending += escapedPropertyName.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Float.cs (19)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 116Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 132Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 146Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 147Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 151int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 169Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 170Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 174int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 218Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatSingleLength - 4); 222int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatSingleLength + 4; 249Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatSingleLength - 4); 251int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatSingleLength + 3; // 2 quotes for property name, and 1 colon 268BytesPending += escapedPropertyName.Length; 283Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatSingleLength - 5 - _newLineLength); 287int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatSingleLength + 5 + _newLineLength; 329Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatSingleLength - 5 - _newLineLength); 331int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatSingleLength + 4; // 2 quotes for property name, 1 colon, and 1 space 359BytesPending += escapedPropertyName.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.FormattedNumber.cs (8)
86Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 102Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 116Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 117Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 121int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 139Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 140Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 144int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp);
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Guid.cs (19)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 112Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 128Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 142Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 143Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 147int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 165Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 166Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 170int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 214Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatGuidLength - 6); 218int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatGuidLength + 6; 249Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatGuidLength - 6); 251int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatGuidLength + 5; // 2 quotes for property name, 2 quotes for date, and 1 colon 268BytesPending += escapedPropertyName.Length; 287Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatGuidLength - 7 - _newLineLength); 291int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatGuidLength + 7 + _newLineLength; 337Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatGuidLength - 7 - _newLineLength); 339int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatGuidLength + 6; // 2 quotes for property name, 2 quotes for date, 1 colon, and 1 space 367BytesPending += escapedPropertyName.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Helpers.cs (12)
17if (propertyName.Length > JsonConstants.MaxCharacterTokenSize || CurrentDepth >= _options.MaxDepth) 24if (utf8PropertyName.Length > JsonConstants.MaxUnescapedTokenSize || CurrentDepth >= _options.MaxDepth) 77Debug.Assert(escapedPropertyName.Length < int.MaxValue - 5); 79int minRequired = escapedPropertyName.Length + 4; // 2 quotes, 1 colon, and 1 start token 96BytesPending += escapedPropertyName.Length; 108Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - 6 - _newLineLength); 110int minRequired = indent + escapedPropertyName.Length + 5; // 2 quotes, 1 colon, 1 space, and 1 start token 138BytesPending += escapedPropertyName.Length; 149Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - 5); 153int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 5; 180Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - 6 - _newLineLength); 184int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 6 + _newLineLength;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.Literal.cs (44)
31escapedPropertyNameSection.Slice(1, escapedPropertyNameSection.Length - 3); 38Debug.Assert(escapedPropertyNameSection.Length <= JsonConstants.MaxUnescapedTokenSize - 3); 51Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 231Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 247Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 261Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 262Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 266int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 284Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 285Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 289int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 333Debug.Assert(value.Length <= JsonConstants.MaxUnescapedTokenSize); 334Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - value.Length - 4); 338int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + value.Length + 4; 359BytesPending += value.Length; 364Debug.Assert(value.Length <= JsonConstants.MaxUnescapedTokenSize); 365Debug.Assert(escapedPropertyName.Length < int.MaxValue - value.Length - 4); 367int minRequired = escapedPropertyName.Length + value.Length + 3; // 2 quotes for property name, and 1 colon 384BytesPending += escapedPropertyName.Length; 390BytesPending += value.Length; 397Debug.Assert(value.Length <= JsonConstants.MaxUnescapedTokenSize); 398Debug.Assert(escapedPropertyNameSection.Length < int.MaxValue - value.Length - 1); 400int minRequired = escapedPropertyNameSection.Length + value.Length; 415BytesPending += escapedPropertyNameSection.Length; 418BytesPending += value.Length; 426Debug.Assert(value.Length <= JsonConstants.MaxUnescapedTokenSize); 427Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - value.Length - 5 - _newLineLength); 431int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + value.Length + 5 + _newLineLength; 464BytesPending += value.Length; 472Debug.Assert(value.Length <= JsonConstants.MaxUnescapedTokenSize); 473Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - value.Length - 5 - _newLineLength); 475int minRequired = indent + escapedPropertyName.Length + value.Length + 4; // 2 quotes for property name, 1 colon, and 1 space 503BytesPending += escapedPropertyName.Length; 510BytesPending += value.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.SignedNumber.cs (19)
26Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 185Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 201Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 215Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 216Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 220int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 238Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 239Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 243int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 287Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatInt64Length - 4); 291int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatInt64Length + 4; 318Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatInt64Length - 4); 320int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatInt64Length + 3; // 2 quotes for property name, and 1 colon 337BytesPending += escapedPropertyName.Length; 352Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatInt64Length - 5 - _newLineLength); 356int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatInt64Length + 5 + _newLineLength; 398Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatInt64Length - 5 - _newLineLength); 400int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatInt64Length + 4; // 2 quotes for property name, 1 colon, and 1 space 428BytesPending += escapedPropertyName.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.String.cs (121)
27escapedPropertyNameSection.Slice(1, escapedPropertyNameSection.Length - 3); 33Debug.Assert(escapedPropertyNameSection.Length <= JsonConstants.MaxUnescapedTokenSize - 3); 45Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 95Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length && propertyIdx < int.MaxValue / 2); 112Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 119int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 158Debug.Assert(escapedPropertyName.Length <= JsonConstants.MaxEscapedTokenSize); 159Debug.Assert(escapedPropertyName.Length < (int.MaxValue - 4) / JsonConstants.MaxExpansionFactorWhileTranscoding); 163int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 4; 189Debug.Assert(escapedPropertyName.Length <= JsonConstants.MaxEscapedTokenSize); 190Debug.Assert(escapedPropertyName.Length < (int.MaxValue - 5 - indent - _newLineLength) / JsonConstants.MaxExpansionFactorWhileTranscoding); 194int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 5 + _newLineLength; 244Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length && propertyIdx < int.MaxValue / 2); 271Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 278int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 319Debug.Assert(escapedPropertyName.Length <= JsonConstants.MaxEscapedTokenSize); 320Debug.Assert(escapedPropertyName.Length < int.MaxValue - 4); 322int minRequired = escapedPropertyName.Length + 3; // 2 quotes for property name, and 1 colon 339BytesPending += escapedPropertyName.Length; 349Debug.Assert(escapedPropertyNameSection.Length <= JsonConstants.MaxEscapedTokenSize - 3); 350Debug.Assert(escapedPropertyNameSection.Length < int.MaxValue - 4); 352int maxRequired = escapedPropertyNameSection.Length + 1; // Optionally, 1 list separator 367BytesPending += escapedPropertyNameSection.Length; 377Debug.Assert(escapedPropertyName.Length <= JsonConstants.MaxEscapedTokenSize); 378Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - 5 - _newLineLength); 380int minRequired = indent + escapedPropertyName.Length + 4; // 2 quotes for property name, 1 colon, and 1 space 408BytesPending += escapedPropertyName.Length; 428Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize && utf8Value.Length <= JsonConstants.MaxUnescapedTokenSize); 595Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 601Debug.Assert(valueIdx >= -1 && valueIdx < value.Length && valueIdx < int.MaxValue / 2); 682Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 688Debug.Assert(valueIdx >= -1 && valueIdx < utf8Value.Length && valueIdx < int.MaxValue / 2); 769Debug.Assert(utf8Value.Length <= JsonConstants.MaxUnescapedTokenSize); 775Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length && propertyIdx < int.MaxValue / 2); 841Debug.Assert(utf8Value.Length <= JsonConstants.MaxUnescapedTokenSize); 847Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length && propertyIdx < int.MaxValue / 2); 896Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 897Debug.Assert(firstEscapeIndex >= 0 && firstEscapeIndex < utf8Value.Length); 901int length = JsonWriterHelper.GetMaxEscapedLength(utf8Value.Length, firstEscapeIndex); 919Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= value.Length); 920Debug.Assert(firstEscapeIndex >= 0 && firstEscapeIndex < value.Length); 924int length = JsonWriterHelper.GetMaxEscapedLength(value.Length, firstEscapeIndex); 942Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 943Debug.Assert(firstEscapeIndex >= 0 && firstEscapeIndex < propertyName.Length); 947int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndex); 965Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 966Debug.Assert(firstEscapeIndex >= 0 && firstEscapeIndex < utf8PropertyName.Length); 970int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndex); 991Debug.Assert(valueIdx >= -1 && valueIdx < value.Length && valueIdx < int.MaxValue / 2); 992Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length && propertyIdx < int.MaxValue / 2); 1010Debug.Assert(valueIdx >= -1 && valueIdx < utf8Value.Length && valueIdx < int.MaxValue / 2); 1011Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length && propertyIdx < int.MaxValue / 2); 1029Debug.Assert(valueIdx >= -1 && valueIdx < utf8Value.Length && valueIdx < int.MaxValue / 2); 1030Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length && propertyIdx < int.MaxValue / 2); 1048Debug.Assert(valueIdx >= -1 && valueIdx < value.Length && valueIdx < int.MaxValue / 2); 1049Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length && propertyIdx < int.MaxValue / 2); 1064Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= value.Length); 1065Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 1073int length = JsonWriterHelper.GetMaxEscapedLength(value.Length, firstEscapeIndexVal); 1093int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 1124Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 1125Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 1133int length = JsonWriterHelper.GetMaxEscapedLength(utf8Value.Length, firstEscapeIndexVal); 1153int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 1184Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 1185Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 1193int length = JsonWriterHelper.GetMaxEscapedLength(utf8Value.Length, firstEscapeIndexVal); 1213int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 1244Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= value.Length); 1245Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 1253int length = JsonWriterHelper.GetMaxEscapedLength(value.Length, firstEscapeIndexVal); 1273int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 1357Debug.Assert(escapedValue.Length <= JsonConstants.MaxUnescapedTokenSize); 1358Debug.Assert(escapedPropertyName.Length < ((int.MaxValue - 6) / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length); 1362int maxRequired = ((escapedPropertyName.Length + escapedValue.Length) * JsonConstants.MaxExpansionFactorWhileTranscoding) + 6; 1392Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1393Debug.Assert(escapedPropertyName.Length < int.MaxValue - escapedValue.Length - 6); 1395int minRequired = escapedPropertyName.Length + escapedValue.Length + 5; // 2 quotes for property name, 2 quotes for value, and 1 colon 1412BytesPending += escapedPropertyName.Length; 1420BytesPending += escapedValue.Length; 1428Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1429Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length - 6); 1433int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + escapedValue.Length + 6; 1456BytesPending += escapedValue.Length; 1464Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1465Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length - 6); 1469int maxRequired = (escapedValue.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + escapedPropertyName.Length + 6; 1485BytesPending += escapedPropertyName.Length; 1503Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1504Debug.Assert(escapedPropertyName.Length < ((int.MaxValue - 7 - indent - _newLineLength) / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length); 1508int maxRequired = indent + ((escapedPropertyName.Length + escapedValue.Length) * JsonConstants.MaxExpansionFactorWhileTranscoding) + 7 + _newLineLength; 1553Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1554Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - escapedValue.Length - 7 - _newLineLength); 1556int minRequired = indent + escapedPropertyName.Length + escapedValue.Length + 6; // 2 quotes for property name, 2 quotes for value, 1 colon, and 1 space 1584BytesPending += escapedPropertyName.Length; 1593BytesPending += escapedValue.Length; 1604Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1605Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length - 7 - indent - _newLineLength); 1609int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + escapedValue.Length + 7 + _newLineLength; 1644BytesPending += escapedValue.Length; 1655Debug.Assert(escapedValue.Length <= JsonConstants.MaxEscapedTokenSize); 1656Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - escapedValue.Length - 7 - indent - _newLineLength); 1660int maxRequired = indent + (escapedValue.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + escapedPropertyName.Length + 7 + _newLineLength; 1687BytesPending += escapedPropertyName.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteProperties.UnsignedNumber.cs (19)
27Debug.Assert(utf8PropertyName.Length <= JsonConstants.MaxUnescapedTokenSize); 194Debug.Assert(propertyIdx >= -1 && propertyIdx < propertyName.Length); 210Debug.Assert(propertyIdx >= -1 && propertyIdx < utf8PropertyName.Length); 224Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length); 225Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < propertyName.Length); 229int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp); 247Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length); 248Debug.Assert(firstEscapeIndexProp >= 0 && firstEscapeIndexProp < utf8PropertyName.Length); 252int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp); 296Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - JsonConstants.MaximumFormatUInt64Length - 4); 300int maxRequired = (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatUInt64Length + 4; 327Debug.Assert(escapedPropertyName.Length < int.MaxValue - JsonConstants.MaximumFormatUInt64Length - 4); 329int minRequired = escapedPropertyName.Length + JsonConstants.MaximumFormatUInt64Length + 3; // 2 quotes for property name, and 1 colon 346BytesPending += escapedPropertyName.Length; 361Debug.Assert(escapedPropertyName.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - JsonConstants.MaximumFormatUInt64Length - 5 - _newLineLength); 365int maxRequired = indent + (escapedPropertyName.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + JsonConstants.MaximumFormatUInt64Length + 5 + _newLineLength; 407Debug.Assert(escapedPropertyName.Length < int.MaxValue - indent - JsonConstants.MaximumFormatUInt64Length - 5 - _newLineLength); 409int minRequired = indent + escapedPropertyName.Length + JsonConstants.MaximumFormatUInt64Length + 4; // 2 quotes for property name, 1 colon, and 1 space 437BytesPending += escapedPropertyName.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Bytes.cs (6)
56if (bytes.Length > MaxLengthAllowed) 58ThrowHelper.ThrowArgumentException_ValueTooLarge(bytes.Length); 61int encodingLength = Base64.GetMaxEncodedToUtf8Length(bytes.Length); 99if (bytes.Length > maxLengthAllowed) 101ThrowHelper.ThrowArgumentException_ValueTooLarge(bytes.Length); 104int encodingLength = Base64.GetMaxEncodedToUtf8Length(bytes.Length);
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Comment.cs (10)
80Debug.Assert(value.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - 4); 84int maxRequired = (value.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 4; 114Debug.Assert(value.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - 4 - _newLineLength); 118int maxRequired = indent + (value.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 4 + _newLineLength; 195Debug.Assert(utf8Value.Length < int.MaxValue - 4); 197int maxRequired = utf8Value.Length + 4; // /*...*/ 210BytesPending += utf8Value.Length; 221Debug.Assert(utf8Value.Length < int.MaxValue - indent - 4 - _newLineLength); 223int minRequired = indent + utf8Value.Length + 4; // /*...*/ 245BytesPending += utf8Value.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.FormattedNumber.cs (5)
49int maxRequired = utf8Value.Length + 1; // Optionally, 1 list separator 64BytesPending += utf8Value.Length; 72Debug.Assert(utf8Value.Length < int.MaxValue - indent - 1 - _newLineLength); 74int maxRequired = indent + utf8Value.Length + 1 + _newLineLength; // Optionally, 1 list separator and 1-2 bytes for new line 99BytesPending += utf8Value.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Helpers.cs (1)
133Debug.Assert(consumed == bytes.Length);
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Literal.cs (6)
66Debug.Assert(utf8Value.Length <= 5); 68int maxRequired = utf8Value.Length + 1; // Optionally, 1 list separator 83BytesPending += utf8Value.Length; 90Debug.Assert(utf8Value.Length <= 5); 92int maxRequired = indent + utf8Value.Length + 1 + _newLineLength; // Optionally, 1 list separator and 1-2 bytes for new line 117BytesPending += utf8Value.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.Raw.cs (7)
105if (utf8Json.Length == int.MaxValue) 195if (json.Length > JsonConstants.MaxUtf16RawValueLength) 197ThrowHelper.ThrowArgumentException_ValueTooLarge(json.Length); 205json.Length <= (JsonConstants.StackallocByteThreshold / JsonConstants.MaxExpansionFactorWhileTranscoding) ? stackalloc byte[JsonConstants.StackallocByteThreshold] : 207json.Length <= (JsonConstants.ArrayPoolMaxSizeBeforeUsingNormalAlloc / JsonConstants.MaxExpansionFactorWhileTranscoding) ? tempArray = ArrayPool<byte>.Shared.Rent(json.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) : 230int len = utf8Json.Length;
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.String.cs (19)
21Debug.Assert(utf8Value.Length <= JsonConstants.MaxUnescapedTokenSize); 86Debug.Assert(valueIdx >= -1 && valueIdx < value.Length); 118Debug.Assert(escapedValue.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - 3); 122int maxRequired = (escapedValue.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 3; 148Debug.Assert(escapedValue.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding) - indent - 3 - _newLineLength); 152int maxRequired = indent + (escapedValue.Length * JsonConstants.MaxExpansionFactorWhileTranscoding) + 3 + _newLineLength; 185Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= value.Length); 186Debug.Assert(firstEscapeIndexVal >= 0 && firstEscapeIndexVal < value.Length); 190int length = JsonWriterHelper.GetMaxEscapedLength(value.Length, firstEscapeIndexVal); 233Debug.Assert(valueIdx >= -1 && valueIdx < utf8Value.Length); 265Debug.Assert(escapedValue.Length < int.MaxValue - 3); 267int minRequired = escapedValue.Length + 2; // 2 quotes 284BytesPending += escapedValue.Length; 295Debug.Assert(escapedValue.Length < int.MaxValue - indent - 3 - _newLineLength); 297int minRequired = indent + escapedValue.Length + 2; // 2 quotes 325BytesPending += escapedValue.Length; 332Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 333Debug.Assert(firstEscapeIndexVal >= 0 && firstEscapeIndexVal < utf8Value.Length); 337int length = JsonWriterHelper.GetMaxEscapedLength(utf8Value.Length, firstEscapeIndexVal);
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.StringSegment.cs (45)
77Debug.Assert(value.Length + partialStringDataBuffer.Length < 2); 78Debug.Assert(charsConsumed == value.Length + partialStringDataBuffer.Length); 84Debug.Assert(charsConsumed > partialStringDataBuffer.Length); 87value = value.Slice(charsConsumed - partialStringDataBuffer.Length); 91Debug.Assert(charsConsumed >= partialStringDataBuffer.Length); 93value = value.Slice(charsConsumed - partialStringDataBuffer.Length); 135Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= value.Length); 136Debug.Assert(firstEscapeIndexVal >= 0 && firstEscapeIndexVal < value.Length); 140int length = JsonWriterHelper.GetMaxEscapedLength(value.Length, firstEscapeIndexVal); 150Debug.Assert(consumed == value.Length || !isFinalSegment); 151if (value.Length != consumed) 154Debug.Assert(value.Length - consumed < 2); 166Debug.Assert(escapedValue.Length < (int.MaxValue / JsonConstants.MaxExpansionFactorWhileTranscoding)); 168int requiredBytes = escapedValue.Length * JsonConstants.MaxExpansionFactorWhileTranscoding; 245Debug.Assert(utf8Value.Length + partialStringDataBuffer.Length < 4); 246Debug.Assert(bytesConsumed == utf8Value.Length + partialStringDataBuffer.Length); 252Debug.Assert(bytesConsumed > partialStringDataBuffer.Length); 255utf8Value = utf8Value.Slice(bytesConsumed - partialStringDataBuffer.Length); 259Debug.Assert(bytesConsumed >= partialStringDataBuffer.Length); 261utf8Value = utf8Value.Slice(bytesConsumed - partialStringDataBuffer.Length); 304Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8Value.Length); 305Debug.Assert(firstEscapeIndexVal >= 0 && firstEscapeIndexVal < utf8Value.Length); 307int length = JsonWriterHelper.GetMaxEscapedLength(utf8Value.Length, firstEscapeIndexVal); 316Debug.Assert(consumed == utf8Value.Length || !isFinalSegment); 317if (utf8Value.Length != consumed) 320Debug.Assert(utf8Value.Length - consumed < 4); 332Debug.Assert(escapedValue.Length < int.MaxValue - 3); 334int requiredBytes = escapedValue.Length; 344BytesPending += escapedValue.Length; 361if (value.Length > Base64.GetMaxDecodedFromUtf8Length(int.MaxValue)) 363ThrowHelper.ThrowArgumentException_ValueTooLarge(value.Length); 411bytes = bytes.Slice(3 - partialStringDataBuffer.Length); 418Debug.Assert(bytes.Length + partialStringDataBuffer.Length < 3); 435if (!isFinalSegment && (leftoverSize = bytes.Length % 3) != 0) 438PartialBase64StringData = bytes.Slice(bytes.Length - leftoverSize); 439bytes = bytes.Slice(0, bytes.Length - leftoverSize); 442if (bytes.Length == 0) 447int requiredBytes = Base64.GetMaxEncodedToUtf8Length(bytes.Length); 541for (int i = 0; i < srcLeft.Length; i++) 552for (int i = 0; i < srcRight.Length; i++)
System.Text.Json.SourceGeneration (15)
src\libraries\Common\src\Roslyn\GetBestTypeByMetadataName.cs (2)
162switch (span.Length) 170var builder = ImmutableArray.CreateBuilder<T>(span.Length);
src\libraries\Common\src\SourceGenerators\SourceWriter.cs (2)
93lineLength = remainingText.Length; 118builder.Append(ptr, span.Length);
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (8)
69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 89_pos += source.Length; 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 98Grow(source.Length); 101_span.Slice(0, _pos).CopyTo(_span.Slice(source.Length)); 103_pos += source.Length;
src\libraries\System.Text.Json\Common\JsonSeparatorNamingPolicy.cs (3)
37int initialBufferLength = (int)(1.2 * chars.Length); 45for (int i = 0; i < chars.Length; i++) 75if (i + 1 < chars.Length && char.IsLower(chars[i + 1]))
System.Text.RegularExpressions (143)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (8)
69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 89_pos += source.Length; 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 98Grow(source.Length); 101_span.Slice(0, _pos).CopyTo(_span.Slice(source.Length)); 103_pos += source.Length;
System\Text\RegularExpressions\Regex.Count.cs (1)
38Count(input, RightToLeft ? input.Length : 0);
System\Text\RegularExpressions\Regex.cs (5)
435int stoppos = span.Length; 467Debug.Assert(startat <= input.Length); 488if (runner.runtextstart == input.Length) 530Debug.Assert((uint)startat <= (uint)inputSpan.Length); 577int stoppos = inputSpan.Length;
System\Text\RegularExpressions\Regex.EnumerateMatches.cs (1)
80new ValueMatchEnumerator(this, input, RightToLeft ? input.Length : 0);
System\Text\RegularExpressions\Regex.EnumerateSplits.cs (5)
136EnumerateSplits(input, count, startat: RightToLeft ? input.Length : 0); 166if ((uint)startat > (uint)input.Length) 201_lastMatch = (rtl ? input.Length : 0, -1); 224_currentSplit = !_regex.RightToLeft ? (_lastMatch.Index + _lastMatch.Length).._input.Length : 0.._lastMatch.Index; 243_currentSplit = start.._input.Length;
System\Text\RegularExpressions\Regex.Match.cs (1)
104IsMatch(input, RightToLeft ? input.Length : 0);
System\Text\RegularExpressions\Regex.Replace.cs (1)
235dest = dest.Slice(segment.Length);
System\Text\RegularExpressions\RegexCharClass.cs (13)
414for (i = 0; i < set.Length - 1; i += 2) 419if (i < set.Length) 1225return (uint)chDiv8 < (uint)ascii.Length ? 1244return (uint)chDiv8 < (uint)ascii.Length ? 1395for (int i = 0; i < categorySetSegment.Length; i++) 1550for (int index = 0; index < chars.Length - 1; index++) 1556switch (chars.Length) 1587int count = chars.Length * 2; 1588if (chars[chars.Length - 1] == LastChar) 1989Span<char> invertedGroup = group.Length <= scratch.Length ? scratch.Slice(0, group.Length) : new char[group.Length]; 1990for (int i = 0; i < group.Length; i++)
System\Text\RegularExpressions\RegexCompiler.cs (3)
6156Debug.Assert(chars.Length > 3, $"chars.Length == {chars.Length}"); 6160if (chars.Length is 4 or 5 && !RegexCharClass.IsAscii(chars))
System\Text\RegularExpressions\RegexFindOptimizations.cs (32)
439if (pos < textSpan.Length - 1 || ((uint)pos < (uint)textSpan.Length && textSpan[pos] != '\n')) 449if (pos < textSpan.Length) 496for (int i = span.Length - 1; i >= 0; i--) 525if (pos > textSpan.Length - MinRequiredLength) 527pos = textSpan.Length; 541if ((uint)posm1 < (uint)textSpan.Length && textSpan[posm1] != '\n') 544if ((uint)newline > textSpan.Length - 1 - pos) 546pos = textSpan.Length; 552if (pos > textSpan.Length - MinRequiredLength) 554pos = textSpan.Length; 571pos = textSpan.Length; 580pos = textSpan.Length; 584if (pos < textSpan.Length - 1) 588pos = textSpan.Length - 1; 593if (pos < textSpan.Length) 597pos = textSpan.Length; 602if (pos < textSpan.Length - MinRequiredLength - 1) 604pos = textSpan.Length - MinRequiredLength - 1; 609if (pos < textSpan.Length - MinRequiredLength) 611pos = textSpan.Length - MinRequiredLength; 626pos = textSpan.Length; 641pos = textSpan.Length; 675for (int i = 0; i < span.Length; i++) 685pos = textSpan.Length; 702pos = textSpan.Length; 717pos = textSpan.Length; 734pos = textSpan.Length; 745int endMinusRequiredLength = textSpan.Length - Math.Max(1, MinRequiredLength); 812pos = textSpan.Length; 841while ((uint)--prev < (uint)slice.Length && RegexCharClass.CharInClass(slice[prev], loopNode.Str!, ref _asciiLookups![0])) ; 858pos = textSpan.Length;
System\Text\RegularExpressions\RegexInterpreter.cs (8)
217if (inputSpan.Length - runtextpos < c) 257if (inputSpan.Length - runtextpos < length) 355if (TryMatchAtCurrentPosition(text) || runtextpos == text.Length) 732if ((uint)m1 < (uint)inputSpan.Length && inputSpan[m1] != '\n') 743if ((uint)runtextpos < (uint)inputSpan.Length && inputSpan[runtextpos] != '\n') 802if (runtextpos < inputSpan.Length - 1 || ((uint)runtextpos < (uint)inputSpan.Length && inputSpan[runtextpos] != '\n')) 811if (runtextpos < inputSpan.Length)
System\Text\RegularExpressions\RegexNode.cs (9)
1251Debug.Assert(startingSpan.Length > 0); 1273if (startingSpan.Length != 1) 1283int minLength = Math.Min(startingSpan.Length, startingNode.Str.Length); 1304Debug.Assert(startingSpan.Length > 0); 1310var prefix = startingSpan.Length == 1 ? 1327Debug.Assert(startingSpan.Length == 1); 1336if (node.Str!.Length == startingSpan.Length) 1341else if (node.Str.Length - 1 == startingSpan.Length) 1349node.Str = node.Str.Substring(startingSpan.Length);
System\Text\RegularExpressions\RegexParser.cs (3)
166ValueStringBuilder vsb = input.Length <= (EscapeMaxBufferSize / 3) ? 168new ValueStringBuilder(input.Length + 200); 205indexOfMetachar = input.Length;
System\Text\RegularExpressions\RegexReplacement.cs (1)
275for (int i = 0; i < span.Length; i += 2)
System\Text\RegularExpressions\RegexRunner.cs (10)
142if (s == null || text != s.AsSpan(beginning, text.Length)) 159InternalScan(runregex!, beginning, beginning + text.Length); 284runtextend = text.Length; 292new Match(runregex, runregex.capsize, runtext, text.Length) : 293new MatchSparse(runregex, runregex.caps, runregex.capsize, runtext, text.Length); 297m.Reset(runtext, text.Length); 417return ((uint)indexM1 < (uint)inputSpan.Length && RegexCharClass.IsBoundaryWordChar(inputSpan[indexM1])) != 418((uint)index < (uint)inputSpan.Length && RegexCharClass.IsBoundaryWordChar(inputSpan[index])); 433return ((uint)indexM1 < (uint)inputSpan.Length && RegexCharClass.IsECMAWordChar(inputSpan[indexM1])) != 434((uint)index < (uint)inputSpan.Length && RegexCharClass.IsECMAWordChar(inputSpan[index]));
System\Text\RegularExpressions\Symbolic\BDD.cs (3)
344Debug.Assert(bytes.Length > 1, "All inputs are expected to be larger than a single byte, which would map to False or True."); 350int n = (bytes.Length - 1) / bytesPerLong; 353Debug.Assert((bytes.Length - 1) % bytesPerLong == 0);
System\Text\RegularExpressions\Symbolic\CharSetSolver.cs (4)
162if (sets.Length == 0) 168for (int i = 1; i < sets.Length; i++) 181if (sets.Length == 0) 187for (int i = 1; i < sets.Length; i++)
System\Text\RegularExpressions\Symbolic\SymbolicRegexMatcher.cs (22)
356Debug.Assert(startat >= 0 && startat <= input.Length, $"{nameof(startat)} == {startat}, {nameof(input.Length)} == {input.Length}"); 495int lengthMinus1 = input.Length - 1; 513innerLoopLength = _checkTimeout && input.Length - pos > NfaCharsPerTimeoutCheck ? pos + NfaCharsPerTimeoutCheck : input.Length; 521if (done || pos >= input.Length) 579innerLoopLength = _checkTimeout && input.Length - pos > DfaCharsPerTimeoutCheck ? pos + DfaCharsPerTimeoutCheck : input.Length; 587innerLoopLength = _checkTimeout && input.Length - pos > NfaCharsPerTimeoutCheck ? pos + NfaCharsPerTimeoutCheck : input.Length; 594if (done || pos >= input.Length) 636if (pos == input.Length) 661if (pos == input.Length) 694if (pos + 1 < input.Length) 864Debug.Assert(matchStartBoundary >= 0 && matchStartBoundary <= input.Length, $"{nameof(matchStartBoundary)} == {matchStartBoundary}"); 1482if ((uint)pos < (uint)input.Length) 1486return c == '\n' && pos == input.Length - 1 ? 1500(uint)pos < (uint)input.Length ? 1558Debug.Assert(pos == input.Length); 1589Debug.Assert(pos == input.Length); 1619Debug.Assert(pos == input.Length);
System\Text\RegularExpressions\Symbolic\SymbolicRegexMatcher.Dgml.cs (3)
152Debug.Assert(deltas.Length == matcher._minterms.Length); 153for (int i = 0; i < deltas.Length; ++i) 167if (nfaDeltas.Length > 0 && nfaDeltas[i] is int[] nfaTargets)
System\Text\RegularExpressions\Symbolic\SymbolicRegexRunnerFactory.cs (1)
108runtextpos = text.Length;
System.Text.RegularExpressions.Generator (52)
RegexGenerator.Emitter.cs (2)
399Debug.Assert(chars.Length > 3); 405return chars.Length > 5 || RegexCharClass.IsAscii(chars)
src\libraries\Common\src\Roslyn\GetBestTypeByMetadataName.cs (2)
162switch (span.Length) 170var builder = ImmutableArray.CreateBuilder<T>(span.Length);
src\libraries\Common\src\System\HexConverter.cs (8)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 185Span<char> result = bytes.Length > 16 ? 186new char[bytes.Length * 2].AsSpan() : 187stackalloc char[bytes.Length * 2]; 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (8)
69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 89_pos += source.Length; 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 98Grow(source.Length); 101_span.Slice(0, _pos).CopyTo(_span.Slice(source.Length)); 103_pos += source.Length;
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexCharClass.cs (13)
414for (i = 0; i < set.Length - 1; i += 2) 419if (i < set.Length) 1225return (uint)chDiv8 < (uint)ascii.Length ? 1244return (uint)chDiv8 < (uint)ascii.Length ? 1395for (int i = 0; i < categorySetSegment.Length; i++) 1550for (int index = 0; index < chars.Length - 1; index++) 1556switch (chars.Length) 1587int count = chars.Length * 2; 1588if (chars[chars.Length - 1] == LastChar) 1989Span<char> invertedGroup = group.Length <= scratch.Length ? scratch.Slice(0, group.Length) : new char[group.Length]; 1990for (int i = 0; i < group.Length; i++)
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNode.cs (9)
1251Debug.Assert(startingSpan.Length > 0); 1273if (startingSpan.Length != 1) 1283int minLength = Math.Min(startingSpan.Length, startingNode.Str.Length); 1304Debug.Assert(startingSpan.Length > 0); 1310var prefix = startingSpan.Length == 1 ? 1327Debug.Assert(startingSpan.Length == 1); 1336if (node.Str!.Length == startingSpan.Length) 1341else if (node.Str.Length - 1 == startingSpan.Length) 1349node.Str = node.Str.Substring(startingSpan.Length);
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexParser.cs (4)
166ValueStringBuilder vsb = input.Length <= (EscapeMaxBufferSize / 3) ? 168new ValueStringBuilder(input.Length + 200); 205indexOfMetachar = input.Length; 1950for (int i = 0; i < input.Length; i++)
Stubs.cs (3)
22return stringBuilder.Append(ptr, span.Length); 48int length = Math.Min(span.Length, other.Length);
System.Web.HttpUtility (14)
src\libraries\Common\src\System\HexConverter.cs (6)
167Debug.Assert(chars.Length >= bytes.Length * 2); 176for (int pos = 0; pos < bytes.Length; pos++) 198return string.Create(bytes.Length * 2, args, static (chars, args) => 359Debug.Assert(chars.Length % 2 == 0, "Un-even number of characters provided"); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 390return c >= CharToHexLookup.Length ? 0xFF : CharToHexLookup[c];
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (3)
241if (pos > _chars.Length - value.Length) 243Grow(value.Length); 247_pos += value.Length;
System\Web\Util\HttpEncoder.cs (5)
75for (int i = 0; i < remaining.Length; i++) 210int count = bytes.Length; 323int count = value.Length; 414byte[] expandedBytes = new byte[bytes.Length + cUnsafe * 2]; 569byte[] bytes = ArrayPool<byte>.Shared.Rent(Encoding.UTF8.GetMaxByteCount(toEncode.Length));
System.Windows.Forms (18)
System\Windows\Forms\ActiveX\AxHost.VBFormat.cs (3)
53if (format.Length >= buffer.Length) 60buffer[format.Length] = '\0'; 61*rcb = (ushort)(format.Length * sizeof(char));
System\Windows\Forms\ActiveX\DataStreamFromComStream.cs (2)
141_comStream->Write(b, (uint)buffer.Length, &bytesWritten); 144if (bytesWritten < buffer.Length)
System\Windows\Forms\Controls\ImageList\ImageListStreamer.cs (2)
39int length = RunLengthEncoder.GetEncodedLength(input) + HeaderMagic.Length; 44Debug.Assert(written == length - HeaderMagic.Length, "RLE compression failure");
System\Windows\Forms\Controls\PropertyGrid\PropertyGridInternal\MultiSelectRootGridEntry.PropertyMerger.cs (3)
100var objectProperties = new PropertyDescriptorCollection[objects.Length]; 108for (int i = 0; i < objects.Length; i++) 131var matchArray = new PropertyDescriptor[objects.Length];
System\Windows\Forms\Dialogs\CommonDialogs\FileDialog.cs (7)
459var fileNames = fileBuffer[(directory.Length + 1)..]; 463if (fileNames.Length == 0 || fileNames[0] == '\0') 470while (fileName.Length > 0) 476fileNames = fileNames[(fileName.Length + 1)..]; 634Debug.Assert(currentExtension.Length == 0 || currentExtension[0] == '.', 639? $"{fileName[..^currentExtension.Length]}.{extensions[j]}" 640: fileName[..^currentExtension.Length];
System\Windows\Forms\SendKeys\SendKeys.cs (1)
322if (keystate.Length < 256)
System.Windows.Forms.Design (6)
System\ComponentModel\Design\ByteViewer.cs (5)
185Debug.Assert(charsBuffer.Length >= lineBuffer.Length); 186Span<char> charsToDraw = charsBuffer[..lineBuffer.Length]; 187for (int i = 0; i < lineBuffer.Length; i++) 207Debug.Assert(charsBuffer.Length >= lineBuffer.Length * 3 + 1); 209for (int i = 0; i < lineBuffer.Length; i++)
System\ComponentModel\Design\Serialization\CodeDomSerializerBase.cs (1)
1305for (int i = 0; i < compatibleTypes.Length; i++)
System.Windows.Forms.Primitives (8)
System\Windows\Forms\DeviceContextExtensions.cs (2)
82Debug.Assert((lines.Length % 4) == 0); 90for (int i = 0; i < lines.Length; i += 4)
System\Windows\Forms\SystemDrawingExtensions.cs (2)
56Debug.Assert((lines.Length % 4) == 0); 58for (int i = 0; i < lines.Length; i += 4)
Windows\Win32\PInvoke.DrawTextEx.cs (1)
20return DrawTextEx(hdc, (PWSTR)c, lpchText.Length, lprc, format, lpdtp);
Windows\Win32\UI\Controls\LVITEMW.cs (3)
15if (cchTextMax <= text.Length) 21cchTextMax = text.Length + 1; 27pszText.Value[text.Length] = '\0';
System.Windows.Forms.Primitives.Tests (1)
System\IO\Compression\RunLengthEncoderTests.cs (1)
42written.Should().Be(data.Length);
System.Windows.Forms.Primitives.TestUtilities (9)
Extensions\AssertExtensions.cs (7)
481if (expected.Length != actual.Length) 483throw new XunitException($"Expected: Span of length {expected.Length}{Environment.NewLine}Actual: Span of length {actual.Length}"); 491for (int i = 0; i < expected.Length; i++) 505message += $"Total number of differences: {diffCount} out of {expected.Length}"; 516for (int i = 0; i < actual.Length; i++)
Extensions\SpanExtensions.cs (2)
10T2[] output = new T2[span.Length]; 11for (int i = 0; i < span.Length; i++)
System.Windows.Forms.Primitives.TestUtilities.Tests (2)
PathLengthTests.cs (2)
38entry.Directory.Length + entry.FileName.Length > maxLength
System.Windows.Forms.Tests (1)
TestAccessorTests.cs (1)
220private int ToStringLength(ReadOnlySpan<char> value) => value.Length;
System.Windows.Forms.UI.IntegrationTests (8)
Infra\ScreenRecordService.cs (8)
286for (int column = 0; column < previousFrameLine.Length; column++) 301for (int column = previousFrameLine.Length - 1; column > lastChangedColumn; column--) 382WriteChunkHeader(stream, buffer, crc, Fdat, (uint)(data.Length + 4)); 540if (bytes.Length < buffer.Length) 543stream.Write(buffer, 0, bytes.Length); 547for (ReadOnlySpan<byte> remaining = bytes; !remaining.IsEmpty; remaining = remaining[Math.Min(buffer.Length, remaining.Length)..]) 549ReadOnlySpan<byte> current = remaining[..Math.Min(buffer.Length, remaining.Length)]; 551stream.Write(buffer, 0, current.Length);
System.Xaml (7)
src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\ReflectionUtils.cs (5)
66fullName = fullName.Slice(0, fullName.Length - nameSlice.Length + commaIndex); 108int tokenLength = tokenEnding == 0 ? assemblyName.Slice(versionIndex).Length : tokenEnding; 118int tokenLength = tokenEnding == 0 ? assemblyName.Slice(tokenIndex).Length : tokenEnding; 123if (assemblyToken.Length != 16)
System\Xaml\Parser\GenericTypeNameScanner.cs (1)
146while (pos < subscript.Length);
System\Xaml\Schema\XamlNamespace.cs (1)
144while (pos < subscript.Length);
Test.Utilities (46)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
Text.Analyzers (47)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (3)
799var sb = new StringBuilder(path.Length); 802if (path.Length > 1 && IsAnyDirectorySeparator(path[0]) && IsAnyDirectorySeparator(path[1])) 810for (int i = start; i < path.Length; i++)
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
135uint length = (uint)source.Length;
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (12)
253state.TotalLength += (uint)source.Length; 258if (source.Length <= InternalBufferLengthBytes - state.BufferedCount) 260source.CopyTo(new Span<byte>(buffer + state.BufferedCount, source.Length)); 261state.BufferedCount += (uint)source.Length; 281Debug.Assert(sourceIndex < source.Length); 284if (source.Length - sourceIndex > NumStripesPerBlock * StripeLengthBytes) 286ulong stripes = (ulong)(source.Length - sourceIndex - 1) / StripeLengthBytes; 310Debug.Assert(sourceIndex < source.Length); // at least some bytes left 316else if (source.Length - sourceIndex > InternalBufferLengthBytes) 324while (source.Length - sourceIndex > InternalBufferLengthBytes); 331Span<byte> remaining = new Span<byte>(buffer, source.Length - sourceIndex); 332Debug.Assert(sourceIndex < source.Length);
src\Compilers\Core\Portable\InternalUtilities\FileNameUtilities.cs (1)
50int length = path.Length;
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (3)
231for (int i = 0; i < data.Length; i++) 295for (int i = 0; i < data.Length; i++) 399for (int i = 0; i < data.Length; i++)
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (4)
413text = Encoding.UTF8.GetString(bytes, utf8Bytes.Length); 532for (var i = 0; i < ascii.Length; i++) 538if (ascii.Length != text.Length) 543for (var i = 0; i < ascii.Length; i++)
src\Dependencies\Collections\Extensions\MemoryExtensions.cs (1)
20int high = span.Length - 1;
src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (1)
126if (remaining[index] == '\r' && remaining.Length > index + 1 && remaining[index + 1] == '\n')
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (2)
330WriteArrayLength(span.Length); 368var spanLength = span.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (11)
87while (chars.Length != 0) 98Debug.Assert(chars.Length != 0); // If TryDecodeFromUtf16() consumed the entire buffer, it could not have returned false. 106if (indexOfFirstNonSpace == chars.Length) 115if ((bytesWrittenInThisIteration % 3) != 0 && chars.Length != 0) 127Debug.Assert(chars.Length != 0 && !chars[0].IsSpace()); 155for (int i = 0; i < chars.Length; i++) 178for (int i = 0; i < chars.Length; i++) 191consumed = chars.Length; 199int srcLength = utf16.Length & ~0x3; // only decode input up to the closest multiple of 4. 205if (utf16.Length == 0) 305if (srcLength != utf16.Length)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (8)
170return source.Length <= target.Length 182Debug.Assert(source.Length <= target.Length); 187while (source.Length > 0 && source[^1] == target[^1]) 193while (source.Length > 0 && source[0] == target[0]) 207var sourceLength = source.Length; 208var targetLength = target.Length;
UIAutomationClientSideProviders (5)
MS\Internal\AutomationProxies\ProxyHwnd.cs (2)
85if (aEvents.Length > 0) 114if (aEvents.Length > 0)
MS\Internal\AutomationProxies\WindowsComboBox.cs (2)
307if (editPortionEvents.Length > 0) 343if (editPortionEvents.Length > 0)
MS\Internal\AutomationProxies\WinEventTracker.cs (1)
586private static Hashtable[] _ahp = new Hashtable[EventIdToIndex.Length];
xunit.assert (6)
Sdk\CollectionTracker.cs (2)
593 var endIndex = Math.Min(span.Length - 1, startIndex + ArgumentFormatter.MAX_ENUMERABLE_LENGTH - 1); 596 var moreItemsPastEndIndex = endIndex < span.Length - 1;
StringAsserts.cs (4)
916 var expectedLength = expected.Length; 917 var actualLength = actual.Length; 1669 if (index < value.Length && value[index] == '\n') 1683 while (index < value.Length)