diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs index c6deb0e0d3..2f31b4b885 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs @@ -422,7 +422,7 @@ internal string WorkingDirectory { return _workingDirectory.Remove(_workingDirectory.Length - 1); } - #endif +#endif return _workingDirectory; } } @@ -529,7 +529,7 @@ private static string GetConfigurationNameFromGroupPolicy() /// private static void EarlyParseHelper(string[] args) { - if(args == null) + if (args == null) { Dbg.Assert(args != null, "Argument 'args' to EarlyParseHelper should never be null"); return; diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs index f925dbd7f7..056cabd531 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs @@ -48,7 +48,7 @@ namespace Microsoft.PowerShell internal static class ConsoleControl { #if !UNIX -#region structs + #region structs internal enum InputRecordEventTypes : ushort { @@ -246,7 +246,7 @@ internal struct TEXTMETRIC public byte tmCharSet; } -#region SentInput Data Structures + #region SentInput Data Structures [StructLayout(LayoutKind.Sequential)] internal struct INPUT @@ -417,11 +417,11 @@ internal enum KeyboardFlag : uint ScanCode = 0x0008 } -#endregion SentInput Data Structures + #endregion SentInput Data Structures -#endregion structs + #endregion structs -#region Window Visibility + #region Window Visibility [DllImport(PinvokeDllNames.GetConsoleWindowDllName)] internal static extern IntPtr GetConsoleWindow(); @@ -473,9 +473,9 @@ internal static void SetConsoleMode(ProcessWindowStyle style) } } #endif -#endregion + #endregion -#region Input break handler (Ctrl-C, Ctrl-Break) + #region Input break handler (Ctrl-C, Ctrl-Break) /// /// Types of control ConsoleBreakSignals received by break Win32Handler delegates. @@ -546,9 +546,9 @@ internal static void RemoveBreakHandler() } } -#endregion + #endregion -#region Win32Handles + #region Win32Handles private static readonly Lazy _keyboardInputHandle = new Lazy(() => { @@ -621,9 +621,9 @@ internal static ConsoleHandle GetActiveScreenBufferHandle() return _outputHandle.Value; } -#endregion + #endregion -#region Mode + #region Mode /// /// Flags used by ConsoleControl.GetMode and ConsoleControl.SetMode. @@ -707,9 +707,9 @@ internal static void SetMode(ConsoleHandle consoleHandle, ConsoleModes mode) } } -#endregion + #endregion -#region Input + #region Input /// /// Reads input from the console device according to the mode in effect (see GetMode, SetMode) @@ -943,9 +943,9 @@ internal static void FlushConsoleInputBuffer(ConsoleHandle consoleHandle) } } -#endregion Input + #endregion Input -#region Buffer + #region Buffer /// /// Wraps Win32 GetConsoleScreenBufferInfo @@ -1178,7 +1178,7 @@ private static void BuildEdgeTypeInfo( firstRightLeadingRow = r; } - for (;;) + for (; ; ) { r++; if (r > contentsRegion.Bottom) @@ -1769,7 +1769,7 @@ internal static void ReadConsoleOutput } } -#region ReadConsoleOutput CJK + #region ReadConsoleOutput CJK /// /// If an edge cell read is a blank, it is potentially part of a double width character. Hence, /// at least one of the left and right edges should be checked. @@ -2066,7 +2066,7 @@ out background rowIndex++; } } -#endregion ReadConsoleOutput CJK + #endregion ReadConsoleOutput CJK private static void ReadConsoleOutputPlain ( @@ -2408,9 +2408,9 @@ internal static void ScrollConsoleScreenBuffer } } -#endregion Buffer + #endregion Buffer -#region Window + #region Window /// /// Wraps Win32 SetConsoleWindowInfo. @@ -2536,7 +2536,7 @@ internal static void SetConsoleWindowTitle(string consoleTitle) } } -#endregion Window + #endregion Window /// /// Wrap Win32 WriteConsole. @@ -2661,7 +2661,7 @@ internal static void SetConsoleTextAttribute(ConsoleHandle consoleHandle, WORD a } #endif -#region Dealing with CJK + #region Dealing with CJK // Return the length of a VT100 control sequence character in str starting // at the given offset. @@ -2748,11 +2748,11 @@ internal static bool IsCJKOutputCodePage(out uint codePage) } #endif -#endregion Dealing with CJK + #endregion Dealing with CJK #if !UNIX -#region Cursor + #region Cursor /// /// Wraps Win32 SetConsoleCursorPosition. @@ -2874,9 +2874,9 @@ internal static void SetConsoleCursorInfo(ConsoleHandle consoleHandle, CONSOLE_C } } -#endregion Cursor + #endregion Cursor -#region helper + #region helper /// /// Helper function to create the proper HostException. @@ -2895,9 +2895,9 @@ private static HostException CreateHostException( return e; } -#endregion helper + #endregion helper -#region + #region internal static int LengthInBufferCells(char c) { @@ -2915,16 +2915,16 @@ internal static int LengthInBufferCells(char c) (c >= 0xfe30 && c <= 0xfe6f) || /* CJK Compatibility Forms */ (c >= 0xff00 && c <= 0xff60) || /* Fullwidth Forms */ (c >= 0xffe0 && c <= 0xffe6)); - // We can ignore these ranges because .Net strings use surrogate pairs - // for this range and we do not handle surrogage pairs. - // (c >= 0x20000 && c <= 0x2fffd) || - // (c >= 0x30000 && c <= 0x3fffd) + // We can ignore these ranges because .Net strings use surrogate pairs + // for this range and we do not handle surrogage pairs. + // (c >= 0x20000 && c <= 0x2fffd) || + // (c >= 0x30000 && c <= 0x3fffd) return 1 + (isWide ? 1 : 0); } -#endregion + #endregion -#region SendInput + #region SendInput internal static void MimicKeyPress(INPUT[] inputs) { @@ -2941,7 +2941,7 @@ internal static void MimicKeyPress(INPUT[] inputs) } } -#endregion SendInput + #endregion SendInput /// /// Class to hold the Native Methods used in this file enclosing class. @@ -2953,7 +2953,7 @@ internal static class NativeMethods internal const int FontTypeMask = 0x06; internal const int TrueTypeFont = 0x04; -#region CreateFile + #region CreateFile [Flags] internal enum AccessQualifiers : uint @@ -2993,14 +2993,14 @@ internal static extern NakedWin32Handle CreateFile NakedWin32Handle templateFileWin32Handle ); -#endregion CreateFile + #endregion CreateFile -#region Code Page + #region Code Page [DllImport(PinvokeDllNames.GetConsoleOutputCPDllName, SetLastError = false, CharSet = CharSet.Unicode)] internal static extern uint GetConsoleOutputCP(); -#endregion Code Page + #endregion Code Page [DllImport(PinvokeDllNames.GetConsoleWindowDllName, SetLastError = true, CharSet = CharSet.Unicode)] internal static extern HWND GetConsoleWindow(); diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs index 7f8ea16553..a0689ba60a 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs @@ -50,7 +50,7 @@ internal sealed partial class ConsoleHost #region static methods internal const int ExitCodeSuccess = 0; - internal const int ExitCodeCtrlBreak = 128+21; // SIGBREAK + internal const int ExitCodeCtrlBreak = 128 + 21; // SIGBREAK internal const int ExitCodeInitFailure = 70; // Internal Software Error internal const int ExitCodeBadCommandLineParameter = 64; // Command Line Usage Error diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs index 5f1c63af9c..af9d754861 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs @@ -1251,7 +1251,7 @@ int LengthInBufferCells(char c) return ConsoleControl.LengthInBufferCells(c); } -#region internal + #region internal /// /// Clear the ReadKey cache. @@ -1262,9 +1262,9 @@ internal void ClearKeyCache() cachedKeyEvent.RepeatCount = 0; } -#endregion internal + #endregion internal -#region helpers + #region helpers // pass-by-ref for speed. /// @@ -1315,7 +1315,7 @@ private static return result; } -#endregion helpers + #endregion helpers private ConsoleColor defaultForeground = ConsoleColor.Gray; diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs index 53431f42d9..8a3709c6d9 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs @@ -1159,7 +1159,7 @@ internal string WrapToCurrentWindowWidth(string text) return sb.ToString(); } -#endregion Word Wrapping + #endregion Word Wrapping /// /// See base class. @@ -1580,8 +1580,8 @@ private string ReadLineFromConsole(bool endOnTab, string initialContent, bool ca } #endif - do - { + do + { #if UNIX keyInfo = Console.ReadKey(true); #else @@ -1595,35 +1595,35 @@ private string ReadLineFromConsole(bool endOnTab, string initialContent, bool ca #else if (s.Length == 0) #endif - { - result = ReadLineResult.endedOnBreak; - s = null; - - if (calledFromPipeline) - { - // make sure that the pipeline that called us is stopped + { + result = ReadLineResult.endedOnBreak; + s = null; - throw new PipelineStoppedException(); - } + if (calledFromPipeline) + { + // make sure that the pipeline that called us is stopped - break; + throw new PipelineStoppedException(); } + break; + } + #if UNIX if (keyInfo.Key == ConsoleKey.Enter) #else if (s.EndsWith(Crlf, StringComparison.Ordinal)) #endif - { - result = ReadLineResult.endedOnEnter; + { + result = ReadLineResult.endedOnEnter; #if UNIX // We're intercepting characters, so we need to echo the newline Console.Out.WriteLine(); #else s = s.Remove(s.Length - Crlf.Length); #endif - break; - } + break; + } #if UNIX if (keyInfo.Key == ConsoleKey.Tab) @@ -1806,15 +1806,15 @@ private string ReadLineFromConsole(bool endOnTab, string initialContent, bool ca Console.Out.Write(s); Console.CursorLeft = cursorCurrent + 1; #endif - } - while (true); + } + while (true); - Dbg.Assert( - (s == null && result == ReadLineResult.endedOnBreak) - || (s != null && result != ReadLineResult.endedOnBreak), - "s should only be null if input ended with a break"); + Dbg.Assert( + (s == null && result == ReadLineResult.endedOnBreak) + || (s != null && result != ReadLineResult.endedOnBreak), + "s should only be null if input ended with a break"); - return s; + return s; #if UNIX } finally diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs index 88ad4e9979..8cf227ba40 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfaceProgress.cs @@ -85,7 +85,7 @@ class ConsoleHostUserInterface : System.Management.Automation.Host.PSHostUserInt progPaneUpdateFlag = 1; // The timer will be auto restarted every 'UpdateTimerThreshold' ms - _progPaneUpdateTimer = new Timer( new TimerCallback(ProgressPaneUpdateTimerElapsed), null, UpdateTimerThreshold, UpdateTimerThreshold); + _progPaneUpdateTimer = new Timer(new TimerCallback(ProgressPaneUpdateTimerElapsed), null, UpdateTimerThreshold, UpdateTimerThreshold); } } diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs index faee86bfd4..2a88d2d997 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs @@ -55,7 +55,8 @@ public static int Start(string consoleFilePath, [MarshalAs(UnmanagedType.LPArray if (args.Length > 0 && !string.IsNullOrEmpty(args[0]) && args[0].Equals("-isswait", StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("Attach the debugger to continue..."); - while (!System.Diagnostics.Debugger.IsAttached) { + while (!System.Diagnostics.Debugger.IsAttached) + { Thread.Sleep(100); } diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Serialization.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Serialization.cs index d65c545a32..e24823da6c 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Serialization.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Serialization.cs @@ -172,7 +172,7 @@ class WrappedDeserializer : Serialization switch (format) { case DataFormat.XML: - _xmlReader = XmlReader.Create(textReader, new XmlReaderSettings { XmlResolver = null }); + _xmlReader = XmlReader.Create(textReader, new XmlReaderSettings { XmlResolver = null }); _xmlDeserializer = new Deserializer(_xmlReader); break; case DataFormat.Text: diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/StartTranscriptCmdlet.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/StartTranscriptCmdlet.cs index f979f9a010..ed602725cf 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/StartTranscriptCmdlet.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/StartTranscriptCmdlet.cs @@ -44,7 +44,7 @@ public string Path /// The literal name of the file in which to write the transcript. /// [Parameter(Position = 0, ParameterSetName = "ByLiteralPath")] - [Alias("PSPath","LP")] + [Alias("PSPath", "LP")] [ValidateNotNullOrEmpty] public string LiteralPath { diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs index 0a827ba10e..988ef5262f 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs @@ -37,7 +37,8 @@ static ApplicationInsightsTelemetry() TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = _developerMode; } - private static bool GetEnvironmentVariableAsBool(string name, bool defaultValue) { + private static bool GetEnvironmentVariableAsBool(string name, bool defaultValue) + { var str = Environment.GetEnvironmentVariable(name); if (string.IsNullOrEmpty(str)) { @@ -62,11 +63,11 @@ private static bool GetEnvironmentVariableAsBool(string name, bool defaultValue) /// /// Send the telemetry. /// - private static void SendTelemetry(string eventName, Dictionary payload) + private static void SendTelemetry(string eventName, Dictionary payload) { try { - var enabled = !GetEnvironmentVariableAsBool(name : TelemetryOptoutEnvVar, defaultValue : false); + var enabled = !GetEnvironmentVariableAsBool(name: TelemetryOptoutEnvVar, defaultValue: false); if (!enabled) {