diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/WebServiceProxy.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/WebServiceProxy.cs index e1ee08b2fb..7ddb52ec82 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/WebServiceProxy.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/WebServiceProxy.cs @@ -150,7 +150,7 @@ namespace Microsoft.PowerShell.Commands /// protected override void BeginProcessing() { - if (_uri.ToString().Trim().Length == 0) + if (string.IsNullOrWhiteSpace(_uri.ToString())) { Exception ex = new ArgumentException(WebServiceResources.InvalidUri); ErrorRecord er = new ErrorRecord(ex, "ArgumentException", ErrorCategory.InvalidOperation, null); diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs index 5a4c3768b2..ae01316a89 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs @@ -2434,7 +2434,7 @@ namespace Microsoft.PowerShell continue; } - if (line.Trim().Length == 0) + if (string.IsNullOrWhiteSpace(line)) { if (inBlockMode) { diff --git a/src/System.Management.Automation/engine/ErrorPackage.cs b/src/System.Management.Automation/engine/ErrorPackage.cs index 1086e84266..44c275e688 100644 --- a/src/System.Management.Automation/engine/ErrorPackage.cs +++ b/src/System.Management.Automation/engine/ErrorPackage.cs @@ -901,7 +901,7 @@ namespace System.Management.Automation string resourceId, params object[] args) { - if (String.IsNullOrEmpty(template) || 1 >= template.Trim().Length) + if (string.IsNullOrWhiteSpace(template)) { _textLookupError = PSTraceSource.NewInvalidOperationException( ErrorPackage.ErrorDetailsEmptyTemplate, diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index 6b57a8318d..e174393603 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -195,7 +195,7 @@ namespace System.Management.Automation.Runspaces public SessionStateTypeEntry(string fileName) : base(fileName) { - if (String.IsNullOrEmpty(fileName) || fileName.Trim().Length == 0) + if (string.IsNullOrWhiteSpace(fileName)) { throw PSTraceSource.NewArgumentException("fileName"); } @@ -300,7 +300,7 @@ namespace System.Management.Automation.Runspaces public SessionStateFormatEntry(string fileName) : base("*") { - if (String.IsNullOrEmpty(fileName) || fileName.Trim().Length == 0) + if (string.IsNullOrWhiteSpace(fileName)) { throw PSTraceSource.NewArgumentException("fileName"); } diff --git a/src/System.Management.Automation/engine/MshMemberInfo.cs b/src/System.Management.Automation/engine/MshMemberInfo.cs index eb32b76fbe..aeee875090 100644 --- a/src/System.Management.Automation/engine/MshMemberInfo.cs +++ b/src/System.Management.Automation/engine/MshMemberInfo.cs @@ -1782,7 +1782,7 @@ namespace System.Management.Automation { get { - return this.SetterScript != null; + return this._setterScript != null || this._setterScriptText != null; } } @@ -1793,7 +1793,7 @@ namespace System.Management.Automation { get { - return this.GetterScript != null; + return this._getterScript != null || this._getterScriptText != null; } } diff --git a/src/System.Management.Automation/engine/hostifaces/Parameter.cs b/src/System.Management.Automation/engine/hostifaces/Parameter.cs index 9818cb5ac1..b87e14f8bc 100644 --- a/src/System.Management.Automation/engine/hostifaces/Parameter.cs +++ b/src/System.Management.Automation/engine/hostifaces/Parameter.cs @@ -49,7 +49,7 @@ namespace System.Management.Automation.Runspaces { if (name != null) { - if (name.Trim().Length == 0) + if (string.IsNullOrWhiteSpace(name)) { throw PSTraceSource.NewArgumentException("name"); } @@ -105,7 +105,7 @@ namespace System.Management.Automation.Runspaces Diagnostics.Assert(name != null, "'name' variable should be initialized at this point"); Diagnostics.Assert(name[0].IsDash(), "first character in parameter name must be a dash"); - Diagnostics.Assert(name.Trim().Length != 0, "Parameter name has to have some non-whitespace characters in it"); + Diagnostics.Assert(name.Trim().Length != 1, "Parameter name has to have some non-whitespace characters in it"); } if (internalParameter.ParameterAndArgumentSpecified)