diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs index d39bbc6c4ce..b2cb8fa96e2 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimCommandBase.cs @@ -511,7 +511,6 @@ private void CloneParameterEntries( /// public class CimBaseCommand : Cmdlet, IDisposable { - #region resolve parameter set name /// /// @@ -982,7 +981,6 @@ internal CimCredential CreateCimCredentials(PSCredential psCredentials, NetworkCredential networkCredential = psCredentials.GetNetworkCredential(); DebugHelper.WriteLog("Domain:{0}; UserName:{1}; Password:{2}.", 1, networkCredential.Domain, networkCredential.UserName, psCredentials.Password); credentials = new CimCredential(passwordAuthentication, networkCredential.Domain, networkCredential.UserName, psCredentials.Password); - } else { diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimNewCimInstance.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimNewCimInstance.cs index 40dff3422a2..14c57c87888 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimNewCimInstance.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimNewCimInstance.cs @@ -79,7 +79,6 @@ public void NewCimInstance(NewCimInstanceCommand cmdlet) cmdlet.Key, cmdlet.Property, cmdlet); - } break; @@ -92,7 +91,6 @@ public void NewCimInstance(NewCimInstanceCommand cmdlet) cmdlet.Key, cmdlet.Property, cmdlet); - } break; @@ -103,7 +101,6 @@ public void NewCimInstance(NewCimInstanceCommand cmdlet) cimInstance = CreateCimInstance(cmdlet.CimClass, cmdlet.Property, cmdlet); - } break; @@ -313,7 +310,6 @@ private CimInstance CreateCimInstance( flag); cimInstance.CimInstanceProperties.Add(newProperty); } - } return cimInstance; diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimRegisterCimIndication.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimRegisterCimIndication.cs index 5dee76e5f3c..1ec18f0922b 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimRegisterCimIndication.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimRegisterCimIndication.cs @@ -12,7 +12,6 @@ namespace Microsoft.Management.Infrastructure.CimCmdlets { - /// /// /// Subscription result event args diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimWriteResultObject.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimWriteResultObject.cs index b1ef21600ed..91f3d574a12 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/CimWriteResultObject.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/CimWriteResultObject.cs @@ -50,5 +50,4 @@ internal object Result private object result; #endregion } - } diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/GetCimInstanceCommand.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/GetCimInstanceCommand.cs index 60c6e6bfa7e..9e38546793b 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/GetCimInstanceCommand.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/GetCimInstanceCommand.cs @@ -619,7 +619,6 @@ private void CheckArgument() new ParameterDefinitionEntry(CimBaseCommand.QueryComputerSet, false), new ParameterDefinitionEntry(CimBaseCommand.ClassNameSessionSet, false), new ParameterDefinitionEntry(CimBaseCommand.ClassNameComputerSet, false), - } }, { diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs index f46793eb50b..415d35ee1ba 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/Utils.cs @@ -371,7 +371,6 @@ private static void WriteLogInternal(string message, int indent, int depth) { writer.WriteLineAsync(spaces[indent] + sourceInformation + @" " + message); } - } } } diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/Common/DateTimeApproximationComparer.cs b/src/Microsoft.Management.UI.Internal/ManagementList/Common/DateTimeApproximationComparer.cs index c7b76d0e51d..affbe8ca4ab 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/Common/DateTimeApproximationComparer.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/Common/DateTimeApproximationComparer.cs @@ -56,8 +56,7 @@ private static void GetRoundedValues(DateTime value1, DateTime value2, out DateT private static bool HasTimeComponent(DateTime value) { - bool hasNoTimeComponent = true - && value.Hour == 0 + bool hasNoTimeComponent = value.Hour == 0 && value.Minute == 0 && value.Second == 0 && value.Millisecond == 0; diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/Common/TextBlockService.cs b/src/Microsoft.Management.UI.Internal/ManagementList/Common/TextBlockService.cs index bbd8e90b7cd..888c03944a2 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/Common/TextBlockService.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/Common/TextBlockService.cs @@ -25,7 +25,7 @@ static partial void IsTextTrimmedMonitoringEnabledProperty_PropertyChangedImplem return; } - if ((bool)e.OldValue == true) + if ((bool)e.OldValue) { tb.SizeChanged -= OnTextBlockSizeChanged; } diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/DefaultFilterRuleCustomizationFactory.cs b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/DefaultFilterRuleCustomizationFactory.cs index 54742e62235..bd5faf32d63 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/DefaultFilterRuleCustomizationFactory.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/DefaultFilterRuleCustomizationFactory.cs @@ -168,8 +168,7 @@ public override string GetErrorMessageForInvalidValue(string value, Type typeToP throw new ArgumentNullException("typeToParseTo"); } - bool isNumericType = false - || typeToParseTo == typeof(byte) + bool isNumericType = typeToParseTo == typeof(byte) || typeToParseTo == typeof(sbyte) || typeToParseTo == typeof(short) || typeToParseTo == typeof(ushort) diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/CommonUtils.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/CommonUtils.cs index bd686e7f9c9..bd99ef7aff2 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/CommonUtils.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/CommonUtils.cs @@ -39,11 +39,9 @@ uint dwFlags [DllImport(LibraryLoadDllName)] private static extern bool FreeLibrary(IntPtr hModule); - [DllImport(LocalizationDllName, EntryPoint = "GetUserDefaultLangID", CallingConvention = CallingConvention.Winapi, SetLastError = true)] private static extern ushort GetUserDefaultLangID(); - public static uint FormatMessageFromModule(uint lastError, string moduleName, out String msg) { Debug.Assert(!string.IsNullOrEmpty(moduleName)); diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs index 1c5da218afc..5ab73cf1ec6 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/GetCounterCommand.cs @@ -212,7 +212,6 @@ public string[] ComputerName // protected override void BeginProcessing() { - if (Platform.IsIoT) { // IoT does not have the '$env:windir\System32\pdh.dll' assembly which is required by this cmdlet. diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs index b9208804caa..33e127565e6 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs @@ -2018,7 +2018,6 @@ private void AddLogsForProviderToInternalMap(EventLogSession eventLogSession, st _providersByLogMap.Add(logLink.LogName.ToLowerInvariant(), provColl); } else - { // // Log is there: add provider, if needed diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CreateInstanceJob.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CreateInstanceJob.cs index b55b105e20b..7f76ff98574 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CreateInstanceJob.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CreateInstanceJob.cs @@ -76,7 +76,7 @@ internal override IObservable GetCimOperation() else { #if DEBUG - Dbg.Assert(_createInstanceOperationGotStarted == true, "GetInstance should be started *after* CreateInstance"); + Dbg.Assert(_createInstanceOperationGotStarted, "GetInstance should be started *after* CreateInstance"); Dbg.Assert(_getInstanceOperationGotStarted == false, "Should not start GetInstance operation twice"); Dbg.Assert(_resultFromGetInstance == null, "GetInstance operation shouldn't happen twice"); _getInstanceOperationGotStarted = true; diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs index d8f0b96fade..dc545e76daa 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs @@ -1876,7 +1876,7 @@ internal static bool IsValidDrive(string drive) { if (logicalDrive.DriveType.Equals(DriveType.Fixed)) { - if (drive.ToString().Equals(logicalDrive.Name.ToString(), System.StringComparison.OrdinalIgnoreCase)) + if (drive.Equals(logicalDrive.Name, System.StringComparison.OrdinalIgnoreCase)) return true; } } diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Hotfix.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Hotfix.cs index f4c634adca2..c0404fa133c 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Hotfix.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Hotfix.cs @@ -66,7 +66,7 @@ public sealed class GetHotFixCommand : PSCmdlet, IDisposable private ManagementObjectSearcher _searchProcess; private bool _inputContainsWildcard = false; - private readonly ConnectionOptions _connectionOptions = new ConnectionOptions { }; + private readonly ConnectionOptions _connectionOptions = new ConnectionOptions(); /// /// Sets connection options. diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs index f62591fa19c..9b5c1450c49 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs @@ -144,7 +144,6 @@ internal void SetServiceSecurityDescriptor( StringUtil.Format(ServiceResources.CouldNotSetServiceSecurityDescriptorSddl, service.ServiceName, exception.Message), accessDenied ? ErrorCategory.PermissionDenied : ErrorCategory.InvalidOperation); } - } #endregion Internal } @@ -2749,7 +2748,6 @@ NakedWin32Handle CreateServiceW( [In] IntPtr lpPassword ); - [DllImport(PinvokeDllNames.SetServiceObjectSecurityDllName, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs index 0b8573f9859..4f7185a7e85 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs @@ -577,7 +577,6 @@ protected override void EndProcessing() return; } - if (_loadAssembly) { // File extension is ".DLL" (ParameterSetName = FromPathParameterSetName or FromLiteralPathParameterSetName). diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs index 5088d4801c4..0372298d7b5 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs @@ -1738,7 +1738,7 @@ internal static char SetDelimiter(PSCmdlet cmdlet, string parameterSetName, char case "UseCulture": case "CulturePath": case "CultureLiteralPath": - if (useCulture == true) + if (useCulture) { // ListSeparator is apparently always a character even though the property returns a string, checked via: // [CultureInfo]::GetCultures("AllCultures") | % { ([CultureInfo]($_.Name)).TextInfo.ListSeparator } | ? Length -ne 1 diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs index 22572c65443..465ef91f037 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs @@ -648,7 +648,7 @@ private void WriteStartOfPSObject( if (property != null) { WriteStartElement(_writer, CustomSerializationStrings.Properties); - WriteAttribute(_writer, CustomSerializationStrings.NameAttribute, property.ToString()); + WriteAttribute(_writer, CustomSerializationStrings.NameAttribute, property); } else { @@ -1063,9 +1063,9 @@ private void WritePropertyWithNullValue( XmlWriter writer, PSPropertyInfo source, int depth) { WriteStartElement(writer, CustomSerializationStrings.Properties); - WriteAttribute(writer, CustomSerializationStrings.NameAttribute, ((PSPropertyInfo)source).Name.ToString()); + WriteAttribute(writer, CustomSerializationStrings.NameAttribute, ((PSPropertyInfo)source).Name); if (!_notypeinformation) - WriteAttribute(writer, CustomSerializationStrings.TypeAttribute, ((PSPropertyInfo)source).TypeNameOfValue.ToString()); + WriteAttribute(writer, CustomSerializationStrings.TypeAttribute, ((PSPropertyInfo)source).TypeNameOfValue); writer.WriteEndElement(); } @@ -1075,7 +1075,7 @@ private void WriteObjectString( if (property != null) { WriteStartElement(writer, CustomSerializationStrings.Properties); - WriteAttribute(writer, CustomSerializationStrings.NameAttribute, property.ToString()); + WriteAttribute(writer, CustomSerializationStrings.NameAttribute, property); } else { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/common/GetFormatDataCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/common/GetFormatDataCommand.cs index 09a6a88693f..70967aa897b 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/common/GetFormatDataCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/common/GetFormatDataCommand.cs @@ -112,9 +112,9 @@ protected override void ProcessRecord() // During remoting, remain compatible with v5.0- clients by default. // Passing a -PowerShellVersion argument allows overriding the client version. - bool writeOldWay = + bool writeOldWay = (remotingClientInfo != null && clientVersion == null) // To be safe: Remoting client version could unexpectedly not be determined. - || + || (clientVersion != null && (clientVersion.Major < 5 diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs index 2e1d8988496..58d9d762ab7 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs @@ -20,7 +20,6 @@ using Dbg = System.Management.Automation.Diagnostics; - namespace Microsoft.PowerShell.Commands { using PowerShell = System.Management.Automation.PowerShell; @@ -800,7 +799,7 @@ private void ReportSkippedCommands() if (_commandsSkippedBecauseOfShadowing.Count != 0) { string skippedCommands = string.Join(", ", _commandsSkippedBecauseOfShadowing.ToArray()); - ErrorRecord errorRecord = this.GetErrorCommandSkippedBecauseOfShadowing(skippedCommands.ToString()); + ErrorRecord errorRecord = this.GetErrorCommandSkippedBecauseOfShadowing(skippedCommands); this.WriteWarning(errorRecord.ErrorDetails.Message); } } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs index b2dd03762cb..c19c85d0a86 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/New-Object.cs @@ -465,7 +465,7 @@ private object CreateComObject() thread.Join(); - if (createInfo.success == true) + if (createInfo.success) { return createInfo.objectCreated; } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs index 25da2e8025f..78e65d806a3 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs @@ -377,7 +377,7 @@ protected override void EndProcessing() finally { _mSmtpClient.Dispose(); - + // If we don't dispose the attachments, the sender can't modify or use the files sent. _mMailMessage.Attachments.Dispose(); } diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs index 1e404991bc9..aa4c2634266 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs @@ -47,7 +47,7 @@ public enum TextEncodingType /// Big Endian UTF32 encoding. /// BigEndianUTF32, - + /// /// UTF8 encoding. /// diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs index e36eee9ad41..f38446ed57f 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs @@ -1070,7 +1070,7 @@ internal virtual HttpRequestMessage GetRequest(Uri uri) if (!string.IsNullOrEmpty(CustomMethod)) { // set the method if the parameter was provided - httpMethod = new HttpMethod(CustomMethod.ToString().ToUpperInvariant()); + httpMethod = new HttpMethod(CustomMethod.ToUpperInvariant()); } break; @@ -1478,7 +1478,7 @@ protected override void ProcessRecord() && PreserveAuthorizationOnRedirect.IsPresent && - WebSession.Headers.ContainsKey(HttpKnownHeaderNames.Authorization.ToString()); + WebSession.Headers.ContainsKey(HttpKnownHeaderNames.Authorization); using (HttpClient client = GetHttpClient(keepAuthorization)) { @@ -1845,7 +1845,7 @@ internal void ParseLinkHeader(HttpResponseMessage response, System.Uri requestUr if (url != string.Empty && rel != string.Empty && !_relationLink.ContainsKey(rel)) { Uri absoluteUri = new Uri(requestUri, url); - _relationLink.Add(rel, absoluteUri.AbsoluteUri.ToString()); + _relationLink.Add(rel, absoluteUri.AbsoluteUri); } } } @@ -1899,7 +1899,7 @@ private void AddMultipartContent(object fieldName, object fieldValue, MultipartF } // Treat the value as a collection and enumerate it if enumeration is true - if (enumerate == true && fieldValue is IEnumerable items) + if (enumerate && fieldValue is IEnumerable items) { foreach (var item in items) { diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs index 736b2bcdc79..def03fc9c45 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/JsonObject.cs @@ -780,7 +780,7 @@ private static object ProcessCustomObject(object o, int depth, in ConvertToJs if (!info2.IsDefined(typeof(T), true)) { MethodInfo getMethod = info2.GetGetMethod(); - if ((getMethod != null) && (getMethod.GetParameters().Length <= 0)) + if ((getMethod != null) && (getMethod.GetParameters().Length == 0)) { object value; try diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs index a66e24f4b9e..7c2f2e44bf9 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WriteConsoleCmdlet.cs @@ -71,7 +71,7 @@ private string ProcessObject(object o) foreach (object element in enumerable) { - if (printSeparator == true && Separator != null) + if (printSeparator && Separator != null) { result.Append(Separator.ToString()); } diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs index ba90c7dd04e..b74c1982c48 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/CommandLineParameterParser.cs @@ -879,7 +879,6 @@ private void ParseHelper(string[] args) { // Just toss this option, it was processed earlier... } - else if (MatchSwitch(switchKey, "modules", "mod")) { if (ConsoleHost.DefaultInitialSessionState == null) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs index 44ad59579d2..5021775d0fa 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs @@ -1280,7 +1280,7 @@ internal bool ShouldEndSession { // If ShouldEndSession is already true, you can't set it back - Dbg.Assert(_shouldEndSession != true || value != false, + Dbg.Assert(_shouldEndSession != true || value, "ShouldEndSession can only be set from false to true"); _shouldEndSession = value; diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs index a4d0e91f540..483fdb4625d 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs @@ -29,7 +29,6 @@ namespace Microsoft.PowerShell [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")] internal partial class ConsoleHostUserInterface : System.Management.Automation.Host.PSHostUserInterface { - /// /// This is the char that is echoed to the console when the input is masked. This not localizable. /// diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs index bdba911e298..cbb02df5473 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs @@ -241,7 +241,7 @@ internal void ExecuteCommandAsyncHelper(Pipeline tempPipeline, out Exception exc // hence the Input pipe. break; } - }; + } des.End(); } diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/Reader/NativeWrapper.cs b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/Reader/NativeWrapper.cs index 8a7fda12c74..8858b067f8a 100644 --- a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/Reader/NativeWrapper.cs +++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/Reader/NativeWrapper.cs @@ -685,7 +685,7 @@ public static void EvtSetChannelConfigProperty(EventLogHandle handle, UnsafeNati case UnsafeNativeMethods.EvtChannelConfigPropertyId.EvtChannelConfigEnabled: { varVal.Type = (uint)UnsafeNativeMethods.EvtVariantType.EvtVarTypeBoolean; - if ((bool)val == true) varVal.Bool = 1; + if ((bool)val) varVal.Bool = 1; else varVal.Bool = 0; } @@ -730,7 +730,7 @@ public static void EvtSetChannelConfigProperty(EventLogHandle handle, UnsafeNati case UnsafeNativeMethods.EvtChannelConfigPropertyId.EvtChannelLoggingConfigRetention: { varVal.Type = (uint)UnsafeNativeMethods.EvtVariantType.EvtVarTypeBoolean; - if ((bool)val == true) varVal.Bool = 1; + if ((bool)val) varVal.Bool = 1; else varVal.Bool = 0; } @@ -738,7 +738,7 @@ public static void EvtSetChannelConfigProperty(EventLogHandle handle, UnsafeNati case UnsafeNativeMethods.EvtChannelConfigPropertyId.EvtChannelLoggingConfigAutoBackup: { varVal.Type = (uint)UnsafeNativeMethods.EvtVariantType.EvtVarTypeBoolean; - if ((bool)val == true) varVal.Bool = 1; + if ((bool)val) varVal.Bool = 1; else varVal.Bool = 0; } diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs index 7384bacf026..326f53d4d94 100644 --- a/src/Microsoft.WSMan.Management/ConfigProvider.cs +++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs @@ -823,7 +823,7 @@ protected override void GetItem(string path) try { PSObject mshObject = null; - if (!uri.Equals(WinrmRootName[0].ToString(), StringComparison.OrdinalIgnoreCase)) + if (!uri.Equals(WinrmRootName[0], StringComparison.OrdinalIgnoreCase)) { foreach (XmlNode innerResourceNodes in xmlResource.ChildNodes) { @@ -2259,7 +2259,7 @@ private void NewItemPluginOrPluginChild(object sessionobj, string path, string h inputStr = ConstructPluginXml(ps, uri, host, "Set", ResourceArray, SecurityArray, InitParamArray); try { - ((IWSManSession)sessionobj).Put(uri + "?" + "Name=" + pName, inputStr.ToString(), 0); + ((IWSManSession)sessionobj).Put(uri + "?" + "Name=" + pName, inputStr, 0); if (path.EndsWith(strPathChk + WSManStringLiterals.containerInitParameters, StringComparison.OrdinalIgnoreCase)) { WriteItemObject(GetItemPSObjectWithTypeName(mshObj.Properties[NewItem].Name, mshObj.Properties[NewItem].TypeNameOfValue, mshObj.Properties[NewItem].Value, null, "InitParams", WsManElementObjectTypes.WSManConfigLeafElement), path + WSManStringLiterals.DefaultPathSeparator + mshObj.Properties[NewItem].Name, false); @@ -2536,7 +2536,7 @@ private string GetRootNodeName(string ResourceURI) MatchCollection regexmatch = objregex.Matches(ResourceURI); if (regexmatch.Count > 0) { - tempuri = regexmatch[0].Value.ToString(); + tempuri = regexmatch[0].Value; } return tempuri; @@ -2686,7 +2686,7 @@ private void PutResourceValue(object sessionobj, string ResourceURI, Hashtable v if (Itemfound) { ResourceURI = GetURIWithFilter(ResourceURI, value); - ((IWSManSession)sessionobj).Put(ResourceURI, node.OuterXml.ToString(), 0); + ((IWSManSession)sessionobj).Put(ResourceURI, node.OuterXml, 0); } else { @@ -3344,7 +3344,7 @@ private string NormalizePath(string path, string host) if (path.Equals(host, StringComparison.OrdinalIgnoreCase)) { - uri = WinrmRootName[0].ToString(); + uri = WinrmRootName[0]; return uri; } @@ -3353,19 +3353,19 @@ private string NormalizePath(string path, string host) string host_prefix = host + WSManStringLiterals.DefaultPathSeparator; if (path.StartsWith(host_prefix + WSManStringLiterals.containerClientCertificate, StringComparison.OrdinalIgnoreCase)) { - uri = WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerCertMapping; + uri = WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerCertMapping; } else if (path.StartsWith(host_prefix + WSManStringLiterals.containerPlugin, StringComparison.OrdinalIgnoreCase)) { - uri = WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerPlugin; + uri = WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerPlugin; } else if (path.StartsWith(host_prefix + WSManStringLiterals.containerShell, StringComparison.OrdinalIgnoreCase)) { - uri = WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerWinrs; + uri = WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerWinrs; } else if (path.StartsWith(host_prefix + WSManStringLiterals.containerListener, StringComparison.OrdinalIgnoreCase)) { - uri = WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerListener; + uri = WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerListener; } else { @@ -3380,7 +3380,7 @@ private string NormalizePath(string path, string host) } } - uri = WinrmRootName[0].ToString() + uri; + uri = WinrmRootName[0] + uri; } return uri; @@ -3795,7 +3795,6 @@ private void GetItemListenerOrCertMapping(string path, XmlDocument xmlResource, if (path.EndsWith(host + WSManStringLiterals.DefaultPathSeparator + ContainerListenerOrClientCert, StringComparison.OrdinalIgnoreCase)) { if (Objcache.ContainsKey(childname)) - WriteItemObject(GetItemPSObjectWithTypeName(childname, WSManStringLiterals.ContainerChildValue, null, (string[])Keyscache[childname], null, WsManElementObjectTypes.WSManConfigContainerElement), path + WSManStringLiterals.DefaultPathSeparator + childname, true); } else @@ -5491,8 +5490,8 @@ private enum WsManElementObjectTypes /// private static readonly List globalWarningUris = new List { - WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerWinrs, - WinrmRootName[0].ToString() + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerService}; + WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerWinrs, + WinrmRootName[0] + WSManStringLiterals.WinrmPathSeparator + WSManStringLiterals.containerService}; #endregion def diff --git a/src/Microsoft.WSMan.Management/CredSSP.cs b/src/Microsoft.WSMan.Management/CredSSP.cs index aaa38a43bab..52c4f4e921d 100644 --- a/src/Microsoft.WSMan.Management/CredSSP.cs +++ b/src/Microsoft.WSMan.Management/CredSSP.cs @@ -480,7 +480,6 @@ protected override void BeginProcessing() } } - #endregion /// diff --git a/src/Microsoft.WSMan.Management/Set-QuickConfig.cs b/src/Microsoft.WSMan.Management/Set-QuickConfig.cs index e81ac154bde..c318ea76477 100644 --- a/src/Microsoft.WSMan.Management/Set-QuickConfig.cs +++ b/src/Microsoft.WSMan.Management/Set-QuickConfig.cs @@ -233,7 +233,7 @@ private void QuickConfigRemoting(bool serviceonly) xpathResult = "/cfg:EnableRemoting_OUTPUT/cfg:Results"; } - if (finalxml.SelectSingleNode(xpathStatus, nsmgr).InnerText.ToString().Equals("succeeded")) + if (finalxml.SelectSingleNode(xpathStatus, nsmgr).InnerText.Equals("succeeded")) { if (serviceonly) { diff --git a/src/Microsoft.WSMan.Management/WSManInstance.cs b/src/Microsoft.WSMan.Management/WSManInstance.cs index 00a824c6d66..5a3d6b74f7f 100644 --- a/src/Microsoft.WSMan.Management/WSManInstance.cs +++ b/src/Microsoft.WSMan.Management/WSManInstance.cs @@ -419,7 +419,7 @@ private string GetFilter() } filter = filter + ""; - return (filter.ToString()); + return (filter); } private void ReturnEnumeration(IWSManEx wsmanObject, IWSManResourceLocator wsmanResourceLocator, IWSManSession wsmanSession) diff --git a/src/Microsoft.WSMan.Management/WsManHelper.cs b/src/Microsoft.WSMan.Management/WsManHelper.cs index 651840cd2ef..f09ba2bb233 100644 --- a/src/Microsoft.WSMan.Management/WsManHelper.cs +++ b/src/Microsoft.WSMan.Management/WsManHelper.cs @@ -1028,7 +1028,7 @@ internal bool ValidateCredSSPRegistry(bool AllowFreshCredentialsValueShouldBePre } string[] valuenames = rGPOLocalMachineKey.GetValueNames(); - if (valuenames.Length <= 0) + if (valuenames.Length == 0) { return !AllowFreshCredentialsValueShouldBePresent; } @@ -1119,7 +1119,7 @@ internal static void LoadResourceData() internal static string GetResourceString(string Key) { // Checks whether resource values already loaded and loads. - if (ResourceValueCache.Count <= 0) + if (ResourceValueCache.Count == 0) { LoadResourceData(); } diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs index 1892a87668b..52e1043cb2c 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs @@ -81,7 +81,7 @@ private string GetStringHelper(StringResourceReference resourceReference, out Lo else { resourceReference.assemblyLocation = loadResult.a.Location; - }; + } // load now the resource from the resource manager cache try diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs index 34702849d14..8b960e32297 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs @@ -98,7 +98,6 @@ private ViewDefinition LoadView(XmlNode viewNode, int index) mainControlFound = true; view.mainControl = LoadListControl(n); } - else if (MatchNodeName(n, XmlTags.WideControlNode)) { if (mainControlFound) diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewManager.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewManager.cs index 3ad2c418db7..aca38f8994b 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewManager.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewManager.cs @@ -516,7 +516,7 @@ internal static FormatEntryData GenerateOutOfBandData(TerminatingErrorContext er } // we must check we have enough properties for a list view - if (new PSPropertyExpression("*").ResolveNames(so).Count <= 0) + if (new PSPropertyExpression("*").ResolveNames(so).Count == 0) { return null; } diff --git a/src/System.Management.Automation/engine/DefaultCommandRuntime.cs b/src/System.Management.Automation/engine/DefaultCommandRuntime.cs index b4f21bb5c26..95e7572810f 100644 --- a/src/System.Management.Automation/engine/DefaultCommandRuntime.cs +++ b/src/System.Management.Automation/engine/DefaultCommandRuntime.cs @@ -36,7 +36,7 @@ public DefaultCommandRuntime(List outputList) /// Implementation of WriteDebug - just discards the input. /// /// Text to write. - public void WriteDebug(string text) {; } + public void WriteDebug(string text) { } /// /// Default implementation of WriteError - if the error record contains @@ -97,38 +97,38 @@ public void WriteObject(object sendToPipeline, bool enumerateCollection) /// Default implementation - just discards it's arguments. /// /// Progress record to write. - public void WriteProgress(ProgressRecord progressRecord) {; } + public void WriteProgress(ProgressRecord progressRecord) { } /// /// Default implementation - just discards it's arguments. /// /// Source ID to write for. /// Record to write. - public void WriteProgress(Int64 sourceId, ProgressRecord progressRecord) {; } + public void WriteProgress(Int64 sourceId, ProgressRecord progressRecord) { } /// /// Default implementation - just discards it's arguments. /// /// Text to write. - public void WriteVerbose(string text) {; } + public void WriteVerbose(string text) { } /// /// Default implementation - just discards it's arguments. /// /// Text to write. - public void WriteWarning(string text) {; } + public void WriteWarning(string text) { } /// /// Default implementation - just discards it's arguments. /// /// Text to write. - public void WriteCommandDetail(string text) {; } + public void WriteCommandDetail(string text) { } /// /// Default implementation - just discards it's arguments. /// /// Record to write. - public void WriteInformation(InformationRecord informationRecord) {; } + public void WriteInformation(InformationRecord informationRecord) { } #endregion Write diff --git a/src/System.Management.Automation/engine/LanguagePrimitives.cs b/src/System.Management.Automation/engine/LanguagePrimitives.cs index d4681be1a7b..d1ebac8c2ce 100644 --- a/src/System.Management.Automation/engine/LanguagePrimitives.cs +++ b/src/System.Management.Automation/engine/LanguagePrimitives.cs @@ -4703,7 +4703,7 @@ private static string GetAvailableProperties(PSObject pso) } availableProperties.Append("[" + p.Name + " <" + p.TypeNameOfValue + ">]"); - if (first == true) + if (first) { first = false; } @@ -5250,7 +5250,7 @@ private static PSConverter FigureParseConversion(Type fromType, Type toT internal static Tuple, ConversionRank> FigureIEnumerableConstructorConversion(Type fromType, Type toType) { // Win8: 653180. If toType is an Abstract type then we cannot construct it anyway. So, bailing out fast. - if (toType.IsAbstract == true) + if (toType.IsAbstract) { return null; } diff --git a/src/System.Management.Automation/engine/Modules/AnalysisCache.cs b/src/System.Management.Automation/engine/Modules/AnalysisCache.cs index 4baa7cc6bfa..dd188b3ff99 100644 --- a/src/System.Management.Automation/engine/Modules/AnalysisCache.cs +++ b/src/System.Management.Automation/engine/Modules/AnalysisCache.cs @@ -738,7 +738,7 @@ private static void Write(string val, byte[] bytes, FileStream stream) private void Serialize(string filename) { AnalysisCacheData fromOtherProcess = null; - Diagnostics.Assert(_saveCacheToDisk != false, "Serialize should never be called without going through QueueSerialization which has a check"); + Diagnostics.Assert(_saveCacheToDisk, "Serialize should never be called without going through QueueSerialization which has a check"); try { diff --git a/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs b/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs index 1521edfc702..f6641930bf7 100644 --- a/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs +++ b/src/System.Management.Automation/engine/Modules/ImportModuleCommand.cs @@ -1920,7 +1920,7 @@ private bool IsModuleInDenyList(string[] moduleDenyList, string moduleName, Modu break; } } - + return match; } @@ -1957,7 +1957,7 @@ private void PrepareNoClobberWinCompatModuleImport(string moduleName, ModuleSpec // moduleName can be just a module name and it also can be a full path to psd1 from which we need to extract the module name string coreModuleToLoad = ModuleIntrinsics.GetModuleName(moduleSpec == null ? moduleName : moduleSpec.Name); - + var isModuleToLoadEngineModule = InitialSessionState.IsEngineModule(coreModuleToLoad); string[] noClobberModuleList = PowerShellConfig.Instance.GetWindowsPowerShellCompatibilityNoClobberModuleList(); if (isModuleToLoadEngineModule || ((noClobberModuleList != null) && noClobberModuleList.Contains(coreModuleToLoad, StringComparer.OrdinalIgnoreCase))) diff --git a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs index 8e2e9c519ef..0a4e51fc743 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs @@ -786,7 +786,7 @@ private PSModuleInfo LoadModuleNamedInManifest(PSModuleInfo parentModule, Module } // The rooted files wasn't found, so don't search anymore... - if (found == false && wasRooted == true) + if (found == false && wasRooted) return null; if (searchModulePath && found == false && moduleFileFound == false) @@ -3162,7 +3162,6 @@ internal PSModuleInfo LoadModuleManifest( newManifestInfo.ExperimentalFeatures = manifestInfo.ExperimentalFeatures; - // If we are in module discovery, then fix the path. if (ss == null) { diff --git a/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs b/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs index 11af91cd4e8..b20e11e4745 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs @@ -420,7 +420,6 @@ internal List GetModules(ModuleSpecification[] fullyQualifiedName, return modulesMatched.OrderBy(m => m.Name).ToList(); } - /// /// Check if a given module info object matches a given module specification. /// diff --git a/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs b/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs index 6f9f5a2f39f..8b2e996bd84 100644 --- a/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs +++ b/src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs @@ -538,7 +538,7 @@ private string QuoteName(string name) { if (name == null) return "''"; - return ("'" + name.ToString().Replace("'", "''") + "'"); + return ("'" + name.Replace("'", "''") + "'"); } /// diff --git a/src/System.Management.Automation/engine/MshObject.cs b/src/System.Management.Automation/engine/MshObject.cs index e7bfeec31d2..cd7a8cf0a14 100644 --- a/src/System.Management.Automation/engine/MshObject.cs +++ b/src/System.Management.Automation/engine/MshObject.cs @@ -776,7 +776,6 @@ public PSMemberInfoCollection Properties } } - /// /// Gets the Method collection, or the members that are actually methods. /// diff --git a/src/System.Management.Automation/engine/NativeCommandProcessor.cs b/src/System.Management.Automation/engine/NativeCommandProcessor.cs index 9c1a92fcda2..5c5f02c4e3e 100644 --- a/src/System.Management.Automation/engine/NativeCommandProcessor.cs +++ b/src/System.Management.Automation/engine/NativeCommandProcessor.cs @@ -1246,7 +1246,7 @@ private void CalculateIORedirection(out bool redirectOutput, out bool redirectEr // In minishell scenario, if output is redirected // then error should also be redirected. - if (redirectError == false && redirectOutput == true && _isMiniShell) + if (redirectError == false && redirectOutput && _isMiniShell) { redirectError = true; } diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index b1cbdf2a1cb..1378f0f0c5e 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -114,7 +114,7 @@ static PSVersionInfo() s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion; s_psVersionTable[PSVersionInfo.WSManStackVersionName] = GetWSManStackVersion(); s_psVersionTable[PSPlatformName] = Environment.OSVersion.Platform.ToString(); - s_psVersionTable[PSOSName] = Runtime.InteropServices.RuntimeInformation.OSDescription.ToString(); + s_psVersionTable[PSOSName] = Runtime.InteropServices.RuntimeInformation.OSDescription; } internal static PSVersionHashTable GetPSVersionTable() diff --git a/src/System.Management.Automation/engine/ProxyCommand.cs b/src/System.Management.Automation/engine/ProxyCommand.cs index 54bce30c9d0..1bb3d15baf3 100644 --- a/src/System.Management.Automation/engine/ProxyCommand.cs +++ b/src/System.Management.Automation/engine/ProxyCommand.cs @@ -434,7 +434,7 @@ public static string GetHelpComments(PSObject help) foreach (PSObject remark in remarks) { string remarkText = GetProperty(remark, "text"); - exsb.Append(remarkText.ToString()); + exsb.Append(remarkText); } } diff --git a/src/System.Management.Automation/engine/SessionStateContainer.cs b/src/System.Management.Automation/engine/SessionStateContainer.cs index e8087539da2..4016bffbaa5 100644 --- a/src/System.Management.Automation/engine/SessionStateContainer.cs +++ b/src/System.Management.Automation/engine/SessionStateContainer.cs @@ -128,7 +128,7 @@ internal bool ItemExists( foreach (string providerPath in providerPaths) { result = ItemExists(providerInstance, providerPath, context); - if (result == true) + if (result) { break; } @@ -3889,7 +3889,7 @@ internal bool HasChildItems( foreach (string providerPath in providerPaths) { result = HasChildItems(providerInstance, providerPath, context); - if (result == true) + if (result) { break; } diff --git a/src/System.Management.Automation/engine/SessionStateFunctionAPIs.cs b/src/System.Management.Automation/engine/SessionStateFunctionAPIs.cs index 573667573a3..42d3607cadb 100644 --- a/src/System.Management.Automation/engine/SessionStateFunctionAPIs.cs +++ b/src/System.Management.Automation/engine/SessionStateFunctionAPIs.cs @@ -120,8 +120,8 @@ internal bool FunctionsExportedWithWildcard set { - Dbg.Assert((value == true), "This property should never be set/reset to false"); - if (value == true) + Dbg.Assert((value), "This property should never be set/reset to false"); + if (value) { _functionsExportedWithWildcard = value; } diff --git a/src/System.Management.Automation/engine/SessionStateProviderAPIs.cs b/src/System.Management.Automation/engine/SessionStateProviderAPIs.cs index d6971865232..f1b637a1d84 100644 --- a/src/System.Management.Automation/engine/SessionStateProviderAPIs.cs +++ b/src/System.Management.Automation/engine/SessionStateProviderAPIs.cs @@ -1269,7 +1269,7 @@ internal ProviderInfo NewProvider(ProviderInfo provider) // An exception during initialization should remove the provider from // session state. - Providers.Remove(provider.Name.ToString()); + Providers.Remove(provider.Name); ProvidersCurrentWorkingDrive.Remove(provider); provider = null; } diff --git a/src/System.Management.Automation/engine/SessionStateScopeAPIs.cs b/src/System.Management.Automation/engine/SessionStateScopeAPIs.cs index 2ab84387726..9dbcfb9c519 100644 --- a/src/System.Management.Automation/engine/SessionStateScopeAPIs.cs +++ b/src/System.Management.Automation/engine/SessionStateScopeAPIs.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. - using Dbg = System.Management.Automation; #pragma warning disable 1634, 1691 // Stops compiler from warning about unknown warnings diff --git a/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs b/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs index 8e199e18cc5..aad2f70246e 100644 --- a/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs +++ b/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs @@ -38,7 +38,6 @@ private static Func> GetVal return s_valueFactoryCache[cacheIndex]; - // Local helper function to avoid creating an instance of the generated delegate helper class // every time 'GetValueFactoryBasedOnInitCapacity' is invoked. static Func> CreateValueFactory(int capacity) diff --git a/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs b/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs index bd0f7943b54..cffbc6d81a1 100644 --- a/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs +++ b/src/System.Management.Automation/engine/hostifaces/ConnectionBase.cs @@ -1043,7 +1043,7 @@ internal void StopNestedPipelines(Pipeline pipeline) // Concurrency check should be done under runspace lock lock (SyncRoot) { - if (_bSessionStateProxyCallInProgress == true) + if (_bSessionStateProxyCallInProgress) { throw PSTraceSource.NewInvalidOperationException(RunspaceStrings.NoPipelineWhenSessionStateProxyInProgress); } @@ -1151,7 +1151,7 @@ private void DoConcurrentCheckAndMarkSessionStateProxyCallInProgress() throw e; } - if (_bSessionStateProxyCallInProgress == true) + if (_bSessionStateProxyCallInProgress) { throw PSTraceSource.NewInvalidOperationException(RunspaceStrings.AnotherSessionStateProxyInProgress); } diff --git a/src/System.Management.Automation/engine/hostifaces/History.cs b/src/System.Management.Automation/engine/hostifaces/History.cs index e22aa0804eb..7bedae6c737 100644 --- a/src/System.Management.Automation/engine/hostifaces/History.cs +++ b/src/System.Management.Automation/engine/hostifaces/History.cs @@ -141,7 +141,6 @@ public override string ToString() /// private long _pipelineId; - /// /// Returns a clone of this object. /// @@ -331,7 +330,7 @@ internal HistoryInfo[] GetEntries(long id, long count, SwitchParameter newest) if (firstId <= 1) break; // if entry is null , continue the loop with the next entry if (_buffer[GetIndexFromId(i)] == null) continue; - if (_buffer[GetIndexFromId(i)].Cleared == true) + if (_buffer[GetIndexFromId(i)].Cleared) { // we have to clear count entries before an id, so if an entry is null,decrement // first id as long as its is greater than the lowest entry in the buffer. @@ -344,7 +343,7 @@ internal HistoryInfo[] GetEntries(long id, long count, SwitchParameter newest) { // if an entry is null after being cleared by clear-history cmdlet, // continue with the next entry - if (_buffer[GetIndexFromId(i)] == null || _buffer[GetIndexFromId(i)].Cleared == true) + if (_buffer[GetIndexFromId(i)] == null || _buffer[GetIndexFromId(i)].Cleared) continue; entriesList.Add(_buffer[GetIndexFromId(i)].Clone()); } @@ -364,7 +363,7 @@ internal HistoryInfo[] GetEntries(long id, long count, SwitchParameter newest) if (firstId >= _countEntriesAdded) break; // if entry is null , continue the loop with the next entry if (_buffer[GetIndexFromId(i)] == null) continue; - if (_buffer[GetIndexFromId(i)].Cleared == true) + if (_buffer[GetIndexFromId(i)].Cleared) { // we have to clear count entries before an id, so if an entry is null,increment first id firstId++; @@ -376,7 +375,7 @@ internal HistoryInfo[] GetEntries(long id, long count, SwitchParameter newest) { // if an entry is null after being cleared by clear-history cmdlet, // continue with the next entry - if (_buffer[GetIndexFromId(i)] == null || _buffer[GetIndexFromId(i)].Cleared == true) + if (_buffer[GetIndexFromId(i)] == null || _buffer[GetIndexFromId(i)].Cleared) continue; entriesList.Add(_buffer[GetIndexFromId(i)].Clone()); } @@ -406,7 +405,7 @@ internal HistoryInfo[] GetEntries(long id, long count, SwitchParameter newest) { if (index > _countEntriesAdded) break; if ((index <= 0 || GetIndexFromId(index) >= _buffer.Length) || - (_buffer[GetIndexFromId(index)].Cleared == true)) + (_buffer[GetIndexFromId(index)].Cleared)) { index++; continue; } @@ -435,7 +434,7 @@ internal HistoryInfo[] GetEntries(long id, long count, SwitchParameter newest) if (index < 1) break; if ((index <= 0 || GetIndexFromId(index) >= _buffer.Length) || - (_buffer[GetIndexFromId(index)].Cleared == true)) + (_buffer[GetIndexFromId(index)].Cleared)) { index--; continue; } else { @@ -1020,7 +1019,7 @@ protected override void EndProcessing() { // Invoke-history can execute only one command. If multiple // ids were provided, throw exception - if (_multipleIdProvided == true) + if (_multipleIdProvided) { Exception ex = new ArgumentException @@ -1717,7 +1716,7 @@ protected override void BeginProcessing() protected override void ProcessRecord() { // case statement to identify the parameter set - switch (ParameterSetName.ToString()) + switch (ParameterSetName) { case "IDParameter": ClearHistoryByID(); diff --git a/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs b/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs index 93cd99d92b6..379deff42e7 100644 --- a/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs +++ b/src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs @@ -1395,7 +1395,7 @@ internal void Stop() PipelineProcessor[] copyStack; lock (_syncRoot) { - if (_stopping == true) + if (_stopping) { return; } diff --git a/src/System.Management.Automation/engine/hostifaces/PSTask.cs b/src/System.Management.Automation/engine/hostifaces/PSTask.cs index 6bf8a74b839..a25e4e2c840 100644 --- a/src/System.Management.Automation/engine/hostifaces/PSTask.cs +++ b/src/System.Management.Automation/engine/hostifaces/PSTask.cs @@ -740,7 +740,7 @@ internal void DisposeRunspaces() { item.Value.Dispose(); } - + _activeRunspaces.Clear(); } diff --git a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs index 646f289076c..ba559a5e1f6 100644 --- a/src/System.Management.Automation/engine/hostifaces/PowerShell.cs +++ b/src/System.Management.Automation/engine/hostifaces/PowerShell.cs @@ -3759,7 +3759,7 @@ public void EndStop(IAsyncResult asyncResult) if ((psAsyncResult == null) || (psAsyncResult.OwnerId != InstanceId) || - (psAsyncResult.IsAssociatedWithAsyncInvoke != false)) + (psAsyncResult.IsAssociatedWithAsyncInvoke)) { throw PSTraceSource.NewArgumentException(nameof(asyncResult), PowerShellStrings.AsyncResultNotOwned, "IAsyncResult", "BeginStop"); @@ -3940,7 +3940,7 @@ private SteppablePipeline GetSteppablePipeline(ExecutionContext context, Command ( Runspace.DefaultRunspace.ExecutionContext, false, - IsNested == true ? CommandOrigin.Internal : CommandOrigin.Runspace + IsNested ? CommandOrigin.Internal : CommandOrigin.Runspace ); commandProcessorBase.RedirectShellErrorOutputPipe = RedirectShellErrorOutputPipe; diff --git a/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs b/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs index aa4252cfcb1..02f0fffaf30 100644 --- a/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs +++ b/src/System.Management.Automation/engine/hostifaces/RunspacePoolInternal.cs @@ -1332,7 +1332,7 @@ protected void CleanupCallback(object state) Runspace runspaceToDestroy = null; lock (pool) { - if (pool.Count <= 0) + if (pool.Count == 0) { break; // break from while } diff --git a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs index df15ce6313e..8538827ea9c 100644 --- a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs +++ b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs @@ -97,7 +97,7 @@ protected PipelineBase(Runspace runspace, // to add cmd to CommandCollection again (Initialize does this).. because of this // I am handling history here.. Initialize(runspace, null, false, isNested); - if (true == addToHistory) + if (addToHistory) { // get command text for history.. string cmdText = command.GetCommandStringForHistory(); diff --git a/src/System.Management.Automation/engine/interpreter/LightCompiler.cs b/src/System.Management.Automation/engine/interpreter/LightCompiler.cs index e05965cb8ff..b05b317dfb5 100644 --- a/src/System.Management.Automation/engine/interpreter/LightCompiler.cs +++ b/src/System.Management.Automation/engine/interpreter/LightCompiler.cs @@ -2034,7 +2034,7 @@ private void CompileNoLabelPush(Expression expr) case ExpressionType.PostDecrementAssign: CompileReducibleExpression(expr); break; default: throw Assert.Unreachable; - }; + } Debug.Assert(_instructions.CurrentStackDepth == startingStackDepth + (expr.Type == typeof(void) ? 0 : 1)); } diff --git a/src/System.Management.Automation/engine/lang/parserutils.cs b/src/System.Management.Automation/engine/lang/parserutils.cs index 6a3a533b121..d3af98dcea5 100644 --- a/src/System.Management.Automation/engine/lang/parserutils.cs +++ b/src/System.Management.Automation/engine/lang/parserutils.cs @@ -905,7 +905,6 @@ private static object AsChar(object obj) return null; } - /// /// The implementation of the PowerShell -replace operator.... /// diff --git a/src/System.Management.Automation/engine/lang/scriptblock.cs b/src/System.Management.Automation/engine/lang/scriptblock.cs index 539be28fe2d..cdce996a3c9 100644 --- a/src/System.Management.Automation/engine/lang/scriptblock.cs +++ b/src/System.Management.Automation/engine/lang/scriptblock.cs @@ -361,7 +361,6 @@ internal PowerShell GetPowerShell( public SteppablePipeline GetSteppablePipeline() => GetSteppablePipelineImpl(commandOrigin: CommandOrigin.Internal, args: null); - /// /// Get a steppable pipeline object. /// diff --git a/src/System.Management.Automation/engine/parser/Compiler.cs b/src/System.Management.Automation/engine/parser/Compiler.cs index 25cee9e73e8..d25aad0485d 100644 --- a/src/System.Management.Automation/engine/parser/Compiler.cs +++ b/src/System.Management.Automation/engine/parser/Compiler.cs @@ -622,7 +622,6 @@ internal static class CachedReflectionInfo internal static readonly MethodInfo VariableOps_SetVariableValue = typeof(VariableOps).GetMethod(nameof(VariableOps.SetVariableValue), StaticFlags); - internal static readonly MethodInfo Utils_IsComObject = typeof(Utils).GetMethod(nameof(Utils.IsComObject), StaticFlags); diff --git a/src/System.Management.Automation/engine/parser/ConstantValues.cs b/src/System.Management.Automation/engine/parser/ConstantValues.cs index ab01c61a651..5813ed9d41f 100644 --- a/src/System.Management.Automation/engine/parser/ConstantValues.cs +++ b/src/System.Management.Automation/engine/parser/ConstantValues.cs @@ -435,7 +435,6 @@ private static object CompileAndInvoke(Ast ast) public object VisitDynamicKeywordStatement(DynamicKeywordStatementAst dynamicKeywordAst) { return AutomationNull.Value; } - public object VisitStatementBlock(StatementBlockAst statementBlockAst) { CheckIsConstant(statementBlockAst, "Caller to verify ast is constant"); diff --git a/src/System.Management.Automation/engine/parser/PSType.cs b/src/System.Management.Automation/engine/parser/PSType.cs index 1064e7a0d10..7ffaab3ff0a 100644 --- a/src/System.Management.Automation/engine/parser/PSType.cs +++ b/src/System.Management.Automation/engine/parser/PSType.cs @@ -349,7 +349,6 @@ private Type GetBaseTypes(Parser parser, TypeDefinitionAst typeDefinitionAst, ou // fall to the default base type } else - { if (baseClass.IsSealed) { diff --git a/src/System.Management.Automation/engine/parser/tokenizer.cs b/src/System.Management.Automation/engine/parser/tokenizer.cs index 3d15ebf4d81..2b85d490366 100644 --- a/src/System.Management.Automation/engine/parser/tokenizer.cs +++ b/src/System.Management.Automation/engine/parser/tokenizer.cs @@ -4243,7 +4243,6 @@ internal Token GetMemberAccessOperator(bool allowLBracket) return NewToken(TokenKind.LBracket); } - if (ExperimentalFeature.IsEnabled("PSNullConditionalOperators") && c == '?') { _tokenStart = _currentIndex; diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index f6c779282a9..8b1779de882 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -240,7 +240,7 @@ internal void LogToEventLog() { // We check to see if the command is needs writing (or if there is anything in the buffer) // before we flush it. Flushing the empty buffer causes a measurable performance degradation. - if (_commands == null || _commands.Count <= 0 || _eventLogBuffer.Count == 0) + if (_commands == null || _commands.Count == 0 || _eventLogBuffer.Count == 0) return; MshLog.LogPipelineExecutionDetailEvent(_commands[0].Command.Context, diff --git a/src/System.Management.Automation/engine/remoting/client/Job.cs b/src/System.Management.Automation/engine/remoting/client/Job.cs index 814b547b3df..1266ebcff6e 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job.cs @@ -2463,7 +2463,7 @@ private void HandleChildJobStateChanged(object sender, JobStateEventArgs e) { SetJobState(JobState.Failed); } - else if (_stopIsCalled == true) + else if (_stopIsCalled) { SetJobState(JobState.Stopped); } @@ -3241,12 +3241,12 @@ protected virtual void HandleOperationComplete(object sender, OperationStateEven /// protected virtual void DoFinish() { - if (_doFinishCalled == true) + if (_doFinishCalled) return; lock (SyncObject) { - if (_doFinishCalled == true) + if (_doFinishCalled) return; _doFinishCalled = true; @@ -4387,12 +4387,12 @@ public override void StopJob() /// protected override void DoFinish() { - if (_doFinishCalled == true) + if (_doFinishCalled) return; lock (SyncObject) { - if (_doFinishCalled == true) + if (_doFinishCalled) return; _doFinishCalled = true; diff --git a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs index a711c7dd8f2..f41a77e7df2 100644 --- a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs +++ b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs @@ -545,7 +545,7 @@ public override void Stop() catch (ObjectDisposedException) { throw PSTraceSource.NewObjectDisposedException("Pipeline"); - }; + } asyncresult.AsyncWaitHandle.WaitOne(); } diff --git a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs index 751969d6f82..38fb0e180fd 100644 --- a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs +++ b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs @@ -1190,7 +1190,7 @@ internal void DoConcurrentCheckAndAddToRunningPipelines(RemotePipeline pipeline, // Concurrency check should be done under runspace lock lock (_syncRoot) { - if (_bSessionStateProxyCallInProgress == true) + if (_bSessionStateProxyCallInProgress) { throw PSTraceSource.NewInvalidOperationException(RunspaceStrings.NoPipelineWhenSessionStateProxyInProgress); } diff --git a/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs b/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs index e8c546ff5e1..3a75567c10f 100644 --- a/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs +++ b/src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs @@ -27,7 +27,6 @@ internal static class NamedPipeUtils { #region Strings - internal const string NamedPipeNamePrefix = "PSHost."; #if UNIX internal const string DefaultAppDomainName = "None"; diff --git a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs index b3159a0e557..7f46151a857 100644 --- a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs +++ b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs @@ -2454,7 +2454,7 @@ private static int StartSSHProcessImpl( if ((ex != null) || (sshProcess == null) || - (sshProcess.HasExited == true)) + (sshProcess.HasExited)) { throw new InvalidOperationException( StringUtil.Format(RemotingErrorIdStrings.CannotStartSSHClient, (ex != null) ? ex.Message : string.Empty), @@ -2552,8 +2552,8 @@ private static Process CreateProcessWithRedirectedStd( { // Create process start command line with filename and argument list. var cmdLine = string.Format( - CultureInfo.InvariantCulture, - @"""{0}"" {1}", + CultureInfo.InvariantCulture, + @"""{0}"" {1}", startInfo.FileName, string.Join(' ', startInfo.ArgumentList)); diff --git a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs index e8a780543bc..0f7f46438cd 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/BaseTransportManager.cs @@ -818,7 +818,7 @@ internal void ServicePendingCallbacks(object objectToProcess) { // If queue is empty or if queue servicing is suspended // then break out of loop. - if (_callbackNotificationQueue.Count <= 0 || _suspendQueueServicing) + if (_callbackNotificationQueue.Count == 0 || _suspendQueueServicing) { break; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs index 174cad6743b..1a9642ca7c2 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs @@ -138,7 +138,7 @@ private void Update(string optionName, string optionValue) case CONFIGFILEPATH: { AssertValueNotAssigned(CONFIGFILEPATH, ConfigFilePath); - ConfigFilePath = optionValue.ToString(); + ConfigFilePath = optionValue; } break; @@ -763,7 +763,7 @@ private static string Dbg.Assert(registryKey != null, "Caller should validate the registryKey parameter"); object value = registryKey.GetValue(name); - if (value == null && mandatory == true) + if (value == null && mandatory) { s_tracer.TraceError("Mandatory property {0} not specified for registry key {1}", name, registryKey.Name); @@ -771,7 +771,7 @@ private static string } string s = value as string; - if (string.IsNullOrEmpty(s) && mandatory == true) + if (string.IsNullOrEmpty(s) && mandatory) { s_tracer.TraceError("Value is null or empty for mandatory property {0} in {1}", name, registryKey.Name); @@ -2392,7 +2392,7 @@ public override InitialSessionState GetInitialSessionState(PSSenderInfo senderIn // Process User Drive if (_configHash.ContainsKey(ConfigFileConstants.MountUserDrive)) { - if (Convert.ToBoolean(_configHash[ConfigFileConstants.MountUserDrive], CultureInfo.InvariantCulture) == true) + if (Convert.ToBoolean(_configHash[ConfigFileConstants.MountUserDrive], CultureInfo.InvariantCulture)) { iss.UserDriveEnabled = true; iss.UserDriveUserName = (senderInfo != null) ? senderInfo.UserInfo.Identity.Name : null; diff --git a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs index 4c3961748eb..28ee574dda1 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs @@ -544,7 +544,7 @@ internal override void CloseAsync() bool shouldRaiseCloseCompleted = false; lock (syncObject) { - if (isClosed == true) + if (isClosed) { return; } @@ -2167,7 +2167,7 @@ internal override void CloseAsync() { lock (syncObject) { - if (isClosed == true) + if (isClosed) { return; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs index 035288443a2..a3c38689c10 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs @@ -167,7 +167,7 @@ internal void SendOneItemToSession( lock (_syncObject) { - if (true == isClosed) + if (isClosed) { WSManPluginInstance.ReportWSManOperationComplete(requestDetails, lastErrorReported); return; @@ -196,7 +196,7 @@ internal bool EnableSessionToSendDataToClient( WSManNativeApi.WSManStreamIDSet_UnToMan streamSet, WSManPluginOperationShutdownContext ctxtToReport) { - if (true == isClosed) + if (isClosed) { WSManPluginInstance.ReportWSManOperationComplete(requestDetails, lastErrorReported); return false; @@ -241,7 +241,7 @@ internal void ReportContext() lock (_syncObject) { - if (true == isClosed) + if (isClosed) { return; } @@ -688,7 +688,7 @@ internal override void CloseOperation( // let command sessions to close. lock (shellSyncObject) { - if (true == isClosed) + if (isClosed) { return; } @@ -788,7 +788,7 @@ internal override void CloseOperation( // let command sessions to close. lock (cmdSyncObject) { - if (true == isClosed) + if (isClosed) { return; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs index 2c963a69d16..31f71c7488a 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs @@ -157,7 +157,7 @@ internal void DoClose( /// internal override void ReportExecutionStatusAsRunning() { - if (true == _isClosed) + if (_isClosed) { return; } @@ -200,7 +200,7 @@ protected override void SendDataToClient( bool reportAsPending, bool reportAsDataBoundary) { - if (true == _isClosed) + if (_isClosed) { return; } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs index 39999788162..1fad7ccb3e8 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs @@ -1191,7 +1191,7 @@ internal override void CloseAsync() // let other threads release the lock before we clean up the resources. lock (syncObject) { - if (isClosed == true) + if (isClosed) { return; } @@ -3105,7 +3105,7 @@ internal override void SendStopSignal() { lock (syncObject) { - if (isClosed == true) + if (isClosed) { return; } @@ -3148,7 +3148,7 @@ internal override void CloseAsync() // then let other threads release the lock before we cleaning up the resources. lock (syncObject) { - if (isClosed == true) + if (isClosed) { return; } diff --git a/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs b/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs index 2662254b877..76a8d8a1081 100644 --- a/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs +++ b/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs @@ -583,7 +583,7 @@ private static bool IsDynamicKeyword(Ast ast) => ast is CommandAst cmdAst && cmdAst.DefiningKeyword != null; private static bool IsUsingTypes(Ast ast) - => ast is UsingStatementAst cmdAst && cmdAst.IsUsingModuleOrAssembly() == true; + => ast is UsingStatementAst cmdAst && cmdAst.IsUsingModuleOrAssembly(); internal static void CacheScriptBlock(ScriptBlock scriptBlock, string fileName, string fileContents) { @@ -723,7 +723,6 @@ internal PowerShell GetPowerShellImpl( args); } - internal SteppablePipeline GetSteppablePipelineImpl(CommandOrigin commandOrigin, object[] args) { var pipelineAst = GetSimplePipeline( @@ -983,10 +982,10 @@ internal void InvokeWithPipeImpl( // Validate at the arguments are consistent. The only public API that gets you here never sets createLocalScope to false... Diagnostics.Assert( - createLocalScope == true || functionsToDefine == null, + createLocalScope || functionsToDefine == null, "When calling ScriptBlock.InvokeWithContext(), if 'functionsToDefine' != null then 'createLocalScope' must be true"); Diagnostics.Assert( - createLocalScope == true || variablesToDefine == null, + createLocalScope || variablesToDefine == null, "When calling ScriptBlock.InvokeWithContext(), if 'variablesToDefine' != null then 'createLocalScope' must be true"); if (args == null) diff --git a/src/System.Management.Automation/help/HelpErrorTracer.cs b/src/System.Management.Automation/help/HelpErrorTracer.cs index 7437e5cc7dd..9c9fd0165b5 100644 --- a/src/System.Management.Automation/help/HelpErrorTracer.cs +++ b/src/System.Management.Automation/help/HelpErrorTracer.cs @@ -156,7 +156,7 @@ internal IDisposable Trace(string helpFile) /// internal void TraceError(ErrorRecord errorRecord) { - if (_traceFrames.Count <= 0) + if (_traceFrames.Count == 0) return; TraceFrame traceFrame = _traceFrames[_traceFrames.Count - 1]; @@ -171,7 +171,7 @@ internal void TraceError(ErrorRecord errorRecord) /// internal void TraceErrors(Collection errorRecords) { - if (_traceFrames.Count <= 0) + if (_traceFrames.Count == 0) return; TraceFrame traceFrame = _traceFrames[_traceFrames.Count - 1]; @@ -181,7 +181,7 @@ internal void TraceErrors(Collection errorRecords) internal void PopFrame(TraceFrame traceFrame) { - if (_traceFrames.Count <= 0) + if (_traceFrames.Count == 0) return; TraceFrame lastFrame = _traceFrames[_traceFrames.Count - 1]; diff --git a/src/System.Management.Automation/help/HelpInfo.cs b/src/System.Management.Automation/help/HelpInfo.cs index bc0b855d807..207d8b54d51 100644 --- a/src/System.Management.Automation/help/HelpInfo.cs +++ b/src/System.Management.Automation/help/HelpInfo.cs @@ -203,7 +203,7 @@ protected void AddCommonHelpProperties() if (this.FullHelp.Properties["Name"] == null) { - this.FullHelp.Properties.Add(new PSNoteProperty("Name", this.Name.ToString())); + this.FullHelp.Properties.Add(new PSNoteProperty("Name", this.Name)); } if (this.FullHelp.Properties["Category"] == null) @@ -213,7 +213,7 @@ protected void AddCommonHelpProperties() if (this.FullHelp.Properties["Synopsis"] == null) { - this.FullHelp.Properties.Add(new PSNoteProperty("Synopsis", this.Synopsis.ToString())); + this.FullHelp.Properties.Add(new PSNoteProperty("Synopsis", this.Synopsis)); } if (this.FullHelp.Properties["Component"] == null) diff --git a/src/System.Management.Automation/help/MamlUtil.cs b/src/System.Management.Automation/help/MamlUtil.cs index 7e8bd8892cf..7ace664b728 100644 --- a/src/System.Management.Automation/help/MamlUtil.cs +++ b/src/System.Management.Automation/help/MamlUtil.cs @@ -192,7 +192,7 @@ internal static void PrependNotes(PSObject maml1, PSObject maml2) /// internal static PSPropertyInfo GetPropertyInfo(PSObject psObject, string[] path) { - if (path.Length <= 0) + if (path.Length == 0) { return null; } @@ -290,7 +290,7 @@ internal static void PrependPropertyValue(PSObject maml1, PSObject maml2, string /// internal static void EnsurePropertyInfoPathExists(PSObject psObject, string[] path) { - if (path.Length <= 0) + if (path.Length == 0) { return; } diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 24e356231a0..1ad37502614 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -2398,7 +2398,7 @@ protected override void NewItem( if (itemType == ItemType.HardLink) { // Hard links can only be to files, not directories. - if (isDirectory == true) + if (isDirectory) { string message = StringUtil.Format(FileSystemProviderStrings.ItemNotFile, strTargetPath); WriteError(new ErrorRecord(new InvalidOperationException(message), "ItemNotFile", ErrorCategory.InvalidOperation, strTargetPath)); diff --git a/src/System.Management.Automation/namespaces/RegistryProvider.cs b/src/System.Management.Automation/namespaces/RegistryProvider.cs index 121d2f1f872..5aa8fbc954d 100644 --- a/src/System.Management.Automation/namespaces/RegistryProvider.cs +++ b/src/System.Management.Automation/namespaces/RegistryProvider.cs @@ -3062,7 +3062,7 @@ private void GetFilteredRegistryKeyProperties(string path, if ( expandAll || ((Context.SuppressWildcardExpansion == false) && (valueNameMatcher.IsMatch(valueNameToMatch))) || - ((Context.SuppressWildcardExpansion == true) && (string.Equals(valueNameToMatch, requestedValueName, StringComparison.OrdinalIgnoreCase)))) + ((Context.SuppressWildcardExpansion) && (string.Equals(valueNameToMatch, requestedValueName, StringComparison.OrdinalIgnoreCase)))) { if (string.IsNullOrEmpty(valueNameToMatch)) { @@ -3833,7 +3833,7 @@ private static object ConvertValueToKind(object value, RegistryValueKind kind) { value = 0; } - }; break; + } break; case RegistryValueKind.ExpandString: value = (value != null) @@ -3870,7 +3870,7 @@ private static object ConvertValueToKind(object value, RegistryValueKind kind) { value = 0; } - }; break; + } break; case RegistryValueKind.String: value = (value != null) diff --git a/src/System.Management.Automation/security/CatalogHelper.cs b/src/System.Management.Automation/security/CatalogHelper.cs index 74a239a2ccd..050c373af74 100644 --- a/src/System.Management.Automation/security/CatalogHelper.cs +++ b/src/System.Management.Automation/security/CatalogHelper.cs @@ -749,7 +749,7 @@ internal static CatalogInformation ValidateCatalog(PSCmdlet cmdlet, Collection /// Constructs a CommandNotFoundException. /// - public CommandNotFoundException() : base() {; } + public CommandNotFoundException() : base() { } /// /// Constructs a CommandNotFoundException. @@ -58,7 +58,7 @@ internal CommandNotFoundException( /// /// The message used in the exception. /// - public CommandNotFoundException(string message) : base(message) {; } + public CommandNotFoundException(string message) : base(message) { } /// /// Constructs a CommandNotFoundException. @@ -69,7 +69,7 @@ internal CommandNotFoundException( /// /// An exception that led to this exception. /// - public CommandNotFoundException(string message, Exception innerException) : base(message, innerException) {; } + public CommandNotFoundException(string message, Exception innerException) : base(message, innerException) { } #region Serialization /// @@ -339,7 +339,7 @@ internal ScriptRequiresException( /// /// Constructs an PSVersionNotCompatibleException. /// - public ScriptRequiresException() : base() {; } + public ScriptRequiresException() : base() { } /// /// Constructs an PSVersionNotCompatibleException. @@ -347,7 +347,7 @@ internal ScriptRequiresException( /// /// The message used in the exception. /// - public ScriptRequiresException(string message) : base(message) {; } + public ScriptRequiresException(string message) : base(message) { } /// /// Constructs an PSVersionNotCompatibleException. @@ -358,7 +358,7 @@ internal ScriptRequiresException( /// /// The exception that led to this exception. /// - public ScriptRequiresException(string message, Exception innerException) : base(message, innerException) {; } + public ScriptRequiresException(string message, Exception innerException) : base(message, innerException) { } #region Serialization /// diff --git a/src/System.Management.Automation/utils/CryptoUtils.cs b/src/System.Management.Automation/utils/CryptoUtils.cs index 2b644f8aebb..f860bdd4b15 100644 --- a/src/System.Management.Automation/utils/CryptoUtils.cs +++ b/src/System.Management.Automation/utils/CryptoUtils.cs @@ -26,7 +26,7 @@ internal static class PSCryptoNativeConverter /// /// The blob version is fixed. /// - public const uint CUR_BLOB_VERSION = 0x00000002; + public const uint CUR_BLOB_VERSION = 0x00000002; /// /// RSA Key. @@ -74,10 +74,10 @@ private static uint ToUInt32LE(byte[] bytes, int offset) private static byte[] GetBytesLE(int val) { - return new [] { - (byte)(val & 0xff), - (byte)((val >> 8) & 0xff), - (byte)((val >> 16) & 0xff), + return new [] { + (byte)(val & 0xff), + (byte)((val >> 8) & 0xff), + (byte)((val >> 16) & 0xff), (byte)((val >> 24) & 0xff) }; } @@ -90,12 +90,12 @@ private static byte[] CreateReverseByteArray(byte[] data) return reverseData; } - internal static RSA FromCapiPublicKeyBlob(byte[] blob) + internal static RSA FromCapiPublicKeyBlob(byte[] blob) { return FromCapiPublicKeyBlob(blob, 0); } - private static RSA FromCapiPublicKeyBlob(byte[] blob, int offset) + private static RSA FromCapiPublicKeyBlob(byte[] blob, int offset) { if (blob == null) { @@ -109,13 +109,13 @@ private static RSA FromCapiPublicKeyBlob(byte[] blob, int offset) var rsap = GetParametersFromCapiPublicKeyBlob(blob, offset); - try + try { RSA rsa = RSA.Create(); rsa.ImportParameters(rsap); return rsa; - } - catch (Exception ex) + } + catch (Exception ex) { throw new CryptographicException(SecuritySupportStrings.CannotImportPublicKey, ex); } @@ -138,14 +138,14 @@ private static RSAParameters GetParametersFromCapiPublicKeyBlob(byte[] blob, int throw new ArgumentException(SecuritySupportStrings.InvalidPublicKey); } - try + try { if ((blob[offset] != PUBLICKEYBLOB) || // PUBLICKEYBLOB (0x06) (blob[offset + 1] != CUR_BLOB_VERSION) || // Version (0x02) (blob[offset + 2] != 0x00) || // Reserved (word) (blob[offset + 3] != 0x00) || (ToUInt32LE(blob, offset + 8) != 0x31415352)) // DWORD magic = RSA1 - { + { throw new CryptographicException(SecuritySupportStrings.InvalidPublicKey); } @@ -158,7 +158,7 @@ private static RSAParameters GetParametersFromCapiPublicKeyBlob(byte[] blob, int rsap.Exponent[0] = blob[offset + 18]; rsap.Exponent[1] = blob[offset + 17]; rsap.Exponent[2] = blob[offset + 16]; - + int pos = offset + 20; int byteLen = (bitLen >> 3); rsap.Modulus = new byte[byteLen]; @@ -166,14 +166,14 @@ private static RSAParameters GetParametersFromCapiPublicKeyBlob(byte[] blob, int Array.Reverse(rsap.Modulus); return rsap; - } - catch (Exception ex) + } + catch (Exception ex) { throw new CryptographicException(SecuritySupportStrings.InvalidPublicKey, ex); } } - internal static byte[] ToCapiPublicKeyBlob(RSA rsa) + internal static byte[] ToCapiPublicKeyBlob(RSA rsa) { if (rsa == null) { @@ -381,7 +381,7 @@ internal class PSRSACryptoServiceProvider : IDisposable // this flag indicates that this class has a key imported from the // remote end and so can be used for encryption - private bool _canEncrypt; + private bool _canEncrypt; // bool indicating if session key was generated before private bool _sessionKeyGenerated = false; @@ -439,7 +439,7 @@ internal void GenerateSessionKey() { // Aes object gens key automatically on construction, so this is somewhat redundant, // but at least the actionable key will not be in-memory until it's requested fwiw. - _aes.GenerateKey(); + _aes.GenerateKey(); _sessionKeyGenerated = true; _canEncrypt = true; // we can encrypt and decrypt once session key is available } @@ -541,7 +541,7 @@ internal byte[] DecryptWithSessionKey(byte[] data) } return targetStream.ToArray(); - } + } } /// diff --git a/src/System.Management.Automation/utils/FuzzyMatch.cs b/src/System.Management.Automation/utils/FuzzyMatch.cs index 828d5cdb148..3052cf6e3f2 100644 --- a/src/System.Management.Automation/utils/FuzzyMatch.cs +++ b/src/System.Management.Automation/utils/FuzzyMatch.cs @@ -21,7 +21,6 @@ public static bool IsFuzzyMatch(string string1, string string2) return GetDamerauLevenshteinDistance(string1, string2) <= MinimumDistance; } - /// /// Compute the case-insensitive distance between two strings. /// Based off https://www.csharpstar.com/csharp-string-distance-algorithm/. @@ -38,8 +37,8 @@ public static int GetDamerauLevenshteinDistance(string string1, string string2) int[,] matrix = new int[bounds.Height, bounds.Width]; - for (int height = 0; height < bounds.Height; height++) { matrix[height, 0] = height; }; - for (int width = 0; width < bounds.Width; width++) { matrix[0, width] = width; }; + for (int height = 0; height < bounds.Height; height++) { matrix[height, 0] = height; } + for (int width = 0; width < bounds.Width; width++) { matrix[0, width] = width; } for (int height = 1; height < bounds.Height; height++) { diff --git a/src/System.Management.Automation/utils/ParameterBinderExceptions.cs b/src/System.Management.Automation/utils/ParameterBinderExceptions.cs index df08765bb2f..903bdc4076c 100644 --- a/src/System.Management.Automation/utils/ParameterBinderExceptions.cs +++ b/src/System.Management.Automation/utils/ParameterBinderExceptions.cs @@ -346,7 +346,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont /// /// DO NOT USE!!! /// - public ParameterBindingException() : base() {; } + public ParameterBindingException() : base() { } /// /// Constructors a ParameterBindingException.