Fix behavior of TextWriter.Write with null StringBuilder (#20451)

With other overloads (including Write(object)) if you passed null it just wouldn't write anything out, so we shouldn't throw for the StringBuilder overload either.

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
This commit is contained in:
Stephen Toub 2018-10-16 20:09:11 -04:00 коммит произвёл Jan Kotas
Родитель 0444608c0b
Коммит 6e9c33c283
1 изменённых файлов: 3 добавлений и 4 удалений

Просмотреть файл

@ -290,12 +290,11 @@ namespace System.IO
/// <param name="value">The string (as a StringBuilder) to write to the stream</param>
public virtual void Write(StringBuilder value)
{
if (value == null)
if (value != null)
{
throw new ArgumentNullException(nameof(value));
foreach (ReadOnlyMemory<char> chunk in value.GetChunks())
Write(chunk);
}
foreach (ReadOnlyMemory<char> chunk in value.GetChunks())
Write(chunk);
}
// Writes out a formatted string. Uses the same semantics as