Run CodeFormatter with BraceNewLine,UsingLocation,FormatDocument,NewLineAbove rules (#9393)

This commit is contained in:
Ilya
2019-04-20 23:20:59 +05:00
committed by GitHub
parent 609d610c71
commit ca447c3ad4
10 changed files with 79 additions and 77 deletions
@@ -422,7 +422,7 @@ namespace Microsoft.PowerShell
{
return _workingDirectory.Remove(_workingDirectory.Length - 1);
}
#endif
#endif
return _workingDirectory;
}
}
@@ -529,7 +529,7 @@ namespace Microsoft.PowerShell
/// </param>
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;
@@ -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 @@ namespace Microsoft.PowerShell
public byte tmCharSet;
}
#region SentInput Data Structures
#region SentInput Data Structures
[StructLayout(LayoutKind.Sequential)]
internal struct INPUT
@@ -417,11 +417,11 @@ namespace Microsoft.PowerShell
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 @@ namespace Microsoft.PowerShell
}
}
#endif
#endregion
#endregion
#region Input break handler (Ctrl-C, Ctrl-Break)
#region Input break handler (Ctrl-C, Ctrl-Break)
/// <summary>
/// Types of control ConsoleBreakSignals received by break Win32Handler delegates.
@@ -546,9 +546,9 @@ namespace Microsoft.PowerShell
}
}
#endregion
#endregion
#region Win32Handles
#region Win32Handles
private static readonly Lazy<ConsoleHandle> _keyboardInputHandle = new Lazy<SafeFileHandle>(() =>
{
@@ -621,9 +621,9 @@ namespace Microsoft.PowerShell
return _outputHandle.Value;
}
#endregion
#endregion
#region Mode
#region Mode
/// <summary>
/// Flags used by ConsoleControl.GetMode and ConsoleControl.SetMode.
@@ -707,9 +707,9 @@ namespace Microsoft.PowerShell
}
}
#endregion
#endregion
#region Input
#region Input
/// <summary>
/// Reads input from the console device according to the mode in effect (see GetMode, SetMode)
@@ -943,9 +943,9 @@ namespace Microsoft.PowerShell
}
}
#endregion Input
#endregion Input
#region Buffer
#region Buffer
/// <summary>
/// Wraps Win32 GetConsoleScreenBufferInfo
@@ -1178,7 +1178,7 @@ namespace Microsoft.PowerShell
firstRightLeadingRow = r;
}
for (;;)
for (; ; )
{
r++;
if (r > contentsRegion.Bottom)
@@ -1769,7 +1769,7 @@ namespace Microsoft.PowerShell
}
}
#region ReadConsoleOutput CJK
#region ReadConsoleOutput CJK
/// <summary>
/// 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 @@ namespace Microsoft.PowerShell
rowIndex++;
}
}
#endregion ReadConsoleOutput CJK
#endregion ReadConsoleOutput CJK
private static void ReadConsoleOutputPlain
(
@@ -2408,9 +2408,9 @@ namespace Microsoft.PowerShell
}
}
#endregion Buffer
#endregion Buffer
#region Window
#region Window
/// <summary>
/// Wraps Win32 SetConsoleWindowInfo.
@@ -2536,7 +2536,7 @@ namespace Microsoft.PowerShell
}
}
#endregion Window
#endregion Window
/// <summary>
/// Wrap Win32 WriteConsole.
@@ -2661,7 +2661,7 @@ namespace Microsoft.PowerShell
}
#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 @@ namespace Microsoft.PowerShell
}
#endif
#endregion Dealing with CJK
#endregion Dealing with CJK
#if !UNIX
#region Cursor
#region Cursor
/// <summary>
/// Wraps Win32 SetConsoleCursorPosition.
@@ -2874,9 +2874,9 @@ namespace Microsoft.PowerShell
}
}
#endregion Cursor
#endregion Cursor
#region helper
#region helper
/// <summary>
/// Helper function to create the proper HostException.
@@ -2895,9 +2895,9 @@ namespace Microsoft.PowerShell
return e;
}
#endregion helper
#endregion helper
#region
#region
internal static int LengthInBufferCells(char c)
{
@@ -2915,16 +2915,16 @@ namespace Microsoft.PowerShell
(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 @@ namespace Microsoft.PowerShell
}
}
#endregion SendInput
#endregion SendInput
/// <summary>
/// Class to hold the Native Methods used in this file enclosing class.
@@ -2953,7 +2953,7 @@ namespace Microsoft.PowerShell
internal const int FontTypeMask = 0x06;
internal const int TrueTypeFont = 0x04;
#region CreateFile
#region CreateFile
[Flags]
internal enum AccessQualifiers : uint
@@ -2993,14 +2993,14 @@ namespace Microsoft.PowerShell
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();
@@ -50,7 +50,7 @@ namespace Microsoft.PowerShell
#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
@@ -1251,7 +1251,7 @@ namespace Microsoft.PowerShell
return ConsoleControl.LengthInBufferCells(c);
}
#region internal
#region internal
/// <summary>
/// Clear the ReadKey cache.
@@ -1262,9 +1262,9 @@ namespace Microsoft.PowerShell
cachedKeyEvent.RepeatCount = 0;
}
#endregion internal
#endregion internal
#region helpers
#region helpers
// pass-by-ref for speed.
/// <summary>
@@ -1315,7 +1315,7 @@ namespace Microsoft.PowerShell
return result;
}
#endregion helpers
#endregion helpers
private ConsoleColor defaultForeground = ConsoleColor.Gray;
@@ -1159,7 +1159,7 @@ namespace Microsoft.PowerShell
return sb.ToString();
}
#endregion Word Wrapping
#endregion Word Wrapping
/// <summary>
/// See base class.
@@ -1580,8 +1580,8 @@ namespace Microsoft.PowerShell
}
#endif
do
{
do
{
#if UNIX
keyInfo = Console.ReadKey(true);
#else
@@ -1595,35 +1595,35 @@ namespace Microsoft.PowerShell
#else
if (s.Length == 0)
#endif
{
result = ReadLineResult.endedOnBreak;
s = null;
if (calledFromPipeline)
{
result = ReadLineResult.endedOnBreak;
s = null;
// make sure that the pipeline that called us is stopped
if (calledFromPipeline)
{
// make sure that the pipeline that called us is stopped
throw new PipelineStoppedException();
}
break;
throw new PipelineStoppedException();
}
break;
}
#if UNIX
if (keyInfo.Key == ConsoleKey.Enter)
#else
if (s.EndsWith(Environment.NewLine, 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 - Environment.NewLine.Length);
#endif
break;
}
break;
}
#if UNIX
if (keyInfo.Key == ConsoleKey.Tab)
@@ -1806,15 +1806,15 @@ namespace Microsoft.PowerShell
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
@@ -85,7 +85,7 @@ namespace Microsoft.PowerShell
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);
}
}
@@ -55,7 +55,8 @@ namespace Microsoft.PowerShell
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);
}
@@ -172,7 +172,7 @@ namespace Microsoft.PowerShell
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:
@@ -44,7 +44,7 @@ namespace Microsoft.PowerShell.Commands
/// The literal name of the file in which to write the transcript.
/// </summary>
[Parameter(Position = 0, ParameterSetName = "ByLiteralPath")]
[Alias("PSPath","LP")]
[Alias("PSPath", "LP")]
[ValidateNotNullOrEmpty]
public string LiteralPath
{
@@ -37,7 +37,8 @@ namespace Microsoft.PowerShell
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 @@ namespace Microsoft.PowerShell
/// <summary>
/// Send the telemetry.
/// </summary>
private static void SendTelemetry(string eventName, Dictionary<string,string> payload)
private static void SendTelemetry(string eventName, Dictionary<string, string> payload)
{
try
{
var enabled = !GetEnvironmentVariableAsBool(name : TelemetryOptoutEnvVar, defaultValue : false);
var enabled = !GetEnvironmentVariableAsBool(name: TelemetryOptoutEnvVar, defaultValue: false);
if (!enabled)
{