@@ -24,7 +24,7 @@ internal sealed partial class ReadOnlySequenceStream : Stream
24
24
/// <summary>
25
25
/// The current position within <see cref="source"/>.
26
26
/// </summary>
27
- private int position ;
27
+ private long position ;
28
28
29
29
/// <summary>
30
30
/// Indicates whether or not the current instance has been disposed
@@ -90,7 +90,7 @@ public sealed override long Position
90
90
MemoryStream . ValidateDisposed ( this . disposed ) ;
91
91
MemoryStream . ValidatePosition ( value , this . source . Length ) ;
92
92
93
- this . position = unchecked ( ( int ) value ) ;
93
+ this . position = value ;
94
94
}
95
95
}
96
96
@@ -123,9 +123,9 @@ public sealed override Task CopyToAsync(Stream destination, int bufferSize, Canc
123
123
124
124
if ( this . source . IsSingleSegment )
125
125
{
126
- ReadOnlyMemory < byte > buffer = this . source . First . Slice ( this . position ) ;
126
+ ReadOnlyMemory < byte > buffer = this . source . First . Slice ( unchecked ( ( int ) this . position ) ) ;
127
127
128
- this . position = ( int ) this . source . Length ;
128
+ this . position = this . source . Length ;
129
129
130
130
return destination . WriteAsync ( buffer , cancellationToken ) . AsTask ( ) ;
131
131
}
@@ -134,7 +134,7 @@ async Task CoreCopyToAsync(Stream destination, CancellationToken cancellationTok
134
134
{
135
135
ReadOnlySequence < byte > sequence = this . source . Slice ( this . position ) ;
136
136
137
- this . position = ( int ) this . source . Length ;
137
+ this . position = this . source . Length ;
138
138
139
139
foreach ( ReadOnlyMemory < byte > segment in sequence )
140
140
{
@@ -220,7 +220,7 @@ public sealed override long Seek(long offset, SeekOrigin origin)
220
220
221
221
MemoryStream . ValidatePosition ( index , this . source . Length ) ;
222
222
223
- this . position = unchecked ( ( int ) index ) ;
223
+ this . position = index ;
224
224
225
225
return index ;
226
226
}
@@ -253,6 +253,7 @@ public sealed override int Read(byte[]? buffer, int offset, int count)
253
253
segment . Span . Slice ( 0 , bytesToCopy ) . CopyTo ( destination ) ;
254
254
255
255
destination = destination . Slice ( bytesToCopy ) ;
256
+
256
257
bytesCopied += bytesToCopy ;
257
258
258
259
this . position += bytesToCopy ;
0 commit comments