<PackageReference Include="System.IO.Pipelines" Version="10.0.0-rc.1.25451.107" />

StreamHelpers

static class StreamHelpers
using System.Runtime.CompilerServices; namespace System.IO { internal static class StreamHelpers { [System.Runtime.CompilerServices.NullableContext(1)] public static void ValidateCopyToArgs(Stream source, Stream destination, int bufferSize) { ExceptionPolyfills.ThrowIfNull(destination, "destination"); if (bufferSize <= 0) throw new ArgumentOutOfRangeException("bufferSize", bufferSize, System.SR.ArgumentOutOfRange_NeedPosNum); bool canRead = source.CanRead; if (!canRead && !source.CanWrite) throw new ObjectDisposedException(null, System.SR.ObjectDisposed_StreamClosed); bool canWrite = destination.CanWrite; if (!canWrite && !destination.CanRead) throw new ObjectDisposedException("destination", System.SR.ObjectDisposed_StreamClosed); if (!canRead) throw new NotSupportedException(System.SR.NotSupported_UnreadableStream); if (!canWrite) throw new NotSupportedException(System.SR.NotSupported_UnwritableStream); } } }