From 2bfbcd4f071d2b92b14748ceba11607e90e9679b Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Thu, 20 Dec 2018 23:23:04 -0800 Subject: [PATCH] Remove empty lines; correct space on closing square brackets, negative signs, and generic brackets (#8508) --- .../commands/utility/CSVCommands.cs | 1 - .../host/msh/CommandLineParameterParser.cs | 1 - .../host/msh/Telemetry.cs | 2 +- .../security/AclCommands.cs | 1 - .../security/CertificateProvider.cs | 2 +- src/Microsoft.WSMan.Management/WsManHelper.cs | 2 - .../engine/COM/ComDispatch.cs | 2 +- .../engine/ComInterop/ComRuntimeHelpers.cs | 6 +-- .../engine/LanguagePrimitives.cs | 38 +++++++++---------- .../engine/PSVersionInfo.cs | 4 +- .../engine/SessionStateContainer.cs | 1 - .../engine/SessionStateScope.cs | 1 - .../engine/interpreter/InstructionList.cs | 4 +- .../engine/parser/Compiler.cs | 2 +- .../remoting/commands/PSRemotingCmdlet.cs | 2 +- .../engine/remoting/fanin/WSManPlugin.cs | 1 - .../engine/runtime/Binding/Binders.cs | 10 ++--- .../namespaces/FileSystemProvider.cs | 5 +-- .../namespaces/LocationGlobber.cs | 7 +--- .../Controllers/ResumeController.cs | 2 +- 20 files changed, 38 insertions(+), 56 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CSVCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CSVCommands.cs index 2f86c324e6..ccb4dd32f2 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CSVCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CSVCommands.cs @@ -1389,7 +1389,6 @@ namespace Microsoft.PowerShell.Commands current.Remove(0, current.Length); } } - else if (ch == '"') { if (seenBeginQuote) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs index bb7a734723..38d657905a 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs @@ -901,7 +901,6 @@ namespace Microsoft.PowerShell break; } } - else if (MatchSwitch(switchKey, "settingsfile", "settings")) { // Parse setting file arg and write error diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs index 4548d3b814..fea8a66708 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Telemetry.cs @@ -62,7 +62,7 @@ namespace Microsoft.PowerShell /// /// Send the telemetry /// - private static void SendTelemetry(string eventName, Dictionarypayload) + private static void SendTelemetry(string eventName, Dictionary payload) { try { diff --git a/src/Microsoft.PowerShell.Security/security/AclCommands.cs b/src/Microsoft.PowerShell.Security/security/AclCommands.cs index a6168fb258..79c63d4e42 100644 --- a/src/Microsoft.PowerShell.Security/security/AclCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/AclCommands.cs @@ -800,7 +800,6 @@ namespace Microsoft.PowerShell.Commands WriteError(er); } } - else { foreach (string p in Path) diff --git a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs index a4286cb595..8f7df3cbb5 100644 --- a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs +++ b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs @@ -3180,7 +3180,7 @@ namespace Microsoft.PowerShell.Commands // if it exists and does not contain a comma // a comma, indicates it is not a DNS name if(cert.Subject.StartsWith(distinguishedNamePrefix, System.StringComparison.InvariantCultureIgnoreCase) && - cert.Subject.IndexOf(",",System.StringComparison.InvariantCulture)==-1) + cert.Subject.IndexOf(",",System.StringComparison.InvariantCulture) == -1) { name = cert.Subject.Substring(distinguishedNamePrefix.Length); try diff --git a/src/Microsoft.WSMan.Management/WsManHelper.cs b/src/Microsoft.WSMan.Management/WsManHelper.cs index fe6e1e4373..3d34373118 100644 --- a/src/Microsoft.WSMan.Management/WsManHelper.cs +++ b/src/Microsoft.WSMan.Management/WsManHelper.cs @@ -334,7 +334,6 @@ namespace Microsoft.WSMan.Management _sr = new StreamReader(_fs); strOut = _sr.ReadToEnd(); } - catch (ArgumentNullException e) { ErrorRecord er = new ErrorRecord(e, "ArgumentNullException", ErrorCategory.InvalidArgument, null); @@ -1078,7 +1077,6 @@ namespace Microsoft.WSMan.Management } } } - catch (IOException e) { diff --git a/src/System.Management.Automation/engine/COM/ComDispatch.cs b/src/System.Management.Automation/engine/COM/ComDispatch.cs index 92d2d7d2d9..f1a1655a8e 100644 --- a/src/System.Management.Automation/engine/COM/ComDispatch.cs +++ b/src/System.Management.Automation/engine/COM/ComDispatch.cs @@ -7,7 +7,7 @@ using COM = System.Runtime.InteropServices.ComTypes; namespace System.Management.Automation { /// - /// Summary description for IDispatch. + /// The IDispatch interface. /// [Guid("00020400-0000-0000-c000-000000000046")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] diff --git a/src/System.Management.Automation/engine/ComInterop/ComRuntimeHelpers.cs b/src/System.Management.Automation/engine/ComInterop/ComRuntimeHelpers.cs index 02ea2d76d9..75d8360987 100644 --- a/src/System.Management.Automation/engine/ComInterop/ComRuntimeHelpers.cs +++ b/src/System.Management.Automation/engine/ComInterop/ComRuntimeHelpers.cs @@ -623,9 +623,9 @@ namespace System.Management.Automation.ComInterop var attributes = new[] { new CustomAttributeBuilder(typeof(UnverifiableCodeAttribute).GetConstructor(Type.EmptyTypes), Utils.EmptyArray()), //PermissionSet(SecurityAction.Demand, Unrestricted = true) - new CustomAttributeBuilder(typeof(PermissionSetAttribute).GetConstructor(new Type[]{typeof(SecurityAction)}), - new object[]{SecurityAction.Demand}, - new PropertyInfo[]{typeof(PermissionSetAttribute).GetProperty("Unrestricted")}, + new CustomAttributeBuilder(typeof(PermissionSetAttribute).GetConstructor(new Type[] { typeof(SecurityAction) }), + new object[] { SecurityAction.Demand }, + new PropertyInfo[] { typeof(PermissionSetAttribute).GetProperty("Unrestricted") }, new object[] {true}) }; diff --git a/src/System.Management.Automation/engine/LanguagePrimitives.cs b/src/System.Management.Automation/engine/LanguagePrimitives.cs index aa545f6add..fdcfc02858 100644 --- a/src/System.Management.Automation/engine/LanguagePrimitives.cs +++ b/src/System.Management.Automation/engine/LanguagePrimitives.cs @@ -996,8 +996,8 @@ namespace System.Management.Automation if (LanguagePrimitives.IsNumeric(LanguagePrimitives.GetTypeCode(objType))) { - ConversionData data = GetConversionData(objType, typeof(bool)) ?? - CacheConversion(objType, typeof(bool), CreateNumericToBoolConverter(objType), ConversionRank.Language); + IConversionData data = GetConversionData(objType, typeof(bool)) ?? + CacheConversion(objType, typeof(bool), CreateNumericToBoolConverter(objType), ConversionRank.Language); return (bool)data.Invoke(obj, typeof(bool), false, null, null, null); } @@ -4212,7 +4212,7 @@ namespace System.Management.Automation internal delegate object PSNullConverter(object nullOrAutomationNull); - internal interface ConversionData + internal interface IConversionData { object Converter { get; } ConversionRank Rank { get; } @@ -4226,7 +4226,7 @@ namespace System.Management.Automation } [System.Diagnostics.DebuggerDisplay("{_converter.Method.Name}")] - internal class ConversionData : ConversionData + internal class ConversionData : IConversionData { private readonly PSConverter _converter; @@ -4249,12 +4249,12 @@ namespace System.Management.Automation } } - private static Dictionary s_converterCache = new Dictionary(256); + private static Dictionary s_converterCache = new Dictionary(256); - private static ConversionData CacheConversion(Type fromType, Type toType, PSConverter converter, ConversionRank rank) + private static IConversionData CacheConversion(Type fromType, Type toType, PSConverter converter, ConversionRank rank) { ConversionTypePair pair = new ConversionTypePair(fromType, toType); - ConversionData data = null; + IConversionData data = null; lock (s_converterCache) { if (!s_converterCache.TryGetValue(pair, out data)) @@ -4271,11 +4271,11 @@ namespace System.Management.Automation return data; } - private static ConversionData GetConversionData(Type fromType, Type toType) + private static IConversionData GetConversionData(Type fromType, Type toType) { lock (s_converterCache) { - ConversionData result = null; + IConversionData result = null; s_converterCache.TryGetValue(new ConversionTypePair(fromType, toType), out result); return result; } @@ -4608,7 +4608,7 @@ namespace System.Management.Automation return availableProperties.ToString(); } - internal static ConversionData FigureConversion(object valueToConvert, Type resultType, out bool debase) + internal static IConversionData FigureConversion(object valueToConvert, Type resultType, out bool debase) { PSObject valueAsPsObj; Type originalType; @@ -4625,7 +4625,7 @@ namespace System.Management.Automation debase = false; - ConversionData data = FigureConversion(originalType, resultType); + IConversionData data = FigureConversion(originalType, resultType); if (data.Rank != ConversionRank.None) { return data; @@ -4764,7 +4764,7 @@ namespace System.Management.Automation throw new PSInvalidCastException("ConversionSupportedOnlyToCoreTypes", null, ExtendedTypeSystem.InvalidCastExceptionNonCoreType, resultType.ToString()); } - private static ConversionData FigureLanguageConversion(Type fromType, Type toType, + private static IConversionData FigureLanguageConversion(Type fromType, Type toType, out PSConverter valueDependentConversion, out ConversionRank valueDependentRank) { @@ -4774,7 +4774,7 @@ namespace System.Management.Automation Type underlyingType = Nullable.GetUnderlyingType(toType); if (underlyingType != null) { - ConversionData nullableConversion = FigureConversion(fromType, underlyingType); + IConversionData nullableConversion = FigureConversion(fromType, underlyingType); if (nullableConversion.Rank != ConversionRank.None) { return CacheConversion(fromType, toType, LanguagePrimitives.ConvertToNullable, nullableConversion.Rank); @@ -4834,7 +4834,7 @@ namespace System.Management.Automation return CacheConversion(fromType, toType, LanguagePrimitives.ConvertEnumerableToArray, ConversionRank.Language); } - ConversionData data = FigureConversion(fromType, toElementType); + IConversionData data = FigureConversion(fromType, toElementType); if (data.Rank != ConversionRank.None) { valueDependentRank = data.Rank & ConversionRank.ValueDependent; @@ -5441,9 +5441,9 @@ namespace System.Management.Automation } internal class InternalPSObject : PSObject { } - internal static ConversionData FigureConversion(Type fromType, Type toType) + internal static IConversionData FigureConversion(Type fromType, Type toType) { - ConversionData data = GetConversionData(fromType, toType); + IConversionData data = GetConversionData(fromType, toType); if (data != null) { return data; @@ -5512,7 +5512,7 @@ namespace System.Management.Automation PSConverter valueDependentConversion = null; ConversionRank valueDependentRank = ConversionRank.None; - ConversionData conversionData = FigureLanguageConversion(fromType, toType, out valueDependentConversion, out valueDependentRank); + IConversionData conversionData = FigureLanguageConversion(fromType, toType, out valueDependentConversion, out valueDependentRank); if (conversionData != null) { return conversionData; @@ -5632,9 +5632,9 @@ namespace System.Management.Automation } internal class Null { }; - private static ConversionData FigureConversionFromNull(Type toType) + private static IConversionData FigureConversionFromNull(Type toType) { - ConversionData data = GetConversionData(typeof(Null), toType); + IConversionData data = GetConversionData(typeof(Null), toType); if (data != null) { return data; diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 11ba7ee498..9342b46a01 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -716,8 +716,8 @@ namespace System.Management.Automation } } - if ((dashIndex != - 1 && String.IsNullOrEmpty(preLabel)) || - (plusIndex != - 1 && String.IsNullOrEmpty(buildLabel)) || + if ((dashIndex != -1 && String.IsNullOrEmpty(preLabel)) || + (plusIndex != -1 && String.IsNullOrEmpty(buildLabel)) || String.IsNullOrEmpty(versionSansLabel)) { // We have dash and no preReleaseLabel or diff --git a/src/System.Management.Automation/engine/SessionStateContainer.cs b/src/System.Management.Automation/engine/SessionStateContainer.cs index 8082b847ba..3b61d0c07f 100644 --- a/src/System.Management.Automation/engine/SessionStateContainer.cs +++ b/src/System.Management.Automation/engine/SessionStateContainer.cs @@ -4643,7 +4643,6 @@ namespace System.Management.Automation if (providerPaths.Count > 0) providerPath = providerPaths[0]; } - catch (DriveNotFoundException) { // This exception is expected for remote sessions where drives exist in a remote session but not diff --git a/src/System.Management.Automation/engine/SessionStateScope.cs b/src/System.Management.Automation/engine/SessionStateScope.cs index 02ca5c1167..c8f074409a 100644 --- a/src/System.Management.Automation/engine/SessionStateScope.cs +++ b/src/System.Management.Automation/engine/SessionStateScope.cs @@ -1505,7 +1505,6 @@ namespace System.Management.Automation } } } - catch (ArgumentException) { throwNotSupported = true; diff --git a/src/System.Management.Automation/engine/interpreter/InstructionList.cs b/src/System.Management.Automation/engine/interpreter/InstructionList.cs index e6542a9bf1..dd65d26ac3 100644 --- a/src/System.Management.Automation/engine/interpreter/InstructionList.cs +++ b/src/System.Management.Automation/engine/interpreter/InstructionList.cs @@ -63,7 +63,7 @@ namespace System.Management.Automation.Interpreter } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] - public InstructionList.DebugView.InstructionView[]/*!*/ A0 + public InstructionList.DebugView.InstructionView[] A0 { get { @@ -109,7 +109,7 @@ namespace System.Management.Automation.Interpreter } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] - public InstructionView[]/*!*/ A0 + public InstructionView[] A0 { get { diff --git a/src/System.Management.Automation/engine/parser/Compiler.cs b/src/System.Management.Automation/engine/parser/Compiler.cs index 53b52645f3..1703b173d4 100644 --- a/src/System.Management.Automation/engine/parser/Compiler.cs +++ b/src/System.Management.Automation/engine/parser/Compiler.cs @@ -368,7 +368,7 @@ namespace System.Management.Automation.Language internal static readonly FieldInfo PSObject_isDeserialized = typeof(PSObject).GetField(nameof(PSObject.isDeserialized), instanceFlags); internal static readonly MethodInfo PSObject_ToStringParser = - typeof(PSObject).GetMethod(nameof(PSObject.ToStringParser), staticFlags, null, new[]{typeof(ExecutionContext), typeof(object)}, null); + typeof(PSObject).GetMethod(nameof(PSObject.ToStringParser), staticFlags, null, new[] { typeof(ExecutionContext), typeof(object) }, null); internal static readonly PropertyInfo PSReference_Value = typeof(PSReference).GetProperty(nameof(PSReference.Value)); diff --git a/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs b/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs index 8b84eb7eba..237bcc0a94 100644 --- a/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs +++ b/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs @@ -852,7 +852,7 @@ namespace Microsoft.PowerShell.Commands { Uri uri = new System.Uri("ssh://" + hostname); host = ResolveComputerName(uri.Host); - ValidateComputerName(new string[]{host}); + ValidateComputerName(new string[] { host }); if (uri.UserInfo != String.Empty) { userName = uri.UserInfo; diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs index da65638603..8794f29584 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs @@ -277,7 +277,6 @@ namespace System.Management.Automation.Remoting { serverTransportMgr = new WSManPluginServerTransportManager(BaseTransportManager.DefaultFragmentSize, new PSRemotingCryptoHelperServer()); } - else { serverTransportMgr = new WSManPluginServerTransportManager(BaseTransportManager.DefaultFragmentSize, null); diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index c8c6810c6b..5321f52098 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -3820,7 +3820,7 @@ namespace System.Management.Automation.Language return null; } - internal static Expression InvokeConverter(LanguagePrimitives.ConversionData conversion, + internal static Expression InvokeConverter(LanguagePrimitives.IConversionData conversion, Expression value, Type resultType, bool debase, @@ -7455,9 +7455,7 @@ namespace System.Management.Automation.Language private static readonly Dictionary, PSCreateInstanceBinder> s_binderCache = - new Dictionary - , PSCreateInstanceBinder>( - new KeyComparer()); + new Dictionary, PSCreateInstanceBinder>(new KeyComparer()); public static PSCreateInstanceBinder Get(CallInfo callInfo, PSMethodInvocationConstraints constraints, bool publicTypeOnly = false) { @@ -7632,9 +7630,7 @@ namespace System.Management.Automation.Language private static readonly Dictionary, PSInvokeBaseCtorBinder> s_binderCache = - new Dictionary - , PSInvokeBaseCtorBinder>( - new KeyComparer()); + new Dictionary, PSInvokeBaseCtorBinder>(new KeyComparer()); public static PSInvokeBaseCtorBinder Get(CallInfo callInfo, PSMethodInvocationConstraints constraints) { diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 578fa312c2..f29e0e203c 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -3373,7 +3373,6 @@ namespace Microsoft.PowerShell.Commands { CopyItemFromRemoteSession(path, destinationPath, recurse, Force, fromSession); } - else { // Copy-Item to session @@ -3385,9 +3384,7 @@ namespace Microsoft.PowerShell.Commands CopyItemLocalOrToSession(path, destinationPath, recurse, Force, ps); } } - - // Copy-Item local - else + else // Copy-Item local { CopyItemLocalOrToSession(path, destinationPath, recurse, Force, null); } diff --git a/src/System.Management.Automation/namespaces/LocationGlobber.cs b/src/System.Management.Automation/namespaces/LocationGlobber.cs index dfaaba27d6..980405d3df 100644 --- a/src/System.Management.Automation/namespaces/LocationGlobber.cs +++ b/src/System.Management.Automation/namespaces/LocationGlobber.cs @@ -1713,25 +1713,22 @@ namespace System.Management.Automation bool result = false; - // Is it the global scope? - if (String.Compare( driveName, StringLiterals.Global, StringComparison.OrdinalIgnoreCase) == 0) { + // It's the global scope. s_tracer.WriteLine("match found: {0}", StringLiterals.Global); result = true; scope = _sessionState.Internal.GlobalScope; } - - // Is it the local scope? - else if (String.Compare( driveName, StringLiterals.Local, StringComparison.OrdinalIgnoreCase) == 0) { + // It's the local scope. s_tracer.WriteLine("match found: {0}", driveName); result = true; scope = _sessionState.Internal.CurrentScope; diff --git a/test/tools/WebListener/Controllers/ResumeController.cs b/test/tools/WebListener/Controllers/ResumeController.cs index 3d0de50bd9..d3f8944a45 100644 --- a/test/tools/WebListener/Controllers/ResumeController.cs +++ b/test/tools/WebListener/Controllers/ResumeController.cs @@ -19,7 +19,7 @@ namespace mvc.Controllers { public class ResumeController : Controller { - private static Byte[] FileBytes = new Byte[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; + private static Byte[] FileBytes = new Byte[] { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 }; public async void Index() {