@@ -71,7 +71,7 @@ public override Span<byte> GetSpan()
7171
7272 public override Memory < byte > Memory => CreateMemory ( length ) ;
7373
74- public override MemoryHandle Pin ( int elementIndex )
74+ public override MemoryHandle Pin ( int elementIndex = 0 )
7575 {
7676 ObjectDisposedException . ThrowIf ( ptr is null , this ) ;
7777 return new ( Unsafe . Add < byte > ( ptr , elementIndex ) ) ;
@@ -117,7 +117,7 @@ public override Span<byte> GetSpan()
117117
118118 public override Memory < byte > Memory => memory ;
119119
120- public override MemoryHandle Pin ( int elementIndex )
120+ public override MemoryHandle Pin ( int elementIndex = 0 )
121121 => memory . Slice ( elementIndex ) . Pin ( ) ;
122122
123123 public override void Unpin ( )
@@ -392,79 +392,79 @@ private void PersistBuffer(bool flushToDisk)
392392 }
393393
394394 /// <inheritdoc/>
395- public override ValueTask WriteAsync ( ReadOnlyMemory < byte > buffer , CancellationToken token = default )
395+ public override ValueTask WriteAsync ( ReadOnlyMemory < byte > input , CancellationToken token = default )
396396 {
397397 if ( IsReading )
398398 return ValueTask . FromException ( new InvalidOperationException ( ExceptionMessages . WriterInReadMode ) ) ;
399399
400- switch ( PrepareMemory ( buffer . Length , out var output ) )
400+ switch ( PrepareMemory ( input . Length , out var output ) )
401401 {
402402 default :
403403 return ValueTask . CompletedTask ;
404404 case MemoryEvaluationResult . Success :
405- buffer . CopyTo ( output ) ;
406- position += buffer . Length ;
405+ input . CopyTo ( output ) ;
406+ position += input . Length ;
407407 goto default ;
408408 case MemoryEvaluationResult . PersistExistingBuffer :
409- return PersistExistingBufferAsync ( buffer , token ) ;
409+ return PersistExistingBufferAsync ( input , token ) ;
410410 case MemoryEvaluationResult . PersistAll :
411- return PersistAllAsync ( buffer , token ) ;
411+ return PersistAllAsync ( input , token ) ;
412412 }
413413 }
414414
415- private ValueTask PersistExistingBufferAsync ( ReadOnlyMemory < byte > buffer , CancellationToken token )
415+ private ValueTask PersistExistingBufferAsync ( ReadOnlyMemory < byte > input , CancellationToken token )
416416 {
417417 Debug . Assert ( HasBufferedData ) ;
418418
419419 EnsureBackingStore ( ) ;
420- secondBuffer = buffer ;
420+ secondBuffer = input ;
421421 return Submit ( RandomAccess . WriteAsync ( fileBackend , WrittenMemory , filePosition , token ) , writeAndCopyCallback ) ;
422422 }
423423
424- private ValueTask PersistAllAsync ( ReadOnlyMemory < byte > buffer , CancellationToken token )
424+ private ValueTask PersistAllAsync ( ReadOnlyMemory < byte > input , CancellationToken token )
425425 {
426426 EnsureBackingStore ( ) ;
427427
428428 ValueTask task ;
429429 if ( HasBufferedData )
430430 {
431- secondBuffer = buffer ;
431+ secondBuffer = input ;
432432 task = RandomAccess . WriteAsync ( fileBackend , ( IReadOnlyList < ReadOnlyMemory < byte > > ) this . As < IDynamicInterfaceCastable > ( ) , filePosition , token ) ;
433433 }
434434 else
435435 {
436- position = buffer . Length ;
437- task = RandomAccess . WriteAsync ( fileBackend , buffer , filePosition , token ) ;
436+ position = input . Length ;
437+ task = RandomAccess . WriteAsync ( fileBackend , input , filePosition , token ) ;
438438 }
439439
440440 return Submit ( task , writeCallback ) ;
441441 }
442442
443- /// <inheritdoc/>
444- public override void Write ( ReadOnlySpan < byte > buffer )
443+ /// <inheritdoc cref="Stream.Write(ReadOnlySpan{byte})" />
444+ public override void Write ( ReadOnlySpan < byte > input )
445445 {
446446 if ( IsReading )
447447 throw new InvalidOperationException ( ExceptionMessages . WriterInReadMode ) ;
448448
449- switch ( PrepareMemory ( buffer . Length , out var output ) )
449+ switch ( PrepareMemory ( input . Length , out var output ) )
450450 {
451451 case MemoryEvaluationResult . Success :
452- buffer . CopyTo ( output . Span ) ;
453- position += buffer . Length ;
452+ input . CopyTo ( output . Span ) ;
453+ position += input . Length ;
454454 break ;
455455 case MemoryEvaluationResult . PersistExistingBuffer :
456456 PersistBuffer ( flushToDisk : false ) ;
457- buffer . CopyTo ( this . buffer . Span ) ;
458- position = buffer . Length ;
457+ input . CopyTo ( this . buffer . Span ) ;
458+ position = input . Length ;
459459 break ;
460460 case MemoryEvaluationResult . PersistAll :
461461 if ( HasBufferedData )
462462 PersistBuffer ( flushToDisk : false ) ;
463463 else
464464 EnsureBackingStore ( ) ;
465465
466- RandomAccess . Write ( fileBackend , buffer , filePosition ) ;
467- filePosition += buffer . Length ;
466+ RandomAccess . Write ( fileBackend , input , filePosition ) ;
467+ filePosition += input . Length ;
468468 break ;
469469 }
470470 }
@@ -473,28 +473,28 @@ public override void Write(ReadOnlySpan<byte> buffer)
473473 private void EnsureBackingStore ( ) => fileBackend ??= fileProvider . CreateBackingFileHandle ( position , out fileName ) ;
474474
475475 /// <inheritdoc/>
476- public override void Write ( byte [ ] buffer , int offset , int count )
476+ public override void Write ( byte [ ] data , int offset , int count )
477477 {
478- ValidateBufferArguments ( buffer , offset , count ) ;
479- Write ( new ReadOnlySpan < byte > ( buffer , offset , count ) ) ;
478+ ValidateBufferArguments ( data , offset , count ) ;
479+ Write ( new ReadOnlySpan < byte > ( data , offset , count ) ) ;
480480 }
481481
482482 /// <inheritdoc/>
483- public override Task WriteAsync ( byte [ ] buffer , int offset , int count , CancellationToken token )
484- => WriteAsync ( new ReadOnlyMemory < byte > ( buffer , offset , count ) , token ) . AsTask ( ) ;
483+ public override Task WriteAsync ( byte [ ] data , int offset , int count , CancellationToken token )
484+ => WriteAsync ( new ReadOnlyMemory < byte > ( data , offset , count ) , token ) . AsTask ( ) ;
485485
486486 /// <inheritdoc/>
487487 public override void WriteByte ( byte value )
488488 => Write ( new ( ref value ) ) ;
489489
490490 /// <inheritdoc/>
491- public override IAsyncResult BeginWrite ( byte [ ] buffer , int offset , int count , AsyncCallback ? callback , object ? state )
492- => TaskToAsyncResult . Begin ( WriteAsync ( buffer , offset , count ) , callback , state ) ;
491+ public override IAsyncResult BeginWrite ( byte [ ] data , int offset , int count , AsyncCallback ? callback , object ? state )
492+ => TaskToAsyncResult . Begin ( WriteAsync ( data , offset , count ) , callback , state ) ;
493493
494494 /// <inheritdoc/>
495495 public override void EndWrite ( IAsyncResult ar ) => TaskToAsyncResult . End ( ar ) ;
496496
497- /// <inheritdoc/>
497+ /// <inheritdoc cref="Stream.Flush()" />
498498 public override void Flush ( ) => Flush ( flushToDisk : false ) ;
499499
500500 /// <summary>
@@ -553,7 +553,7 @@ public ValueTask FlushAsync(bool flushToDisk, CancellationToken token = default)
553553 return result ;
554554 }
555555
556- /// <inheritdoc/>
556+ /// <inheritdoc cref="Stream.FlushAsync(CancellationToken)" />
557557 public override Task FlushAsync ( CancellationToken token )
558558 => FlushAsync ( flushToDisk : false , token ) . AsTask ( ) ;
559559
@@ -562,23 +562,23 @@ public override int ReadByte()
562562 => throw new NotSupportedException ( ) ;
563563
564564 /// <inheritdoc/>
565- public override int Read ( byte [ ] buffer , int offset , int count )
565+ public override int Read ( byte [ ] data , int offset , int count )
566566 => throw new NotSupportedException ( ) ;
567567
568568 /// <inheritdoc/>
569- public override int Read ( Span < byte > buffer )
569+ public override int Read ( Span < byte > data )
570570 => throw new NotSupportedException ( ) ;
571571
572572 /// <inheritdoc/>
573- public override Task < int > ReadAsync ( byte [ ] buffer , int offset , int count , CancellationToken token )
573+ public override Task < int > ReadAsync ( byte [ ] data , int offset , int count , CancellationToken token )
574574 => Task . FromException < int > ( new NotSupportedException ( ) ) ;
575575
576576 /// <inheritdoc/>
577- public override ValueTask < int > ReadAsync ( Memory < byte > buffer , CancellationToken token )
577+ public override ValueTask < int > ReadAsync ( Memory < byte > data , CancellationToken token = default )
578578 => ValueTask . FromException < int > ( new NotSupportedException ( ) ) ;
579579
580580 /// <inheritdoc/>
581- public override IAsyncResult BeginRead ( byte [ ] buffer , int offset , int count , AsyncCallback ? callback , object ? state )
581+ public override IAsyncResult BeginRead ( byte [ ] data , int offset , int count , AsyncCallback ? callback , object ? state )
582582 => throw new NotSupportedException ( ) ;
583583
584584 /// <inheritdoc/>
@@ -599,15 +599,15 @@ public override void SetLength(long value)
599599 /// <returns>The task representing asynchronous execution of this method.</returns>
600600 /// <exception cref="OperationCanceledException">The operation has been canceled.</exception>
601601 public async Task CopyToAsync < TConsumer > ( TConsumer consumer , int bufferSize , CancellationToken token )
602- where TConsumer : notnull , ISupplier < ReadOnlyMemory < byte > , CancellationToken , ValueTask >
602+ where TConsumer : ISupplier < ReadOnlyMemory < byte > , CancellationToken , ValueTask >
603603 {
604604 ArgumentOutOfRangeException . ThrowIfNegativeOrZero ( bufferSize ) ;
605605
606606 if ( fileBackend is not null )
607607 {
608608 using var buffer = allocator . AllocateAtLeast ( bufferSize ) ;
609609 int count ;
610- for ( long offset = 0L ; ( count = await RandomAccess . ReadAsync ( fileBackend , buffer . Memory , offset , token ) . ConfigureAwait ( false ) ) > 0 ; offset += count )
610+ for ( var offset = 0L ; ( count = await RandomAccess . ReadAsync ( fileBackend , buffer . Memory , offset , token ) . ConfigureAwait ( false ) ) > 0 ; offset += count )
611611 await consumer . Invoke ( buffer . Memory . Slice ( 0 , count ) , token ) . ConfigureAwait ( false ) ;
612612 }
613613
@@ -628,13 +628,13 @@ ValueTask IGrowableBuffer<byte>.CopyToAsync<TConsumer>(TConsumer consumer, Cance
628628 /// <param name="token">The token that can be used to cancel the operation.</param>
629629 /// <exception cref="OperationCanceledException">The operation has been canceled.</exception>
630630 public void CopyTo < TConsumer > ( TConsumer consumer , int bufferSize , CancellationToken token )
631- where TConsumer : notnull , IReadOnlySpanConsumer < byte >
631+ where TConsumer : IReadOnlySpanConsumer < byte >
632632 {
633633 if ( fileBackend is not null )
634634 {
635635 using var buffer = allocator . AllocateAtLeast ( bufferSize ) ;
636636 int count ;
637- for ( long offset = 0L ; ( count = RandomAccess . Read ( fileBackend , buffer . Span , offset ) ) > 0 ; offset += count , token . ThrowIfCancellationRequested ( ) )
637+ for ( var offset = 0L ; ( count = RandomAccess . Read ( fileBackend , buffer . Span , offset ) ) > 0 ; offset += count , token . ThrowIfCancellationRequested ( ) )
638638 consumer . Invoke ( buffer . Span . Slice ( 0 , count ) ) ;
639639 }
640640
0 commit comments