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
/// 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
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.