public static byte[] ToBytes(this Stream stream) { if (stream == null) throw new ArgumentNullException(nameof(stream)); return stream.ReadFully(); }