Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #32277 to 3.1 #32482

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/common/tools.ps1
Expand Up @@ -323,7 +323,7 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
}

$msbuildVersionDir = if ([int]$vsMajorVersion -lt 16) { "$vsMajorVersion.0" } else { "Current" }
return $global:_MSBuildExe = Join-Path $vsInstallDir "MSBuild\$msbuildVersionDir\Bin\msbuild.exe"
return $global:_MSBuildExe = Join-Path $vsInstallDir "MSBuild\$msbuildVersionDir\Bin\amd64\msbuild.exe"
}

function InitializeVisualStudioEnvironmentVariables([string] $vsInstallDir, [string] $vsMajorVersion) {
Expand Down
11 changes: 8 additions & 3 deletions src/Mvc/Mvc.ViewFeatures/src/Buffers/ViewBufferTextWriter.cs
Expand Up @@ -110,16 +110,21 @@ public override void Write(char[] buffer, int index, int count)
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));
}

Expand Down Expand Up @@ -326,4 +331,4 @@ public override async Task FlushAsync()
await _inner.FlushAsync();
}
}
}
}
Expand Up @@ -124,6 +124,22 @@ public async Task WriteLines_WritesCharBuffer()
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()
{
Expand Down Expand Up @@ -170,4 +186,4 @@ public override string ToString()
}
}
}
}
}