From 83079f6397fe40b3b21ebf5276eeebbfe8bf5a0a Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sat, 29 Aug 2020 07:21:28 +0100 Subject: [PATCH] Reformat StringUtil (#13509) --- .../utils/StringUtil.cs | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/System.Management.Automation/utils/StringUtil.cs b/src/System.Management.Automation/utils/StringUtil.cs index 0b74385d33..c84b3f5e9f 100644 --- a/src/System.Management.Automation/utils/StringUtil.cs +++ b/src/System.Management.Automation/utils/StringUtil.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +using System.Globalization; using System.Management.Automation.Host; using System.Threading; @@ -8,24 +9,21 @@ using Dbg = System.Management.Automation.Diagnostics; namespace System.Management.Automation.Internal { - internal static - class StringUtil + internal static class StringUtil { internal static string Format(string format, object arg0) - => string.Format(Globalization.CultureInfo.CurrentCulture, format, arg0); + => string.Format(CultureInfo.CurrentCulture, format, arg0); internal static string Format(string format, object arg0, object arg1) - => string.Format(Globalization.CultureInfo.CurrentCulture, format, arg0, arg1); + => string.Format(CultureInfo.CurrentCulture, format, arg0, arg1); internal static string Format(string format, object arg0, object arg1, object arg2) - => string.Format(Globalization.CultureInfo.CurrentCulture, format, arg0, arg1, arg2); + => string.Format(CultureInfo.CurrentCulture, format, arg0, arg1, arg2); internal static string Format(string format, params object[] args) - => string.Format(Globalization.CultureInfo.CurrentCulture, format, args); + => string.Format(CultureInfo.CurrentCulture, format, args); - internal static - string - TruncateToBufferCellWidth(PSHostRawUserInterface rawUI, string toTruncate, int maxWidthInBufferCells) + internal static string TruncateToBufferCellWidth(PSHostRawUserInterface rawUI, string toTruncate, int maxWidthInBufferCells) { Dbg.Assert(rawUI != null, "need a reference"); Dbg.Assert(maxWidthInBufferCells >= 0, "maxWidthInBufferCells must be positive"); @@ -58,19 +56,19 @@ namespace System.Management.Automation.Internal // Typical padding is at most a screen's width, any more than that and we won't bother caching. private const int IndentCacheMax = 120; - private static readonly string[] IndentCache = new string[IndentCacheMax]; + private static readonly string[] s_indentCache = new string[IndentCacheMax]; internal static string Padding(int countOfSpaces) { if (countOfSpaces >= IndentCacheMax) return new string(' ', countOfSpaces); - var result = IndentCache[countOfSpaces]; + var result = s_indentCache[countOfSpaces]; if (result == null) { - Interlocked.CompareExchange(ref IndentCache[countOfSpaces], new string(' ', countOfSpaces), null); - result = IndentCache[countOfSpaces]; + Interlocked.CompareExchange(ref s_indentCache[countOfSpaces], new string(' ', countOfSpaces), null); + result = s_indentCache[countOfSpaces]; } return result; @@ -78,23 +76,22 @@ namespace System.Management.Automation.Internal private const int DashCacheMax = 120; - private static readonly string[] DashCache = new string[DashCacheMax]; + private static readonly string[] s_dashCache = new string[DashCacheMax]; internal static string DashPadding(int count) { if (count >= DashCacheMax) return new string('-', count); - var result = DashCache[count]; + var result = s_dashCache[count]; if (result == null) { - Interlocked.CompareExchange(ref DashCache[count], new string('-', count), null); - result = DashCache[count]; + Interlocked.CompareExchange(ref s_dashCache[count], new string('-', count), null); + result = s_dashCache[count]; } return result; } } } -