Skip to content

Instantly share code, notes, and snippets.

@kevingosse
Created May 21, 2020 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevingosse/0ce049d72896b244203731ed293d74aa to your computer and use it in GitHub Desktop.
Save kevingosse/0ce049d72896b244203731ed293d74aa to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Text;
internal class StartupHook
{
public static void Initialize()
{
Console.SetOut(new FixCasingTextWriter(Console.Out));
}
class FixCasingTextWriter : TextWriter
{
private readonly TextWriter _writer;
public FixCasingTextWriter(TextWriter writer)
{
_writer = writer;
}
public override Encoding Encoding => _writer.Encoding;
public override void Write(string value)
{
int index = 0;
int lastIndex = 0;
while (index < value.Length)
{
index = value.IndexOf(".NET", lastIndex);
if (index == -1) break;
_writer.Write(value.Substring(lastIndex, index - lastIndex));
_writer.Write(".NeT");
lastIndex = index + 4;
}
if (lastIndex < value.Length)
{
_writer.Write(value.Substring(lastIndex));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment