Skip to content

Commit 01351ce

Browse files
Comment for #9035 (#9040)
Preserve the constraint in code as well as in the commit message for #9035.
1 parent 9fde70b commit 01351ce

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/MSBuild/LiveLogger/Terminal.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.Build.Logging.LiveLogger;
1616
internal sealed class Terminal : ITerminal
1717
{
1818
/// <summary>
19-
/// The encoding read from <see cref="Console.OutputEncoding"/> when the terminal is instantiated.
19+
/// The encoding read from <see cref="Console.OutputEncoding"/> when the terminal is constructed.
2020
/// </summary>
2121
private readonly Encoding _originalOutputEncoding;
2222

@@ -67,6 +67,10 @@ public Terminal()
6767
_originalOutputEncoding = Console.OutputEncoding;
6868
Console.OutputEncoding = Encoding.UTF8;
6969

70+
// Capture the TextWriter AFTER setting the encoding, because setting
71+
// the encoding creates a new TextWriter in the Console class, but it's
72+
// possible to hang on to the old one (with the wrong encoding) and emit
73+
// garbage, as in https://github.com/dotnet/msbuild/issues/9030.
7074
Output = Console.Out;
7175
}
7276

0 commit comments

Comments
 (0)