diff --git a/src/PowerShellEditorServices/Properties/AssemblyInfo.cs b/src/PowerShellEditorServices/Properties/AssemblyInfo.cs index fe5340efe..17939a129 100644 --- a/src/PowerShellEditorServices/Properties/AssemblyInfo.cs +++ b/src/PowerShellEditorServices/Properties/AssemblyInfo.cs @@ -5,5 +5,6 @@ using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("Microsoft.PowerShell.EditorServices.Test")] [assembly: InternalsVisibleTo("Microsoft.PowerShell.EditorServices.Test.Shared")] diff --git a/src/PowerShellEditorServices/Session/SessionPSHostUserInterface.cs b/src/PowerShellEditorServices/Session/SessionPSHostUserInterface.cs index 4c144f480..0c6627e81 100644 --- a/src/PowerShellEditorServices/Session/SessionPSHostUserInterface.cs +++ b/src/PowerShellEditorServices/Session/SessionPSHostUserInterface.cs @@ -30,6 +30,14 @@ internal class ConsoleServicePSHostUserInterface : PSHostUserInterface, IHostUIS #endregion + #region Public Constants + + public const string DebugMessagePrefix = "DEBUG: "; + public const string WarningMessagePrefix = "WARNING: "; + public const string VerboseMessagePrefix = "VERBOSE: "; + + #endregion + #region Properties internal IConsoleHost ConsoleHost @@ -57,9 +65,9 @@ public ConsoleServicePSHostUserInterface(bool enableConsoleRepl) { if (enableConsoleRepl) { - // Set the output encoding to Unicode so that all - // Unicode characters are written correctly - System.Console.OutputEncoding = System.Text.Encoding.Unicode; + // Set the output encoding to UTF-8 so that special + // characters are written to the console correctly + System.Console.OutputEncoding = System.Text.Encoding.UTF8; } this.rawUserInterface = @@ -338,9 +346,10 @@ public override void WriteDebugLine(string message) if (this.consoleHost != null) { this.consoleHost.WriteOutput( - message, + DebugMessagePrefix + message, true, - OutputType.Debug); + OutputType.Debug, + foregroundColor: ConsoleColor.Yellow); } } @@ -349,9 +358,10 @@ public override void WriteVerboseLine(string message) if (this.consoleHost != null) { this.consoleHost.WriteOutput( - message, + VerboseMessagePrefix + message, true, - OutputType.Verbose); + OutputType.Verbose, + foregroundColor: ConsoleColor.Blue); } } @@ -360,9 +370,10 @@ public override void WriteWarningLine(string message) if (this.consoleHost != null) { this.consoleHost.WriteOutput( - message, + WarningMessagePrefix + message, true, - OutputType.Warning); + OutputType.Warning, + foregroundColor: ConsoleColor.Yellow); } } diff --git a/test/PowerShellEditorServices.Test/Console/ConsoleServiceTests.cs b/test/PowerShellEditorServices.Test/Console/ConsoleServiceTests.cs index 4fc660469..5be4d1902 100644 --- a/test/PowerShellEditorServices.Test/Console/ConsoleServiceTests.cs +++ b/test/PowerShellEditorServices.Test/Console/ConsoleServiceTests.cs @@ -119,7 +119,7 @@ await this.powerShellContext.ExecuteScriptString( TestOutputString)); Assert.Equal( - TestOutputString + Environment.NewLine, + ConsoleServicePSHostUserInterface.VerboseMessagePrefix + TestOutputString + Environment.NewLine, this.GetOutputForType(OutputType.Verbose)); } @@ -137,7 +137,7 @@ await this.powerShellContext.ExecuteScriptString( TestOutputString)); Assert.Equal( - TestOutputString + Environment.NewLine, + ConsoleServicePSHostUserInterface.DebugMessagePrefix + TestOutputString + Environment.NewLine, this.GetOutputForType(OutputType.Debug)); } @@ -150,7 +150,7 @@ await this.powerShellContext.ExecuteScriptString( TestOutputString)); Assert.Equal( - TestOutputString + Environment.NewLine, + ConsoleServicePSHostUserInterface.WarningMessagePrefix + TestOutputString + Environment.NewLine, this.GetOutputForType(OutputType.Warning)); }