Check CanWrite on the destination stream first.
In the common case CanWrite is true, and CanRead is only needed to
determine which kind of exception to throw when CanWrite is false.
Commit migrated from https://github.com/dotnet/coreclr/commit/
85a1a1d4e981e184f2f5d91c41a4d3be2a4ea3fa
}
bool destinationCanWrite = destination.CanWrite;
- if (!destination.CanRead && !destinationCanWrite)
+ if (!destinationCanWrite && !destination.CanRead)
{
throw new ObjectDisposedException(nameof(destination), Environment.GetResourceString("ObjectDisposed_StreamClosed"));
}