Last active
November 16, 2022 15:13
-
-
Save jozkee/aee5a36d7d1238a320acb366fa08539d to your computer and use it in GitHub Desktop.
Make Stream easier to implement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class Stream2022 : Stream | |
{ | |
public sealed override int Read(byte[] buffer, int offset, int count) | |
=> Read(buffer.AsSpan(offset, count)); | |
public abstract override int Read(Span<byte> buffer); | |
public sealed override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) | |
=> ReadAsync(buffer.AsMemory(offset, count), cancellationToken).AsTask(); | |
public abstract override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default); | |
public sealed override void Write(byte[] buffer, int offset, int count) | |
=> Write(buffer.AsSpan(offset, count)); | |
public abstract override void Write(ReadOnlySpan<byte> buffer); | |
public sealed override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) | |
=> WriteAsync(buffer.AsMemory(offset, count), cancellationToken).AsTask(); | |
public abstract override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment