3367 references to Length
aspire (3)
src\Shared\CircularBuffer.cs (3)
104var overflowItem = data[data.Length - 1]; 106var shiftLength = data.Length - internalIndex - 1; 120data.Slice(internalIndex, data.Length - internalIndex - 1).CopyTo(data.Slice(internalIndex + 1));
Aspire.Dashboard (4)
src\Shared\CircularBuffer.cs (3)
104var overflowItem = data[data.Length - 1]; 106var shiftLength = data.Length - internalIndex - 1; 120data.Slice(internalIndex, data.Length - internalIndex - 1).CopyTo(data.Slice(internalIndex + 1));
src\Shared\CompareHelpers.cs (1)
30Debug.Assert(encodedByteCount == requestBytesSpan.Length, "Should match because span was previously trimmed to byte count value.");
Aspire.Hosting (5)
src\Shared\CircularBuffer.cs (3)
104var overflowItem = data[data.Length - 1]; 106var shiftLength = data.Length - internalIndex - 1; 120data.Slice(internalIndex, data.Length - internalIndex - 1).CopyTo(data.Slice(internalIndex + 1));
src\Shared\CompareHelpers.cs (1)
30Debug.Assert(encodedByteCount == requestBytesSpan.Length, "Should match because span was previously trimmed to byte count value.");
Utils\PasswordGenerator.cs (1)
84Debug.Assert(destination.Length >= minValues);
Aspire.Playground.Tests (1)
src\Aspire.Hosting\Utils\PasswordGenerator.cs (1)
84Debug.Assert(destination.Length >= minValues);
http2cat (40)
src\Shared\Http2cat\Http2Utilities.cs (2)
292var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength); 378var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength);
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (19)
34if (destination.Length != 0) 90if ((uint)destination.Length >= 2) 122if ((uint)destination.Length >= 2) 154if ((uint)destination.Length >= 2) 192if ((uint)destination.Length != 0) 272if ((uint)destination.Length >= 3) 305if ((uint)destination.Length >= 3) 344if ((uint)destination.Length >= 2) 371if (destination.Length != 0) 379if (value.Length <= destination.Length) 397Debug.Assert(destination.Length >= value.Length); 421if (destination.Length != 0) 429if (value.Length <= destination.Length) 460if (destination.Length != 0) 472if (encodedStringLength <= destination.Length) 503if (destination.Length != 0) 526if (destination.Length != 0) 553if (destination.Length >= valueLength) 639span = new byte[span.Length * 2];
src\Shared\runtime\Http2\Hpack\Huffman.cs (5)
680Debug.Assert(dst.Length > 0); 712if (j == dst.Length) 714Array.Resize(ref dstArray, dst.Length * 2); 779if (j == dst.Length) 781Array.Resize(ref dstArray, dst.Length * 2);
src\Shared\runtime\Http2\Hpack\IntegerEncoder.cs (3)
28if (destination.Length == 0) 47if (1 == destination.Length) 60if (i >= destination.Length)
src\Shared\ServerInfrastructure\BufferExtensions.cs (5)
120if (sourceLength <= dest.Length) 139if (number < 10 && buffer.Length >= 1) 144else if (number < 100 && buffer.Length >= 2) 153else if (number < 1000 && buffer.Length >= 3) 201if (sourceLength <= dest.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 111if (_span.Length < count) 140if (_span.Length == 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
IIS.FunctionalTests (40)
src\Shared\Http2cat\Http2Utilities.cs (2)
292var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength); 378var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength);
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (19)
34if (destination.Length != 0) 90if ((uint)destination.Length >= 2) 122if ((uint)destination.Length >= 2) 154if ((uint)destination.Length >= 2) 192if ((uint)destination.Length != 0) 272if ((uint)destination.Length >= 3) 305if ((uint)destination.Length >= 3) 344if ((uint)destination.Length >= 2) 371if (destination.Length != 0) 379if (value.Length <= destination.Length) 397Debug.Assert(destination.Length >= value.Length); 421if (destination.Length != 0) 429if (value.Length <= destination.Length) 460if (destination.Length != 0) 472if (encodedStringLength <= destination.Length) 503if (destination.Length != 0) 526if (destination.Length != 0) 553if (destination.Length >= valueLength) 639span = new byte[span.Length * 2];
src\Shared\runtime\Http2\Hpack\Huffman.cs (5)
680Debug.Assert(dst.Length > 0); 712if (j == dst.Length) 714Array.Resize(ref dstArray, dst.Length * 2); 779if (j == dst.Length) 781Array.Resize(ref dstArray, dst.Length * 2);
src\Shared\runtime\Http2\Hpack\IntegerEncoder.cs (3)
28if (destination.Length == 0) 47if (1 == destination.Length) 60if (i >= destination.Length)
src\Shared\ServerInfrastructure\BufferExtensions.cs (5)
120if (sourceLength <= dest.Length) 139if (number < 10 && buffer.Length >= 1) 144else if (number < 100 && buffer.Length >= 2) 153else if (number < 1000 && buffer.Length >= 3) 201if (sourceLength <= dest.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 111if (_span.Length < count) 140if (_span.Length == 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
IIS.LongTests (40)
src\Shared\Http2cat\Http2Utilities.cs (2)
292var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength); 378var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength);
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (19)
34if (destination.Length != 0) 90if ((uint)destination.Length >= 2) 122if ((uint)destination.Length >= 2) 154if ((uint)destination.Length >= 2) 192if ((uint)destination.Length != 0) 272if ((uint)destination.Length >= 3) 305if ((uint)destination.Length >= 3) 344if ((uint)destination.Length >= 2) 371if (destination.Length != 0) 379if (value.Length <= destination.Length) 397Debug.Assert(destination.Length >= value.Length); 421if (destination.Length != 0) 429if (value.Length <= destination.Length) 460if (destination.Length != 0) 472if (encodedStringLength <= destination.Length) 503if (destination.Length != 0) 526if (destination.Length != 0) 553if (destination.Length >= valueLength) 639span = new byte[span.Length * 2];
src\Shared\runtime\Http2\Hpack\Huffman.cs (5)
680Debug.Assert(dst.Length > 0); 712if (j == dst.Length) 714Array.Resize(ref dstArray, dst.Length * 2); 779if (j == dst.Length) 781Array.Resize(ref dstArray, dst.Length * 2);
src\Shared\runtime\Http2\Hpack\IntegerEncoder.cs (3)
28if (destination.Length == 0) 47if (1 == destination.Length) 60if (i >= destination.Length)
src\Shared\ServerInfrastructure\BufferExtensions.cs (5)
120if (sourceLength <= dest.Length) 139if (number < 10 && buffer.Length >= 1) 144else if (number < 100 && buffer.Length >= 2) 153else if (number < 1000 && buffer.Length >= 3) 201if (sourceLength <= dest.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 111if (_span.Length < count) 140if (_span.Length == 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
IIS.NewHandler.FunctionalTests (40)
src\Shared\Http2cat\Http2Utilities.cs (2)
292var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength); 378var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength);
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (19)
34if (destination.Length != 0) 90if ((uint)destination.Length >= 2) 122if ((uint)destination.Length >= 2) 154if ((uint)destination.Length >= 2) 192if ((uint)destination.Length != 0) 272if ((uint)destination.Length >= 3) 305if ((uint)destination.Length >= 3) 344if ((uint)destination.Length >= 2) 371if (destination.Length != 0) 379if (value.Length <= destination.Length) 397Debug.Assert(destination.Length >= value.Length); 421if (destination.Length != 0) 429if (value.Length <= destination.Length) 460if (destination.Length != 0) 472if (encodedStringLength <= destination.Length) 503if (destination.Length != 0) 526if (destination.Length != 0) 553if (destination.Length >= valueLength) 639span = new byte[span.Length * 2];
src\Shared\runtime\Http2\Hpack\Huffman.cs (5)
680Debug.Assert(dst.Length > 0); 712if (j == dst.Length) 714Array.Resize(ref dstArray, dst.Length * 2); 779if (j == dst.Length) 781Array.Resize(ref dstArray, dst.Length * 2);
src\Shared\runtime\Http2\Hpack\IntegerEncoder.cs (3)
28if (destination.Length == 0) 47if (1 == destination.Length) 60if (i >= destination.Length)
src\Shared\ServerInfrastructure\BufferExtensions.cs (5)
120if (sourceLength <= dest.Length) 139if (number < 10 && buffer.Length >= 1) 144else if (number < 100 && buffer.Length >= 2) 153else if (number < 1000 && buffer.Length >= 3) 201if (sourceLength <= dest.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 111if (_span.Length < count) 140if (_span.Length == 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
IIS.NewShim.FunctionalTests (40)
src\Shared\Http2cat\Http2Utilities.cs (2)
292var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength); 378var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength);
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (19)
34if (destination.Length != 0) 90if ((uint)destination.Length >= 2) 122if ((uint)destination.Length >= 2) 154if ((uint)destination.Length >= 2) 192if ((uint)destination.Length != 0) 272if ((uint)destination.Length >= 3) 305if ((uint)destination.Length >= 3) 344if ((uint)destination.Length >= 2) 371if (destination.Length != 0) 379if (value.Length <= destination.Length) 397Debug.Assert(destination.Length >= value.Length); 421if (destination.Length != 0) 429if (value.Length <= destination.Length) 460if (destination.Length != 0) 472if (encodedStringLength <= destination.Length) 503if (destination.Length != 0) 526if (destination.Length != 0) 553if (destination.Length >= valueLength) 639span = new byte[span.Length * 2];
src\Shared\runtime\Http2\Hpack\Huffman.cs (5)
680Debug.Assert(dst.Length > 0); 712if (j == dst.Length) 714Array.Resize(ref dstArray, dst.Length * 2); 779if (j == dst.Length) 781Array.Resize(ref dstArray, dst.Length * 2);
src\Shared\runtime\Http2\Hpack\IntegerEncoder.cs (3)
28if (destination.Length == 0) 47if (1 == destination.Length) 60if (i >= destination.Length)
src\Shared\ServerInfrastructure\BufferExtensions.cs (5)
120if (sourceLength <= dest.Length) 139if (number < 10 && buffer.Length >= 1) 144else if (number < 100 && buffer.Length >= 2) 153else if (number < 1000 && buffer.Length >= 3) 201if (sourceLength <= dest.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 111if (_span.Length < count) 140if (_span.Length == 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
IIS.ShadowCopy.Tests (11)
src\Shared\ServerInfrastructure\BufferExtensions.cs (5)
120if (sourceLength <= dest.Length) 139if (number < 10 && buffer.Length >= 1) 144else if (number < 100 && buffer.Length >= 2) 153else if (number < 1000 && buffer.Length >= 3) 201if (sourceLength <= dest.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 111if (_span.Length < count) 140if (_span.Length == 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
IISExpress.FunctionalTests (40)
src\Shared\Http2cat\Http2Utilities.cs (2)
292var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength); 378var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength);
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (19)
34if (destination.Length != 0) 90if ((uint)destination.Length >= 2) 122if ((uint)destination.Length >= 2) 154if ((uint)destination.Length >= 2) 192if ((uint)destination.Length != 0) 272if ((uint)destination.Length >= 3) 305if ((uint)destination.Length >= 3) 344if ((uint)destination.Length >= 2) 371if (destination.Length != 0) 379if (value.Length <= destination.Length) 397Debug.Assert(destination.Length >= value.Length); 421if (destination.Length != 0) 429if (value.Length <= destination.Length) 460if (destination.Length != 0) 472if (encodedStringLength <= destination.Length) 503if (destination.Length != 0) 526if (destination.Length != 0) 553if (destination.Length >= valueLength) 639span = new byte[span.Length * 2];
src\Shared\runtime\Http2\Hpack\Huffman.cs (5)
680Debug.Assert(dst.Length > 0); 712if (j == dst.Length) 714Array.Resize(ref dstArray, dst.Length * 2); 779if (j == dst.Length) 781Array.Resize(ref dstArray, dst.Length * 2);
src\Shared\runtime\Http2\Hpack\IntegerEncoder.cs (3)
28if (destination.Length == 0) 47if (1 == destination.Length) 60if (i >= destination.Length)
src\Shared\ServerInfrastructure\BufferExtensions.cs (5)
120if (sourceLength <= dest.Length) 139if (number < 10 && buffer.Length >= 1) 144else if (number < 100 && buffer.Length >= 2) 153else if (number < 1000 && buffer.Length >= 3) 201if (sourceLength <= dest.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 111if (_span.Length < count) 140if (_span.Length == 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
illink (14)
InMemory.FunctionalTests (11)
Http2\Http2TestBase.cs (2)
663var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength); 753var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength);
Http3\Http3StreamTests.cs (2)
2908for (var i = 0; i < chars.Length; i++) 2948for (var i = 0; i < chars.Length; i++)
ResponseTests.cs (6)
1568for (var i = 0; i < span.Length; i++) 1572httpContext.Response.BodyWriter.Advance(span.Length); 1649for (var i = 0; i < span.Length; i++) 1653httpContext.Response.BodyWriter.Advance(span.Length); 1658for (var i = 0; i < span.Length; i++) 1662httpContext.Response.BodyWriter.Advance(span.Length);
src\Servers\Kestrel\shared\test\PipeWriterHttp2FrameExtensions.cs (1)
74frame.PayloadLength = headerData.Length;
Microsoft.AspNetCore.Components (11)
ParameterView.cs (3)
217if (oldDirectParameterFrames.Length == 0) 224if (newDirectParameterFrames.Length < oldDirectParameterFrames.Length)
src\Shared\UrlDecoder\UrlDecoder.cs (7)
20if (destination.Length < source.Length) 52if (sourceIndex == buffer.Length) 155if (sourceIndex == buffer.Length) 303if (scan == buffer.Length) 385return buffer.Length; 396if (sourceIndex == buffer.Length) 491if (sourceIndex == buffer.Length)
SupplyParameterFromPersistentComponentStateValueProvider.cs (1)
180keyBuffer = keyBuffer[..(preKey.Length + currentBuffer.Length)];
Microsoft.AspNetCore.Components.Endpoints (2)
Rendering\EndpointHtmlRenderer.Streaming.cs (1)
155for (var i = 0; i < componentIdsInDepthOrder.Length; i++)
Rendering\TypeNameHash.cs (1)
26written = typeNameBytes.Length;
Microsoft.AspNetCore.Components.Forms (6)
src\Components\Shared\src\ExpressionFormatting\ReverseStringBuilder.cs (6)
27_nextEndIndex = _currentBuffer.Length; 33_nextEndIndex = _currentBuffer.Length; 36public readonly bool Empty => _nextEndIndex == _currentBuffer.Length; 59var sizeToRent = _currentBuffer.Length + Math.Max(MinimumRentedArraySize, remainingLength * 2); 63var newEndIndex = newBuffer.Length - _currentBuffer.Length + _nextEndIndex; 85startIndex = _currentBuffer.Length - remainingLength;
Microsoft.AspNetCore.Components.QuickGrid (1)
Columns\GridSort.cs (1)
172var nextPos = chars.Length;
Microsoft.AspNetCore.Components.Server (11)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
249Debug.Assert(span.Length >= _bytesWritten);
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\BufferWriter.cs (4)
162if (_span.Length >= source.Length) 180if (_span.Length < count) 234if (_span.Length == 0) 239var writable = Math.Min(bytesLeftToCopy, _span.Length);
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\SequenceReader.cs (6)
457if (firstSpan.Length >= destination.Length) 459firstSpan.Slice(0, destination.Length).CopyTo(destination); 468if (this.Remaining < destination.Length) 474Debug.Assert(firstSpan.Length < destination.Length, "firstSpan.Length < destination.Length"); 484int toCopy = Math.Min(nextSpan.Length, destination.Length - copied); 487if (copied >= destination.Length)
Microsoft.AspNetCore.Components.Server.Tests (6)
Circuits\RenderBatchWriterTest.cs (6)
39Assert.Equal(36, bytes.Length); // No other data 66Assert.Equal(48, bytes.Length); // No other data 93Assert.Equal(60, bytes.Length); // No other data 135Assert.Equal(60, bytes.Length); // No other data 169var diffsStartIndex = ReadInt(bytes, bytes.Length - 20); 233var referenceFramesStartIndex = ReadInt(bytes, bytes.Length - 16);
Microsoft.AspNetCore.Components.Web (6)
src\Components\Shared\src\ExpressionFormatting\ReverseStringBuilder.cs (6)
27_nextEndIndex = _currentBuffer.Length; 33_nextEndIndex = _currentBuffer.Length; 36public readonly bool Empty => _nextEndIndex == _currentBuffer.Length; 59var sizeToRent = _currentBuffer.Length + Math.Max(MinimumRentedArraySize, remainingLength * 2); 63var newEndIndex = newBuffer.Length - _currentBuffer.Length + _nextEndIndex; 85startIndex = _currentBuffer.Length - remainingLength;
Microsoft.AspNetCore.DataProtection (13)
Managed\ManagedAuthenticatedEncryptor.cs (3)
227_keyDerivationKey.WriteSecretIntoBuffer(decryptedKdkUnsafe, decryptedKdk.Length); 353_keyDerivationKey.WriteSecretIntoBuffer(decryptedKdkUnsafe, decryptedKdk.Length); 375var cipherTextLength = symmetricAlgorithm.GetCiphertextLengthCbc(plainTextSpan.Length); // CBC because symmetricAlgorithm is created with CBC mode
SP800_108\ManagedSP800_108_CTR_HMACSHA512.cs (10)
53var outputCount = operationSubkey.Length + validationSubkey.Length; 85prfInput[prfInput.Length - 4] = (byte)(outputSizeInBits >> 24); 86prfInput[prfInput.Length - 3] = (byte)(outputSizeInBits >> 16); 87prfInput[prfInput.Length - 2] = (byte)(outputSizeInBits >> 8); 88prfInput[prfInput.Length - 1] = (byte)(outputSizeInBits); 111CryptoUtil.Assert(prfOutputSizeInBytes == prfOutput.Length, "prfOutputSizeInBytes == prfOutput.Length"); 117var bytesToWrite = Math.Min(numBytesToCopyThisIteration, operationSubkey.Length - operationSubKeyIndex); 119if (operationSubKeyIndex < operationSubkey.Length) // meaning we need to write to operationSubKey 126if (operationSubKeyIndex == operationSubkey.Length && leftOverBytes != 0) // we have filled the operationSubKey. It's time for the validationSubKey
Microsoft.AspNetCore.DataProtection.Tests (1)
SequentialGenRandom.cs (1)
34for (var i = 0; i < target.Length; i++)
Microsoft.AspNetCore.Http (1)
src\Shared\Dictionary\AdaptiveCapacityDictionary.cs (1)
561for (var i = 0; i < ArrayStorageSpan.Length; ++i)
Microsoft.AspNetCore.Http.Abstractions (15)
Extensions\HttpResponseWritingExtensions.cs (1)
78if (encodedLength <= destination.Length)
src\Shared\UrlDecoder\UrlDecoder.cs (7)
20if (destination.Length < source.Length) 52if (sourceIndex == buffer.Length) 155if (sourceIndex == buffer.Length) 303if (scan == buffer.Length) 385return buffer.Length; 396if (sourceIndex == buffer.Length) 491if (sourceIndex == buffer.Length)
src\Shared\ValueStringBuilder\ValueListBuilder.cs (7)
33if ((uint)pos < (uint)span.Length) 47Debug.Assert(_pos == _span.Length); 78int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 88nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
Microsoft.AspNetCore.Http.Connections (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
249Debug.Assert(span.Length >= _bytesWritten);
Microsoft.AspNetCore.Http.Extensions (23)
src\Shared\ValueStringBuilder\ValueListBuilder.cs (7)
33if ((uint)pos < (uint)span.Length) 47Debug.Assert(_pos == _span.Length); 78int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 88nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (16)
38Debug.Assert(value <= _chars.Length); 43public int Capacity => _chars.Length; 51if ((uint)capacity > (uint)_chars.Length) 137if (_pos > _chars.Length - count) 157if (_pos > (_chars.Length - count)) 172if ((uint)pos < (uint)_chars.Length) 192if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 206if (pos > _chars.Length - s.Length) 217if (_pos > _chars.Length - count) 223for (int i = 0; i < dst.Length; i++) 233if (pos > _chars.Length - length) 239for (int i = 0; i < dst.Length; i++) 249if (pos > _chars.Length - value.Length) 262if (origPos > _chars.Length - length) 290Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 293char[] poolArray = ArrayPool<char>.Shared.Rent((int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), (uint)_chars.Length * 2));
Microsoft.AspNetCore.HttpLogging (23)
src\Shared\ValueStringBuilder\ValueListBuilder.cs (7)
33if ((uint)pos < (uint)span.Length) 47Debug.Assert(_pos == _span.Length); 78int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 88nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (16)
38Debug.Assert(value <= _chars.Length); 43public int Capacity => _chars.Length; 51if ((uint)capacity > (uint)_chars.Length) 137if (_pos > _chars.Length - count) 157if (_pos > (_chars.Length - count)) 172if ((uint)pos < (uint)_chars.Length) 192if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 206if (pos > _chars.Length - s.Length) 217if (_pos > _chars.Length - count) 223for (int i = 0; i < dst.Length; i++) 233if (pos > _chars.Length - length) 239for (int i = 0; i < dst.Length; i++) 249if (pos > _chars.Length - value.Length) 262if (origPos > _chars.Length - length) 290Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 293char[] poolArray = ArrayPool<char>.Shared.Rent((int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), (uint)_chars.Length * 2));
Microsoft.AspNetCore.Identity.FunctionalTests (12)
src\Identity\Extensions.Core\src\Base32.cs (7)
32for (int offset = 0; offset < bytes.Length;) 123switch (input.Length - offset) 132b1 = (offset < input.Length) ? input[offset++] : 0U; 133b2 = (offset < input.Length) ? input[offset++] : 0U; 134b3 = (offset < input.Length) ? input[offset++] : 0U; 135b4 = (offset < input.Length) ? input[offset++] : 0U; 136b5 = (offset < input.Length) ? input[offset++] : 0U;
src\Identity\Extensions.Core\src\Rfc6238AuthenticationService.cs (5)
54Debug.Assert(written == hash.Length); 60var offset = hash[hash.Length - 1] & 0xf; 61Debug.Assert(offset + 4 < hash.Length); 72var combined = new byte[checked(input.Length + modifierBytes.Length)]; 74Buffer.BlockCopy(modifierBytes, 0, combined, input.Length, modifierBytes.Length);
Microsoft.AspNetCore.OpenApi (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
249Debug.Assert(span.Length >= _bytesWritten);
Microsoft.AspNetCore.OutputCaching (4)
FormatterBinaryWriter.cs (2)
116length = span.Length; 200var toWrite = Math.Min(value.Length, available.Length);
RecyclableSequenceBuilder.cs (2)
92if (available.Length >= buffer.Length) 100var toWrite = Math.Min(buffer.Length, available.Length);
Microsoft.AspNetCore.OutputCaching.Microbenchmarks (1)
EndToEndBenchmarks.cs (1)
98bytes = Math.Min(bytes, span.Length);
Microsoft.AspNetCore.Razor.Runtime (2)
Runtime\TagHelpers\TagHelperRunner.cs (2)
37for (var i = 0; i < tagHelpers.Length; i++) 42return Awaited(task, executionContext, i + 1, tagHelpers.Length);
Microsoft.AspNetCore.Routing (14)
Matching\DefaultEndpointSelector.cs (3)
26switch (candidateState.Length) 63for (var i = 0; i < candidateState.Length; i++) 112for (var i = 0; i < candidateState.Length; i++)
Matching\FastPathTokenizer.cs (2)
27while ((end = span.IndexOf('/')) >= 0 && count < segments.Length) 36if (length > 0 && count < segments.Length)
Matching\HttpMethodMatcherPolicy.cs (2)
399for (var i = 0; i < methods.Length; i++) 408for (var i = 0; i < methods.Length; i++)
Matching\ILEmitTrieFactory.cs (7)
128if (groups.Length < binarySearchThreshold) 132for (var i = 0; i < groups.Length; i++) 153var mid = groups.Length / 2; 348if (groups.Length < binarySearchThreshold) 368var mid = groups.Length / 2; 473if (disableBinarySearch || groups.Length < binarySearchThreshold) 500var mid = groups.Length / 2;
Microsoft.AspNetCore.Routing.Microbenchmarks (2)
Matching\JumpTableMultipleEntryBenchmark.cs (2)
163for (var c = 0; c < buffer.Length; c++) 167if (char.IsDigit(buffer[c]) && c < buffer.Length / 2)
Microsoft.AspNetCore.Server.HttpSys (19)
RequestProcessing\Response.cs (3)
297_nativeResponse.Base.EntityChunkCount = checked((ushort)dataChunks.Length); 536if (unknownHeaders.Length == 0) 567if (knownHeaderInfo.Length == 0)
RequestProcessing\ResponseBody.cs (1)
272Debug.Assert(currentChunk == dataChunks.Length, "All chunks should be accounted for");
src\Shared\HttpSys\RequestProcessing\RawUrlHelper.cs (4)
23if (raw[0] != '/' && !(raw.Length == 1 && raw[0] == '*')) 60while (scan < raw.Length && raw[scan] != '?') 75if (raw.Length < 7) 113if (raw.Length < 8)
src\Shared\HttpSys\RequestProcessing\RequestUriBuilder.cs (5)
23Debug.Assert(rawUrlBytes.Length != 0, "Length of the URL cannot be zero."); 26if (rawPath.Length == 0) 33if (rawPath.Length == 1 && rawPath[0] == (byte)'*') 59var end = rawPath.Length; 162if (reader == buffer.Length)
src\Shared\PathNormalizer\PathNormalizer.cs (4)
24while (src.Length > readPointer) 30return src.Length; 36writtenLength += src.Length - readPointer; 47var remainingLength = src.Length - readPointer;
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (38)
src\Shared\Http2cat\Http2Utilities.cs (2)
292var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength); 378var payload = buffer.Slice(extendedHeaderLength, buffer.Length - padLength - extendedHeaderLength);
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (19)
34if (destination.Length != 0) 90if ((uint)destination.Length >= 2) 122if ((uint)destination.Length >= 2) 154if ((uint)destination.Length >= 2) 192if ((uint)destination.Length != 0) 272if ((uint)destination.Length >= 3) 305if ((uint)destination.Length >= 3) 344if ((uint)destination.Length >= 2) 371if (destination.Length != 0) 379if (value.Length <= destination.Length) 397Debug.Assert(destination.Length >= value.Length); 421if (destination.Length != 0) 429if (value.Length <= destination.Length) 460if (destination.Length != 0) 472if (encodedStringLength <= destination.Length) 503if (destination.Length != 0) 526if (destination.Length != 0) 553if (destination.Length >= valueLength) 639span = new byte[span.Length * 2];
src\Shared\runtime\Http2\Hpack\Huffman.cs (5)
680Debug.Assert(dst.Length > 0); 712if (j == dst.Length) 714Array.Resize(ref dstArray, dst.Length * 2); 779if (j == dst.Length) 781Array.Resize(ref dstArray, dst.Length * 2);
src\Shared\runtime\Http2\Hpack\IntegerEncoder.cs (3)
28if (destination.Length == 0) 47if (1 == destination.Length) 60if (i >= destination.Length)
src\Shared\ServerInfrastructure\BufferExtensions.cs (5)
120if (sourceLength <= dest.Length) 139if (number < 10 && buffer.Length >= 1) 144else if (number < 100 && buffer.Length >= 2) 153else if (number < 1000 && buffer.Length >= 3) 201if (sourceLength <= dest.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 111if (_span.Length < count) 140if (_span.Length == 0) 145var writable = Math.Min(source.Length, _span.Length);
Microsoft.AspNetCore.Server.IIS (26)
Core\IISHttpContext.cs (2)
325if (rawUrlInBytes.Length == 0) 332if (rawUrlInBytes.Length > 0 && rawUrlInBytes[^1] == 0)
src\Shared\HttpSys\RequestProcessing\RawUrlHelper.cs (4)
23if (raw[0] != '/' && !(raw.Length == 1 && raw[0] == '*')) 60while (scan < raw.Length && raw[scan] != '?') 75if (raw.Length < 7) 113if (raw.Length < 8)
src\Shared\HttpSys\RequestProcessing\RequestUriBuilder.cs (5)
23Debug.Assert(rawUrlBytes.Length != 0, "Length of the URL cannot be zero."); 26if (rawPath.Length == 0) 33if (rawPath.Length == 1 && rawPath[0] == (byte)'*') 59var end = rawPath.Length; 162if (reader == buffer.Length)
src\Shared\PathNormalizer\PathNormalizer.cs (4)
24while (src.Length > readPointer) 30return src.Length; 36writtenLength += src.Length - readPointer; 47var remainingLength = src.Length - readPointer;
src\Shared\ServerInfrastructure\BufferExtensions.cs (5)
120if (sourceLength <= dest.Length) 139if (number < 10 && buffer.Length >= 1) 144else if (number < 100 && buffer.Length >= 2) 153else if (number < 1000 && buffer.Length >= 3) 201if (sourceLength <= dest.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 111if (_span.Length < count) 140if (_span.Length == 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
Microsoft.AspNetCore.Server.Kestrel.Core (71)
Internal\Http\Http1Connection.cs (9)
298Debug.Assert(target.Length != 0, "Request target must be non-zero length"); 308else if (ch == ByteAsterisk && target.Length == 1) 346if (target.Length == 1) 363previousValue == null || previousValue.Length != target.Length || 394if (target.Length == targetPath.Length) 434var queryLength = query.Length; 482previousValue == null || previousValue.Length != target.Length || 540previousValue == null || previousValue.Length != target.Length || 572previousValue == null || previousValue.Length != query.Length ||
Internal\Http\HttpParser.cs (1)
448if (terminatorSize == -1 || !TryTakeSingleHeader(handler, headerSpan.Slice(0, headerSpan.Length - terminatorSize)))
Internal\Http\PathDecoder.cs (1)
38if (path.Length == pathLength && queryLength == 0)
Internal\Infrastructure\HttpUtilities.cs (1)
101Debug.Assert(written == destination.Length);
src\Shared\PathNormalizer\PathNormalizer.cs (4)
24while (src.Length > readPointer) 30return src.Length; 36writtenLength += src.Length - readPointer; 47var remainingLength = src.Length - readPointer;
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (19)
34if (destination.Length != 0) 90if ((uint)destination.Length >= 2) 122if ((uint)destination.Length >= 2) 154if ((uint)destination.Length >= 2) 192if ((uint)destination.Length != 0) 272if ((uint)destination.Length >= 3) 305if ((uint)destination.Length >= 3) 344if ((uint)destination.Length >= 2) 371if (destination.Length != 0) 379if (value.Length <= destination.Length) 397Debug.Assert(destination.Length >= value.Length); 421if (destination.Length != 0) 429if (value.Length <= destination.Length) 460if (destination.Length != 0) 472if (encodedStringLength <= destination.Length) 503if (destination.Length != 0) 526if (destination.Length != 0) 553if (destination.Length >= valueLength) 639span = new byte[span.Length * 2];
src\Shared\runtime\Http2\Hpack\Huffman.cs (5)
680Debug.Assert(dst.Length > 0); 712if (j == dst.Length) 714Array.Resize(ref dstArray, dst.Length * 2); 779if (j == dst.Length) 781Array.Resize(ref dstArray, dst.Length * 2);
src\Shared\runtime\Http2\Hpack\IntegerEncoder.cs (3)
28if (destination.Length == 0) 47if (1 == destination.Length) 60if (i >= destination.Length)
src\Shared\runtime\Http3\Frames\Http3Frame.cs (1)
45if (buffer.Length != 0)
src\Shared\runtime\Http3\Helpers\VariableLengthIntegerHelper.cs (1)
154if (buffer.Length != 0)
src\Shared\runtime\Http3\QPack\QPackEncoder.cs (8)
69if (destination.Length >= 2) 184if (buffer.Length != 0) 195if (buffer.Length >= encodedStringLength) 233if (buffer.Length > 0) 258if (buffer.Length >= valueLength) 303Debug.Assert(buffer.Length >= s.Length); 320if (buffer.Length != 0) 328if (buffer.Length >= s.Length)
src\Shared\ServerInfrastructure\BufferExtensions.cs (5)
120if (sourceLength <= dest.Length) 139if (number < 10 && buffer.Length >= 1) 144else if (number < 100 && buffer.Length >= 2) 153else if (number < 1000 && buffer.Length >= 3) 201if (sourceLength <= dest.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 111if (_span.Length < count) 140if (_span.Length == 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
src\Shared\UrlDecoder\UrlDecoder.cs (7)
20if (destination.Length < source.Length) 52if (sourceIndex == buffer.Length) 155if (sourceIndex == buffer.Length) 303if (scan == buffer.Length) 385return buffer.Length; 396if (sourceIndex == buffer.Length) 491if (sourceIndex == buffer.Length)
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (12)
AsciiDecoding.cs (5)
41Assert.Equal(s.Length, asciiBytes.Length); 43for (var i = 0; i < asciiBytes.Length; i++) 103Assert.False(StringUtilities.BytesOrdinalEqualsStringAndAscii(s, span.Slice(0, span.Length - 1))); 107Assert.False(StringUtilities.BytesOrdinalEqualsStringAndAscii(s, span.Slice(1, span.Length - 1))); 140for (var i = 0; i < asciiBytes.Length; i++)
Http2\Http2HPackEncoderTests.cs (4)
605headers.Cookie = new string('a', buffer.Length + 1); 620headers.Cookie = new string('a', buffer.Length + 1); 635headers.Cookie = new string('a', buffer.Length - 1); 651headers.Cookie = new string('a', buffer.Length - 1);
src\Servers\Kestrel\shared\test\PipeWriterHttp2FrameExtensions.cs (1)
74frame.PayloadLength = headerData.Length;
TestHelpers\AssertExtensions.cs (2)
13if (expected.Length != actual.Length) 15throw new XunitException($"Expected length to be {expected.Length} but was {actual.Length}");
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (2)
Mocks\NullParser.cs (1)
40new TargetOffsetPathLength(4, startLine.Length - 4, false),
src\Servers\Kestrel\shared\test\PipeWriterHttp2FrameExtensions.cs (1)
74frame.PayloadLength = headerData.Length;
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (2)
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
Microsoft.AspNetCore.Shared.Tests (69)
src\Shared\Dictionary\AdaptiveCapacityDictionary.cs (1)
561for (var i = 0; i < ArrayStorageSpan.Length; ++i)
src\Shared\HttpSys\RequestProcessing\RawUrlHelper.cs (4)
23if (raw[0] != '/' && !(raw.Length == 1 && raw[0] == '*')) 60while (scan < raw.Length && raw[scan] != '?') 75if (raw.Length < 7) 113if (raw.Length < 8)
src\Shared\HttpSys\RequestProcessing\RequestUriBuilder.cs (5)
23Debug.Assert(rawUrlBytes.Length != 0, "Length of the URL cannot be zero."); 26if (rawPath.Length == 0) 33if (rawPath.Length == 1 && rawPath[0] == (byte)'*') 59var end = rawPath.Length; 162if (reader == buffer.Length)
src\Shared\PathNormalizer\PathNormalizer.cs (4)
24while (src.Length > readPointer) 30return src.Length; 36writtenLength += src.Length - readPointer; 47var remainingLength = src.Length - readPointer;
src\Shared\runtime\Http2\Hpack\HPackEncoder.cs (19)
34if (destination.Length != 0) 90if ((uint)destination.Length >= 2) 122if ((uint)destination.Length >= 2) 154if ((uint)destination.Length >= 2) 192if ((uint)destination.Length != 0) 272if ((uint)destination.Length >= 3) 305if ((uint)destination.Length >= 3) 344if ((uint)destination.Length >= 2) 371if (destination.Length != 0) 379if (value.Length <= destination.Length) 397Debug.Assert(destination.Length >= value.Length); 421if (destination.Length != 0) 429if (value.Length <= destination.Length) 460if (destination.Length != 0) 472if (encodedStringLength <= destination.Length) 503if (destination.Length != 0) 526if (destination.Length != 0) 553if (destination.Length >= valueLength) 639span = new byte[span.Length * 2];
src\Shared\runtime\Http2\Hpack\Huffman.cs (5)
680Debug.Assert(dst.Length > 0); 712if (j == dst.Length) 714Array.Resize(ref dstArray, dst.Length * 2); 779if (j == dst.Length) 781Array.Resize(ref dstArray, dst.Length * 2);
src\Shared\runtime\Http2\Hpack\IntegerEncoder.cs (3)
28if (destination.Length == 0) 47if (1 == destination.Length) 60if (i >= destination.Length)
src\Shared\runtime\Http3\Frames\Http3Frame.cs (1)
45if (buffer.Length != 0)
src\Shared\runtime\Http3\Helpers\VariableLengthIntegerHelper.cs (1)
154if (buffer.Length != 0)
src\Shared\runtime\Http3\QPack\QPackEncoder.cs (8)
69if (destination.Length >= 2) 184if (buffer.Length != 0) 195if (buffer.Length >= encodedStringLength) 233if (buffer.Length > 0) 258if (buffer.Length >= valueLength) 303Debug.Assert(buffer.Length >= s.Length); 320if (buffer.Length != 0) 328if (buffer.Length >= s.Length)
src\Shared\ServerInfrastructure\BufferExtensions.cs (5)
120if (sourceLength <= dest.Length) 139if (number < 10 && buffer.Length >= 1) 144else if (number < 100 && buffer.Length >= 2) 153else if (number < 1000 && buffer.Length >= 3) 201if (sourceLength <= dest.Length)
src\Shared\ServerInfrastructure\BufferWriter.cs (4)
93if (_span.Length >= source.Length) 111if (_span.Length < count) 140if (_span.Length == 0) 145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\StringUtilities.cs (2)
34Debug.Assert(destination[0] == '\0' || written == destination.Length); 63Debug.Assert(written == destination.Length);
src\Shared\UrlDecoder\UrlDecoder.cs (7)
20if (destination.Length < source.Length) 52if (sourceIndex == buffer.Length) 155if (sourceIndex == buffer.Length) 303if (scan == buffer.Length) 385return buffer.Length; 396if (sourceIndex == buffer.Length) 491if (sourceIndex == buffer.Length)
Microsoft.AspNetCore.SignalR.Client.Tests (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
249Debug.Assert(span.Length >= _bytesWritten);
Microsoft.AspNetCore.SignalR.Common (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
249Debug.Assert(span.Length >= _bytesWritten);
Microsoft.AspNetCore.SignalR.Protocols.MessagePack (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
249Debug.Assert(span.Length >= _bytesWritten);
Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
249Debug.Assert(span.Length >= _bytesWritten);
Microsoft.AspNetCore.SignalR.Specification.Tests (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
249Debug.Assert(span.Length >= _bytesWritten);
Microsoft.AspNetCore.SignalR.StackExchangeRedis (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
249Debug.Assert(span.Length >= _bytesWritten);
Microsoft.AspNetCore.StaticAssets (1)
StaticAssetsInvoker.cs (1)
415for (var i = 0; i < states.Length; i++)
Microsoft.AspNetCore.StaticAssets.Tests (1)
StaticAssetsIntegrationTests.cs (1)
488for (var i = 0; i < resources.Length; i++)
Microsoft.AspNetCore.WebSockets (23)
src\Shared\ValueStringBuilder\ValueListBuilder.cs (7)
33if ((uint)pos < (uint)span.Length) 47Debug.Assert(_pos == _span.Length); 78int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 88nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (16)
38Debug.Assert(value <= _chars.Length); 43public int Capacity => _chars.Length; 51if ((uint)capacity > (uint)_chars.Length) 137if (_pos > _chars.Length - count) 157if (_pos > (_chars.Length - count)) 172if ((uint)pos < (uint)_chars.Length) 192if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 206if (pos > _chars.Length - s.Length) 217if (_pos > _chars.Length - count) 223for (int i = 0; i < dst.Length; i++) 233if (pos > _chars.Length - length) 239for (int i = 0; i < dst.Length; i++) 249if (pos > _chars.Length - value.Length) 262if (origPos > _chars.Length - length) 290Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 293char[] poolArray = ArrayPool<char>.Shared.Rent((int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), (uint)_chars.Length * 2));
Microsoft.AspNetCore.WebUtilities (9)
FileBufferingReadStream.cs (1)
312else if (buffer.Length > 0)
HttpRequestStreamReader.cs (1)
172var count = buffer.Length;
src\Shared\UrlDecoder\UrlDecoder.cs (7)
20if (destination.Length < source.Length) 52if (sourceIndex == buffer.Length) 155if (sourceIndex == buffer.Length) 303if (scan == buffer.Length) 385return buffer.Length; 396if (sourceIndex == buffer.Length) 491if (sourceIndex == buffer.Length)
Microsoft.Build (6)
FileUtilities.cs (3)
643for (int i = 0; i < str.Length; i++) 660int endId = path.Length - 1; 664bool hasQuotes = path.Length > 2
Logging\OptimizedStringIndenter.cs (3)
64int indentedStringLength = segments.Length * (Environment.NewLine.Length + indent); 132if (segmentCount <= segments.Length) 144for (int i = 0; i < segments.Length; i++)
Microsoft.Build.Engine.OM.UnitTests (3)
FileUtilities.cs (3)
643for (int i = 0; i < str.Length; i++) 660int endId = path.Length - 1; 664bool hasQuotes = path.Length > 2
Microsoft.Build.Framework (6)
ArraySortHelper.cs (6)
690Debug.Assert(0 <= i && i < keys.Length && i < values.Length); 691Debug.Assert(0 <= j && j < keys.Length && j < values.Length); 723Debug.Assert(keys.Length == values.Length); 734Debug.Assert(values.Length == keys.Length); 976Debug.Assert(values.Length == keys.Length); 1254if ((uint)i < (uint)values.Length) // check to see if we have values
Microsoft.Build.Tasks.Core (3)
FileUtilities.cs (3)
643for (int i = 0; i < str.Length; i++) 660int endId = path.Length - 1; 664bool hasQuotes = path.Length > 2
Microsoft.Build.Utilities.Core (3)
FileUtilities.cs (3)
643for (int i = 0; i < str.Length; i++) 660int endId = path.Length - 1; 664bool hasQuotes = path.Length > 2
Microsoft.CodeAnalysis (21)
CodeAnalysisEventSource.Common.cs (2)
57WriteEventCore(eventId: 4, data.Length, dataPtr); 91WriteEventCore(eventId: 6, data.Length, dataPtr);
CodeGen\PrivateImplementationDetails.cs (1)
575Debug.Assert(bytesWritten == hash.Length);
CommandLine\CommandLineParser.cs (2)
637if (lineBufferLength >= lineBuffer.Length) 639var temp = new char[lineBuffer.Length * 2];
Hashing\NonCryptographicHashAlgorithm.cs (5)
208if (destination.Length < HashLengthInBytes) 233if (destination.Length < HashLengthInBytes) 270if (destination.Length < HashLengthInBytes) 295if (destination.Length < HashLengthInBytes) 329Debug.Assert(destination.Length == HashLengthInBytes);
Hashing\XxHash128.cs (1)
108if (destination.Length >= sizeof(ulong) * 2)
Hashing\XxHashShared.cs (2)
333Debug.Assert(remaining.Length <= InternalBufferLengthBytes); 336state.BufferedCount = (uint)remaining.Length;
src\Dependencies\Collections\Internal\ArraySortHelper.cs (6)
694Debug.Assert(0 <= i && i < keys.Length && i < values.Length); 695Debug.Assert(0 <= j && j < keys.Length && j < values.Length); 727Debug.Assert(keys.Length == values.Length); 738Debug.Assert(values.Length == keys.Length); 978Debug.Assert(values.Length == keys.Length); 1252if ((uint)i < (uint)values.Length) // check to see if we have values
src\Dependencies\Collections\Internal\BitHelper.cs (2)
40if (bitArrayIndex < (uint)span.Length) 55bitArrayIndex < (uint)span.Length &&
Microsoft.CodeAnalysis.CodeStyle (19)
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (5)
208if (destination.Length < HashLengthInBytes) 233if (destination.Length < HashLengthInBytes) 270if (destination.Length < HashLengthInBytes) 295if (destination.Length < HashLengthInBytes) 329Debug.Assert(destination.Length == HashLengthInBytes);
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
108if (destination.Length >= sizeof(ulong) * 2)
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (2)
333Debug.Assert(remaining.Length <= InternalBufferLengthBytes); 336state.BufferedCount = (uint)remaining.Length;
src\Dependencies\Collections\Internal\ArraySortHelper.cs (6)
694Debug.Assert(0 <= i && i < keys.Length && i < values.Length); 695Debug.Assert(0 <= j && j < keys.Length && j < values.Length); 727Debug.Assert(keys.Length == values.Length); 738Debug.Assert(values.Length == keys.Length); 978Debug.Assert(values.Length == keys.Length); 1252if ((uint)i < (uint)values.Length) // check to see if we have values
src\Dependencies\Collections\Internal\BitHelper.cs (2)
40if (bitArrayIndex < (uint)span.Length) 55bitArrayIndex < (uint)span.Length &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (3)
175Debug.Assert(tempBuffer.Length != 0); // We only bound-check after writing a character to the tempBuffer. 184if (charsWritten == tempBuffer.Length) 200int destLength = bytes.Length;
Microsoft.CodeAnalysis.Collections.Package (8)
Internal\ArraySortHelper.cs (6)
694Debug.Assert(0 <= i && i < keys.Length && i < values.Length); 695Debug.Assert(0 <= j && j < keys.Length && j < values.Length); 727Debug.Assert(keys.Length == values.Length); 738Debug.Assert(values.Length == keys.Length); 978Debug.Assert(values.Length == keys.Length); 1252if ((uint)i < (uint)values.Length) // check to see if we have values
Internal\BitHelper.cs (2)
40if (bitArrayIndex < (uint)span.Length) 55bitArrayIndex < (uint)span.Length &&
Microsoft.CodeAnalysis.InteractiveHost (8)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (6)
694Debug.Assert(0 <= i && i < keys.Length && i < values.Length); 695Debug.Assert(0 <= j && j < keys.Length && j < values.Length); 727Debug.Assert(keys.Length == values.Length); 738Debug.Assert(values.Length == keys.Length); 978Debug.Assert(values.Length == keys.Length); 1252if ((uint)i < (uint)values.Length) // check to see if we have values
src\Dependencies\Collections\Internal\BitHelper.cs (2)
40if (bitArrayIndex < (uint)span.Length) 55bitArrayIndex < (uint)span.Length &&
Microsoft.CodeAnalysis.Threading.Package (8)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (6)
694Debug.Assert(0 <= i && i < keys.Length && i < values.Length); 695Debug.Assert(0 <= j && j < keys.Length && j < values.Length); 727Debug.Assert(keys.Length == values.Length); 738Debug.Assert(values.Length == keys.Length); 978Debug.Assert(values.Length == keys.Length); 1252if ((uint)i < (uint)values.Length) // check to see if we have values
src\Dependencies\Collections\Internal\BitHelper.cs (2)
40if (bitArrayIndex < (uint)span.Length) 55bitArrayIndex < (uint)span.Length &&
Microsoft.CodeAnalysis.Workspaces (22)
src\Compilers\Core\Portable\CodeAnalysisEventSource.Common.cs (2)
57WriteEventCore(eventId: 4, data.Length, dataPtr); 91WriteEventCore(eventId: 6, data.Length, dataPtr);
src\Compilers\Core\Portable\Hashing\NonCryptographicHashAlgorithm.cs (5)
208if (destination.Length < HashLengthInBytes) 233if (destination.Length < HashLengthInBytes) 270if (destination.Length < HashLengthInBytes) 295if (destination.Length < HashLengthInBytes) 329Debug.Assert(destination.Length == HashLengthInBytes);
src\Compilers\Core\Portable\Hashing\XxHash128.cs (1)
108if (destination.Length >= sizeof(ulong) * 2)
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (2)
333Debug.Assert(remaining.Length <= InternalBufferLengthBytes); 336state.BufferedCount = (uint)remaining.Length;
src\Dependencies\Collections\Internal\ArraySortHelper.cs (6)
694Debug.Assert(0 <= i && i < keys.Length && i < values.Length); 695Debug.Assert(0 <= j && j < keys.Length && j < values.Length); 727Debug.Assert(keys.Length == values.Length); 738Debug.Assert(values.Length == keys.Length); 978Debug.Assert(values.Length == keys.Length); 1252if ((uint)i < (uint)values.Length) // check to see if we have values
src\Dependencies\Collections\Internal\BitHelper.cs (2)
40if (bitArrayIndex < (uint)span.Length) 55bitArrayIndex < (uint)span.Length &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\Base64Utilities.cs (3)
175Debug.Assert(tempBuffer.Length != 0); // We only bound-check after writing a character to the tempBuffer. 184if (charsWritten == tempBuffer.Length) 200int destLength = bytes.Length;
Workspace\Solution\Checksum.cs (1)
88Contract.ThrowIfTrue(span.Length < HashSize);
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (8)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (6)
694Debug.Assert(0 <= i && i < keys.Length && i < values.Length); 695Debug.Assert(0 <= j && j < keys.Length && j < values.Length); 727Debug.Assert(keys.Length == values.Length); 738Debug.Assert(values.Length == keys.Length); 978Debug.Assert(values.Length == keys.Length); 1252if ((uint)i < (uint)values.Length) // check to see if we have values
src\Dependencies\Collections\Internal\BitHelper.cs (2)
40if (bitArrayIndex < (uint)span.Length) 55bitArrayIndex < (uint)span.Length &&
Microsoft.CodeAnalysis.Workspaces.UnitTests (5)
ChecksumTests.cs (5)
58for (var i = 0; i < builder.Length; i++) 65for (var i = 1; i < builder.Length; i++) 87for (var i = 0; i < builder.Length; i++) 90for (var i = builder.Length - 10; i < builder.Length; i++)
Microsoft.Data.Analysis (32)
DataFrame.cs (2)
428for (int i = 0; i < span.Length; i++) 448for (int i = 0; i < span.Length; i++)
PrimitiveColumnContainer.BinaryOperations.cs (2)
31for (var j = 0; j < leftSpan.Length; j++) 82for (var j = 0; j < rightSpan.Length; j++)
PrimitiveColumnContainer.cs (4)
186for (int i = 0; i < mutableBuffer.Length; i++) 204for (int i = 0; i < span.Length; i++) 247for (int i = 0; i < span.Length; i++) 295Debug.Assert(bitMapBufferSpan.Length >= bitMapBufferIndex);
PrimitiveDataFrameColumnComputations.cs (24)
253for (int i = 0; i < mutableSpan.Length; i++) 722for (int i = 0; i < mutableSpan.Length; i++) 740for (int i = 0; i < mutableSpan.Length; i++) 1209for (int i = 0; i < mutableSpan.Length; i++) 1227for (int i = 0; i < mutableSpan.Length; i++) 1696for (int i = 0; i < mutableSpan.Length; i++) 1714for (int i = 0; i < mutableSpan.Length; i++) 2183for (int i = 0; i < mutableSpan.Length; i++) 2201for (int i = 0; i < mutableSpan.Length; i++) 2670for (int i = 0; i < mutableSpan.Length; i++) 2688for (int i = 0; i < mutableSpan.Length; i++) 3157for (int i = 0; i < mutableSpan.Length; i++) 3175for (int i = 0; i < mutableSpan.Length; i++) 3644for (int i = 0; i < mutableSpan.Length; i++) 3662for (int i = 0; i < mutableSpan.Length; i++) 4131for (int i = 0; i < mutableSpan.Length; i++) 4149for (int i = 0; i < mutableSpan.Length; i++) 4618for (int i = 0; i < mutableSpan.Length; i++) 4636for (int i = 0; i < mutableSpan.Length; i++) 5105for (int i = 0; i < mutableSpan.Length; i++) 5123for (int i = 0; i < mutableSpan.Length; i++) 5592for (int i = 0; i < mutableSpan.Length; i++) 5610for (int i = 0; i < mutableSpan.Length; i++) 6079for (int i = 0; i < mutableSpan.Length; i++)
Microsoft.Extensions.AI.Abstractions (1)
Embeddings\BinaryEmbedding.cs (1)
101for (int i = 0; i < utf8.Length; i++)
Microsoft.Extensions.AI.OpenAI (3)
src\Shared\ServerSentEvents\Helpers.cs (3)
35Debug.Assert(buffer.Length >= MaxDecimalDigits); 53Debug.Assert(value.Length <= buffer.Length); 67Debug.Assert(maxByteCount <= buffer.Length);
Microsoft.Extensions.Caching.Hybrid.Tests (1)
TagSetTests.cs (1)
172for (int i = 0; i < chars.Length; i++)
Microsoft.Extensions.Compliance.Abstractions (3)
Redaction\NullRedactor.cs (1)
28Throw.IfBufferTooSmall(destination.Length, source.Length, nameof(destination));
Redaction\Redactor.cs (2)
236if (rlen > destination.Length) 277if (len > destination.Length)
Microsoft.Extensions.Compliance.Abstractions.Tests (1)
Redaction\TestSpanFormattable.cs (1)
27if (destination.Length < _value.Length)
Microsoft.Extensions.Compliance.Redaction (1)
HmacRedactor.cs (1)
73Throw.IfBufferTooSmall(destination.Length, length, nameof(destination));
Microsoft.Extensions.Compliance.Testing (1)
FakeRedactor.cs (1)
79Throw.IfBufferTooSmall(destination.Length, str.Length, nameof(destination));
Microsoft.Extensions.Diagnostics (1)
src\libraries\Common\src\System\Diagnostics\DiagnosticsHelper.cs (1)
127_maxIndex = bitMap.Length * sizeof(ulong) * 8;
Microsoft.Extensions.Identity.Core (8)
Base32.cs (6)
123switch (input.Length - offset) 132b1 = (offset < input.Length) ? input[offset++] : 0U; 133b2 = (offset < input.Length) ? input[offset++] : 0U; 134b3 = (offset < input.Length) ? input[offset++] : 0U; 135b4 = (offset < input.Length) ? input[offset++] : 0U; 136b5 = (offset < input.Length) ? input[offset++] : 0U;
Rfc6238AuthenticationService.cs (2)
72var combined = new byte[checked(input.Length + modifierBytes.Length)]; 74Buffer.BlockCopy(modifierBytes, 0, combined, input.Length, modifierBytes.Length);
Microsoft.Extensions.Logging.Abstractions (14)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
Microsoft.Extensions.Telemetry (3)
Logging\JustInTimeRedactor.cs (3)
99if (maxLenToRedact > workBuffer.Length) 129if (maxLenToRedact > workBuffer.Length) 153if (redactedLen > destination.Length)
Microsoft.Extensions.Telemetry.Tests (1)
Logging\JustInTimeRedactorTests.cs (1)
124if (s.Length > destination.Length)
Microsoft.ML.Core (10)
Utilities\BigArray.cs (1)
389Contracts.Assert(0 <= length && length <= dst.Length);
Utilities\HashArray.cs (1)
237Contracts.Check(destination.Length >= _ct);
Utilities\Stream.cs (1)
703int numElementsToReadThisChunk = Math.Min(maxChunkSizeInElements, destination.Length);
Utilities\Utils.cs (4)
191Contracts.Assert(src.Count <= dst.Length); 463Contracts.Assert(0 <= lim && lim <= a.Length); 549for (int iv = 0; iv < rgv.Length; iv++) 550Swap(ref rgv[iv], ref rgv[iv + rand.Next(rgv.Length - iv)]);
Utilities\VBufferUtils.cs (3)
277for (int i = 0; i < editor.Values.Length; i++) 283for (int i = 0; i < editor.Values.Length; i++) 309int dstValuesCount = editor.Values.Length;
Microsoft.ML.Core.Tests (4)
UnitTests\TestVBuffer.cs (4)
124for (int i = 0; i < editor.Values.Length; ++i) 561for (int i = 0; i < editor.Indices.Length; ++i) 1129for (int i = 0; i < bEditor.Values.Length; ++i) 1151GenericSpanSortHelper<int>.Sort(bEditor.Indices, 0, bEditor.Indices.Length);
Microsoft.ML.CpuMath (35)
AlignedArray.cs (2)
114Contracts.Assert(0 <= index && index <= dst.Length - count); 122Contracts.Assert(0 <= index && index <= dst.Length - count);
AvxIntrinsics.cs (10)
424float* pDstEnd = pdst + dst.Length; 468int length = dst.Length; 571Contracts.Assert(count <= dst.Length); 621float* pDstEnd = pdst + dst.Length; 666Contracts.Assert(count <= dst.Length); 721Contracts.Assert(count <= result.Length); 777Contracts.Assert(count <= dst.Length); 828Contracts.Assert(count <= dst.Length); 877Contracts.Assert(count <= dst.Length); 926Contracts.Assert(count <= dst.Length);
CpuMathUtils.cs (5)
54Contracts.Assert(count <= destination.Length); 73Contracts.Assert(count <= destination.Length); 95Contracts.Assert(count <= result.Length); 113Contracts.Assert(count <= destination.Length); 134Contracts.Assert(count <= destination.Length);
CpuMathUtils.netcoreapp.cs (8)
171if (destination.Length < MinInputSize || !Sse.IsSupported) 173for (int i = 0; i < destination.Length; i++) 205Contracts.Assert(count < destination.Length); 241Contracts.Assert(count < destination.Length); 536Contracts.Assert(count <= v.Length); 537Contracts.Assert(count <= w.Length); 578Contracts.Assert(count <= v.Length); 579Contracts.Assert(count <= w.Length);
SseIntrinsics.cs (10)
359float* pDstEnd = pdst + dst.Length; 392int length = dst.Length; 490Contracts.Assert(count <= dst.Length); 528float* pDstEnd = pdst + dst.Length; 560Contracts.Assert(count <= dst.Length); 602Contracts.Assert(count <= result.Length); 645Contracts.Assert(count <= dst.Length); 684Contracts.Assert(count <= dst.Length); 721Contracts.Assert(count <= dst.Length); 758Contracts.Assert(count <= dst.Length);
Microsoft.ML.Data (12)
Deprecated\Vector\GenericSpanSortHelper.cs (9)
50Contracts.Assert(index >= 0 && length >= 0 && (keys.Length - index >= length), "Check the arguments in the caller!"); 93Contracts.Assert(length <= keys.Length); 94Contracts.Assert(length + left <= keys.Length); 95Contracts.Assert(length + left <= values.Length); 106Contracts.Assert(hi < keys.Length); 152Contracts.Assert(hi < keys.Length); 195Contracts.Assert(hi < keys.Length); 212Contracts.Assert(lo < keys.Length); 238Contracts.Assert(hi <= keys.Length);
Deprecated\Vector\VectorUtils.cs (1)
444Contracts.CheckParam(src.Length == dst.Length, nameof(dst), "Arrays must have the same dimensionality.");
Scorers\FeatureContributionCalculation.cs (1)
241var count = values.Length;
Transforms\ValueToKeyMappingTransformerImpl.cs (1)
660Contracts.Assert(0 <= nstr.Id && nstr.Id < editor.Values.Length);
Microsoft.ML.DataView (5)
VBuffer.cs (3)
270/// <param name="destination">The destination buffer. This <see cref="Span{T}.Length"/> must have least <see cref="Length"/>.</param> 279/// <param name="destination">The destination buffer. This <see cref="Span{T}.Length"/> must be at least <see cref="Length"/> 287Contracts.CheckParam(0 <= destinationIndex && destinationIndex <= destination.Length - Length,
VBufferEditor.cs (2)
136return new VBuffer<T>(_logicalLength, Values.Length, _values, _indices); 159Contracts.CheckParam(physicalValuesCount <= Values.Length, nameof(physicalValuesCount),
Microsoft.ML.ImageAnalytics (3)
ImageLoader.cs (3)
342if (bytesRead != srcSpan.Length) 345Contract.Assert(srcSpan.Length == dstSpan.Length);
Microsoft.ML.KMeansClustering (1)
KMeansModelParameters.cs (1)
167Host.Assert(distances.Length >= _k);
Microsoft.ML.StandardTrainers (5)
Standard\LogisticRegression\LogisticRegression.cs (1)
214Contracts.Assert(editor.Values.Length >= BiasCount && (grad.IsDense || editor.Indices[BiasCount - 1] == BiasCount - 1));
Standard\LogisticRegression\MulticlassLogisticRegression.cs (2)
272Contracts.Assert(editor.Values.Length >= BiasCount && (grad.IsDense || editor.Indices[BiasCount - 1] == BiasCount - 1)); 1241Host.Assert(dst.Length == NumberOfClasses);
Standard\MulticlassClassification\PairwiseCouplingTrainer.cs (1)
385Contracts.Assert(output.Length >= _numClasses);
Standard\PoissonRegression\PoissonRegression.cs (1)
179Contracts.Assert(editor.Values.Length >= BiasCount && (grad.IsDense || editor.Indices[BiasCount - 1] == BiasCount - 1));
Microsoft.ML.TestFrameworkCommon (1)
TestLogger.cs (1)
48if ((span.Length >= 2) && (span[count - 2] == '\r') && (span[count - 1] == '\n'))
Microsoft.ML.Tokenizers (130)
Model\BertTokenizer.cs (16)
347if (destination.Length < 1) 355if (destination.Length <= valuesWritten) 364if (destination.Length <= valuesWritten) 375if (destination.Length <= valuesWritten) 383if (destination.Length <= valuesWritten) 476if (destination.Length < 1) 484if (destination.Length <= valuesWritten) 492if (destination.Length <= valuesWritten) 503if (destination.Length <= valuesWritten) 511if (destination.Length <= valuesWritten) 524if (destination.Length <= valuesWritten) 536if (destination.Length <= valuesWritten) 613if (destination.Length < 2) 622if (destination.Length <= valuesWritten) 634if (destination.Length <= valuesWritten) 642if (destination.Length < valuesWritten)
Model\BPETokenizer.cs (9)
930if (buffer.Length == 0) 960if (sSpan.Length > buffer.Length) 1013if (specialTokenSpan.Length > buffer.Length) 1042if (current.Length < span.Length) 1058if (current.Length == utf8BytesConsumed) // encoding is complete 1061if (completeCharsWritten > buffer.Length) 1079incompleteUtf8BytesInBuffer = current.Length - utf8BytesConsumed; 1213if (ContinuingSubwordPrefix.Length + s.Length <= buffer.Length) 1233if (s.Length + EndOfWordSuffix.Length <= buffer.Length)
Model\CodeGenTokenizer.cs (19)
1136if (destinationMaxSize > token.Length) 1200if (destinationMaxSize > token.Length) 1379if (BeginningOfSentenceToken!.Length > buffer.Length) 1402if (EndOfSentenceToken!.Length > buffer.Length) 1425if (UnknownToken!.Length > buffer.Length) 1452if (specialTokenSpan.Length > buffer.Length) 1472if (current.Length < span.Length) 1488if (current.Length == utf8BytesConsumed) // encoding is complete 1491if (completeCharsWritten > buffer.Length) 1509incompleteUtf8BytesInBuffer = current.Length - utf8BytesConsumed; 1600if (text.Length == 0) 1605if (text.Length == 1) 1613BpeSymbol[] symbols = ArrayPool<BpeSymbol>.Shared.Rent(text.Length); 1617for (int i = 0; i < text.Length; i++) 1621next: i == text.Length - 1 ? -1 : i + 1, 1627for (int i = 1; i < text.Length; i++) 1659List<EncodedToken> result = new List<EncodedToken>(text.Length); 1661for (int index = 0; (uint)index < (uint)text.Length; index = symbols[index].next) 1682int endIndex = index + length < mapping.Length ? mapping[index + length] : originalText.Length;
Model\EnglishRobertaTokenizer.cs (5)
808if (s.Length > buffer.Length) 917Debug.Assert(index + tokens[i].Value.Length <= indexMapping.Length); 950if (token.Length == 0) 957if (token.Length == 1) 964List<string> word = new(token.Length);
Model\SentencePieceBaseModel.cs (6)
601if (buffer.Length < specialToken!.Length) 629if (charCount > buffer.Length) 646if (buffer.Length < 1) 678if (tokenSpan.Length > buffer.Length) 705if (tokenSpan.Length > buffer.Length) 726if (buffer.Length < token.Length - delta)
Model\SentencePieceBpeModel.cs (4)
229if (len > utf8Bytes.Length) 529if (len > utf8Bytes.Length) 792if (len > utf8Bytes.Length) 1068if (len > utf8Bytes.Length)
Model\SentencePieceUnigramModel.cs (12)
183if (text.Length > utf16NormalizedString.Length) 196if (Encoding.UTF8.GetMaxCharCount(normalizationSpan.Length) > normalizedUtf16Span.Length) 302Debug.Assert(normalizationSpan.Length >= (byteCount << 1)); 345BestPathNode[] bestPathEndsAt = ArrayPool<BestPathNode>.Shared.Rent(normalizationSpan.Length + 1); 355int endsAt = normalizationSpan.Length; 478Debug.Assert(bestPathEndsAt.Length >= size + 1); 785BestPathNode[] bestPathEndsAt = ArrayPool<BestPathNode>.Shared.Rent(normalizationSpan.Length + 1); 791int endsAt = normalizationSpan.Length; 1116BestPathNode[] bestPathEndsAt = ArrayPool<BestPathNode>.Shared.Rent(normalizationSpan.Length + 1); 1126int endsAt = normalizationSpan.Length; 1367BestPathNode[] bestPathEndsAt = ArrayPool<BestPathNode>.Shared.Rent(normalizationSpan.Length + 1); 1372int endsAt = normalizationSpan.Length;
Model\TiktokenTokenizer.cs (10)
328Debug.Assert(encodedLength < indexMappingSpan.Length); 445Debug.Assert(encodedLength < indexMappingSpan.Length); 610Debug.Assert(encodedLength < indexMappingSpan.Length); 736Debug.Assert(encodedLength < indexMappingSpan.Length); 819if ((uint)utf8ByteCount + (uint)tokenBytes.Length > (uint)utf8Bytes.Length) 841byte[] tmp = ArrayPool<byte>.Shared.Rent(Math.Max(utf8Bytes.Length * 2, requiredCapacity)); 893if (utf8BytesIncompleteCount + tokenBytes.Length > utf8Bytes.Length) 899if (Encoding.UTF8.GetMaxCharCount(utf8BytesIncompleteCount + tokenBytes.Length) > tempBuffer.Length) 917if (incompleteCharsWritten > buffer.Length) 950if (charsConsumed > buffer.Length)
Model\WordPieceTokenizer.cs (3)
755if (token.Length - ContinuingSubwordPrefix.Length > buffer.Length) 767if (token.Length + 1 > buffer.Length) 779if (token.Length > buffer.Length)
Normalizer\BertNormalizer.cs (2)
163if (index + chars.Length >= buffer.Length) 169index += chars.Length;
Normalizer\SentencePieceNormalizer.cs (8)
134if (span.Length < spanLength) 226Debug.Assert(bufferIndex < span.Length - 1); 259Debug.Assert(bufferIndex < span.Length); 403if (normalized.Length <= normalizedIndex + _spaceSymbol.Length) 415if (normalized.Length <= normalizedIndex + 1) 443int length = normalizedIndex - space.Length; 467if (normalized.Length <= normalizedIndex + _spaceSymbol.Length) 476if (normalized.Length <= normalizedIndex + 1)
Utils\BytePairEncoder.cs (7)
30for (int i = 0; i < byteIndicesAndRanks.Length; i++) 37if (startIndex + skip + 2 < byteIndicesAndRanks.Length) 49for (int i = 0; i < byteIndicesAndRanks.Length - 2; i++) 58while (byteIndicesAndRanks.Length > 1) 61for (int i = 0; i < byteIndicesAndRanks.Length - 1; i++) 79byteIndicesAndRanks = byteIndicesAndRanks.Slice(0, byteIndicesAndRanks.Length - 1); 87var result = new (int Id, int TokenIndex, int TokenLength)[byteIndicesAndRanks.Length - 1];
Utils\DoubleArrayTrie.cs (2)
747if (encodingLength > bytes.Length) 1086if (numResults < results.Length)
Utils\Helpers.cs (9)
32Debug.Assert(span.Length <= newSize); 70Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length); 71Debug.Assert(indexMapping.Length >= destination.Length); 124Debug.Assert(destination.Length >= 4); 162Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length); 163Debug.Assert(indexMapping.Length >= destination.Length); 237Debug.Assert(utf16Chars.Length >= GetUtf16LengthFromUtf8Bytes(utf8Bytes));
Utils\OrdinalUtf8StringComparer.cs (2)
61if (requiredLength1 > buffer1.Length) 67if (requiredLength2 > buffer2.Length)
Utils\ValueStringBuilder.cs (16)
41Debug.Assert(value <= _chars.Length); 46public int Capacity => _chars.Length; 54if ((uint)capacity > (uint)_chars.Length) 231if (_pos > _chars.Length - count) 251if (_pos > (_chars.Length - count)) 271if ((uint)pos < (uint)chars.Length) 291if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 305if (pos > _chars.Length - s.Length) 320if (_pos > _chars.Length - count) 326for (int i = 0; i < dst.Length; i++) 336if (pos > _chars.Length - length) 342for (int i = 0; i < dst.Length; i++) 352if (pos > _chars.Length - value.Length) 365if (origPos > _chars.Length - length) 395Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 401Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
Microsoft.ML.Tokenizers.Tests (27)
BertTokenizerTests.cs (4)
401Assert.Equal(ids1Span.Length, written); 424Assert.Equal(ids1Span.Length, written); 441Assert.Equal(ids1Span.Length, written); 594Assert.Equal(ids1Span.Length, written);
LlamaTests.cs (3)
904if (sp.Length > 0 && sp[sp.Length - 1] == ' ') 906sp = sp.Slice(0, sp.Length - 1);
src\Microsoft.ML.Tokenizers\Utils\DoubleArrayTrie.cs (2)
747if (encodingLength > bytes.Length) 1086if (numResults < results.Length)
src\Microsoft.ML.Tokenizers\Utils\Helpers.cs (9)
32Debug.Assert(span.Length <= newSize); 70Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length); 71Debug.Assert(indexMapping.Length >= destination.Length); 124Debug.Assert(destination.Length >= 4); 162Debug.Assert(Encoding.UTF8.GetMaxByteCount(text.Length) <= destination.Length); 163Debug.Assert(indexMapping.Length >= destination.Length); 237Debug.Assert(utf16Chars.Length >= GetUtf16LengthFromUtf8Bytes(utf8Bytes));
src\Microsoft.ML.Tokenizers\Utils\Helpers.netstandard.cs (6)
76return Encoding.UTF8.GetBytes(sourcePtr, source.Length, destPtr, destination.Length); 85if (Encoding.UTF8.GetByteCount(sourcePtr, source.Length) <= destination.Length) 87bytesWritten = Encoding.UTF8.GetBytes(sourcePtr, source.Length, destPtr, destination.Length); 109return Encoding.UTF8.GetChars(bytesPtr, bytes.Length, charsPtr, chars.Length); 115for (int i = 0; i < span.Length; i++) 122Debug.Assert(source.Length <= destination.Length);
src\Microsoft.ML.Tokenizers\Utils\OrdinalUtf8StringComparer.cs (2)
61if (requiredLength1 > buffer1.Length) 67if (requiredLength2 > buffer2.Length)
TokenizerTests.cs (1)
86if (pos >= destination.Length)
Microsoft.ML.Transforms (6)
Dracula\CMCountTable.cs (1)
147Contracts.Assert(counts.Length == LabelCardinality);
Dracula\DictCountTable.cs (1)
118Contracts.Check(counts.Length == LabelCardinality);
Dracula\Featurizer.cs (4)
140_host.Assert(features.Length == NumFeatures); 173_host.Assert(_labelBinCount == counts.Length); 194_host.Assert(counts.Length == _labelBinCount); 195_host.Assert(logOdds.Length == _logOddsCount);
Microsoft.Net.Http.Headers (2)
HeaderUtilities.cs (2)
629var spanLength = span.Length; 699span[span.Length - 1] = span[0] = '\"';
MSBuild (3)
FileUtilities.cs (3)
643for (int i = 0; i < str.Length; i++) 660int endId = path.Length - 1; 664bool hasQuotes = path.Length > 2
PresentationCore (8)
System\Windows\Input\TextCompositionManager.cs (2)
407ptrMultiByte, multiByte.Length, ptrOutputChars, outputChars.Length); 857Debug.Assert(destination.Length == 2, "Invalid buffer length");
System\Windows\Media\ColorTransform.cs (6)
101for (int i = 0; i < dstValue.Length; i++) 132if (srcValue.Length < 3 || srcValue.Length > 8) 137if (srcValue.Length <= 4) 141for (int i = 0; i < srcValue.Length; i++) 163for (int i = 0; i < srcValue.Length; i++)
PresentationCore.Tests (6)
System\Windows\Media\Imaging\WriteableBitmap.Tests.cs (6)
101smallRect.Length, tileSize * channels, 0, 0); 105smallRect.Length, tileSize * channels, width - tileSize, 0); 109smallRect.Length, tileSize * channels, (width - tileSize) / 2, (height - tileSize) / 2); 113smallRect.Length, tileSize * channels, 0, height - tileSize); 117smallRect.Length, tileSize * channels, width - tileSize, height - tileSize); 166bigRect.Length * channels, width * channels, 0, 0);
PresentationFramework (3)
MS\Internal\PtsHost\ListMarkerSourceInfo.cs (2)
191result[result.Length - 1] = NumberSuffix; 192for (int i = result.Length - 2; i >= 0; --i)
System\Windows\Documents\FixedSOMTextRun.cs (1)
156for (int i = 0; i < destination.Length; i++)
ReachFramework (1)
Serialization\XpsFontSubsetter.cs (1)
683for (int i = 0; i < guidByteArray.Length; i++)
Shared (2)
ServerSentEvents\Helpers.cs (2)
53Debug.Assert(value.Length <= buffer.Length); 67Debug.Assert(maxByteCount <= buffer.Length);
System.Collections (2)
src\libraries\Common\src\System\Collections\Generic\BitHelper.cs (1)
30if (bitArrayIndex < (uint)span.Length)
System\Collections\BitArray.cs (1)
801Debug.Assert(span.Length > 0);
System.Collections.Immutable (14)
System\Collections\Frozen\FrozenDictionary.cs (1)
384if (destination.Length < Count)
System\Collections\Frozen\FrozenHashTable.cs (6)
59int[] arrayPoolBuckets = ArrayPool<int>.Shared.Rent(numBuckets + hashCodes.Length); 61Span<int> nexts = arrayPoolBuckets.AsSpan(numBuckets, hashCodes.Length); 68for (int index = 0; index < hashCodes.Length; index++) 71int bucketNum = (int)HashHelpers.FastMod((uint)hashCode, (uint)bucketStarts.Length, fastModMultiplier); 84var hashtableHashcodes = new int[hashCodes.Length]; 85var hashtableBuckets = new Bucket[bucketStarts.Length];
System\Collections\Frozen\Int32\Int32FrozenDictionary.cs (1)
40for (int srcIndex = 0; srcIndex < hashCodes.Length; srcIndex++)
System\Collections\Frozen\ItemsFrozenSet.cs (1)
35for (int srcIndex = 0; srcIndex < hashCodes.Length; srcIndex++)
System\Collections\Frozen\KeysAndValuesFrozenDictionary.cs (1)
37for (int srcIndex = 0; srcIndex < hashCodes.Length; srcIndex++)
System\Collections\Frozen\String\OrdinalStringFrozenDictionary.cs (1)
52for (int srcIndex = 0; srcIndex < hashCodes.Length; srcIndex++)
System\Collections\Frozen\String\OrdinalStringFrozenSet.cs (1)
43for (int srcIndex = 0; srcIndex < hashCodes.Length; srcIndex++)
System\Collections\Immutable\ImmutableArray_1.Builder.cs (1)
1018Requires.Range(this.Count <= destination.Length, nameof(destination));
System\Collections\Immutable\ImmutableArray_1.cs (1)
916Requires.Range(self.Length <= destination.Length, nameof(destination));
System.Collections.Specialized (2)
System\Collections\Specialized\BitVector32.cs (2)
166dst[dst.Length - 1] = '}'; 170for (int i = 0; i < dst.Length; i++)
System.Console (22)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\ConsolePal.Unix.cs (6)
513Debug.Assert(readBytesPos > 0 && readBytesPos <= readBytes.Length); 570if (dstPos == dst.Length) 572var tmpReadBytes = new byte[dst.Length * 2]; 605Debug.Assert(foundByteDstPos < foundByteDst.Length, "Should only be called when there's room for at least one byte."); 942int result = Interop.CheckIo(Interop.Sys.Read(fd, bufPtr, buffer.Length)); 943Debug.Assert(result <= buffer.Length);
System\IO\CachedConsoleStream.cs (1)
65if (lastNewLine + 1 < charBuffer.Length)
System\IO\StdInReader.cs (1)
77if (spaceRemaining < chars.Length)
System.Data.Common (8)
System\Data\SQLTypes\SQLBytes.cs (1)
326int count = Math.Min(buffer.Length, (int)(Length - offset));
System\Data\SQLTypes\SQLDecimal.cs (7)
1165ArgumentOutOfRangeException.ThrowIfLessThan(destination.Length, 4, nameof(destination)); 1859Debug.Assert(rgulData.Length == s_cNumeMax, "rgulData.Length == x_cNumeMax", "Invalid array length"); 1933Debug.Assert(rglData.Length == 4, "rglData.Length == 4", $"Wrong array length: {rglData.Length}"); 2465Debug.Assert(rgulD.Length >= ciulS, "rgulD.Length >= ciulS", "Invalid array length"); 2537Debug.Assert(rgulU.Length == s_cNumeMax); 2606Debug.Assert(rgulD.Length == s_cNumeMax);
System.Diagnostics.DiagnosticSource (25)
src\libraries\Common\src\System\Diagnostics\DiagnosticsHelper.cs (1)
127_maxIndex = bitMap.Length * sizeof(ulong) * 8;
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Diagnostics\Activity.cs (5)
2008Debug.Assert(outBytes.Length == 16 || outBytes.Length == 8); 2013if (outBytes.Length == 16) 2025Debug.Assert(outBytes.Length * 2 == charData.Length); 2026for (int i = 0; i < outBytes.Length; i++)
System\Diagnostics\Metrics\AggregatorStore.cs (1)
502KeyValuePair<string, string>[] labels = new KeyValuePair<string, string>[indexedNames.Length];
System\Diagnostics\Metrics\TagList.netcore.cs (1)
143if (tags.Length < _tagsCount)
System.Diagnostics.FileVersionInfo (5)
System\Diagnostics\FileVersionInfo.Unix.cs (5)
207if (parts.Length <= 4 && parts.Length > 0) 210if (!endedEarly && parts.Length > 1) 213if (!endedEarly && parts.Length > 2) 216if (!endedEarly && parts.Length > 3)
System.Diagnostics.Process (25)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.GetGroupList.cs (2)
23int ngroups = groups.Length; 33else if (rv == -1 && ngroups > groups.Length)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.IsMemberOfGroup.cs (2)
30rv = Interop.Sys.GetGroups(groups.Length, pGroups); 41groups = new uint[groups.Length * 2];
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadLink.cs (3)
46int resultLength = ReadLink(ref pathReference, ref MemoryMarshal.GetReference(spanBuffer), spanBuffer.Length); 54else if (resultLength < spanBuffer.Length) 74arrayBuffer = ArrayPool<byte>.Shared.Rent(spanBuffer.Length * 2);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (1)
27if (_bytes.Length < maxSize)
System\Diagnostics\Process.Linux.cs (3)
282if (bytesRead == buffer.Length) 284uint newLength = (uint)buffer.Length * 2; 296Debug.Assert(bytesRead < buffer.Length);
System.Diagnostics.TextWriterTraceListener (1)
System\Diagnostics\XmlWriterTraceListener.cs (1)
411Debug.Assert(charsWritten == span.Length);
System.Formats.Asn1 (17)
System\Formats\Asn1\Asn1Tag.cs (3)
301/// <see langword="false"/> if <paramref name="destination"/>.<see cref="Span{T}.Length"/> &lt; 308if (destination.Length < spaceRequired) 360/// <paramref name="destination"/>.<see cref="Span{T}.Length"/> &lt; <see cref="CalculateEncodedSize"/>.
System\Formats\Asn1\AsnCharacterStringEncodings.cs (1)
71return encoding.GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length);
System\Formats\Asn1\AsnDecoder.BitString.cs (2)
189if (value.Length > destination.Length) 609if (dest.Length < contentLength)
System\Formats\Asn1\AsnDecoder.NamedBitList.cs (1)
395for (int byteIdx = 0; byteIdx < value.Length; byteIdx++)
System\Formats\Asn1\AsnDecoder.OctetString.cs (5)
86if (contents.Length > destination.Length) 464if (dest.Length < contentLength) 506if (tmpSpace.Length > 0 && tooBig > tmpSpace.Length) 512if (tooBig > tmpSpace.Length)
System\Formats\Asn1\AsnDecoder.Oid.cs (2)
199Debug.Assert(writeSpan.Length >= SemanticByteCount); 212int bytesWritten = tmpBytes.Length - writeSpan.Length;
System\Formats\Asn1\AsnDecoder.Text.cs (1)
354if (contents.Length > destination.Length)
System\Formats\Asn1\AsnWriter.cs (1)
144if (destination.Length < _offset)
System\Formats\Asn1\AsnWriter.Oid.cs (1)
190Debug.Assert(dest.Length > 0);
System.Formats.Cbor (6)
System\Formats\Cbor\Reader\CborReader.String.cs (4)
80if (length > destination.Length) 241if (charLength > destination.Length) 355if (concatenatedBufferSize > destination.Length) 424if (concatenatedStringSize > destination.Length)
System\Formats\Cbor\Writer\CborWriter.cs (2)
192if (encoding.Length > destination.Length) 210if (encoding.Length > destination.Length)
System.Formats.Nrbf (1)
System\Formats\Nrbf\ArraySinglePrimitiveRecord.cs (1)
134int sliceSize = Math.Min(valuesToRead.Length, MaxChunkLength);
System.Formats.Tar (29)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Formats\Tar\SeekableSubReadStream.cs (2)
49int origCount = destination.Length; 50int count = destination.Length;
System\Formats\Tar\SubReadStream.cs (2)
111int origCount = destination.Length; 112int count = destination.Length;
System\Formats\Tar\TarHeader.Write.cs (11)
907if (span.Length < length) 1047int i = destination.Length - 3; 1048int j = converted.Length - 2; // Skip the null terminator in 'converted' 1070Debug.Assert(destination.Length > 1); 1073int numToCopy = Math.Min(bytesToWrite.Length, destination.Length); 1084Debug.Assert(destination.Length > 1); 1090int numToCopy = Math.Min(bytesToWrite.Length, destination.Length - 1); 1092int copyPos = destination.Length - 1 - bytesToWrite.Length; 1112Debug.Assert(destination.Length == 8, "8 byte field expected."); 1137Debug.Assert(destination.Length == 12, "12 byte field expected."); 1166int i = digits.Length - 1;
System.IO.Compression (30)
System\IO\Compression\DeflateManaged\DeflateManagedStream.cs (3)
105int initialLength = buffer.Length; 113if (buffer.Length == 0) 140return initialLength - buffer.Length;
System\IO\Compression\DeflateManaged\InflaterManaged.cs (1)
115bytes = bytes.Slice(0, (int)Math.Min(bytes.Length, _uncompressedSize - _currentInflatedCount));
System\IO\Compression\DeflateManaged\OutputWindow.cs (6)
125if (output.Length > _bytesUsed) 133copy_end = (_end - _bytesUsed + output.Length) & WindowMask; // copy length of bytes 136int copied = output.Length; 138int tailLen = output.Length - copy_end; 146_window.AsSpan(copy_end - output.Length, output.Length).CopyTo(output);
System\IO\Compression\DeflateZLib\Inflater.cs (2)
78if (destination.Length == 0) 83return InflateVerified(bufPtr, destination.Length);
System\IO\Compression\ZipBlocks.cs (7)
440int bytesRead = stream.ReadAtLeast(blockContents, blockContents.Length, throwOnEndOfStream: false); 519int bytesRead = stream.ReadAtLeast(blockContents, blockContents.Length, throwOnEndOfStream: false); 633Debug.Assert(blockBytes.Length == FieldLengths.FilenameLength + FieldLengths.ExtraFieldLength); 665int bytesRead = stream.ReadAtLeast(blockBytes, blockBytes.Length, throwOnEndOfStream: false); 670bytesRead = stream.ReadAtLeast(blockBytes, blockBytes.Length, throwOnEndOfStream: false); 822Debug.Assert(bytesToRead == collatedHeader[remainingBufferLength..].Length); 962int bytesRead = stream.ReadAtLeast(blockContents, blockContents.Length, throwOnEndOfStream: false);
System\IO\Compression\ZipCustomStreams.cs (2)
309int origCount = destination.Length; 310int count = destination.Length;
System\IO\Compression\ZipHelper.cs (9)
133outOfBytes = bytesRead < bufferSpan.Length; 134if (bytesRead < bufferSpan.Length) 140Debug.Assert(bufferPointer < bufferSpan.Length); 142totalBytesRead += (bufferSpan.Length - duplicateBytesRead); 177if (stream.Position >= buffer.Length) 179Debug.Assert(overlap <= buffer.Length); 180stream.Seek(-(buffer.Length - overlap), SeekOrigin.Current); 181bytesRead = ReadBytes(stream, buffer, buffer.Length); 182stream.Seek(-buffer.Length, SeekOrigin.Current);
System.IO.Compression.Brotli (15)
System\IO\Compression\dec\BrotliDecoder.cs (6)
64nuint availableOutput = (nuint)destination.Length; 83Debug.Assert(availableOutput <= (nuint)destination.Length); 86bytesWritten += destination.Length - (int)availableOutput; 97destination = destination.Slice(destination.Length - (int)availableOutput); 119nuint availableOutput = (nuint)destination.Length; 122Debug.Assert(success ? availableOutput <= (nuint)destination.Length : availableOutput == 0);
System\IO\Compression\dec\BrotliStream.Decompress.cs (2)
225(lastResult == OperationStatus.DestinationTooSmall && destination.IsEmpty && _bufferCount == 0), $"{nameof(lastResult)} == {lastResult}, {nameof(destination.Length)} == {destination.Length}");
System\IO\Compression\enc\BrotliEncoder.cs (7)
149nuint availableOutput = (nuint)destination.Length; 167Debug.Assert(availableOutput <= (nuint)destination.Length); 170bytesWritten += destination.Length - (int)availableOutput; 173if ((int)availableOutput == destination.Length && Interop.Brotli.BrotliEncoderHasMoreOutput(_state) == Interop.BOOL.FALSE && availableInput == 0) 179destination = destination.Slice(destination.Length - (int)availableOutput); 217nuint availableOutput = (nuint)destination.Length; 220Debug.Assert(success ? availableOutput <= (nuint)destination.Length : availableOutput == 0);
System.IO.FileSystem.Watcher (14)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System.IO.Hashing (17)
System\IO\Hashing\Crc32.cs (2)
138if (destination.Length < Size) 160if (destination.Length < Size)
System\IO\Hashing\Crc64.cs (2)
136if (destination.Length < Size) 158if (destination.Length < Size)
System\IO\Hashing\NonCryptographicHashAlgorithm.cs (5)
163if (destination.Length < HashLengthInBytes) 188if (destination.Length < HashLengthInBytes) 225if (destination.Length < HashLengthInBytes) 250if (destination.Length < HashLengthInBytes) 284Debug.Assert(destination.Length == HashLengthInBytes);
System\IO\Hashing\XxHash128.cs (1)
104if (destination.Length >= sizeof(ulong) * 2)
System\IO\Hashing\XxHash3.cs (1)
104if (destination.Length >= sizeof(long))
System\IO\Hashing\XxHash32.cs (2)
214if (destination.Length < HashSize) 237if (destination.Length < HashSize)
System\IO\Hashing\XxHash64.cs (2)
214if (destination.Length < HashSize) 237if (destination.Length < HashSize)
System\IO\Hashing\XxHashShared.cs (2)
324Debug.Assert(remaining.Length <= InternalBufferLengthBytes); 327state.BufferedCount = (uint)remaining.Length;
System.IO.Packaging (2)
System\IO\Packaging\InterleavedZipPackagePartStream.cs (2)
93if (buffer.Length == 0) 129while (totalBytesRead < buffer.Length)
System.IO.Pipelines (2)
System\IO\Pipelines\Pipe.cs (1)
1104int writable = Math.Min(destination.Length, source.Length);
System\IO\Pipelines\PipeReaderStream.cs (1)
126int actual = (int)Math.Min(bufferLength, buffer.Length);
System.IO.Pipes (1)
System\IO\Pipes\PipeStream.Unix.cs (1)
261if (buffer.Length == 0)
System.IO.Ports (1)
System\IO\Ports\SerialStream.Unix.cs (1)
785int numBytes = Interop.Serial.Read(_handle, bufPtr, buff.Length);
System.Linq (18)
System\Linq\OrderedEnumerable.SpeedOpt.cs (1)
48for (int i = 0; i < destination.Length; i++)
System\Linq\Range.cs (2)
82ref int end = ref Unsafe.Add(ref pos, destination.Length); 85destination.Length >= Vector<int>.Count)
System\Linq\SegmentedArrayBuilder.cs (6)
107if ((uint)countInCurrentSegment < (uint)currentSegment.Length) 144int availableSpaceInCurrentSpan = _currentSegment.Length - _countInCurrentSegment; 162bool currentSegmentIsScratchBufferWithRemainingSpace = _segmentsCount == 0 && _countInCurrentSegment < _currentSegment.Length; 169int remainingSpaceInCurrentSegment = _currentSegment.Length - _countInCurrentSegment; 219if ((uint)countInCurrentSegment < (uint)currentSegment.Length) 342int currentSegmentLength = _currentSegment.Length;
System\Linq\Select.SpeedOpt.cs (6)
165for (int i = 0; i < destination.Length; i++) 304for (int i = 0; i < results.Length; i++, start++) 417for (int i = 0; i < destination.Length; i++) 535for (int i = 0; i < results.Length; i++) 810Debug.Assert(index == results.Length, "All list elements were not initialized."); 978for (int i = 0; i < destination.Length; i++, sourceIndex++)
System\Linq\SingleLinkedNode.cs (1)
119int index = span.Length;
System\Linq\SkipTake.SpeedOpt.cs (2)
151sourceSpan.Slice(sourceIndex, destination.Length).CopyTo(destination); 155for (int i = 0; i < destination.Length; i++, sourceIndex++)
System.Memory (14)
System\Buffers\BuffersExtensions.cs (4)
68if (span.Length > destination.Length) 80if (sequence.Length > destination.Length) 121if (value.Length <= destination.Length) 137int writeSize = Math.Min(destination.Length, input.Length);
System\Buffers\SequenceReader.cs (6)
417if (firstSpan.Length >= destination.Length) 419firstSpan.Slice(0, destination.Length).CopyTo(destination); 430if (Remaining < destination.Length) 434Debug.Assert(firstSpan.Length < destination.Length); 444int toCopy = Math.Min(nextSpan.Length, destination.Length - copied); 447if (copied >= destination.Length)
System\Text\EncodingExtensions.cs (4)
116int originalBytesLength = bytes.Length; 130return originalBytesLength - bytes.Length; // total number of bytes we wrote 307int originalCharsLength = chars.Length; 321return originalCharsLength - chars.Length; // total number of chars we wrote
System.Memory.Data (5)
src\libraries\Common\src\System\IO\ReadOnlyMemoryStream.cs (5)
108if (remaining <= 0 || buffer.Length == 0) 112else if (remaining <= buffer.Length) 120_content.Span.Slice(_position, buffer.Length).CopyTo(buffer); 121_position += buffer.Length; 122return buffer.Length;
System.Net.Http (111)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\IO\ReadOnlyMemoryStream.cs (5)
108if (remaining <= 0 || buffer.Length == 0) 112else if (remaining <= buffer.Length) 120_content.Span.Slice(_position, buffer.Length).CopyTo(buffer); 121_position += buffer.Length; 122return buffer.Length;
src\libraries\Common\src\System\Net\Http\aspnetcore\Http2\Hpack\HPackEncoder.cs (19)
34if (destination.Length != 0) 90if ((uint)destination.Length >= 2) 122if ((uint)destination.Length >= 2) 154if ((uint)destination.Length >= 2) 192if ((uint)destination.Length != 0) 272if ((uint)destination.Length >= 3) 305if ((uint)destination.Length >= 3) 344if ((uint)destination.Length >= 2) 371if (destination.Length != 0) 379if (value.Length <= destination.Length) 397Debug.Assert(destination.Length >= value.Length); 421if (destination.Length != 0) 429if (value.Length <= destination.Length) 460if (destination.Length != 0) 472if (encodedStringLength <= destination.Length) 503if (destination.Length != 0) 526if (destination.Length != 0) 553if (destination.Length >= valueLength) 639span = new byte[span.Length * 2];
src\libraries\Common\src\System\Net\Http\aspnetcore\Http2\Hpack\Huffman.cs (5)
680Debug.Assert(dst.Length > 0); 712if (j == dst.Length) 714Array.Resize(ref dstArray, dst.Length * 2); 779if (j == dst.Length) 781Array.Resize(ref dstArray, dst.Length * 2);
src\libraries\Common\src\System\Net\Http\aspnetcore\Http2\Hpack\IntegerEncoder.cs (3)
28if (destination.Length == 0) 47if (1 == destination.Length) 60if (i >= destination.Length)
src\libraries\Common\src\System\Net\Http\aspnetcore\Http3\Frames\Http3Frame.cs (1)
45if (buffer.Length != 0)
src\libraries\Common\src\System\Net\Http\aspnetcore\Http3\Helpers\VariableLengthIntegerHelper.cs (1)
154if (buffer.Length != 0)
src\libraries\Common\src\System\Net\Http\aspnetcore\Http3\QPack\QPackEncoder.cs (8)
69if (destination.Length >= 2) 184if (buffer.Length != 0) 195if (buffer.Length >= encodedStringLength) 233if (buffer.Length > 0) 258if (buffer.Length >= valueLength) 303Debug.Assert(buffer.Length >= s.Length); 320if (buffer.Length != 0) 328if (buffer.Length >= s.Length)
src\libraries\Common\src\System\Net\MultiArrayBuffer.cs (1)
387if (destination.Length < _length)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Net\Http\HttpContent.cs (6)
1000Debug.Assert(remainingInCurrentBuffer.Length < buffer.Length); 1001buffer.Slice(0, remainingInCurrentBuffer.Length).CopyTo(remainingInCurrentBuffer); 1002buffer = buffer.Slice(remainingInCurrentBuffer.Length); 1042Debug.Assert(destination.Length >= _totalLength); 1055Debug.Assert(destination.Length >= buffer.Length); 1063Debug.Assert(_lastBufferOffset <= destination.Length);
System\Net\Http\MultipartContent.cs (1)
492if (buffer.Length == 0)
System\Net\Http\SocketsHttpHandler\ChunkedEncodingReadStream.cs (10)
37if (buffer.Length == 0) 64buffer.Length >= _connection.ReadBufferSize && 72Debug.Assert(buffer.Length != 0); 73int bytesRead = _connection.Read(buffer.Slice(0, (int)Math.Min((ulong)buffer.Length, _chunkBytesRemaining))); 86if (buffer.Length == 0) 101if (buffer.Length == 0) 296Debug.Assert(buffer.Length > 0); 298while (buffer.Length > 0) 300if (ReadChunkFromConnectionBuffer(buffer.Length, cancellationRegistration) is not ReadOnlyMemory<byte> bytesRead || bytesRead.Length == 0) 305Debug.Assert(bytesRead.Length <= buffer.Length);
System\Net\Http\SocketsHttpHandler\ConnectionCloseReadStream.cs (1)
28if (bytesRead == 0 && buffer.Length != 0)
System\Net\Http\SocketsHttpHandler\ContentLengthReadStream.cs (2)
32if ((ulong)buffer.Length > _contentBytesRemaining) 38if (bytesRead <= 0 && buffer.Length != 0)
System\Net\Http\SocketsHttpHandler\DecompressionHandler.cs (1)
369if (buffer.Length != 0)
System\Net\Http\SocketsHttpHandler\Http2Connection.cs (2)
1691Debug.Assert(span.Length == 0); 1943Debug.Assert(destination.Length >= Size);
System\Net\Http\SocketsHttpHandler\Http2Stream.cs (2)
1116int bytesRead = Math.Min(buffer.Length, activeBuffer.Length); 1153else if (buffer.Length != 0)
System\Net\Http\SocketsHttpHandler\Http3RequestStream.cs (4)
1170int copyLen = (int)Math.Min(buffer.Length, Math.Min(_responseDataPayloadRemaining, _recvBuffer.ActiveLength)); 1190int copyLen = (int)Math.Min(buffer.Length, _responseDataPayloadRemaining); 1193if (bytesRead == 0 && buffer.Length != 0) 1207while (buffer.Length != 0);
System\Net\Http\SocketsHttpHandler\HttpConnection.cs (21)
1041int length = (uint)carriageReturnIndex < (uint)buffer.Length && buffer[carriageReturnIndex] == '\r' 1050if (_allowedReadLineBytes <= buffer.Length) 1065if (line.Length < MinStatusLineLength || line[8] != ' ') 1101if (line.Length == MinStatusLineLength) 1137int bytesScanned = finished ? bytesConsumed : buffer.Length; 1152int originalBufferLength = buffer.Length; 1159return (finished: false, bytesConsumed: originalBufferLength - buffer.Length); 1166return (finished: true, bytesConsumed: originalBufferLength - buffer.Length + colIdx + 1); 1173if ((uint)valueStartIdx >= (uint)buffer.Length) 1175return (finished: false, bytesConsumed: originalBufferLength - buffer.Length); 1185if ((uint)lfIdx >= (uint)valueIterator.Length) 1187return (finished: false, bytesConsumed: originalBufferLength - buffer.Length); 1191int crOrLfIdx = (uint)crIdx < (uint)valueIterator.Length && valueIterator[crIdx] == '\r' 1196if ((uint)spIdx >= (uint)valueIterator.Length) 1198return (finished: false, bytesConsumed: originalBufferLength - buffer.Length); 1208ReadOnlySpan<byte> headerValue = buffer.Slice(valueStartIdx, buffer.Length - valueIterator.Length + crOrLfIdx - valueStartIdx); 1212buffer = buffer.Slice(buffer.Length - valueIterator.Length + spIdx); 1749int toCopy = Math.Min(available.Length, buffer.Length); 1810if (destination.Length == 0)
System\Net\Http\SocketsHttpHandler\RawConnectionStream.cs (1)
34if (bytesRead == 0 && buffer.Length != 0)
System.Net.HttpListener (5)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Net\WebHeaderEncoding.cs (1)
32int byteCount = buffer.Length;
System\Net\HttpListener.cs (1)
206toLowerLength = destination.Length;
System.Net.Mail (26)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Net\Base64Stream.cs (1)
88byte* end = start + buffer.Length;
System\Net\BufferedReadStream.cs (2)
36int read = Math.Min(buffer.Length, _storedLength - _storedOffset); 39if (read == buffer.Length || !_readMore)
System\Net\Mail\SmtpNegotiateAuthenticationModule.cs (1)
150if (unwrappedChallenge.Length != 4 || (unwrappedChallenge[0] & 1) != 1)
System\Net\Mail\SmtpReplyReaderFactory.cs (1)
270if (buffer.Length == 0 || _currentReader != caller || _readState == ReadState.Done)
System\Net\Mime\QEncodedStream.cs (2)
72byte* end = start + buffer.Length; 85if (buffer.Length == 1)
System\Net\Mime\QuotedPrintableStream.cs (2)
101byte* end = start + buffer.Length; 114if (buffer.Length == 1)
System.Net.NameResolution (7)
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (7)
81err = Interop.Sys.SetAddressFamily(rawAddress, buffer.Length, (int)family); 106err = Interop.Sys.SetPort(rawAddress, buffer.Length, port); 132err = Interop.Sys.GetIPv6Address(rawAddress, buffer.Length, ipAddress, address.Length, &localScope); 144err = Interop.Sys.SetIPv4Address(rawAddress, buffer.Length, address); 161SetIPv6Address(buffer, rawInput, address.Length, scope); 170err = Interop.Sys.SetIPv6Address(rawAddress, buffer.Length, address, addressLength, scope); 181buffer[0] = (byte)Math.Min(buffer.Length, 255);
System.Net.NetworkInformation (4)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
System\Net\NetworkInformation\UnicastIPAddressInformation.cs (1)
80Debug.Assert(prefixLength <= (addressBytes.Length * 8));
System.Net.Ping (9)
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (7)
81err = Interop.Sys.SetAddressFamily(rawAddress, buffer.Length, (int)family); 106err = Interop.Sys.SetPort(rawAddress, buffer.Length, port); 132err = Interop.Sys.GetIPv6Address(rawAddress, buffer.Length, ipAddress, address.Length, &localScope); 144err = Interop.Sys.SetIPv4Address(rawAddress, buffer.Length, address); 161SetIPv6Address(buffer, rawInput, address.Length, scope); 170err = Interop.Sys.SetIPv6Address(rawAddress, buffer.Length, address, addressLength, scope); 181buffer[0] = (byte)Math.Min(buffer.Length, 255);
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (1)
27if (_bytes.Length < maxSize)
System\Net\NetworkInformation\Ping.RawSocket.cs (1)
311header.SocketAddressLen = socketAddress.Length;
System.Net.Primitives (18)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Net\IPv4AddressHelper.Common.cs (1)
41for (int i = 0; i < numbers.Length; ++i)
src\libraries\Common\src\System\Net\NetworkInformation\InterfaceInfoPal.Unix.cs (1)
62buffer[buffer.Length - 1] = 0;
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (7)
81err = Interop.Sys.SetAddressFamily(rawAddress, buffer.Length, (int)family); 106err = Interop.Sys.SetPort(rawAddress, buffer.Length, port); 132err = Interop.Sys.GetIPv6Address(rawAddress, buffer.Length, ipAddress, address.Length, &localScope); 144err = Interop.Sys.SetIPv4Address(rawAddress, buffer.Length, address); 161SetIPv6Address(buffer, rawInput, address.Length, scope); 170err = Interop.Sys.SetIPv6Address(rawAddress, buffer.Length, address, addressLength, scope); 181buffer[0] = (byte)Math.Min(buffer.Length, 255);
System\Net\IPAddress.cs (5)
327if (destination.Length < IPAddressParserStatics.IPv6AddressBytes) 338if (destination.Length < IPAddressParserStatics.IPv4AddressBytes) 500if (destination.Length >= IPAddressParser.MaxIPv4StringLength) 508if (destination.Length >= IPAddressParser.MaxIPv6StringLength) 516Debug.Assert(tmpDestination.Length >= IPAddressParser.MaxIPv4StringLength);
System\Net\IPAddressParser.cs (1)
234pos += used.Length;
System.Net.Quic (22)
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.BIO.cs (2)
29return BioGets(b, pBuf, buf.Length); 38internal static int BioRead(SafeBioHandle b, Span<byte> data) => BioRead(b, data, data.Length);
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Net\IPv4AddressHelper.Common.cs (1)
41for (int i = 0; i < numbers.Length; ++i)
src\libraries\Common\src\System\Net\MultiArrayBuffer.cs (1)
387if (destination.Length < _length)
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (7)
81err = Interop.Sys.SetAddressFamily(rawAddress, buffer.Length, (int)family); 106err = Interop.Sys.SetPort(rawAddress, buffer.Length, port); 132err = Interop.Sys.GetIPv6Address(rawAddress, buffer.Length, ipAddress, address.Length, &localScope); 144err = Interop.Sys.SetIPv4Address(rawAddress, buffer.Length, address); 161SetIPv6Address(buffer, rawInput, address.Length, scope); 170err = Interop.Sys.SetIPv6Address(rawAddress, buffer.Length, address, addressLength, scope); 181buffer[0] = (byte)Math.Min(buffer.Length, 255);
src\libraries\Common\src\System\Net\StreamBuffer.cs (1)
205int bytesRead = Math.Min(buffer.Length, _buffer.ActiveMemory.Length);
System\Net\Quic\Internal\ReceiveBuffers.cs (4)
56if (totalLength < quicBuffer.Length) 61_buffer.Commit(quicBuffer.Length); 62totalCopied += quicBuffer.Length; 63totalLength -= quicBuffer.Length;
System\Net\Quic\QuicConnection.SslConnectionOptions.cs (1)
206if (chainData.Length > 0)
System\Net\Quic\QuicStream.Stream.cs (2)
118byte[] rentedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 126int readLength = ReadAsync(new Memory<byte>(rentedBuffer, 0, buffer.Length), cts?.Token ?? default).AsTask().GetAwaiter().GetResult();
System.Net.Requests (1)
System\Net\HttpWebResponse.cs (1)
403int readBytes = innerStream.Read(buffer.Slice(0, (int)Math.Min(buffer.Length, _maxRemainingLength)));
System.Net.Security (25)
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.BIO.cs (2)
29return BioGets(b, pBuf, buf.Length); 38internal static int BioRead(SafeBioHandle b, Span<byte> data) => BioRead(b, data, data.Length);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.OpenSsl.cs (4)
259Ssl.SslCtxSetCaching(sslCtx, 1, cacheSize, contextId.Length, contextId, null, null); 655int retVal = Ssl.SslRead(context, ref MemoryMarshal.GetReference(buffer), buffer.Length, out errorCode); 753while (clientList.Length > 0) 856Debug.Assert(buffer.Length >= count);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.Ssl.cs (3)
231Debug.Assert(GetAlpnProtocolListSerializedLength(applicationProtocols) == buffer.Length, 255return SslSetAlpnProtos(ssl, pBuffer, serializedProtocols.Length); 271return SslAddClientCAs(ssl, pHandles, x509handles.Length);
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Net\IPv4AddressHelper.Common.cs (1)
41for (int i = 0; i < numbers.Length; ++i)
src\libraries\Common\src\System\Net\Security\MD4.cs (3)
65Debug.Assert(destination.Length == 128 >> 3); 175for (int i = 0, j = 0; j < output.Length; i++, j += 4) 183for (int i = 0, j = 0; i < output.Length; i++, j += 4)
src\libraries\Common\src\System\Net\Security\RC4.cs (1)
78Debug.Assert(input.Length == output.Length);
System\Net\NegotiateAuthenticationPal.ManagedNtlm.cs (6)
298Debug.Assert(asBytes.Length == sizeof(NegotiateMessage)); 401Debug.Assert(clientChallenge.Length == ChallengeLength); 424SetField(ref field, blob.Length, payloadOffset); 426payloadOffset += blob.Length; 811unwrappedLength = input.Length - SignatureLength; 818if (input.Length < SignatureLength)
System\Net\Security\SslStream.cs (1)
785PoolingPointerMemoryManager memoryManager = RentPointerMemoryManager(ref _readPointerMemoryManager, ptr, buffer.Length);
System\Net\Security\SslStream.Protocol.cs (1)
212Debug.Assert(ret && written == certHash.Length);
System.Net.ServerSentEvents (3)
System\Net\ServerSentEvents\Helpers.cs (3)
18Debug.Assert(MaxDecimalDigits <= buffer.Length); 36Debug.Assert(value.Length <= buffer.Length); 50Debug.Assert(maxByteCount <= buffer.Length);
System.Net.Sockets (38)
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (7)
81err = Interop.Sys.SetAddressFamily(rawAddress, buffer.Length, (int)family); 106err = Interop.Sys.SetPort(rawAddress, buffer.Length, port); 132err = Interop.Sys.GetIPv6Address(rawAddress, buffer.Length, ipAddress, address.Length, &localScope); 144err = Interop.Sys.SetIPv4Address(rawAddress, buffer.Length, address); 161SetIPv6Address(buffer, rawInput, address.Length, scope); 170err = Interop.Sys.SetIPv6Address(rawAddress, buffer.Length, address, addressLength, scope); 181buffer[0] = (byte)Math.Min(buffer.Length, 255);
System\Net\Sockets\SafeSocketHandle.Unix.OptionTracking.cs (2)
34Debug.Assert(values.Length == TrackableOptionCount); 64for (int i = 0; i < values.Length; i++)
System\Net\Sockets\Socket.cs (6)
142int bufferLength = buffer.Length; 151Debug.Assert(bufferLength <= buffer.Length); 185bufferLength = buffer.Length; 310int size = buffer.Length; 358int size = buffer.Length; 2291int realOptionLength = optionValue.Length;
System\Net\Sockets\SocketAsyncContext.Unix.cs (2)
1657Length = buffer.Length, 1877Length = buffer.Length,
System\Net\Sockets\SocketPal.Unix.cs (21)
113received = Interop.Sys.Read(handle, b, buffer.Length); 131buffer.Length, 155Count = (UIntPtr)buffer.Length 158Debug.Assert(socketAddress.Length != 0 || sockAddr == null); 162SocketAddressLen = socketAddress.Length, 414int sockAddrLen = socketAddress.Length; 498Count = (UIntPtr)buffer.Length 501Debug.Assert(socketAddress.Length != 0 || rawSocketAddress == null); 505SocketAddressLen = socketAddress.Length, 531socketAddressLen = socketAddress.Length; 580SocketAddressLen = socketAddress.Length, 603socketAddressLen = socketAddress.Length; 685if (data.Length > 0) 688err = Interop.Sys.Connectx(socket, rawSocketAddress, socketAddress.Length, data, data.Length, tfo ? 1 : 0, &sentBytes); 785else if (buffer.Length == 0) 853else if (buffer.Length == 0) 1686Debug.Assert((uint)optionLength <= optionValue.Length); 1851Interop.Error err = Interop.Sys.Select(readFDs, readFDs.Length, writeFDs, writeFDs.Length, errorFDs, errorFDs.Length, microseconds, maxFd, out triggered); 1894Debug.Assert(buffer.Length == socketList.Count);
System.Net.WebClient (3)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
System.Net.WebSockets (16)
System\Net\WebSockets\Compression\WebSocketDeflater.cs (7)
95Debug.Assert(written == output.Length); 133_stream.AvailOut = (uint)output.Length; 141written = output.Length - (int)_stream.AvailOut; 149|| written == output.Length; 157Debug.Assert(output.Length > 0); 165_stream.AvailOut = (uint)output.Length; 188return output.Length - (int)_stream.AvailOut;
System\Net\WebSockets\Compression\WebSocketInflater.cs (7)
130if (_available > 0 && output.Length > 0) 171if (output.Length == written) 181if (output.Length > written) 188if (written < output.Length || IsFinished(_stream, out _remainingByte)) 230Debug.Assert(destination.Length > 0); 236stream.AvailOut = (uint)destination.Length; 242return destination.Length - (int)stream.AvailOut;
System\Net\WebSockets\ManagedWebSocket.cs (2)
924int limit = (int)Math.Min(header.Compressed ? _inflater!.Span.Length : payloadBuffer.Length, header.PayloadLength); 1674byte* toMaskEnd = toMaskBeg + toMask.Length;
System.Numerics.Tensors (81)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IBinaryOperator.cs (2)
66if (x.Length > destination.Length) 1400if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IBooleanUnaryOperator.cs (1)
205if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IStatefulUnaryOperator.cs (1)
34if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.ITernaryOperator.cs (3)
49if (x.Length > destination.Length) 1526if (x.Length > destination.Length) 3014if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryInputBinaryOutput.cs (6)
52if (x.Length > destination1.Length) 57if (x.Length > destination2.Length) 184if (x.Length > destination1.Length) 189if (x.Length > destination2.Length) 368if (x.Length > destination1.Length) 373if (x.Length > destination2.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryOneToFourOperator.cs (1)
35if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryOneToTwoOperator.cs (1)
35if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryOperator.cs (1)
70if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IUnaryTwoToOneOperator.cs (1)
35if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\Tensor.cs (9)
465for (int i = 0; i < span.Length; i++) 487for (int i = 0; i < span.Length; i++) 1673span.Slice(0, ospan.Length).CopyTo(ospan); 1710if (ospan.Length >= span.Length) 1713span.Slice(0, ospan.Length).CopyTo(ospan); 1776for (int i = 0; i < srcIndexes.Length; i++) 2148for (int i = 0; i < strideOrder.Length; i++) 2150for (int j = removed.Length - 1; j >= 0; j--) 2162for (int i = 0; i < strideOrder.Length; i++)
System\Numerics\Tensors\netcore\TensorOperation.cs (33)
162for (nint i = 0; i < destination.Length; i++) 423for (int i = 0; i < destination.Length; i++) 431for (int i = 0; i < destination.Length; i++) 460Debug.Assert(destination.Length == 1); 463for (int i = 0; i < destination.Length; i++) 478Debug.Assert(destination.Length == 1); 481for (int i = 0; i < destination.Length; i++) 654for (int i = 0; i < destination.Length; i++) 683for (int i = 0; i < destination.Length; i++) 2219for (int i = 0; i < destination.Length; i++) 2227for (int i = 0; i < destination.Length; i++) 2256Debug.Assert(destination.Length == 1); 2259for (int i = 0; i < destination.Length; i++) 2274Debug.Assert(destination.Length == 1); 2277for (int i = 0; i < destination.Length; i++) 2308for (int i = 0; i < destination.Length; i++) 2316for (int i = 0; i < destination.Length; i++) 2345Debug.Assert(destination.Length == 1); 2348for (int i = 0; i < destination.Length; i++) 2363Debug.Assert(destination.Length == 1); 2366for (int i = 0; i < destination.Length; i++) 2397for (int i = 0; i < destination.Length; i++) 2405for (int i = 0; i < destination.Length; i++) 2434Debug.Assert(destination.Length == 1); 2437for (int i = 0; i < destination.Length; i++) 2452Debug.Assert(destination.Length == 1); 2455for (int i = 0; i < destination.Length; i++) 2486for (int i = 0; i < destination.Length; i++) 2494for (int i = 0; i < destination.Length; i++) 2523Debug.Assert(destination.Length == 1); 2526for (int i = 0; i < destination.Length; i++) 2541Debug.Assert(destination.Length == 1); 2544for (int i = 0; i < destination.Length; i++)
System\Numerics\Tensors\netcore\TensorPrimitives.ConvertHelpers.cs (1)
21if (source.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.IsCanonical.cs (1)
27if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.IsComplexNumber.cs (1)
27if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.IsFinite.cs (1)
27if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.IsImaginaryNumber.cs (1)
27if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.IsInteger.cs (1)
26if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.IsNaN.cs (1)
27if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.IsNegative.cs (1)
26if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.IsRealNumber.cs (1)
27if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorPrimitives.SoftMax.cs (1)
32if (x.Length > destination.Length)
System\Numerics\Tensors\netcore\TensorShape.cs (6)
462Debug.Assert(indexes.Length >= Rank); 463Debug.Assert(indexes.Length == destinationShape.Rank); 499if (indexes.Length != Rank) 527Debug.Assert(indexes.Length >= Rank); 528Debug.Assert(indexes.Length == destinationShape.Rank); 564if (indexes.Length != Rank)
System\Numerics\Tensors\netcore\TensorSpan.cs (3)
84_shape = TensorShape.Create(ref reference, span.Length); 92_shape = TensorShape.Create(ref reference, span.Length, lengths); 100_shape = TensorShape.Create(ref reference, span.Length, lengths, strides);
System\Numerics\Tensors\TensorPrimitives.Helpers.cs (2)
31Debug.Assert(destination1.Length >= inputLength); 32Debug.Assert(destination1.Length >= inputLength);
System\Numerics\Tensors\TensorPrimitives.Single.cs (1)
855if (x.Length > destination.Length)
System.Private.CoreLib (487)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.IsMemberOfGroup.cs (2)
30rv = Interop.Sys.GetGroups(groups.Length, pGroups); 41groups = new uint[groups.Length * 2];
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadDir.cs (1)
38Debug.Assert(buffer.Length >= Encoding.UTF8.GetMaxCharCount(NameBufferSize - 1 - 1));
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadLink.cs (3)
46int resultLength = ReadLink(ref pathReference, ref MemoryMarshal.GetReference(spanBuffer), spanBuffer.Length); 54else if (resultLength < spanBuffer.Length) 74arrayBuffer = ArrayPool<byte>.Shared.Rent(spanBuffer.Length * 2);
src\libraries\Common\src\Interop\Windows\Kernel32\Interop.FormatMessage.cs (1)
46int length = FormatMessage(flags, moduleHandle, unchecked((uint)errorCode), 0, bufferPtr, stackBuffer.Length, IntPtr.Zero);
src\libraries\Common\src\System\Collections\Generic\BitHelper.cs (1)
30if (bitArrayIndex < (uint)span.Length)
src\libraries\Common\src\System\HexConverter.cs (4)
167Debug.Assert(chars.Length >= bytes.Length * 2); 263Debug.Assert(chars.Length <= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Number.Formatting.Common.cs (2)
502if (thousandsSepCtr >= thousandsSepPos.Length) 504var newThousandsSepPos = new int[thousandsSepPos.Length * 2];
src\libraries\Common\src\System\Number.NumberBuffer.cs (3)
69for (numDigits = 0; numDigits < Digits.Length; numDigits++) 82Debug.Assert(numDigits < Digits.Length, "Null terminator not found in Number"); 97for (int i = 0; i < Digits.Length; i++)
src\libraries\Common\src\System\Number.Parsing.Common.cs (1)
95int maxDigCount = number.Digits.Length - 1;
src\libraries\Common\src\System\Reflection\AssemblyNameParser.cs (2)
256if (parts.Length is < 2 or > 4) 262for (int i = 0; i < parts.Length; i++)
src\libraries\Common\src\System\Sha1ForNonSecretPurposes.cs (2)
96int end = output.Length < 20 ? output.Length : 20;
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (1)
27if (_bytes.Length < maxSize)
src\libraries\System.Private.CoreLib\src\System\BitConverter.cs (13)
43if (destination.Length < sizeof(byte)) 71if (destination.Length < sizeof(char)) 99if (destination.Length < sizeof(short)) 127if (destination.Length < sizeof(int)) 155if (destination.Length < sizeof(long)) 183if (destination.Length < Int128.Size) 213if (destination.Length < sizeof(ushort)) 243if (destination.Length < sizeof(uint)) 273if (destination.Length < sizeof(ulong)) 303if (destination.Length < UInt128.Size) 331if (destination.Length < sizeof(Half)) 359if (destination.Length < sizeof(float)) 387if (destination.Length < sizeof(double))
src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.ReverseEndianness.cs (2)
289if (destination.Length < source.Length) 381if (destination.Length < source.Length)
src\libraries\System.Private.CoreLib\src\System\Buffers\MemoryManager.cs (1)
16public virtual Memory<T> Memory => new Memory<T>(this, GetSpan().Length);
src\libraries\System.Private.CoreLib\src\System\Buffers\StandardFormat.cs (2)
160Debug.Assert(destination.Length == FormatStringLength); 164if (symbol != default && destination.Length == FormatStringLength)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Helper\Base64DecoderHelper.cs (8)
33int destLength = bytes.Length; 328uint bufferLength = (uint)buffer.Length; 332if (decoder.IsInvalidLength(buffer.Length)) 462for (; encodedIdx < source.Length && (uint)bufferIdx < (uint)buffer.Length; ++encodedIdx) 569int BlockSize = Math.Min(source.Length - (int)sourceIndex, 4); 577while (sourceIndex < (uint)source.Length) 581while (bufferIdx < BlockSize && sourceIndex < (uint)source.Length) 609Debug.Assert(source.Length == sourceIndex);
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Helper\Base64EncoderHelper.cs (2)
32int destLength = destination.Length; 598if (buffer.Length < encodedLength)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Url\Base64UrlDecoder.cs (1)
219for (; encodedIdx < source.Length && (uint)bufferIdx < (uint)buffer.Length; ++encodedIdx)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Url\Base64UrlEncoder.cs (1)
161Debug.Assert(buffer.Length == charsWritten, $"The source length: {source.Length}, bytes written: {charsWritten}");
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Number.cs (1)
61int maxDigitCount = digits.Length - 1;
src\libraries\System.Private.CoreLib\src\System\Byte.cs (2)
371if (destination.Length >= sizeof(byte)) 389if (destination.Length >= sizeof(byte))
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs (44)
125if (keys.Length > 1) 127IntroSort(keys, 2 * (BitOperations.Log2((uint)keys.Length) + 1), comparer); 140int partitionSize = keys.Length; 181Debug.Assert(keys.Length >= Array.IntrosortSizeThreshold); 184int hi = keys.Length - 1; 222int n = keys.Length; 260for (int i = 0; i < keys.Length - 1; i++) 289if (keys.Length > 1) 299if (nanLeft == keys.Length) 306IntroSort(keys, 2 * (BitOperations.Log2((uint)keys.Length) + 1)); 416int partitionSize = keys.Length; 460Debug.Assert(keys.Length >= Array.IntrosortSizeThreshold); 464ref T lastRef = ref Unsafe.Add(ref zeroRef, keys.Length - 1); 465ref T middleRef = ref Unsafe.Add(ref zeroRef, (keys.Length - 1) >> 1); 471ref T nextToLastRef = ref Unsafe.Add(ref zeroRef, keys.Length - 2); 511int n = keys.Length; 547for (int i = 0; i < keys.Length - 1; i++) 636Debug.Assert(0 <= i && i < keys.Length && i < values.Length); 637Debug.Assert(0 <= j && j < keys.Length && j < values.Length); 669Debug.Assert(keys.Length == values.Length); 671if (keys.Length > 1) 673IntroSort(keys, values, 2 * (BitOperations.Log2((uint)keys.Length) + 1), comparer); 680Debug.Assert(values.Length == keys.Length); 684int partitionSize = keys.Length; 725Debug.Assert(keys.Length >= Array.IntrosortSizeThreshold); 728int hi = keys.Length - 1; 766int n = keys.Length; 810for (int i = 0; i < keys.Length - 1; i++) 840if (keys.Length > 1) 850if (nanLeft == keys.Length) 858IntroSort(keys, values, 2 * (BitOperations.Log2((uint)keys.Length) + 1)); 910Debug.Assert(values.Length == keys.Length); 913int partitionSize = keys.Length; 954Debug.Assert(keys.Length >= Array.IntrosortSizeThreshold); 956int hi = keys.Length - 1; 1001int n = keys.Length; 1041for (int i = 0; i < keys.Length - 1; i++) 1117for (int i = 0; i < keys.Length; i++) 1127if ((uint)i < (uint)values.Length) // check to see if we have values
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (14)
32Debug.Assert(value <= _span.Length); 53if ((uint)pos < (uint)span.Length) 69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 113if ((ulong)(uint)pos + (ulong)(uint)length <= (ulong)(uint)span.Length) // same guard condition as in Span<T>.Slice on 64-bit 128Grow(_span.Length - pos + length); 137Debug.Assert(_pos == _span.Length); 200int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 210nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
src\libraries\System.Private.CoreLib\src\System\Convert.Base64.cs (1)
37int destLength = bytes.Length;
src\libraries\System.Private.CoreLib\src\System\Convert.cs (10)
2302int i = chars.Length; 2445if (charLengthRequired > chars.Length) 2478Debug.Assert(chars.Length >= charLengthRequired); 2765Debug.Assert(tempBuffer.Length != 0); // We only bound-check after writing a character to the tempBuffer. 2774if (charsWritten == tempBuffer.Length) 3004if (destination.Length < quotient) 3006source = source.Slice(0, destination.Length * 2); 3007quotient = destination.Length; 3102else if (source.Length > int.MaxValue / 2 || destination.Length < source.Length * 2) 3179else if (source.Length > int.MaxValue / 2 || destination.Length < source.Length * 2)
src\libraries\System.Private.CoreLib\src\System\DateOnly.cs (2)
757Debug.Assert(charsWritten == destination.Length); 763Debug.Assert(charsWritten == destination.Length);
src\libraries\System.Private.CoreLib\src\System\Decimal.cs (7)
593if (destination.Length <= 3) 614if (destination.Length <= 3) 630Debug.Assert(buffer.Length >= 16); 1147if (destination.Length >= sizeof(sbyte)) 1161if (destination.Length >= sizeof(sbyte)) 1175if (destination.Length >= (sizeof(uint) + sizeof(ulong))) 1204if (destination.Length >= (sizeof(ulong) + sizeof(uint)))
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventPipe.cs (1)
134return Enable(outputFilePath, format, circularBufferSizeInMB, providersNativePointer, (uint)providersNative.Length);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventProvider.cs (3)
521if (refObjIndex >= dataRefObj.Length) 523Span<object?> newDataRefObj = new object?[dataRefObj.Length * 2]; 527Span<int> newRefObjPosition = new int[refObjPosition.Length * 2];
src\libraries\System.Private.CoreLib\src\System\Enum.cs (2)
1555if (sizeof(TStorage) * 2 <= destination.Length) 1992if (length <= destination.Length)
src\libraries\System.Private.CoreLib\src\System\Environment.Variables.Windows.cs (2)
37uint length = Interop.Kernel32.GetEnvironmentVariable(variable, ref MemoryMarshal.GetReference(span), (uint)span.Length); 38return length > 0 && length <= span.Length ?
src\libraries\System.Private.CoreLib\src\System\Exception.cs (1)
175Debug.Assert(resultSpan.Length == 0);
src\libraries\System.Private.CoreLib\src\System\Globalization\CalendarData.Icu.cs (2)
131return Interop.Globalization.GetCalendarInfo(locale, id, type, bufferPtr, buffer.Length); 222Debug.Assert(index + 3 < modifiedPattern.Length);
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Icu.cs (7)
769actualSortKeyLength = Interop.Globalization.GetSortKey(_sortHandle, pSource, source.Length, pDest, destination.Length, options); 775if ((uint)actualSortKeyLength > (uint)destination.Length) 777if (actualSortKeyLength > destination.Length) 882sortKeyLength = Interop.Globalization.GetSortKey(_sortHandle, pSource, source.Length, pSortKey, sortKey.Length, options); 886if (sortKeyLength > sortKey.Length) // slow path for big strings 905sortKeyLength = Interop.Globalization.GetSortKey(_sortHandle, pSource, source.Length, pSortKey, sortKey.Length, options); 911if (sortKeyLength == 0 || sortKeyLength > sortKey.Length) // internal error (0) or a bug (2nd call failed) in ucol_getSortKey
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Invariant.cs (3)
46Debug.Assert(sortKey.Length >= source.Length * sizeof(char)); 58Debug.Assert(sortKey.Length >= source.Length * sizeof(char)); 93if ((uint)destination.Length < (uint)source.Length * sizeof(char))
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Nls.cs (2)
497pSortKey, destination.Length, 519Debug.Assert(actualSortKeyLength <= destination.Length);
src\libraries\System.Private.CoreLib\src\System\Globalization\CultureData.Icu.cs (1)
88if (buffer.Length - bufferIndex >= length + 1)
src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeFormat.cs (9)
1318if (destination.Length < 16) 1346if (destination.Length < 8) 1373if (destination.Length < 10) 1400if (destination.Length < 16) 1465if (destination.Length < charsRequired) 1524if (destination.Length < FormatSLength) 1559if (destination.Length < FormatuLength) 1600if (destination.Length < FormatRLength) 1671if (destination.Length < bytesRequired)
src\libraries\System.Private.CoreLib\src\System\Globalization\InvariantModeCasing.cs (2)
114Debug.Assert(source.Length <= destination.Length); 140Debug.Assert(source.Length <= destination.Length);
src\libraries\System.Private.CoreLib\src\System\Globalization\Normalization.Icu.cs (4)
78realLen = Interop.Globalization.NormalizeString(normalizationForm, pInput, strInput.Length, pDest, buffer.Length); 87if (realLen <= buffer.Length) 149realLen = Interop.Globalization.NormalizeString(normalizationForm, pInput, source.Length, pDest, destination.Length); 158if (realLen <= destination.Length)
src\libraries\System.Private.CoreLib\src\System\Globalization\Normalization.Nls.cs (3)
65realLength = Interop.Normaliz.NormalizeString(normalizationForm, pInput, strInput.Length, pDest, buffer.Length); 80Debug.Assert(realLength > buffer.Length, "Buffer overflow should have iLength > cBuffer.Length"); 136realLength = Interop.Normaliz.NormalizeString(normalizationForm, pInput, source.Length, pDest, destination.Length);
src\libraries\System.Private.CoreLib\src\System\Globalization\Ordinal.cs (1)
692if (destination.Length < source.Length)
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 (1)
226if (destination.Length < requiredOutputLength)
src\libraries\System.Private.CoreLib\src\System\Guid.cs (4)
935if (destination.Length < 16) 954if (destination.Length < 16) 1228if ((byte)flags > destination.Length) 1352if (dest.Length < 68)
src\libraries\System.Private.CoreLib\src\System\Half.cs (2)
1368if (destination.Length >= sizeof(sbyte)) 1382if (destination.Length >= sizeof(sbyte))
src\libraries\System.Private.CoreLib\src\System\IO\BinaryReader.cs (3)
326int numBytes = buffer.Length; 474Debug.Assert(buffer.Length != 1, "length of 1 should use ReadByte."); 480return Unsafe.As<MemoryStream>(_stream).InternalReadSpan(buffer.Length);
src\libraries\System.Private.CoreLib\src\System\IO\BinaryWriter.cs (1)
196if (maxByteCount > buffer.Length)
src\libraries\System.Private.CoreLib\src\System\IO\BufferedStream.cs (3)
448int readbytes = Math.Min(_readLen - _readPos, destination.Length); 536if (bytesFromBuffer == destination.Length) 558if (destination.Length >= _bufferSize)
src\libraries\System.Private.CoreLib\src\System\IO\Directory.Unix.cs (1)
56return Encoding.UTF8.GetString(path.Slice(0, path.Length - 1)); // trim off the trailing '\0'
src\libraries\System.Private.CoreLib\src\System\IO\Enumeration\FileSystemEntry.Unix.cs (2)
82Debug.Assert(Directory.Length + FileName.Length < _pathBuffer.Length, 83$"directory ({Directory.Length} chars) & name ({Directory.Length} chars) too long for buffer ({_pathBuffer.Length} chars)");
src\libraries\System.Private.CoreLib\src\System\IO\Enumeration\FileSystemName.cs (3)
253if (currentMatch >= currentMatches.Length - 2) 255int newSize = currentMatches.Length * 2; 390int previousLength = priorMatches.Length;
src\libraries\System.Private.CoreLib\src\System\IO\File.cs (5)
1469if (bytesRead == buffer.Length) 1471uint newLength = (uint)buffer.Length * 2; 1474newLength = (uint)Math.Max(Array.MaxLength, buffer.Length + 1); 1487Debug.Assert(bytesRead < buffer.Length); 1548fileOffset += toStore.Length;
src\libraries\System.Private.CoreLib\src\System\IO\MemoryStream.cs (1)
357int n = Math.Min(_length - _position, buffer.Length);
src\libraries\System.Private.CoreLib\src\System\IO\Path.cs (4)
592if (destination.Length < pathToUse.Length) 604if (destination.Length < charsNeeded) 636if (destination.Length < charsNeeded) 799Debug.Assert(chars.Length == 12, $"Unexpected {nameof(chars)}.Length");
src\libraries\System.Private.CoreLib\src\System\IO\Path.Unix.cs (1)
121return Encoding.UTF8.GetString(path.Slice(0, path.Length - 1)); // trim off the trailing '\0'
src\libraries\System.Private.CoreLib\src\System\IO\RandomAccess.Unix.cs (4)
36result = Interop.Sys.PRead(handle, bufPtr, buffer.Length, fileOffset); 47result = Interop.Sys.Read(handle, bufPtr, buffer.Length); 53result = Interop.Sys.Read(handle, bufPtr, buffer.Length); 194bytesWritten = Interop.Sys.PWriteV(handle, pinnedVectors, left.Length, fileOffset);
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\BufferedFileStreamStrategy.cs (4)
178if (!_strategy.CanSeek || (destination.Length >= _bufferSize)) 207if (n > destination.Length) 209n = destination.Length; 231if (n < destination.Length && !isBlocked)
src\libraries\System.Private.CoreLib\src\System\IO\Stream.cs (6)
782byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 785int numRead = Read(sharedBuffer, 0, buffer.Length); 786if ((uint)numRead > (uint)buffer.Length) 818_ = ReadAtLeastCore(buffer, buffer.Length, throwOnEndOfStream: true); 880ValidateReadAtLeastArguments(buffer.Length, minimumBytes); 888Debug.Assert(minimumBytes <= buffer.Length);
src\libraries\System.Private.CoreLib\src\System\IO\StreamReader.cs (5)
373int count = buffer.Length; 454} while (i > 0 && n < buffer.Length); 692readToUserBuffer = userBuffer.Length >= _maxCharsPerBuffer; 745readToUserBuffer = userBuffer.Length >= _maxCharsPerBuffer; 781_isBlocked &= charsRead < userBuffer.Length;
src\libraries\System.Private.CoreLib\src\System\IO\StringReader.cs (2)
133if (n > buffer.Length) 135n = buffer.Length;
src\libraries\System.Private.CoreLib\src\System\IO\TextReader.cs (6)
98char[] array = ArrayPool<char>.Shared.Rent(buffer.Length); 102int numRead = Read(array, 0, buffer.Length); 103if ((uint)numRead > (uint)buffer.Length) 148char[] array = ArrayPool<char>.Shared.Rent(buffer.Length); 152int numRead = ReadBlock(array, 0, buffer.Length); 153if ((uint)numRead > (uint)buffer.Length)
src\libraries\System.Private.CoreLib\src\System\IO\UnmanagedMemoryStream.cs (1)
371long n = Math.Min(len - pos, buffer.Length);
src\libraries\System.Private.CoreLib\src\System\Memory.cs (1)
318lengthOfUnderlyingSpan = memoryManagerSpan.Length;
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.cs (37)
3684if (span.Length > 1) 3686SpanHelpers.Reverse(ref MemoryMarshal.GetReference(span), (nuint)span.Length); 4146/// no larger element, the bitwise complement of <see cref="Span{T}.Length"/>. 4168/// no larger element, the bitwise complement of <see cref="Span{T}.Length"/>. 4193/// no larger element, the bitwise complement of <see cref="Span{T}.Length"/>. 4313if (span.Length > 1) 4331if (span.Length > 1) 4377if (keys.Length != items.Length) 4380if (keys.Length > 1) 4403if (keys.Length != items.Length) 4406if (keys.Length > 1) 4422nuint length = (uint)span.Length; 4500(uint)span.Length); 4512(uint)span.Length); 4523(uint)span.Length); 4534(uint)span.Length); 4542for (int i = 0; i < span.Length; i++) 4557for (int i = 0; i < span.Length; i++) 4587if (length > (uint)destination.Length) 4598(nuint)byteOffset > (nuint)(-((nint)destination.Length * sizeof(T))))) 4671if (length > (uint)destination.Length) 4682(nuint)byteOffset > (nuint)(-((nint)destination.Length * sizeof(T))))) 4773if (source.Length > destination.Length) 4823if (source.Length > destination.Length) 5149if (separators.IsEmpty && destination.Length > source.Length) 5190if (separators.IsEmpty && destination.Length > source.Length) 5237if (destination.Length == 1) 5281Span<Range> destinationMinusOne = destination.Slice(0, destination.Length - 1); 5282while (separatorIndex < separatorList.Length && (rangeCount < destinationMinusOne.Length || !keepEmptyEntries)) 5305if ((uint)rangeCount >= (uint)destinationMinusOne.Length) 5324if ((uint)rangeCount < (uint)destination.Length) 6030_success = shouldAppend = destination.Length >= literalLength; 6046_success = shouldAppend = destination.Length >= literalLength; 6255if (alignment <= _destination.Length - _pos) 6375if (paddingNeeded <= _destination.Length - _pos)
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.Globalization.cs (4)
205if (destination.Length < source.Length) 229if (destination.Length < source.Length) 257if (destination.Length < source.Length) 281if (destination.Length < source.Length)
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.Trim.cs (3)
790if (span.Length == 0 || 801for (; start < span.Length; start++) 809int end = span.Length - 1;
src\libraries\System.Private.CoreLib\src\System\Net\WebUtility.cs (1)
349Span<byte> utf8Bytes = MemoryMarshal.AsBytes(dest).Slice(dest.Length * 2 - state.byteCount);
src\libraries\System.Private.CoreLib\src\System\Number.Dragon4.cs (3)
60Debug.Assert(buffer.Length > 0); 240int cutoffExponent = digitExponent - buffer.Length; 478Debug.Assert(outputLen <= buffer.Length);
src\libraries\System.Private.CoreLib\src\System\Number.Formatting.cs (14)
1411if (bufferLength > destination.Length) 1459if (bufferLength > destination.Length) 1515if (bufferLength > destination.Length) 1729if (bufferLength <= destination.Length) 1750if (bufferLength <= destination.Length) 1844if (bufferLength > destination.Length) 1892if (bufferLength > destination.Length) 1964if (bufferLength > destination.Length) 2157if (bufferLength <= destination.Length) 2177if (bufferLength <= destination.Length) 2274if (bufferLength > destination.Length) 2326if (bufferLength > destination.Length) 2389if (bufferLength > destination.Length) 2518if (bufferLength <= destination.Length)
src\libraries\System.Private.CoreLib\src\System\Numerics\INumberBase.cs (1)
490int destinationMaxCharCount = Encoding.UTF8.GetMaxCharCount(utf8Destination.Length);
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector2.cs (2)
1017if (destination.Length < ElementCount) 1031if (destination.Length < ElementCount)
src\libraries\System.Private.CoreLib\src\System\Numerics\Vector3.cs (2)
1027if (destination.Length < ElementCount) 1041if (destination.Length < ElementCount)
src\libraries\System.Private.CoreLib\src\System\Random.CompatImpl.cs (2)
244for (int i = 0; i < buffer.Length; i++) 332for (int i = 0; i < buffer.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Random.cs (11)
226if (destination.Length < randomBytes.Length) 228randomBytes = randomBytes.Slice(0, destination.Length); 233for (int i = 0; i < randomBytes.Length; i++) 238destination = destination.Slice(randomBytes.Length); 254if (destination.Length * 2 < randomBytes.Length) 256randomBytes = randomBytes.Slice(0, destination.Length * 2); 264if ((uint)i >= (uint)destination.Length) 284for (int i = 0; i < destination.Length; i++) 366int n = values.Length;
src\libraries\System.Private.CoreLib\src\System\Random.Xoshiro256StarStarImpl.cs (3)
140while (buffer.Length >= sizeof(ulong)) 160Debug.Assert(buffer.Length < sizeof(ulong)); 161for (int i = 0; i < buffer.Length; i++)
src\libraries\System.Private.CoreLib\src\System\ReadOnlyMemory.cs (1)
240lengthOfUnderlyingSpan = memoryManagerSpan.Length;
src\libraries\System.Private.CoreLib\src\System\ReadOnlySpan.cs (2)
299if ((uint)_length <= (uint)destination.Length) 320if ((uint)_length <= (uint)destination.Length)
src\libraries\System.Private.CoreLib\src\System\Reflection\AssemblyNameHelpers.StrongName.cs (1)
31publicKeyToken[i] = hash[hash.Length - 1 - i];
src\libraries\System.Private.CoreLib\src\System\Reflection\ConstructorInvoker.cs (2)
204int argLen = arguments.Length; 391for (int i = 0; i < dest.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Reflection\MethodInvoker.cs (2)
241int argLen = arguments.Length; 444for (int i = 0; i < dest.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Resources\ResourceReader.cs (1)
607for (int i = 0; i < bits.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\DefaultInterpolatedStringHandler.cs (4)
585if (_chars.Length - _pos < additionalChars) 619Debug.Assert(additionalChars > _chars.Length - _pos); 630GrowCore((uint)_chars.Length + 1); 642uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)_chars.Length * 2, string.MaxLength));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\ComWrappers.cs (3)
865for (int i = 0; i < dispatches.Length; i++) 869for (int j = 0; j < dispatchVtables.Length; j++) 871int index = i * dispatchVtables.Length + j;
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\AnsiStringMarshaller.cs (2)
79if ((long)Marshal.SystemMaxDBCSCharSize * managed.Length >= buffer.Length) 83if (exactByteCount > buffer.Length)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\ArrayMarshaller.cs (1)
141if (array.Length <= buffer.Length)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\BStrStringMarshaller.cs (1)
80if (manualBstrNeeds > buffer.Length)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\PointerArrayMarshaller.cs (1)
142if (array.Length <= buffer.Length)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\ReadOnlySpanMarshaller.cs (1)
114if (managed.Length <= buffer.Length)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\SpanMarshaller.cs (6)
44numElements = managed.Length; 141if (managed.Length <= buffer.Length) 143_span = buffer[0..managed.Length]; 147int bufferSize = checked(managed.Length * sizeof(TUnmanagedElement)); 149_span = new Span<TUnmanagedElement>(_allocatedMemory, managed.Length);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\Utf8StringMarshaller.cs (2)
83if ((long)MaxUtf8BytesPerChar * managed.Length >= buffer.Length) 87if (exactByteCount > buffer.Length)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\MemoryMarshal.cs (6)
38checked(span.Length * sizeof(T))); 93internal static unsafe ref T GetNonNullPinnableReference<T>(Span<T> span) => ref (span.Length != 0) ? ref Unsafe.AsRef(in span._reference) : ref Unsafe.AsRef<T>((void*)1); 127uint fromLength = (uint)span.Length; 514if ((uint)sizeof(T) > (uint)destination.Length) 533if (sizeof(T) > (uint)destination.Length) 556if (sizeof(T) > (uint)span.Length)
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NFloat.cs (4)
1043if (destination.Length >= sizeof(NativeExponentType)) 1067if (destination.Length >= sizeof(NativeExponentType)) 1091if (destination.Length >= sizeof(NativeSignificandType)) 1115if (destination.Length >= sizeof(NativeSignificandType))
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeBuffer.cs (2)
239SpaceCheck(ptr, checked((nuint)(alignedSizeofT * buffer.Length))); 247for (int i = 0; i < buffer.Length; i++)
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\ISimdVector_2.cs (2)
203if (destination.Length < TSelf.ElementCount) 787if (destination.Length < TSelf.ElementCount)
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector128.cs (2)
695if (destination.Length < Vector128<T>.Count) 3902if (destination.Length < Vector128<T>.Count)
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector256.cs (2)
722if (destination.Length < Vector256<T>.Count) 3936if (destination.Length < Vector256<T>.Count)
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector512.cs (2)
633if ((uint)destination.Length < (uint)Vector512<T>.Count) 3914if ((uint)destination.Length < (uint)Vector512<T>.Count)
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector64.cs (2)
669if (destination.Length < Vector64<T>.Count) 3929if (destination.Length < Vector64<T>.Count)
src\libraries\System.Private.CoreLib\src\System\Runtime\Versioning\FrameworkName.cs (1)
140for (int i = 1; i < components.Length; i++)
src\libraries\System.Private.CoreLib\src\System\SByte.cs (2)
429if (destination.Length >= sizeof(sbyte)) 443if (destination.Length >= sizeof(sbyte))
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\RabinKarp.cs (1)
175Debug.Assert(charsWritten == upperCase.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\TeddyBucketizer.cs (1)
122for (int i = 0; i < bucketIndexes.Length; i++)
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\StringSearchValues.cs (2)
64Debug.Assert(i == normalizedValues.Length); 109Debug.Assert(newCount <= values.Length - unreachableValues.Count);
src\libraries\System.Private.CoreLib\src\System\Security\SecureString.cs (1)
361byteLength = (span.Length + 1) * sizeof(char);
src\libraries\System.Private.CoreLib\src\System\Single.cs (2)
720if (destination.Length >= sizeof(sbyte)) 734if (destination.Length >= sizeof(sbyte))
src\libraries\System.Private.CoreLib\src\System\Span.cs (3)
246if (index < _span.Length) 317if ((uint)_length <= (uint)destination.Length) 338if ((uint)_length <= (uint)destination.Length)
src\libraries\System.Private.CoreLib\src\System\String.Manipulation.cs (1)
1444Debug.Assert(this.Length - thisIdx == dstSpan.Length - dstIdx);
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.CaseConversion.cs (5)
170if (source.Length <= destination.Length) 177numElementsToConvert = (uint)destination.Length; 198nuint numElementsActuallyConverted = ChangeCase<T, T, TCasing>(pBuffer, pBuffer, (nuint)buffer.Length); 199Debug.Assert(numElementsActuallyConverted <= (nuint)buffer.Length); 202return elementsWritten == buffer.Length ? OperationStatus.Done : OperationStatus.InvalidData;
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.Transcoding.cs (4)
25if (source.Length <= destination.Length) 32numElementsToConvert = (uint)destination.Length; 60if (source.Length <= destination.Length) 67numElementsToConvert = (uint)destination.Length;
src\libraries\System.Private.CoreLib\src\System\Text\ASCIIEncoding.cs (8)
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); 423return originalBytesLength - bytes.Length; // total number of bytes written 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); 711return originalCharsLength - chars.Length; // total number of chars written
src\libraries\System.Private.CoreLib\src\System\Text\Decoder.cs (2)
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)
269int originalCharCount = chars.Length; 287charsWritten = originalCharCount - chars.Length;
src\libraries\System.Private.CoreLib\src\System\Text\DecoderNLS.cs (3)
351Debug.Assert(combinedBufferBytesConsumed == combinedBuffer.Length, "We should be asked to persist the entire combined buffer."); 382if ((uint)total >= (uint)dest.Length) 394if ((uint)total >= (uint)dest.Length)
src\libraries\System.Private.CoreLib\src\System\Text\Encoder.cs (2)
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 (3)
195int originalBytesLength = bytes.Length; 218bytesWritten = originalBytesLength - bytes.Length; 239bytesWritten = originalBytesLength - bytes.Length;
src\libraries\System.Private.CoreLib\src\System\Text\Encoding.cs (4)
732return GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length); 744if (required <= bytes.Length) 881return GetChars(bytesPtr, bytes.Length, charsPtr, chars.Length); 893if (required <= chars.Length)
src\libraries\System.Private.CoreLib\src\System\Text\Encoding.Internal.cs (11)
541ThrowBytesOverflow(encoder, nothingEncoded: bytes.Length == originalByteCount); // might not throw if we wrote at least one byte 552bytesLength: bytes.Length, 572return originalByteCount - bytes.Length; // total number of bytes written up until now 655bytesLength: bytes.Length, 684ThrowBytesOverflow(encoder, nothingEncoded: bytes.Length == originalBytesLength); 703return originalBytesLength - bytes.Length; 1155charsLength: chars.Length, 1168return originalCharCount - chars.Length; // total number of chars written 1255charsLength: chars.Length, 1281ThrowCharsOverflow(decoder, nothingDecoded: chars.Length == originalCharsLength); 1298return originalCharsLength - chars.Length; // total number of chars written
src\libraries\System.Private.CoreLib\src\System\Text\Latin1Encoding.cs (5)
233return GetBytesCommon(charsPtr, chars.Length, bytesPtr, bytes.Length); 243int written = GetBytesCommon(charsPtr, chars.Length, bytesPtr, bytes.Length, throwForDestinationOverflow: false); 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 (4)
1045else if (destination.Length > 1) 1092if (destination.Length > 1) 1103if (destination.Length > 2) 1115if (destination.Length > 3)
src\libraries\System.Private.CoreLib\src\System\Text\StringBuilder.cs (3)
1723if ((uint)charsWritten > (uint)RemainingCurrentChunk.Length) 2899if ((uint)charsWritten > (uint)destination.Length) 2963if ((uint)charsWritten > (uint)destination.Length)
src\libraries\System.Private.CoreLib\src\System\Text\TranscodingStream.cs (1)
353int bytesToReturn = Math.Min(_readBufferCount, buffer.Length);
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8.cs (11)
66outputBytesRemaining: destination.Length, 95if (destination.Length <= 2) 157outputCharsRemaining: destination.Length, 252outputCharsRemaining: destination.Length, 289if (destination.Length < bytesConsumedJustNow) 374_success = shouldAppend = destination.Length >= literalLength; // UTF8 encoding never produces fewer bytes than input characters 390_success = shouldAppend = destination.Length >= literalLength; // UTF8 encoding never produces fewer bytes than input characters 408ref MemoryMarshal.GetReference(dest), dest.Length); 679GrowAndAppendFormatted(ref this, value, utf16.Length, out charsWritten, format); 726GrowAndAppendFormatted(ref this, value, utf16.Length, out charsWritten, format); 783if (paddingNeeded <= _destination.Length - _pos)
src\libraries\System.Private.CoreLib\src\System\Text\UTF8Encoding.cs (5)
368return GetBytesCommon(charsPtr, chars.Length, bytesPtr, bytes.Length); 378int written = GetBytesCommon(charsPtr, chars.Length, bytesPtr, bytes.Length, throwForDestinationOverflow: false); 563return GetCharsCommon(bytesPtr, bytes.Length, charsPtr, chars.Length); 573int written = GetCharsCommon(bytesPtr, bytes.Length, charsPtr, chars.Length, throwForDestinationOverflow: false); 661return originalCharsLength - chars.Length; // total number of chars written
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Task.cs (2)
3514for (int i = 0; i < continuations.Length; i++) 3568for (int i = 0; i < continuations.Length; i++)
src\libraries\System.Private.CoreLib\src\System\TimeOnly.cs (2)
929Debug.Assert(charsWritten == destination.Length); 935Debug.Assert(charsWritten == destination.Length);
src\libraries\System.Private.CoreLib\src\System\TimeZoneInfo.FullGlobalizationData.Unix.cs (2)
118return Interop.Globalization.GetTimeZoneDisplayName(locale, id, type, bufferPtr, buffer.Length); 138return Interop.Globalization.GetTimeZoneDisplayName(locale, id, type, bufferPtr, buffer.Length);
src\System\RuntimeHandles.cs (2)
190Span<IntPtr> outHandles = inHandles.Length <= stackScratch.Length ? 552int countLocal = buffer.Length;
src\System\RuntimeType.CoreCLR.cs (3)
362Filter filter = new Filter(pUtf8Name, utf8Name.Length, listType); 845Debug.Assert(count > result.Length); 1269(!declaringType.IsInterface && !isInterface && usedSlots.Length >= numVirtuals));
System.Private.CoreLib.Generators (14)
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (14)
32Debug.Assert(value <= _span.Length); 53if ((uint)pos < (uint)span.Length) 69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 113if ((ulong)(uint)pos + (ulong)(uint)length <= (ulong)(uint)span.Length) // same guard condition as in Span<T>.Slice on 64-bit 128Grow(_span.Length - pos + length); 137Debug.Assert(_pos == _span.Length); 200int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 210nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
System.Private.DataContractSerialization (12)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
System\Runtime\Serialization\Json\JsonEncodingStreamWrapper.cs (1)
206int count = buffer.Length;
System\Runtime\Serialization\MemoryStreamAdapter.cs (1)
64if (slicedBuffer.Length < buffer.Length)
System\Xml\EncodingStreamWrapper.cs (1)
616int count = buffer.Length;
System\Xml\XmlBufferReader.cs (4)
493if (dst.Length > 0) 495GetBuffer(dst.Length, out _offset) 496.AsSpan(_offset, dst.Length) 499Advance(dst.Length);
System\Xml\XmlConverter.cs (2)
1099return chars.Length; 1140Debug.Assert(count == chars.Length);
System.Private.Uri (34)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Net\IPv4AddressHelper.Common.cs (1)
41for (int i = 0; i < numbers.Length; ++i)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Uri.cs (9)
4566for (int i = span.Length - 1; i >= 0; i--) 4603|| (lastSlash == 0 && i + dotCount + 1 == span.Length)) // "/..." 4611span = span.Slice(0, span.Length - (lastSlash - i - 1)); 4639span = span.Slice(0, span.Length - (lastSlash - i)); 4645if (span.Length != 0 && syntax.InFact(UriSyntaxFlags.CanonicalizeAsFilePath)) 4654return span.Length - lastSlash; 4660if (lastSlash == dotCount || (lastSlash == 0 && dotCount == span.Length)) 4664return span.Length - dotCount; 4670return span.Length;
System\UriExt.cs (1)
668if (destination.Length >= newLength)
System\UriHelper.cs (4)
18Debug.Assert(charsWritten == buffer.Length); 121if (destination.Length < charsToEscape.Length) 157if (destination.Length >= newLength) 629Debug.Assert(buffer.Length == destIndex);
System\ValueStringBuilderExtensions.cs (2)
15if ((uint)(pos + 1) < (uint)chars.Length && (uint)pos < (uint)chars.Length)
System.Private.Windows.Core (56)
System\BufferScope.cs (3)
60if (initialBuffer.Length >= minimumLength) 84if (_span!.Length >= capacity) 112public readonly int Length => _span.Length;
System\IO\BinaryReaderExtensions.cs (1)
124if (reader.Read(arrayData) != arrayData.Length)
System\Private\Windows\Ole\Composition.NativeToManagedAdapter.cs (1)
216uint charactersCopied = PInvokeCore.DragQueryFile(hdrop, i, buffer, (uint)fileName.Length);
System\SpanHelpers.cs (2)
17if (source.Length >= destination.Length) 19source = source[..(destination.Length - 1)];
System\SpanWriter.cs (2)
102Debug.Assert((uint)start <= (uint)span.Length && (uint)length <= (uint)(span.Length - start));
System\Text\ValueStringBuilder.cs (15)
54Debug.Assert(value <= _chars.Length); 59public readonly int Capacity => _chars.Length; 67if ((uint)capacity > (uint)_chars.Length) 157if (_pos > _chars.Length - count) 177if (_pos > (_chars.Length - count)) 192if ((uint)pos < (uint)_chars.Length) 218if (s.Length == 1 && (uint)pos < (uint)_chars.Length) 233if (pos > _chars.Length - s.Length) 262if (_pos > _chars.Length - count) 268for (int i = 0; i < dst.Length; i++) 279if (pos > _chars.Length - length) 285for (int i = 0; i < dst.Length; i++) 296if (pos > _chars.Length - value.Length) 324Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 332Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
Windows\Win32\Graphics\Gdi\ArgbBuffer.cs (2)
30public ArgbBuffer(Span<Color> colors) : this(colors.Length) 32for (int i = 0; i < colors.Length; i++)
Windows\Win32\PInvokeCore.GetPaletteEntries.cs (1)
13return GetPaletteEntries(hpal, 0, (uint)entries.Length, entry);
Windows\Win32\System\Com\ComInterfaceTable.cs (8)
26Count = entries.Length 44Count = entries.Length 64Count = entries.Length 86Count = entries.Length 110Count = entries.Length 136Count = entries.Length 170Count = entries.Length 240Count = entries.Length
Windows\Win32\System\Variant\VARIANT.cs (21)
330for (int i = 0; i < data.Length; i++) 342for (int i = 0; i < data.Length; i++) 354for (int i = 0; i < data.Length; i++) 366for (int i = 0; i < data.Length; i++) 378for (int i = 0; i < data.Length; i++) 391for (int i = 0; i < data.Length; i++) 403for (int i = 0; i < data.Length; i++) 761bool[] result = new bool[data.Length]; 762for (int i = 0; i < data.Length; i++) 788decimal[] result = new decimal[data.Length]; 789for (int i = 0; i < data.Length; i++) 800var result = new DateTime[data.Length]; 801for (int i = 0; i < data.Length; i++) 812var result = new DateTime[data.Length]; 813for (int i = 0; i < data.Length; i++) 827string?[] result = new string?[data.Length]; 828for (int i = 0; i < data.Length; i++) 839string?[] result = new string?[data.Length]; 840for (int i = 0; i < data.Length; i++) 851object?[] result = new object?[data.Length]; 852for (int i = 0; i < data.Length; i++)
System.Private.Xml (24)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Xml\Base64Decoder.cs (2)
125if ((uint)iByte >= (uint)bytes.Length) 159if (iByte == bytes.Length)
System\Xml\BinaryXml\XmlBinaryReader.cs (1)
2333int cch = dstChars.Length;
System\Xml\BinHexDecoder.cs (1)
146if ((uint)iByte >= (uint)bytes.Length)
System\Xml\Schema\XsdDateTime.cs (1)
540return destination.Length >= vsb.Length;
System\Xml\Schema\XsdDuration.cs (1)
444return destination.Length >= vsb.Length;
System\Xml\XmlConvert.cs (1)
1650if (destination.Length < 1) return false;
System.Reflection.Metadata (20)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Reflection\AssemblyNameParser.cs (2)
256if (parts.Length is < 2 or > 4) 262for (int i = 0; i < parts.Length; i++)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Reflection\Internal\Utilities\StreamExtensions.cs (1)
52=> stream.ReadAtLeast(buffer, buffer.Length, throwOnEndOfStream: false);
System.Runtime.Numerics (259)
src\libraries\Common\src\System\Number.Formatting.Common.cs (2)
502if (thousandsSepCtr >= thousandsSepPos.Length) 504var newThousandsSepPos = new int[thousandsSepPos.Length * 2];
src\libraries\Common\src\System\Number.NumberBuffer.cs (3)
69for (numDigits = 0; numDigits < Digits.Length; numDigits++) 82Debug.Assert(numDigits < Digits.Length, "Null terminator not found in Number"); 97for (int i = 0; i < Digits.Length; i++)
src\libraries\Common\src\System\Number.Parsing.Common.cs (1)
95int maxDigCount = number.Digits.Length - 1;
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (14)
32Debug.Assert(value <= _span.Length); 53if ((uint)pos < (uint)span.Length) 69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 113if ((ulong)(uint)pos + (ulong)(uint)length <= (ulong)(uint)span.Length) // same guard condition as in Span<T>.Slice on 64-bit 128Grow(_span.Length - pos + length); 137Debug.Assert(_pos == _span.Length); 200int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 210nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
System\Number.BigInteger.cs (20)
445Debug.Assert(bits.Trim(0u).Length == 0); 541for (int i = 0; i < bits.Length; i++) 568int cur = bits.Length - 1; 652long tmpCharCount = charsInHighByte + ((long)(bytes.Length - 1) << 3); 672if (charsIncludeDigits > destination.Length) 698for (int i = bytes.Length - 2; i >= 0; i--) 835if (destination.Length < strLength) 863BigIntegerToDecChars((Utf16Char*)ptr + span.Length, new ReadOnlySpan<uint>((void*)state.ptr, state.Length), state.digits); 1055Debug.Assert(pow1E9.Length >= 1); 1057if (pow1E9.Length <= LeadingPowers1E9.Length) 1070if (pow1E9.Length - toExclusive < (src.Length << 1)) 1077Debug.Assert(toExclusive == pow1E9.Length || pow1E9[toExclusive] == 0); 1124bits.Length <= BigIntegerCalculator.StackAllocThreshold 1126: powersOfTenFromPool = ArrayPool<uint>.Shared.Rent(bits.Length)).Slice(0, bits.Length); 1160if (power.Length < src.Length) 1180if (left.Length < powersOfTen.Length) 1192for (int i = 0; i < bits2.Length; i++) 1237Debug.Assert(destination.Length * TParser.DigitsPerBlock == input.Length); 1240for (int i = 0; i < destination.Length; i++)
System\Numerics\BigInteger.cs (53)
230Debug.Assert(bits.Length == 4 && (bits[3] & DecimalScaleFactorMask) == 0); 549if ((value.Length > 0) && ((int)value[^1] < 0)) 568if (value.Length > MaxLength) 573if (value.Length == 0) 578else if (value.Length == 1) 1343if (destination.Length != 0) 1440if (destination.Length < length) 1517Debug.Assert(_bits is null || _sign == 0 ? buffer.Length == 2 : buffer.Length >= _bits.Length + 1); 1532NumericsHelpers.DangerousMakeTwosComplement(buffer.Slice(0, buffer.Length - 1)); // Mutates dwords 1540int msb = buffer.Length - 2; 1554buffer[buffer.Length - 1] = highDWord; 2361size = Math.Max(x.Length, y.Length); 2366for (int i = 0; i < z.Length; i++) 2368uint xu = ((uint)i < (uint)x.Length) ? x[i] : xExtend; 2369uint yu = ((uint)i < (uint)y.Length) ? y[i] : yExtend; 2417size = Math.Max(x.Length, y.Length); 2422for (int i = 0; i < z.Length; i++) 2424uint xu = ((uint)i < (uint)x.Length) ? x[i] : xExtend; 2425uint yu = ((uint)i < (uint)y.Length) ? y[i] : yExtend; 2468size = Math.Max(x.Length, y.Length); 2473for (int i = 0; i < z.Length; i++) 2475uint xu = ((uint)i < (uint)x.Length) ? x[i] : xExtend; 2476uint yu = ((uint)i < (uint)y.Length) ? y[i] : yExtend; 2524for (int i = 0; i < xd.Length; i++) 2533for (i = 0; i < xd.Length; i++) 2541zd[zd.Length - 1] = carry; 2579if (shift >= ((long)kcbitUint * xd.Length)) 2593trackSignBit = smallShift == 0 && xd[xd.Length - 1] == 0; 2605for (int i = xd.Length - 1; i >= digitShift; i--) 2614for (int i = xd.Length - 1; i >= digitShift; i--) 2617if (negx && i == xd.Length - 1) 2630zd[zd.Length - 1] = 0xFFFFFFFF; 3113Debug.Assert(_bits is null ? xd.Length == 1 : xd.Length == _bits.Length); 3305int srcIndex = xd.Length - digitShift; 3315while (srcIndex < xd.Length); 3319while (dstIndex < zd.Length) 3343srcIndex = xd.Length - digitShift; 3357while (srcIndex < xd.Length); 3361while (dstIndex < zd.Length) 3470while (srcIndex < xd.Length); 3474while (dstIndex < zd.Length) 3487int dstIndex = xd.Length - 1; 3489? xd.Length - 1 3504while ((uint)srcIndex < (uint)xd.Length); // is equivalent to (srcIndex >= 0 && srcIndex < xd.Length) 3506srcIndex = xd.Length - 1; 3508while ((uint)dstIndex < (uint)zd.Length) // is equivalent to (dstIndex >= 0 && dstIndex < zd.Length) 3641if (destination.Length >= byteCount) 3743if (destination.Length >= byteCount)
System\Numerics\BigIntegerCalculator.AddSub.cs (8)
22Debug.Assert(bits.Length == left.Length + 1); 31Debug.Assert(bits.Length == left.Length + 1); 61Debug.Assert(left.Length >= right.Length); 80for (; carry != 0 && i < left.Length; i++) 94Debug.Assert(bits.Length == left.Length); 104Debug.Assert(bits.Length == left.Length); 134Debug.Assert(left.Length >= right.Length); 156for (; carry != 0 && i < left.Length; i++)
System\Numerics\BigIntegerCalculator.DivRem.cs (64)
37Debug.Assert(quotient.Length == left.Length); 73Debug.Assert(quotient.Length == left.Length - right.Length + 1); 74Debug.Assert(remainder.Length == left.Length); 94Debug.Assert(quotient.Length == left.Length - right.Length + 1); 126Debug.Assert(remainder.Length == left.Length); 161Debug.Assert(left.Length >= 1); 163Debug.Assert(left.Length >= right.Length); 164Debug.Assert(quotient.Length == left.Length - right.Length + 1 165|| quotient.Length == 0); 168if (right.Length < DivideBurnikelZieglerThreshold || left.Length - right.Length < DivideBurnikelZieglerThreshold) 178Span<uint> leftCopy = (left.Length <= StackAllocThreshold ? 180: leftCopyFromPool = ArrayPool<uint>.Shared.Rent(left.Length)).Slice(0, left.Length); 186if (quotient.Length == 0) 188int quotientLength = left.Length - right.Length + 1; 210Debug.Assert(left.Length >= 1); 212Debug.Assert(left.Length >= right.Length); 214quotient.Length == 0 215|| quotient.Length == left.Length - right.Length + 1 216|| (CompareActual(left.Slice(left.Length - right.Length), right) < 0 && quotient.Length == left.Length - right.Length)); 241for (int i = left.Length; i >= right.Length; i--) 244uint t = (uint)i < (uint)left.Length ? left[i] : 0; 285if ((uint)n < (uint)quotient.Length) 288if ((uint)i < (uint)left.Length) 295Debug.Assert(left.Length >= right.Length); 314Debug.Assert(left.Length >= right.Length); 360Debug.Assert(quotient.Length == left.Length - right.Length + 1); 361Debug.Assert(remainder.Length == left.Length 362|| remainder.Length == 0); 406Debug.Assert(src.Length + sigmaDigit <= bits.Length); 419for (int i = 0; i < bits.Length; i++) 434int t = Math.Max(2, (a.Length + n - 1) / n); // Max(2, Ceil(a.Length/n)) 435Debug.Assert(t < a.Length || (t == a.Length && (int)a[^1] >= 0)); 447z.Slice(a.Length - (t - 2) * n).Clear(); 450if (quotientUpper.Length < n) 459Debug.Assert(!q.Slice(quotientUpper.Length).ContainsAnyExcept(0u)); 460q.Slice(0, quotientUpper.Length).CopyTo(quotientUpper); 487if (remainder.Length != 0) 490remainder.Slice(rt.Length).Clear(); 500for (int i = rt.Length - 1; i >= 0; i--) 525Debug.Assert(quotient.Length == right.Length); 526Debug.Assert(remainder.Length >= right.Length + 1); 542if (quotient.Length < left.Length) 544Debug.Assert(quotient.Length + 1 == left.Length); 548Divide(left.Slice(0, quotient.Length), right[0], quotient, ref carry); 557if (remainder.Length != 0) 571int quotientLength = Math.Min(left.Length - right.Length + 1, quotient.Length); 576if (r1.Length < remainder.Length) 578remainder.Slice(r1.Length).Clear(); 583Debug.Assert(!r1.Slice(remainder.Length).ContainsAnyExcept(0u)); 584r1.Slice(0, remainder.Length).CopyTo(remainder); 597Debug.Assert(quotient.Length == right.Length); 598Debug.Assert(remainder.Length >= right.Length + 1); 627Debug.Assert(2 * quotient.Length == right.Length); 628Debug.Assert(remainder.Length >= right.Length + 1); 666Span<uint> rr = remainder.Slice(0, d.Length + 1); 673Debug.Assert((uint)qi < (uint)quotient.Length); 685Debug.Assert(bits.Length == left.Length + right.Length);
System\Numerics\BigIntegerCalculator.FastReducer.cs (12)
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); 32r[r.Length - 1] = 1; 46Debug.Assert(value.Length <= _modulus.Length * 2); 49if (value.Length < _modulus.Length) 50return value.Length; 72Debug.Assert(bits.Length + k >= left.Length + right.Length); 109if (left.Length > k) 123return left.Length;
System\Numerics\BigIntegerCalculator.GcdInv.cs (17)
62Debug.Assert(result.Length == left.Length); 80Debug.Assert(left.Length >= 2); 81Debug.Assert(right.Length >= 2); 82Debug.Assert(left.Length >= right.Length); 93while (right.Length > 2) 182if (right.Length > 0) 190if (right.Length > 1) 205Debug.Assert(buffer.Length >= 2); 207if (buffer.Length > 2) 280Debug.Assert(x.Length >= 1); 281Debug.Assert(y.Length >= 1); 282Debug.Assert(x.Length >= y.Length); 288int length = y.Length; 306Debug.Assert(bits.Length >= maxLength); 308if (bits.Length > maxLength)
System\Numerics\BigIntegerCalculator.PowMod.cs (32)
23Debug.Assert(bits.Length == PowBound(power, value.Length)); 26Span<uint> temp = (bits.Length <= StackAllocThreshold ? 28: tempFromPool = ArrayPool<uint>.Shared.Rent(bits.Length)).Slice(0, bits.Length); 32Span<uint> valueCopy = (bits.Length <= StackAllocThreshold ? 34: valueCopyFromPool = ArrayPool<uint>.Shared.Rent(bits.Length)).Slice(0, bits.Length); 40bits.Slice(result.Length).Clear(); 50Debug.Assert(value.Length >= valueLength); 51Debug.Assert(temp.Length == result.Length); 52Debug.Assert(value.Length == temp.Length); 72Debug.Assert(leftLength <= left.Length); 95Debug.Assert(valueLength <= value.Length); 96Debug.Assert(temp.Length >= valueLength + valueLength); 212Debug.Assert(bits.Length == modulus.Length + modulus.Length); 218int size = Math.Max(value.Length, bits.Length); 238Span<uint> temp = (bits.Length <= StackAllocThreshold ? 240: tempFromPool = ArrayPool<uint>.Shared.Rent(bits.Length)).Slice(0, bits.Length); 261Debug.Assert(bits.Length == modulus.Length + modulus.Length); 266int size = Math.Max(value.Length, bits.Length); 287Span<uint> temp = (bits.Length <= StackAllocThreshold ? 289: tempFromPool = ArrayPool<uint>.Shared.Rent(bits.Length)).Slice(0, bits.Length); 320bits.Slice(result.Length).Clear(); 331size = r.Length - modulus.Length + 1; 358bits.Slice(result.Length).Clear(); 380bits.Slice(result.Length).Clear(); 391size = r.Length - modulus.Length + 1; 418bits.Slice(result.Length).Clear();
System\Numerics\BigIntegerCalculator.SquMul.cs (9)
23Debug.Assert(bits.Length == value.Length + value.Length); 133Debug.Assert(bits.Length == left.Length + 1); 162Debug.Assert(bits.Length >= left.Length + right.Length); 252Debug.Assert(bits.Length >= left.Length + right.Length); 274Debug.Assert(bitsLow.Length >= bitsHigh.Length); 309MultiplyKaratsuba(leftFold, rightFold, core, (leftFold.Length + 1) >> 1); 365Debug.Assert(core.Length >= left.Length); 396for (; carry != 0 && i < core.Length; i++)
System\Numerics\BigIntegerCalculator.Utils.cs (2)
70if (bits.Length >= modulus.Length) 76return bits.Length;
System\Numerics\Complex.cs (3)
2212if (destination.Length >= 6) 2223if (destination.Length >= 4) 2231if ((uint)(2 + imaginaryChars) < (uint)destination.Length)
System\Numerics\NumericsHelpers.cs (5)
113if (d.Length > 0) 129while (Vector512.IsHardwareAccelerated && d.Length - offset >= Vector512<uint>.Count) 136while (Vector256.IsHardwareAccelerated && d.Length - offset >= Vector256<uint>.Count) 143while (Vector128.IsHardwareAccelerated && d.Length - offset >= Vector128<uint>.Count) 150for (; offset < d.Length; offset++)
System.Security.Cryptography (323)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ReadLink.cs (3)
46int resultLength = ReadLink(ref pathReference, ref MemoryMarshal.GetReference(spanBuffer), spanBuffer.Length); 54else if (resultLength < spanBuffer.Length) 74arrayBuffer = ArrayPool<byte>.Shared.Rent(spanBuffer.Length * 2);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.BIO.cs (2)
29return BioGets(b, pBuf, buf.Length); 38internal static int BioRead(SafeBioHandle b, Span<byte> data) => BioRead(b, data, data.Length);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Cipher.cs (3)
154if (!EvpCipherGetGcmTag(ctx, ref MemoryMarshal.GetReference(tag), tag.Length)) 169if (!EvpCipherGetAeadTag(ctx, ref MemoryMarshal.GetReference(tag), tag.Length)) 214if (!EvpCipherGetCcmTag(ctx, ref MemoryMarshal.GetReference(tag), tag.Length))
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.cs (5)
84destination.Length); 89return EvpDigestFinalXOF(ctx, destination, (uint)destination.Length); 94return EvpDigestCurrentXOF(ctx, destination, (uint)destination.Length); 99return EvpDigestXOFOneShot(type, source, source.Length, destination, (uint)destination.Length); 104int ret = EvpDigestSqueeze(ctx, destination, (uint)destination.Length, out bool haveFeature);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Kdf.cs (4)
83destination.Length); 108destination.Length); 133destination.Length); 161destination.Length);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Kem.cs (3)
154int ret = CryptoNative_EvpKemDecapsulate(key, GetExtraHandle(key), ciphertext, ciphertext.Length, sharedSecret, sharedSecret.Length); 184int ret = CryptoNative_EvpKemEncapsulate(key, GetExtraHandle(key), ciphertext, ciphertext.Length, sharedSecret, sharedSecret.Length);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Mac.cs (3)
78destination.Length, 90int ret = CryptoNative_EvpMacFinal(ctx, mac, mac.Length); 102int ret = CryptoNative_EvpMacCurrent(ctx, mac, mac.Length);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.Ecdh.cs (1)
34(uint)destination.Length);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.EcDsa.cs (1)
34destination.Length);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.ExportKeyContents.cs (1)
21int ret = action(key, destination, destination.Length);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.MLDsa.cs (1)
84destination, destination.Length);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.Rsa.cs (3)
74destination.Length); 111destination.Length); 152destination.Length);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.EvpPkey.SlhDsa.cs (1)
93destination, destination.Length);
src\libraries\Common\src\Interop\Unix\System.Security.Cryptography.Native\Interop.Hmac.cs (1)
39int size = destination.Length;
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Security\Cryptography\DSAOpenSsl.cs (4)
236if (destination.Length < p1363SignatureSize) 251if (destination.Length >= maxSignatureSize) 255else if (maxSignatureSize > signDestination.Length) 287if (signatureLength > destination.Length)
src\libraries\Common\src\System\Security\Cryptography\ECDiffieHellmanDerivation.cs (3)
223int len = Math.Min(p.Length, retSpan.Length); 228if (retSpan.Length == 0)
src\libraries\Common\src\System\Security\Cryptography\ECDsaOpenSsl.cs (1)
119if (destination.Length < encodedSize)
src\libraries\Common\src\System\Security\Cryptography\MLDsa.cs (4)
127if (destination.Length < Algorithm.SignatureSizeInBytes) 624if (destination.Length < Algorithm.PublicKeySizeInBytes) 651if (destination.Length < Algorithm.SecretKeySizeInBytes) 678if (destination.Length < Algorithm.PrivateSeedSizeInBytes)
src\libraries\Common\src\System\Security\Cryptography\MLKem.cs (7)
115if (ciphertext.Length != Algorithm.CiphertextSizeInBytes) 122if (sharedSecret.Length != Algorithm.SharedSecretSizeInBytes) 204if (sharedSecret.Length != Algorithm.SharedSecretSizeInBytes) 279if (destination.Length != Algorithm.PrivateSeedSizeInBytes) 510if (destination.Length != Algorithm.DecapsulationKeySizeInBytes) 564if (destination.Length != Algorithm.EncapsulationKeySizeInBytes) 697if (destination.Length < MinimumPossiblePkcs8MLKemKey)
src\libraries\Common\src\System\Security\Cryptography\PasswordBasedEncryption.cs (10)
75Debug.Assert(destination.Length >= encryptedData.Length); 185if (byteCount > buf.Length) 201Debug.Assert(written == buf.Length); 470if (byteCount > buf.Length) 486Debug.Assert(written == buf.Length); 503CryptoPool.Return(rented, buf.Length); 925byte[] rentedDestination = CryptoPool.Rent(destination.Length); 971CryptoPool.Return(rentedDestination, destination.Length); 1006if (!hasher.TryGetHashAndReset(t, out tLength) || tLength != t.Length) 1014t.Slice(0, dk.Length).CopyTo(dk);
src\libraries\Common\src\System\Security\Cryptography\Pkcs\Pkcs12Builder.cs (3)
212if (!mac.TryGetHashAndReset(macSpan, out int bytesWritten) || bytesWritten != macSpan.Length) 214Debug.Fail($"TryGetHashAndReset wrote {bytesWritten} of {macSpan.Length} bytes"); 356if (destination.Length < _sealedData.Length)
src\libraries\Common\src\System\Security\Cryptography\Pkcs12Kdf.cs (19)
183if (!hash.TryGetHashAndReset(hashBuf, out int bytesWritten) || bytesWritten != hashBuf.Length) 185Debug.Fail($"Hash output wrote {bytesWritten} bytes when {hashBuf.Length} was expected"); 200if (hashBuf.Length >= destination.Length) 202hashBuf.Slice(0, destination.Length).CopyTo(destination); 207destination = destination.Slice(hashBuf.Length); 238Debug.Assert(into.Length == addend.Length); 242for (int i = into.Length - 1; i >= 0; i--) 254while (destination.Length > 0) 256if (destination.Length >= bytes.Length) 263bytes.Slice(0, destination.Length).CopyTo(destination); 273Debug.Assert(destination.Length % 2 == 0); 275while (destination.Length > 0) 277if (destination.Length >= fullCopyLen) 288Span<byte> nullTerminator = destination.Slice(0, Math.Min(2, destination.Length)); 290destination = destination.Slice(nullTerminator.Length); 294ReadOnlySpan<char> trimmed = password.Slice(0, destination.Length / 2); 298if (count != destination.Length) 300Debug.Fail($"Partial copy wrote {count} bytes of {destination.Length} expected");
src\libraries\Common\src\System\Security\Cryptography\RSAOpenSsl.cs (7)
123if (destination.Length < keySizeBytes) 129if (keySizeBytes > tmp.Length) 138if (destination.Length < written) 183if (destination.Length < rsaSize) 185Debug.Fail($"Caller is responsible for temporary decryption buffer creation destination. destination.Length: {destination.Length}, needed: {rsaSize}"); 250if (destination.Length < rsaSize) 763if (destination.Length < bytesRequired)
src\libraries\Common\src\System\Security\Cryptography\RsaPaddingProcessor.cs (22)
125int k = destination.Length; 134Span<byte> mInEM = destination.Slice(destination.Length - source.Length); 135Span<byte> ps = destination.Slice(2, destination.Length - source.Length - 3); 138destination[ps.Length + 2] = 0; 157int spaceRemain = destination.Length - len; 161len = Choose(spaceRemainSign, destination.Length, len); 271if (destination.Length - 11 < tLen) 277int paddingLength = destination.Length - tLen - 3; 303int maxInput = checked(destination.Length - hLen - hLen - 2); 325Span<byte> mDest = db.Slice(db.Length - source.Length); 326Span<byte> ps = db.Slice(hLen, db.Length - hLen - 1 - mDest.Length); 327Span<byte> psEnd = db.Slice(hLen + ps.Length, 1); 349dbMask = CryptoPool.Rent(db.Length); 350dbMaskSpan = new Span<byte>(dbMask, 0, db.Length); 410destination.Slice(0, destination.Length - emLen).Clear(); 413Span<byte> em = destination.Slice(destination.Length - emLen, emLen); 557ReadOnlySpan<byte> salt = dbMask.Slice(dbMask.Length - sLen); 595while (writePtr.Length > 0) 601if (writePtr.Length >= hLen) 624tmp.Slice(0, writePtr.Length).CopyTo(writePtr); 637if (a.Length != b.Length)
src\libraries\Common\src\System\Security\Cryptography\SlhDsa.cs (4)
128if (destination.Length != signatureSizeInBytes) 398if (destination.Length < MinimumPossiblePkcs8SlhDsaKey) 855if (destination.Length != publicKeySizeInBytes) 906if (destination.Length != secretKeySizeInBytes)
src\libraries\Common\src\System\Security\Cryptography\SP800108HmacCounterKdf.cs (4)
275CheckPrfOutputLength(destination.Length, nameof(destination)); 355CheckPrfOutputLength(destination.Length, nameof(destination)); 431CheckPrfOutputLength(destination.Length, nameof(destination)); 482CheckPrfOutputLength(destination.Length, nameof(destination));
src\libraries\Common\src\System\Security\Cryptography\Utf8DataEncoding.cs (1)
18_buffer = (uint)maxLength <= stackBuffer.Length ?
src\libraries\Common\src\System\Security\Cryptography\X509Certificates\X509CertificateLoader.Pkcs12.cs (2)
950if (!mac.TryGetHashAndReset(macKey, out int bytesWritten) || bytesWritten != macKey.Length) 952Debug.Fail($"TryGetHashAndReset wrote {bytesWritten} of {macKey.Length} bytes");
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\Common\src\System\Text\ValueUtf8Converter.cs (1)
27if (_bytes.Length < maxSize)
System\Security\Cryptography\AesCcm.OpenSsl.cs (5)
47Interop.Crypto.EvpCipherSetCcmTagLength(ctx, tag.Length); 77if (ciphertextBytesWritten != ciphertext.Length) 79Debug.Fail($"CCM encrypt wrote {ciphertextBytesWritten} of {ciphertext.Length} bytes."); 134if (plaintextBytesWritten != plaintext.Length) 136Debug.Fail($"CCM decrypt wrote {plaintextBytesWritten} of {plaintext.Length} bytes.");
System\Security\Cryptography\AesGcm.OpenSsl.cs (4)
69if (ciphertextBytesWritten != ciphertext.Length) 71Debug.Fail($"GCM encrypt wrote {ciphertextBytesWritten} of {ciphertext.Length} bytes."); 117if (plaintextBytesWritten != plaintext.Length) 119Debug.Fail($"GCM decrypt wrote {plaintextBytesWritten} of {plaintext.Length} bytes.");
System\Security\Cryptography\AsnFormatter.cs (1)
41Debug.Assert(j == hexOrder.Length);
System\Security\Cryptography\AsymmetricAlgorithmHelpers.Der.cs (5)
68Debug.Assert(destination.Length >= encodedSize); 192if (signatureField.Length > response.Length) 194if (signatureField.Length != response.Length + 1 || 199Debug.Fail($"A signature field was longer ({signatureField.Length}) than expected ({response.Length})"); 209int writeOffset = response.Length - signatureField.Length;
System\Security\Cryptography\Base64Transforms.cs (10)
55Debug.Assert(written == output.Length); 163bytesToTransform = transformBuffer.Length; 172ReturnToCryptoPool(transformBufferArray, transformBuffer.Length); 179ReturnToCryptoPool(transformBufferArray, transformBuffer.Length); 209bytesToTransform = transformBuffer.Length; 217ReturnToCryptoPool(transformBufferArray, transformBuffer.Length); 228ReturnToCryptoPool(transformBufferArray, transformBuffer.Length); 275int len = tmpBuffer.Length; 294int bytesToTransform = transformBuffer.Length; 301transformBuffer.Slice(transformBuffer.Length - _inputIndex).CopyTo(_inputBuffer);
System\Security\Cryptography\ChaCha20Poly1305.OpenSsl.cs (4)
66if (ciphertextBytesWritten != ciphertext.Length) 68Debug.Fail($"ChaCha20Poly1305 encrypt wrote {ciphertextBytesWritten} of {ciphertext.Length} bytes."); 114if (plaintextBytesWritten != plaintext.Length) 116Debug.Fail($"ChaCha20Poly1305 decrypt wrote {plaintextBytesWritten} of {plaintext.Length} bytes.");
System\Security\Cryptography\CryptographicOperations.cs (4)
190if (destination.Length < hashSizeInBytes) 267CheckDestinationSize(hashSizeInBytes, destination.Length); 505if (destination.Length < hashSizeInBytes) 617CheckDestinationSize(hashSizeInBytes, destination.Length);
System\Security\Cryptography\DSA.cs (1)
883Debug.Assert(tmp.Length == HashBufferStackSize);
System\Security\Cryptography\ECDsa.cs (4)
147if (maxSignatureSize > signature.Length) 429if (maxSignatureSize > signature.Length) 1018if (hash.Length <= destination.Length) 1203Debug.Assert(tmp.Length == HashBufferStackSize);
System\Security\Cryptography\HashAlgorithm.cs (2)
57if (destination.Length < HashSizeValue / 8) 265if (destination.Length >= hashSizeInBytes)
System\Security\Cryptography\HashProvider.cs (1)
52if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\HashProviderDispenser.Unix.cs (3)
45if (hashSize <= 0 || destination.Length < hashSize) 63if (hashSize <= 0 || destination.Length < hashSize) 70uint length = (uint)destination.Length;
System\Security\Cryptography\Helpers.cs (1)
346return ref buffer.Length != 0 ? ref MemoryMarshal.GetReference(buffer) : ref Unsafe.AsRef<byte>((void*)1);
System\Security\Cryptography\HKDF.cs (6)
55if (prk.Length < hashLength) 60if (prk.Length > hashLength) 122if (output.Length == 0) 130if (output.Length > maxOkmLength) 179if (output.Length == 0) 184if (output.Length > maxOkmLength)
System\Security\Cryptography\HKDFManagedImplementation.cs (7)
16Debug.Assert(written == prk.Length, $"Bytes written is {written} bytes which does not match output length ({prk.Length} bytes)"); 59if (remainingOutput.Length >= hashLength) 67if (remainingOutput.Length > 0) 72lastChunk.Slice(0, remainingOutput.Length).CopyTo(remainingOutput); 98Debug.Assert(written == output.Length, $"Bytes written is {written} bytes which does not match output length ({output.Length} bytes)");
System\Security\Cryptography\HMACMD5.cs (2)
152if (destination.Length < HashSizeInBytes) 189if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\HMACSHA1.cs (2)
154if (destination.Length < HashSizeInBytes) 190if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\HMACSHA256.cs (2)
146if (destination.Length < HashSizeInBytes) 182if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\HMACSHA3_256.cs (2)
184if (destination.Length < HashSizeInBytes) 220if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\HMACSHA3_384.cs (2)
184if (destination.Length < HashSizeInBytes) 220if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\HMACSHA3_512.cs (2)
184if (destination.Length < HashSizeInBytes) 220if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\HMACSHA384.cs (2)
163if (destination.Length < HashSizeInBytes) 199if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\HMACSHA512.cs (2)
160if (destination.Length < HashSizeInBytes) 196if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\IncrementalHash.cs (8)
146/// <paramref name="destination"/> has a <see cref="Span{T}.Length"/> value less 153if (destination.Length < HashLengthInBytes) 163if (destination.Length < HashLengthInBytes) 175Debug.Assert(destination.Length >= HashLengthInBytes); 218/// <paramref name="destination"/> has a <see cref="Span{T}.Length"/> value less 225if (destination.Length < HashLengthInBytes) 253if (destination.Length < HashLengthInBytes) 265Debug.Assert(destination.Length >= HashLengthInBytes);
System\Security\Cryptography\Kmac128.cs (2)
130Debug.Assert(written == destination.Length); 170Debug.Assert(written == destination.Length);
System\Security\Cryptography\Kmac256.cs (2)
130Debug.Assert(written == destination.Length); 170Debug.Assert(written == destination.Length);
System\Security\Cryptography\KmacXof128.cs (2)
130Debug.Assert(written == destination.Length); 170Debug.Assert(written == destination.Length);
System\Security\Cryptography\KmacXof256.cs (2)
130Debug.Assert(written == destination.Length); 170Debug.Assert(written == destination.Length);
System\Security\Cryptography\LiteHash.OpenSsl.cs (2)
69return destination.Length; 75return destination.Length;
System\Security\Cryptography\LiteHash.Unix.cs (8)
71return destination.Length; 159Debug.Assert(destination.Length >= _hashSizeInBytes); 161uint length = (uint)destination.Length; 175uint length = (uint)destination.Length; 245Debug.Assert(destination.Length >= _hashSizeInBytes); 247int length = destination.Length; 255Debug.Assert(destination.Length >= _hashSizeInBytes); 257int length = destination.Length;
System\Security\Cryptography\LiteHashProvider.Xof.cs (2)
17Debug.Assert(written == destination.Length); 39Debug.Assert(written == destination.Length);
System\Security\Cryptography\MD5.cs (2)
110if (destination.Length < HashSizeInBytes) 146if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\OpenSslCipher.cs (1)
52Debug.Assert(input.Length <= output.Length);
System\Security\Cryptography\PemEncoding.cs (4)
235Debug.Assert(destination.Length >= size); 465if (destination.Length < encodedSize) 528if (destination.Length < encodedSize) 719if (charsWritten != destination.Length)
System\Security\Cryptography\RandomNumberGenerator.cs (22)
59byte[] array = ArrayPool<byte>.Shared.Rent(data.Length); 62GetBytes(array, 0, data.Length); 63new ReadOnlySpan<byte>(array, 0, data.Length).CopyTo(data); 67Array.Clear(array, 0, data.Length); 82byte[] array = ArrayPool<byte>.Shared.Rent(data.Length); 89new ReadOnlySpan<byte>(array, 0, data.Length).CopyTo(data); 93Array.Clear(array, 0, data.Length); 291int n = values.Length; 318int needed = (destination.Length + 1) >>> 1; 323if (destination.Length % 2 != 0) 335needed = destination.Length / 2; 344destination = destination.Slice(remainingRandom.Length * 2); 373if (destination.Length < randomBytes.Length) 375randomBytes = randomBytes.Slice(0, destination.Length); 380for (int i = 0; i < randomBytes.Length; i++) 385destination = destination.Slice(randomBytes.Length); 401if (destination.Length * 2 < randomBytes.Length) 403randomBytes = randomBytes.Slice(0, destination.Length * 2); 411if ((uint)i >= (uint)destination.Length) 431for (int i = 0; i < destination.Length; i++)
System\Security\Cryptography\RandomNumberGeneratorImplementation.cs (6)
21if (data.Length > 0) 23fixed (byte* ptr = data) GetBytes(ptr, data.Length); 42if (data.Length > 0) 44fixed (byte* ptr = data) GetBytes(ptr, data.Length); 62while (data.Length > 0) 97data = data.Slice(data.Length - zerosFound);
System\Security\Cryptography\Rfc2898DeriveBytes.cs (1)
186int cb = destination.Length;
System\Security\Cryptography\RSA.cs (4)
106if (destination.Length >= result.Length) 121if (destination.Length >= result.Length) 330if (destination.Length >= result.Length) 345if (destination.Length >= result.Length)
System\Security\Cryptography\SHA1.cs (2)
105if (destination.Length < HashSizeInBytes) 140if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\SHA256.cs (2)
105if (destination.Length < HashSizeInBytes) 140if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\SHA3_256.cs (2)
138if (destination.Length < HashSizeInBytes) 176if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\SHA3_384.cs (2)
139if (destination.Length < HashSizeInBytes) 177if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\SHA3_512.cs (2)
138if (destination.Length < HashSizeInBytes) 176if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\SHA384.cs (2)
104if (destination.Length < HashSizeInBytes) 139if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\SHA512.cs (2)
104if (destination.Length < HashSizeInBytes) 139if (destination.Length < HashSizeInBytes)
System\Security\Cryptography\SP800108HmacCounterKdfImplementationManaged.cs (7)
28if (destination.Length == 0) 33Debug.Assert(destination.Length <= 0x1FFFFFFF); 49BinaryPrimitives.WriteUInt32BigEndian(lBuffer, (uint)destination.Length * 8U); 60if (destination.Length >= hash.HashLengthInBytes) 68Debug.Assert(hmacBufferWritten > destination.Length); 69hmacBuffer.Slice(0, destination.Length).CopyTo(destination); 87if (destination.Length == 0)
System\Security\Cryptography\SP800108HmacCounterKdfImplementationOpenSsl.cs (1)
102if (destination.Length == 0)
System\Security\Cryptography\SymmetricAlgorithm.cs (1)
776|| (uint)written > decryptBuffer.Length)
System\Security\Cryptography\SymmetricPadding.cs (5)
48if (destination.Length < count) 63if (destination.Length < ansiSize) 80if (destination.Length < isoSize) 97if (destination.Length < pkcsSize) 118if (destination.Length < zeroSize)
System\Security\Cryptography\UniversalCryptoDecryptor.cs (1)
114if (decryptedBytes.Length > 0)
System\Security\Cryptography\UniversalCryptoOneShot.cs (6)
38if (output.Length >= input.Length) 69if (!depaddingRequired || input.Length - cipher.BlockSizeInBytes > output.Length) 93if (output.Length < depaddedLength) 144if (output.Length - writtenToOutput < depaddedLength) 185if (unpaddedLength > output.Length) 212if (output.Length < ciphertextLength)
System\Security\Cryptography\X509Certificates\OpenSslCrlCache.cs (1)
284if (SHA256.HashData(utf16Url, hash) != hash.Length)
System\Security\Cryptography\X509Certificates\OpenSslX509ChainProcessor.cs (1)
283if (chainSize <= tempChain.Length)
System\Security\Cryptography\X509Certificates\X500NameEncoder.cs (1)
562Debug.Assert(destination.Length >= chars.Length);
System\Security\Cryptography\X509Certificates\X509Certificate2Collection.cs (2)
568charsWritten != destination.Length) 616if (buffer.Length < certSize)
System.Security.Cryptography.Cose (4)
System\Security\Cryptography\Cose\CoseMultiSignMessage.cs (2)
350if (expectedSize > destination.Length) 578if (destination.Length < GetEncodedLength())
System\Security\Cryptography\Cose\CoseSign1Message.cs (2)
281if (expectedSize > destination.Length) 767if (destination.Length < GetEncodedLength())
System.Security.Cryptography.Pkcs (43)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Security\Cryptography\PasswordBasedEncryption.cs (10)
75Debug.Assert(destination.Length >= encryptedData.Length); 185if (byteCount > buf.Length) 201Debug.Assert(written == buf.Length); 470if (byteCount > buf.Length) 486Debug.Assert(written == buf.Length); 503CryptoPool.Return(rented, buf.Length); 925byte[] rentedDestination = CryptoPool.Rent(destination.Length); 971CryptoPool.Return(rentedDestination, destination.Length); 1006if (!hasher.TryGetHashAndReset(t, out tLength) || tLength != t.Length) 1014t.Slice(0, dk.Length).CopyTo(dk);
src\libraries\Common\src\System\Security\Cryptography\Pkcs\Pkcs12Builder.cs (3)
212if (!mac.TryGetHashAndReset(macSpan, out int bytesWritten) || bytesWritten != macSpan.Length) 214Debug.Fail($"TryGetHashAndReset wrote {bytesWritten} of {macSpan.Length} bytes"); 356if (destination.Length < _sealedData.Length)
src\libraries\Common\src\System\Security\Cryptography\Pkcs12Kdf.cs (19)
183if (!hash.TryGetHashAndReset(hashBuf, out int bytesWritten) || bytesWritten != hashBuf.Length) 185Debug.Fail($"Hash output wrote {bytesWritten} bytes when {hashBuf.Length} was expected"); 200if (hashBuf.Length >= destination.Length) 202hashBuf.Slice(0, destination.Length).CopyTo(destination); 207destination = destination.Slice(hashBuf.Length); 238Debug.Assert(into.Length == addend.Length); 242for (int i = into.Length - 1; i >= 0; i--) 254while (destination.Length > 0) 256if (destination.Length >= bytes.Length) 263bytes.Slice(0, destination.Length).CopyTo(destination); 273Debug.Assert(destination.Length % 2 == 0); 275while (destination.Length > 0) 277if (destination.Length >= fullCopyLen) 288Span<byte> nullTerminator = destination.Slice(0, Math.Min(2, destination.Length)); 290destination = destination.Slice(nullTerminator.Length); 294ReadOnlySpan<char> trimmed = password.Slice(0, destination.Length / 2); 298if (count != destination.Length) 300Debug.Fail($"Partial copy wrote {count} bytes of {destination.Length} expected");
System\Security\Cryptography\Pkcs\CmsSignature.cs (3)
158int fieldSize = ieeeSignature.Length / 2; 161fieldSize * 2 == ieeeSignature.Length, 162$"ieeeSignature.Length ({ieeeSignature.Length}) must be even");
System\Security\Cryptography\Pkcs\Rfc3161TimestampRequest.cs (1)
153if (destination.Length < _encodedBytes.Length)
System\Security\Cryptography\Pkcs\Rfc3161TimestampToken.cs (3)
191$"TryGetHashAndReset did not fit in {stackSpan.Length} for hash {hashAlgorithmId.Value}"); 489written != thumbprint.Length || 527$"TryGetCertHash did not fit in {thumbprint.Length} for hash {certId2.Value.HashAlgorithm.Algorithm}");
System\Security\Cryptography\Pkcs\Rfc3161TimestampTokenInfo.cs (1)
215if (destination.Length < _encodedBytes.Length)
System.Security.Cryptography.ProtectedData (2)
src\libraries\Common\src\Interop\Windows\Kernel32\Interop.FormatMessage.cs (1)
46int length = FormatMessage(flags, moduleHandle, unchecked((uint)errorCode), 0, bufferPtr, stackBuffer.Length, IntPtr.Zero);
System\Security\Cryptography\ProtectedData.cs (1)
388if (outputBlob.cbData > outputSpan.Length)
System.Security.Cryptography.Xml (3)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
System.ServiceModel.NetFramingBase (2)
System\ServiceModel\Channels\Connection.cs (2)
242byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length); 243Memory<byte> memBuffer = new Memory<byte>(sharedBuffer, 0, buffer.Length);
System.Text.Encoding.CodePages (1)
System\Text\BaseCodePageEncoding.netcoreapp.cs (1)
18Debug.Assert(bytesRead == codePageIndex.Length);
System.Text.Encodings.Web (59)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Text\Encodings\Web\AllowedBmpCodePointsBitmap.cs (2)
70Debug.Assert(definedCharsBitmapAsLittleEndian.Length == thisAllowedCharactersBitmap.Length * sizeof(uint)); 87for (int i = 0; i < thisAllowedCharactersBitmap.Length; i++)
System\Text\Encodings\Web\DefaultHtmlEncoder.cs (8)
109if ((uint)destination.Length <= (uint)idxOfSemicolon) { goto OutOfSpaceInner; } 118for (int i = destination.Length - 1; (uint)destination.Length > (uint)i; i--) 125return destination.Length + 4; 184if ((uint)destination.Length <= (uint)idxOfSemicolon) { goto OutOfSpaceInner; } 195for (int i = destination.Length - 1; (uint)destination.Length > (uint)i; i--) 202return destination.Length + 4;
System\Text\Encodings\Web\DefaultJavaScriptEncoder.cs (6)
117if ((uint)destination.Length <= 1) { goto OutOfSpace; } 135if ((uint)destination.Length <= 5) { goto OutOfSpaceInner; } 146if ((uint)destination.Length <= 11) { goto OutOfSpaceInner; } 168if ((uint)destination.Length <= 1) { goto OutOfSpace; } 186if ((uint)destination.Length <= 5) { goto OutOfSpaceInner; } 197if ((uint)destination.Length <= 11) { goto OutOfSpaceInner; }
System\Text\Encodings\Web\DefaultUrlEncoder.cs (8)
146if ((uint)destination.Length <= 2) { goto OutOfSpace; } 151if ((uint)destination.Length <= 5) { goto OutOfSpace; } 156if ((uint)destination.Length <= 8) { goto OutOfSpace; } 161if ((uint)destination.Length <= 11) { goto OutOfSpace; } 175if ((uint)destination.Length <= 2) { goto OutOfSpace; } 180if ((uint)destination.Length <= 5) { goto OutOfSpace; } 185if ((uint)destination.Length <= 8) { goto OutOfSpace; } 190if ((uint)destination.Length <= 11) { goto OutOfSpace; }
System\Text\Encodings\Web\OptimizedInboxTextEncoder.cs (3)
153if ((uint)destination.Length <= (uint)dstIdx) 173if ((uint)destination.Length <= (uint)dstIdxTemp) 290if ((uint)destination.Length <= (uint)dstIdxTemp)
System\Text\Encodings\Web\TextEncoder.cs (15)
46return TryEncodeUnicodeScalar((int)unicodeScalar, pBuffer, buffer.Length, out charsWritten); 76if ((uint)utf8Destination.Length > (uint)dstIdx) 168if (charsWrittenJustNow == 0 || (uint)charsWrittenJustNow > (uint)destBuffer.Length) 175stringBuilder.Length -= destBuffer.Length - charsWrittenJustNow; 293if (utf8Destination.Length < utf8Source.Length) 295sourceSearchSpace = utf8Source.Slice(0, utf8Destination.Length); 330int originalUtf8DestinationLength = utf8Destination.Length; 355if ((uint)dstIdxTemp >= (uint)utf8Destination.Length) 383bytesWritten = originalUtf8DestinationLength - utf8Destination.Length; 423if (destination.Length < source.Length) 425sourceSearchSpace = source.Slice(0, destination.Length); 455int originalDestinationLength = destination.Length; 499charsWritten = originalDestinationLength - destination.Length; 527if (charsWrittenJustNow == 0 || (uint)charsWrittenJustNow > (uint)scratchBuffer.Length) 580if (destination.Length < source.Length)
System.Text.Json (46)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\System.Text.Json\Common\JsonCamelCaseNamingPolicy.cs (2)
30for (int i = 0; i < chars.Length; i++) 37bool hasNext = (i + 1 < chars.Length);
src\libraries\System.Text.Json\Common\JsonHelpers.cs (4)
64Span<(TKey, int)> keys = span.Length <= StackallocThreshold 65? (stackalloc (TKey, int)[StackallocThreshold]).Slice(0, span.Length) 66: new (TKey, int)[span.Length]; 68for (int i = 0; i < keys.Length; i++)
src\libraries\System.Text.Json\Common\JsonSeparatorNamingPolicy.cs (2)
146if (charsWritten == destination.Length) 156int newSize = checked(destination.Length * 2);
System\Text\Json\Document\JsonDocument.TryGetProperty.cs (1)
187Span<byte> utf8Unescaped = remaining <= utf8UnescapedStack.Length ?
System\Text\Json\JsonEncodedText.cs (1)
91Debug.Assert(expectedByteCount == utf8Bytes.Length);
System\Text\Json\Reader\JsonReaderHelper.cs (3)
93if (JsonHelpers.IsValidUnescapedDateTimeOffsetParseLength(sourceUnescaped.Length) 115if (JsonHelpers.IsValidUnescapedDateTimeOffsetParseLength(sourceUnescaped.Length) 137if (utf8Unescaped.Length == JsonConstants.MaximumFormatGuidLength
System\Text\Json\Reader\JsonReaderHelper.Unescaping.cs (4)
446Debug.Assert(destination.Length >= source.Length); 459Debug.Assert(destination.Length >= source.Length); 496if (written == destination.Length) 601if ((uint)(written + nextUnescapedSegmentLength) >= (uint)destination.Length)
System\Text\Json\Reader\Utf8JsonReader.MultiSegment.cs (1)
588int amountToWrite = Math.Min(span.Length, readSoFar.Length - written);
System\Text\Json\Writer\JsonWriterHelper.cs (1)
15Debug.Assert(buffer.Length >= indent);
System\Text\Json\Writer\JsonWriterHelper.Date.cs (6)
51Debug.Assert(buffer.Length == maxDateTimeLength || 52buffer.Length == maxDateTimeLength + 1 || 53buffer.Length == JsonConstants.MaximumFormatDateTimeOffsetLength); 77bytesWritten = buffer.Length; 83if (buffer.Length == maxDateTimeLength) 88else if (buffer.Length == JsonConstants.MaximumFormatDateTimeOffsetLength)
System\Text\Json\Writer\Utf8JsonWriter.WriteValues.StringSegment.cs (4)
408if (combinedBuffer.Length is 3) 416Debug.Assert(combinedBuffer.Length is 1 or 2); 543if ((uint)total >= (uint)dest.Length) 554if ((uint)total >= (uint)dest.Length)
System.Text.Json.SourceGeneration (18)
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (14)
32Debug.Assert(value <= _span.Length); 53if ((uint)pos < (uint)span.Length) 69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 113if ((ulong)(uint)pos + (ulong)(uint)length <= (ulong)(uint)span.Length) // same guard condition as in Span<T>.Slice on 64-bit 128Grow(_span.Length - pos + length); 137Debug.Assert(_pos == _span.Length); 200int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 210nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
src\libraries\System.Text.Json\Common\JsonCamelCaseNamingPolicy.cs (2)
30for (int i = 0; i < chars.Length; i++) 37bool hasNext = (i + 1 < chars.Length);
src\libraries\System.Text.Json\Common\JsonSeparatorNamingPolicy.cs (2)
146if (charsWritten == destination.Length) 156int newSize = checked(destination.Length * 2);
System.Text.RegularExpressions (47)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (14)
32Debug.Assert(value <= _span.Length); 53if ((uint)pos < (uint)span.Length) 69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 113if ((ulong)(uint)pos + (ulong)(uint)length <= (ulong)(uint)span.Length) // same guard condition as in Span<T>.Slice on 64-bit 128Grow(_span.Length - pos + length); 137Debug.Assert(_pos == _span.Length); 200int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 210nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
System\Text\RegularExpressions\Regex.Replace.cs (2)
224for (int i = 0; i < span.Length; i++) 231for (int i = 0; i < span.Length; i++)
System\Text\RegularExpressions\RegexCharClass.cs (9)
672numCategories == categories.Length) 687numCategories == categories.Length) 712if (numCategories == categories.Length) 733if (numCategories == categories.Length) 856if (++evaluated > chars.Length) 1063Debug.Assert(twoChars.Length >= 2); 1600span[SetLengthIndex] = (char)(span.Length - SetStartIndex); 1611Debug.Assert(i == span.Length); 1989Span<char> invertedGroup = group.Length <= scratch.Length ? scratch.Slice(0, group.Length) : new char[group.Length];
System\Text\RegularExpressions\RegexReplacement.cs (2)
265int length = ((span.Length / 2) - 1) * replacement.Length; 266for (int i = 1; i < span.Length; i += 2) // the count of each pair is the second item
System\Text\RegularExpressions\Symbolic\RegexNodeConverter.cs (3)
428Debug.Assert(cat >= 0 && cat < categoryCodes.Length, $"Expected {cat} to be in range [0, {categoryCodes.Length})."); 507for (int i = 0; i < catCodes.Length; i++)
System.Text.RegularExpressions.Generator (40)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (14)
32Debug.Assert(value <= _span.Length); 53if ((uint)pos < (uint)span.Length) 69if (source.Length == 1 && (uint)pos < (uint)span.Length) 83if ((uint)(_pos + source.Length) > (uint)_span.Length) 85Grow(_span.Length - _pos + source.Length); 96if ((uint)(_pos + source.Length) > (uint)_span.Length) 113if ((ulong)(uint)pos + (ulong)(uint)length <= (ulong)(uint)span.Length) // same guard condition as in Span<T>.Slice on 64-bit 128Grow(_span.Length - pos + length); 137Debug.Assert(_pos == _span.Length); 200int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 210nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexCharClass.cs (9)
672numCategories == categories.Length) 687numCategories == categories.Length) 712if (numCategories == categories.Length) 733if (numCategories == categories.Length) 856if (++evaluated > chars.Length) 1063Debug.Assert(twoChars.Length >= 2); 1620span[SetLengthIndex] = (char)(span.Length - SetStartIndex); 1632Debug.Assert(i == span.Length); 1989Span<char> invertedGroup = group.Length <= scratch.Length ? scratch.Slice(0, group.Length) : new char[group.Length];
System.Web.HttpUtility (19)
src\libraries\Common\src\System\HexConverter.cs (3)
167Debug.Assert(chars.Length >= bytes.Length * 2); 360Debug.Assert(chars.Length / 2 == bytes.Length, "Target buffer not right-sized for provided characters"); 366while (j < bytes.Length)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (14)
39Debug.Assert(value <= _chars.Length); 44public int Capacity => _chars.Length; 52if ((uint)capacity > (uint)_chars.Length) 136if (_pos > _chars.Length - count) 156if (_pos > (_chars.Length - count)) 176if ((uint)pos < (uint)chars.Length) 196if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. 210if (pos > _chars.Length - s.Length) 225if (_pos > _chars.Length - count) 231for (int i = 0; i < dst.Length; i++) 241if (pos > _chars.Length - value.Length) 254if (origPos > _chars.Length - length) 282Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed."); 290Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Web\Util\HttpEncoder.cs (2)
684for (int i = idxOfFirstSurrogate; (uint)i < (uint)chars.Length; i++) 688if ((uint)(i + 1) >= (uint)chars.Length || !char.IsLowSurrogate(chars[i + 1]))
System.Windows.Forms (16)
System\Windows\Forms\ActiveX\AxHost.VBFormat.cs (2)
53if (format.Length >= buffer.Length) 56format = format[..(buffer.Length - 1)];
System\Windows\Forms\ActiveX\DataStreamFromComStream.cs (1)
78_comStream->Read(ch, (uint)buffer.Length, &bytesRead);
System\Windows\Forms\Control.cs (1)
2182length = PInvoke.GetClassName(lastParentHandle, lpClassName, buffer.Length);
System\Windows\Forms\Controls\ComboBox\ComboBox.AutoCompleteDropDownFinder.cs (1)
42int length = PInvoke.GetClassName(hwnd, (PWSTR)b, buffer.Length);
System\Windows\Forms\Controls\Labels\LinkUtilities.cs (1)
44int nMax = Math.Min(rgb.Length, rgbsCount);
System\Windows\Forms\Controls\MonthCalendar\MonthCalendar.cs (1)
1107for (int i = 0; i < boldDates.Length; ++i, ++startMonth)
System\Windows\Forms\Controls\MonthCalendar\MonthCalendar.MonthCalendarAccessibleObject.cs (1)
299cchName = (UIntPtr)name.Length - 1
System\Windows\Forms\Dialogs\CommonDialogs\ColorDialog.cs (1)
87MemoryMarshal.Cast<int, COLORREF>(value)[..Math.Min(customColors.Length, value.Length)].CopyTo(customColors);
System\Windows\Forms\Printing\PageSetupDialog.cs (1)
293buffer.Length);
System\Windows\Forms\SendKeys\SendKeys.cs (1)
311if (keystate.Length < 256)
System\Windows\Forms\VisualStyles\VisualStyleInformation.cs (3)
45PInvoke.GetCurrentThemeName(pFilename, filename.Length, null, 0, null, 0); 67PInvoke.GetCurrentThemeName(null, 0, pColorScheme, colorScheme.Length, null, 0); 89PInvoke.GetCurrentThemeName(null, 0, null, 0, pSize, size.Length);
System\Windows\Forms\VisualStyles\VisualStyleRenderer.cs (2)
520_lastHResult = PInvoke.GetThemeFilename(HTHEME, Part, State, (THEME_PROPERTY_SYMBOL_ID)prop, pFilename, filename.Length); 649_lastHResult = PInvoke.GetThemeString(HTHEME, Part, State, (int)prop, pString, aString.Length);
System.Windows.Forms.Design (3)
System\ComponentModel\Design\ByteViewer.cs (2)
185Debug.Assert(charsBuffer.Length >= lineBuffer.Length); 207Debug.Assert(charsBuffer.Length >= lineBuffer.Length * 3 + 1);
System\Windows\Forms\Design\DesignerUtils.cs (1)
664for (int i = 0; i < alphaValues.Length; i++)
System.Windows.Forms.Primitives (3)
System\ComponentModel\TypeConverterHelper.cs (2)
35if (tokensCount != output.Length) 52for (int i = 0; i < output.Length; i++)
Windows\Win32\PInvoke.GetThemeDocumentationProperty.cs (1)
13GetThemeDocumentationProperty(pszThemeName, pszPropertyName, pBuffer, buffer.Length);
System.Windows.Forms.Primitives.Tests (1)
System\IO\Compression\RunLengthEncoderTests.cs (1)
29encoded.Length.Should().Be(expectedLength);
System.Windows.Forms.Tests (8)
System\Windows\Forms\ListBoxTests.cs (7)
2661Assert.Equal(1, (int)PInvokeCore.SendMessage(control, PInvoke.LB_GETSELITEMS, (WPARAM)buffer.Length, ref buffer[0])); 2667Assert.Equal(2, (int)PInvokeCore.SendMessage(control, PInvoke.LB_GETSELITEMS, (WPARAM)buffer.Length, ref buffer[0])); 2673Assert.Equal(0, (int)PInvokeCore.SendMessage(control, PInvoke.LB_GETSELITEMS, (WPARAM)buffer.Length, ref buffer[0])); 3178Assert.Equal(1, (int)PInvokeCore.SendMessage(control, PInvoke.LB_GETSELITEMS, (WPARAM)buffer.Length, ref buffer[0])); 3185Assert.Equal(1, (int)PInvokeCore.SendMessage(control, PInvoke.LB_GETSELITEMS, (WPARAM)buffer.Length, ref buffer[0])); 3191Assert.Equal(2, (int)PInvokeCore.SendMessage(control, PInvoke.LB_GETSELITEMS, (WPARAM)buffer.Length, ref buffer[0])); 3197Assert.Equal(0, (int)PInvokeCore.SendMessage(control, PInvoke.LB_GETSELITEMS, (WPARAM)buffer.Length, ref buffer[0]));
System\Windows\Forms\RichTextBoxTests.cs (1)
11023length = PInvoke.GetClassName(hWnd, lpClassName, buffer.Length);