Merge in 'release/5.0' changes
This commit is contained in:
commit
8cddac6e61
|
|
@ -110,16 +110,21 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Buffers
|
|||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
|
||||
if (index < 0 || index >= buffer.Length)
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
|
||||
if (count < 0 || (buffer.Length - index < count))
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
|
||||
if (buffer.Length - index < count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(buffer.Length));
|
||||
}
|
||||
|
||||
Buffer.AppendHtml(new string(buffer, index, count));
|
||||
}
|
||||
|
||||
|
|
@ -326,4 +331,4 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Buffers
|
|||
await _inner.FlushAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,6 +124,22 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Buffers
|
|||
Assert.Equal<object>(new[] { newLine, newLine }, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Write_WritesEmptyCharBuffer()
|
||||
{
|
||||
// Arrange
|
||||
var buffer = new ViewBuffer(new TestViewBufferScope(), "some-name", pageSize: 4);
|
||||
var writer = new ViewBufferTextWriter(buffer, Encoding.UTF8);
|
||||
var charBuffer = new char[0];
|
||||
|
||||
// Act
|
||||
writer.Write(charBuffer, 0, 0);
|
||||
|
||||
// Assert
|
||||
var actual = GetValues(buffer);
|
||||
Assert.Equal<object>(new[] { string.Empty }, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Write_WritesStringBuffer()
|
||||
{
|
||||
|
|
@ -170,4 +186,4 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Buffers
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue