diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/Common/Utilities.cs b/src/Microsoft.Management.UI.Internal/ManagementList/Common/Utilities.cs
index f0308a8c2b..c6bcfcb173 100644
--- a/src/Microsoft.Management.UI.Internal/ManagementList/Common/Utilities.cs
+++ b/src/Microsoft.Management.UI.Internal/ManagementList/Common/Utilities.cs
@@ -90,7 +90,7 @@ namespace Microsoft.Management.UI.Internal
foreach (object item in items)
{
- if (!(item is T))
+ if (item is not T)
{
return false;
}
diff --git a/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ParameterSetControl.xaml.cs b/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ParameterSetControl.xaml.cs
index c258a2819a..08f9df2933 100644
--- a/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ParameterSetControl.xaml.cs
+++ b/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ParameterSetControl.xaml.cs
@@ -357,7 +357,7 @@ namespace Microsoft.PowerShell.Commands.ShowCommandInternal
/// Will adding UIControl.
private void AddControlToMainGrid(UIElement uiControl)
{
- if (this.firstFocusableElement == null && !(uiControl is Label))
+ if (this.firstFocusableElement == null && uiControl is not Label)
{
this.firstFocusableElement = uiControl;
}
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetContentCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetContentCommand.cs
index 36af765eeb..3b449f9145 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetContentCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetContentCommand.cs
@@ -142,7 +142,7 @@ namespace Microsoft.PowerShell.Commands
holder.Reader != null,
"All holders should have a reader assigned");
- if (_tailSpecified && !(holder.Reader is FileSystemContentReaderWriter))
+ if (_tailSpecified && holder.Reader is not FileSystemContentReaderWriter)
{
string errMsg = SessionStateStrings.GetContent_TailNotSupported;
ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), "TailNotSupported", ErrorCategory.InvalidOperation, Tail);
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 a7add8fcda..ad0bac503c 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
@@ -1897,7 +1897,7 @@ namespace Microsoft.PowerShell.Commands
// Treat Strings and other single values as a StringContent.
// If enumeration is false, also treat IEnumerables as StringContents.
// String implements IEnumerable so the explicit check is required.
- if (enumerate == false || fieldValue is string || !(fieldValue is IEnumerable))
+ if (enumerate == false || fieldValue is string || fieldValue is not IEnumerable)
{
formData.Add(GetMultipartStringContent(fieldName: fieldName, fieldValue: fieldValue));
return;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceListenerCommandBase.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceListenerCommandBase.cs
index a58af1b7f8..984ce18c73 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceListenerCommandBase.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceListenerCommandBase.cs
@@ -419,7 +419,7 @@ namespace Microsoft.PowerShell.Commands
{
TraceListener listenerToRemove = source.Listeners[index];
- if (fileListenersOnly && !(listenerToRemove is TextWriterTraceListener))
+ if (fileListenersOnly && listenerToRemove is not TextWriterTraceListener)
{
// Since we only want to remove file listeners, skip any that
// aren't file listeners
diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
index e135e1681b..fd5898a48e 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
@@ -1868,7 +1868,7 @@ namespace Microsoft.PowerShell
// If we're not going to continue, then get the exit code out of the runspace and
// and indicate that it should be returned...
- if (!_noExit && !(this.Runspace is RemoteRunspace))
+ if (!_noExit && this.Runspace is not RemoteRunspace)
{
this.Runspace.ExecutionContext.ScriptCommandProcessorShouldRethrowExit = true;
}
diff --git a/src/System.Management.Automation/DscSupport/CimDSCParser.cs b/src/System.Management.Automation/DscSupport/CimDSCParser.cs
index 6d264f76fc..1d6ff12f27 100644
--- a/src/System.Management.Automation/DscSupport/CimDSCParser.cs
+++ b/src/System.Management.Automation/DscSupport/CimDSCParser.cs
@@ -73,7 +73,9 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
MemberInfo[] memberInfo = targetType.GetMember(property.Name, BindingFlags.Public | BindingFlags.Instance);
// verify property exists in corresponding class type
- if (memberInfo == null || memberInfo.Length > 1 || !(memberInfo[0] is PropertyInfo || memberInfo[0] is FieldInfo))
+ if (memberInfo == null
+ || memberInfo.Length > 1
+ || (memberInfo[0] is not PropertyInfo && memberInfo[0] is not FieldInfo))
{
errorMessage = string.Format(CultureInfo.CurrentCulture, ParserStrings.PropertyNotDeclaredInPSClass, new object[] { property.Name, className });
var invalidOperationException = new InvalidOperationException(errorMessage);
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 8b960e3229..505c766b9d 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs
@@ -170,7 +170,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
return false;
}
- if (!(view.mainControl is ComplexControlBody) && !(view.mainControl is ListControlBody))
+ if (view.mainControl is not ComplexControlBody && view.mainControl is not ListControlBody)
{
// Error at XPath {0} in file {1}: Out Of Band views can only have CustomControl or ListControl.
ReportError(StringUtil.Format(FormatAndOutXmlLoadingStrings.InvalidControlForOutOfBandView, ComputeCurrentXPath(), FilePath));
diff --git a/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.xmlSerializer.autogen.cs b/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.xmlSerializer.autogen.cs
index f4892b51bc..a05d597999 100644
--- a/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.xmlSerializer.autogen.cs
+++ b/src/System.Management.Automation/cimSupport/cmdletization/xml/cmdlets-over-objects.xmlSerializer.autogen.cs
@@ -2071,22 +2071,22 @@ namespace Microsoft.PowerShell.Cmdletization.Xml
{
if (ci == Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@RegularQuery && ((object)(ai) != null))
{
- if (((object)ai) != null && !(ai is global::Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery)) throw CreateMismatchChoiceException(@"Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery", @"ItemsElementName", @"Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@RegularQuery");
+ if (((object)ai) != null && ai is not global::Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery) throw CreateMismatchChoiceException(@"Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery", @"ItemsElementName", @"Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@RegularQuery");
Write13_WildcardablePropertyQuery(@"RegularQuery", @"http://schemas.microsoft.com/cmdlets-over-objects/2009/11", ((global::Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery)ai), false, false);
}
else if (ci == Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@ExcludeQuery && ((object)(ai) != null))
{
- if (((object)ai) != null && !(ai is global::Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery)) throw CreateMismatchChoiceException(@"Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery", @"ItemsElementName", @"Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@ExcludeQuery");
+ if (((object)ai) != null && ai is not global::Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery) throw CreateMismatchChoiceException(@"Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery", @"ItemsElementName", @"Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@ExcludeQuery");
Write13_WildcardablePropertyQuery(@"ExcludeQuery", @"http://schemas.microsoft.com/cmdlets-over-objects/2009/11", ((global::Microsoft.PowerShell.Cmdletization.Xml.WildcardablePropertyQuery)ai), false, false);
}
else if (ci == Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@MaxValueQuery && ((object)(ai) != null))
{
- if (((object)ai) != null && !(ai is global::Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery)) throw CreateMismatchChoiceException(@"Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery", @"ItemsElementName", @"Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@MaxValueQuery");
+ if (((object)ai) != null && ai is not global::Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery) throw CreateMismatchChoiceException(@"Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery", @"ItemsElementName", @"Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@MaxValueQuery");
Write14_PropertyQuery(@"MaxValueQuery", @"http://schemas.microsoft.com/cmdlets-over-objects/2009/11", ((global::Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery)ai), false, false);
}
else if (ci == Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@MinValueQuery && ((object)(ai) != null))
{
- if (((object)ai) != null && !(ai is global::Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery)) throw CreateMismatchChoiceException(@"Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery", @"ItemsElementName", @"Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@MinValueQuery");
+ if (((object)ai) != null && ai is not global::Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery) throw CreateMismatchChoiceException(@"Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery", @"ItemsElementName", @"Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType.@MinValueQuery");
Write14_PropertyQuery(@"MinValueQuery", @"http://schemas.microsoft.com/cmdlets-over-objects/2009/11", ((global::Microsoft.PowerShell.Cmdletization.Xml.PropertyQuery)ai), false, false);
}
else if ((object)(ai) != null)
diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs
index f3347cdf4f..97c1f72101 100644
--- a/src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs
+++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs
@@ -627,7 +627,7 @@ namespace System.Management.Automation
completionContext.ReplacementLength = replacementLength = 0;
result = GetResultForAttributeArgument(completionContext, ref replacementIndex, ref replacementLength);
}
- else if (lastAst is HashtableAst hashTableAst && !(lastAst.Parent is DynamicKeywordStatementAst) && CheckForPendingAssignment(hashTableAst))
+ else if (lastAst is HashtableAst hashTableAst && lastAst.Parent is not DynamicKeywordStatementAst && CheckForPendingAssignment(hashTableAst))
{
// Handle scenarios such as 'gci | Format-Table @{Label=' if incomplete parsing of the assignment.
return null;
diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
index 611de0b584..13349c8b97 100644
--- a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
+++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
@@ -5050,7 +5050,7 @@ namespace System.Management.Automation
memberName = memberNameAst.Value + "*";
}
}
- else if (!(lastAst is ErrorExpressionAst) && targetExpr == null)
+ else if (lastAst is not ErrorExpressionAst && targetExpr == null)
{
// I don't think we can complete anything interesting
return results;
@@ -6567,7 +6567,7 @@ namespace System.Management.Automation
object value;
if (SafeExprEvaluator.TrySafeEval(targetExpr, context.ExecutionContext, out value) && value != null)
{
- if (targetExpr is ArrayExpressionAst && !(value is object[]))
+ if (targetExpr is ArrayExpressionAst && value is not object[])
{
// When the array contains only one element, the evaluation result would be that element. We wrap it into an array
value = new[] { value };
diff --git a/src/System.Management.Automation/engine/CommandProcessor.cs b/src/System.Management.Automation/engine/CommandProcessor.cs
index 1c0303ade3..be6b075656 100644
--- a/src/System.Management.Automation/engine/CommandProcessor.cs
+++ b/src/System.Management.Automation/engine/CommandProcessor.cs
@@ -319,7 +319,7 @@ namespace System.Management.Automation
// NOTICE-2004/06/08-JonN 959638
using (commandRuntime.AllowThisCommandToWrite(true))
{
- if (Context._debuggingMode > 0 && !(Command is PSScriptCmdlet))
+ if (Context._debuggingMode > 0 && Command is not PSScriptCmdlet)
{
Context.Debugger.CheckCommand(this.Command.MyInvocation);
}
diff --git a/src/System.Management.Automation/engine/CommandProcessorBase.cs b/src/System.Management.Automation/engine/CommandProcessorBase.cs
index 87fd4606c9..33804b69ae 100644
--- a/src/System.Management.Automation/engine/CommandProcessorBase.cs
+++ b/src/System.Management.Automation/engine/CommandProcessorBase.cs
@@ -517,7 +517,7 @@ namespace System.Management.Automation
{
SetCurrentScopeToExecutionScope();
- if (Context._debuggingMode > 0 && !(Command is PSScriptCmdlet))
+ if (Context._debuggingMode > 0 && Command is not PSScriptCmdlet)
{
Context.Debugger.CheckCommand(this.Command.MyInvocation);
}
@@ -896,7 +896,7 @@ namespace System.Management.Automation
// An explicit throw is written to $error as an ErrorRecord, so we
// skip adding what is more or less a duplicate.
- if (!(e is PipelineStoppedException) && !e.WasThrownFromThrowStatement)
+ if (e is not PipelineStoppedException && !e.WasThrownFromThrowStatement)
commandRuntime.AppendErrorToVariables(e);
}
// Upstream cmdlets see only that execution stopped
diff --git a/src/System.Management.Automation/engine/ExecutionContext.cs b/src/System.Management.Automation/engine/ExecutionContext.cs
index 3fea333958..3a726be8f7 100644
--- a/src/System.Management.Automation/engine/ExecutionContext.cs
+++ b/src/System.Management.Automation/engine/ExecutionContext.cs
@@ -875,7 +875,7 @@ namespace System.Management.Automation
internal void AppendDollarError(object obj)
{
ErrorRecord objAsErrorRecord = obj as ErrorRecord;
- if (objAsErrorRecord == null && !(obj is Exception))
+ if (objAsErrorRecord == null && obj is not Exception)
{
Diagnostics.Assert(false, "Object to append was neither an ErrorRecord nor an Exception in ExecutionContext.AppendDollarError");
return;
diff --git a/src/System.Management.Automation/engine/GetCommandCommand.cs b/src/System.Management.Automation/engine/GetCommandCommand.cs
index e71ed1218e..369ce76ad0 100644
--- a/src/System.Management.Automation/engine/GetCommandCommand.cs
+++ b/src/System.Management.Automation/engine/GetCommandCommand.cs
@@ -1320,7 +1320,9 @@ namespace Microsoft.PowerShell.Commands
}
}
- if (ArgumentList != null && !(current is CmdletInfo || current is IScriptCommandInfo))
+ if (ArgumentList != null
+ && current is not CmdletInfo
+ && current is not IScriptCommandInfo)
{
// If current is not a cmdlet or script, we need to throw a terminating error.
ThrowTerminatingError(
diff --git a/src/System.Management.Automation/engine/InternalCommands.cs b/src/System.Management.Automation/engine/InternalCommands.cs
index 063e04d7a7..7906e3e2b0 100644
--- a/src/System.Management.Automation/engine/InternalCommands.cs
+++ b/src/System.Management.Automation/engine/InternalCommands.cs
@@ -1035,7 +1035,7 @@ namespace Microsoft.PowerShell.Commands
_propertyOrMethodName,
possibleMatches));
}
- else if (methods.Count == 0 || !(methods[0] is PSMethodInfo))
+ else if (methods.Count == 0 || methods[0] is not PSMethodInfo)
{
// write error record: method no found
WriteError(GenerateNameParameterError(
diff --git a/src/System.Management.Automation/engine/MinishellParameterBinderController.cs b/src/System.Management.Automation/engine/MinishellParameterBinderController.cs
index cff1835278..bd23408fcf 100644
--- a/src/System.Management.Automation/engine/MinishellParameterBinderController.cs
+++ b/src/System.Management.Automation/engine/MinishellParameterBinderController.cs
@@ -99,7 +99,7 @@ namespace System.Management.Automation
// Value of -Command parameter must be scriptblock
var scriptBlockArgument = parameters[i];
var argumentValue = PSObject.Base(scriptBlockArgument.ArgumentValue);
- if (!scriptBlockArgument.ArgumentSpecified || !(argumentValue is ScriptBlock))
+ if (!scriptBlockArgument.ArgumentSpecified || argumentValue is not ScriptBlock)
{
throw NewParameterBindingException(null, ErrorCategory.InvalidArgument, CommandParameter,
typeof(ScriptBlock), argumentValue.GetType(),
diff --git a/src/System.Management.Automation/engine/Modules/PSModuleInfo.cs b/src/System.Management.Automation/engine/Modules/PSModuleInfo.cs
index a61ffef50c..caa4a5a666 100644
--- a/src/System.Management.Automation/engine/Modules/PSModuleInfo.cs
+++ b/src/System.Management.Automation/engine/Modules/PSModuleInfo.cs
@@ -1360,7 +1360,7 @@ namespace System.Management.Automation
try
{
// Only copy simple mutable variables...
- if (v.Options == ScopedItemOptions.None && !(v is NullVariable))
+ if (v.Options == ScopedItemOptions.None && v is not NullVariable)
{
PSVariable newVar = new PSVariable(v.Name, v.Value, v.Options, v.Description);
// The variable is already defined/set in the scope, and that means the attributes
diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs
index ea076c1142..975707bcf0 100644
--- a/src/System.Management.Automation/engine/MshCommandRuntime.cs
+++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs
@@ -2384,7 +2384,10 @@ namespace System.Management.Automation
// PipelineStoppedException should not get added to $Error
// 2008/06/25 - narrieta: ExistNestedPromptException should not be added to $error either
// 2019/10/18 - StopUpstreamCommandsException should not be added either
- if (!(e is HaltCommandException) && !(e is PipelineStoppedException) && !(e is ExitNestedPromptException) && !(e is StopUpstreamCommandsException))
+ if (e is not HaltCommandException
+ && e is not PipelineStoppedException
+ && e is not ExitNestedPromptException
+ && e is not StopUpstreamCommandsException)
{
try
{
diff --git a/src/System.Management.Automation/engine/MshObject.cs b/src/System.Management.Automation/engine/MshObject.cs
index 460e62af69..b7e046ded2 100644
--- a/src/System.Management.Automation/engine/MshObject.cs
+++ b/src/System.Management.Automation/engine/MshObject.cs
@@ -2150,7 +2150,7 @@ namespace System.Management.Automation
private bool MustDeferIDMOP()
{
var baseObject = PSObject.Base(Value);
- return baseObject is IDynamicMetaObjectProvider && !(baseObject is PSObject);
+ return baseObject is IDynamicMetaObjectProvider && baseObject is not PSObject;
}
private DynamicMetaObject DeferForIDMOP(DynamicMetaObjectBinder binder, params DynamicMetaObject[] args)
diff --git a/src/System.Management.Automation/engine/Pipe.cs b/src/System.Management.Automation/engine/Pipe.cs
index c60ae52c9f..98b55cf110 100644
--- a/src/System.Management.Automation/engine/Pipe.cs
+++ b/src/System.Management.Automation/engine/Pipe.cs
@@ -510,7 +510,7 @@ namespace System.Management.Automation.Internal
// If our object came from GetEnumerator (and hence is not IEnumerator), then we need to dispose
// Otherwise, we don't own the object, so don't dispose.
var disposable = ie as IDisposable;
- if (disposable != null && !(objects is IEnumerator))
+ if (disposable != null && objects is not IEnumerator)
{
disposable.Dispose();
}
diff --git a/src/System.Management.Automation/engine/ScopedItemSearcher.cs b/src/System.Management.Automation/engine/ScopedItemSearcher.cs
index 4361e39b05..fc67ee2637 100644
--- a/src/System.Management.Automation/engine/ScopedItemSearcher.cs
+++ b/src/System.Management.Automation/engine/ScopedItemSearcher.cs
@@ -274,7 +274,7 @@ namespace System.Management.Automation
VariablePath name,
out PSVariable variable)
{
- Diagnostics.Assert(!(name is FunctionLookupPath),
+ Diagnostics.Assert(name is not FunctionLookupPath,
"name was scanned incorrect if we get here and it is a FunctionLookupPath");
bool result = true;
@@ -328,7 +328,7 @@ namespace System.Management.Automation
VariablePath name,
out AliasInfo alias)
{
- Diagnostics.Assert(!(name is FunctionLookupPath),
+ Diagnostics.Assert(name is not FunctionLookupPath,
"name was scanned incorrect if we get here and it is a FunctionLookupPath");
bool result = true;
@@ -470,7 +470,7 @@ namespace System.Management.Automation
VariablePath name,
out PSDriveInfo drive)
{
- Diagnostics.Assert(!(name is FunctionLookupPath),
+ Diagnostics.Assert(name is not FunctionLookupPath,
"name was scanned incorrect if we get here and it is a FunctionLookupPath");
bool result = true;
diff --git a/src/System.Management.Automation/engine/hostifaces/Connection.cs b/src/System.Management.Automation/engine/hostifaces/Connection.cs
index 2cb17f9bbd..29e86c91b9 100644
--- a/src/System.Management.Automation/engine/hostifaces/Connection.cs
+++ b/src/System.Management.Automation/engine/hostifaces/Connection.cs
@@ -650,7 +650,7 @@ namespace System.Management.Automation.Runspaces
{
get
{
- return !(this is LocalRunspace || ConnectionInfo == null);
+ return this is not LocalRunspace && ConnectionInfo != null;
}
}
@@ -943,7 +943,8 @@ namespace System.Management.Automation.Runspaces
case PipelineState.Completed:
case PipelineState.Stopped:
case PipelineState.Failed:
- if (this.InNestedPrompt || !(this is RemoteRunspace) && this.Debugger.InBreakpoint)
+ if (this.InNestedPrompt
+ || (this is not RemoteRunspace && this.Debugger.InBreakpoint))
{
this.RunspaceAvailability = RunspaceAvailability.AvailableForNestedCommand;
}
diff --git a/src/System.Management.Automation/engine/hostifaces/InternalHost.cs b/src/System.Management.Automation/engine/hostifaces/InternalHost.cs
index 724b975e51..54897a99de 100644
--- a/src/System.Management.Automation/engine/hostifaces/InternalHost.cs
+++ b/src/System.Management.Automation/engine/hostifaces/InternalHost.cs
@@ -39,7 +39,7 @@ namespace System.Management.Automation.Internal.Host
internal InternalHost(PSHost externalHost, ExecutionContext executionContext)
{
Dbg.Assert(externalHost != null, "must supply an PSHost");
- Dbg.Assert(!(externalHost is InternalHost), "try to create an InternalHost from another InternalHost");
+ Dbg.Assert(externalHost is not InternalHost, "try to create an InternalHost from another InternalHost");
Dbg.Assert(executionContext != null, "must supply an ExecutionContext");
diff --git a/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs b/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs
index a78f8e01bd..c8a0e9403e 100644
--- a/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs
+++ b/src/System.Management.Automation/engine/hostifaces/LocalConnection.cs
@@ -987,7 +987,7 @@ namespace System.Management.Automation.Runspaces
foreach (Job job in this.JobRepository.Jobs)
{
// Only stop or disconnect PowerShell jobs.
- if (job is PSRemotingJob == false)
+ if (job is not PSRemotingJob)
{
continue;
}
diff --git a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs
index 64efdb12e4..3dfea3a2e3 100644
--- a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs
+++ b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs
@@ -491,7 +491,9 @@ namespace System.Management.Automation.Runspaces
throw e;
}
- if (syncCall && !(InputStream is PSDataCollectionStream || InputStream is PSDataCollectionStream