Fixes dotnet/corefx#11220 Commit migrated from https://github.com/dotnet/corefx/commit/8afa43291b97861020885b21572e23102841ade2