public void ReadFully(byte[] sink) { try { Require(sink.Length); } catch (IndexOutOfRangeException e) { // The underlying source is exhausted. Copy the bytes we got before rethrowing. int offset = 0; while (_easyBuffer.Size > 0) { int read = _easyBuffer.Read(sink, offset, (int)_easyBuffer.Size); if (read == -1) { throw new AssertionException(); } offset += read; } throw e; } _easyBuffer.ReadFully(sink); }