diff --git a/src/System.Management.Automation/engine/remoting/client/ClientMethodExecutor.cs b/src/System.Management.Automation/engine/remoting/client/ClientMethodExecutor.cs
index 73c432158f..9d52bcb4dc 100644
--- a/src/System.Management.Automation/engine/remoting/client/ClientMethodExecutor.cs
+++ b/src/System.Management.Automation/engine/remoting/client/ClientMethodExecutor.cs
@@ -133,7 +133,7 @@ namespace System.Management.Automation.Remoting
///
private static bool IsRunspacePushed(PSHost host)
{
- if (!(host is IHostSupportsInteractiveSession host2))
+ if (host is not IHostSupportsInteractiveSession host2)
{
return false;
}
diff --git a/src/System.Management.Automation/engine/remoting/client/Job.cs b/src/System.Management.Automation/engine/remoting/client/Job.cs
index b3a0135afc..adf47d04ca 100644
--- a/src/System.Management.Automation/engine/remoting/client/Job.cs
+++ b/src/System.Management.Automation/engine/remoting/client/Job.cs
@@ -752,10 +752,10 @@ namespace System.Management.Automation
private static Exception GetExceptionFromErrorRecord(ErrorRecord errorRecord)
{
- if (!(errorRecord.Exception is RuntimeException runtimeException))
+ if (errorRecord.Exception is not RuntimeException runtimeException)
return null;
- if (!(runtimeException is RemoteException remoteException))
+ if (runtimeException is not RemoteException remoteException)
return null;
PSPropertyInfo wasThrownFromThrow =
@@ -1911,7 +1911,7 @@ namespace System.Management.Automation
foreach (Job j in ChildJobs)
{
- if (!(j is PSRemotingChildJob child)) continue;
+ if (j is not PSRemotingChildJob child) continue;
if (string.Equals(child.Runspace.ConnectionInfo.ComputerName, computerName,
StringComparison.OrdinalIgnoreCase))
{
@@ -1934,7 +1934,7 @@ namespace System.Management.Automation
foreach (Job j in ChildJobs)
{
- if (!(j is PSRemotingChildJob child)) continue;
+ if (j is not PSRemotingChildJob child) continue;
if (child.Runspace.InstanceId.Equals(runspace.InstanceId))
{
returnJobList.Add(child);
@@ -1957,7 +1957,7 @@ namespace System.Management.Automation
foreach (Job j in ChildJobs)
{
- if (!(j is PSRemotingChildJob child)) continue;
+ if (j is not PSRemotingChildJob child) continue;
if (child.Helper.Equals(helper))
{
returnJobList.Add(child);
diff --git a/src/System.Management.Automation/engine/remoting/client/JobSourceAdapter.cs b/src/System.Management.Automation/engine/remoting/client/JobSourceAdapter.cs
index 9f6297fbfa..85cd6c7ba1 100644
--- a/src/System.Management.Automation/engine/remoting/client/JobSourceAdapter.cs
+++ b/src/System.Management.Automation/engine/remoting/client/JobSourceAdapter.cs
@@ -413,7 +413,7 @@ namespace System.Management.Automation
duplicateDetector.Add(job.InstanceId, job.InstanceId);
foreach (Job child in job.ChildJobs)
{
- if (!(child is Job2 childJob)) continue;
+ if (child is not Job2 childJob) continue;
StoreJobIdForReuseHelper(duplicateDetector, childJob, true);
}
}
@@ -429,7 +429,7 @@ namespace System.Management.Automation
if (!recurse || job.ChildJobs == null) return;
foreach (Job child in job.ChildJobs)
{
- if (!(child is Job2 childJob)) continue;
+ if (child is not Job2 childJob) continue;
StoreJobIdForReuseHelper(duplicateDetector, childJob, recurse);
}
}
diff --git a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs
index c414b5095e..983180bd5c 100644
--- a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs
+++ b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs
@@ -1237,7 +1237,7 @@ namespace System.Management.Automation.Runspaces.Internal
internal static RunspacePool[] GetRemoteRunspacePools(RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable)
{
- if (!(connectionInfo is WSManConnectionInfo wsmanConnectionInfoParam))
+ if (connectionInfo is not WSManConnectionInfo wsmanConnectionInfoParam)
{
// Disconnect-Connect currently only supported by WSMan.
throw new NotSupportedException();
diff --git a/src/System.Management.Automation/engine/remoting/client/remoterunspaceinfo.cs b/src/System.Management.Automation/engine/remoting/client/remoterunspaceinfo.cs
index 55c2b23db7..c1b3469110 100644
--- a/src/System.Management.Automation/engine/remoting/client/remoterunspaceinfo.cs
+++ b/src/System.Management.Automation/engine/remoting/client/remoterunspaceinfo.cs
@@ -374,7 +374,7 @@ namespace System.Management.Automation.Runspaces
string transportName,
PSCmdlet psCmdlet)
{
- if (!(runspace is RemoteRunspace remoteRunspace))
+ if (runspace is not RemoteRunspace remoteRunspace)
{
throw new PSArgumentException(RemotingErrorIdStrings.InvalidPSSessionArgument);
}
diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs
index e600661eab..1d88210e7b 100644
--- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs
+++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs
@@ -1753,7 +1753,7 @@ else
}
StringBuilder conditionalACE = new StringBuilder();
- if (!(configTable[ConfigFileConstants.RequiredGroups] is Hashtable requiredGroupsHash))
+ if (configTable[ConfigFileConstants.RequiredGroups] is not Hashtable requiredGroupsHash)
{
throw new PSInvalidOperationException(RemotingErrorIdStrings.RequiredGroupsNotHashTable);
}
diff --git a/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs b/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs
index 2145a1dbe2..0dd769537c 100644
--- a/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs
+++ b/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs
@@ -1050,7 +1050,7 @@ namespace Microsoft.PowerShell.Commands
// create collection of input writers here
foreach (IThrottleOperation operation in Operations)
{
- if (!(operation is ExecutionCmdletHelperRunspace ecHelper))
+ if (operation is not ExecutionCmdletHelperRunspace ecHelper)
{
// either all the operations will be of type ExecutionCmdletHelperRunspace
// or not...there is no mix.
diff --git a/src/System.Management.Automation/engine/remoting/commands/ReceivePSSession.cs b/src/System.Management.Automation/engine/remoting/commands/ReceivePSSession.cs
index b9cf33e4b1..67477e5b36 100644
--- a/src/System.Management.Automation/engine/remoting/commands/ReceivePSSession.cs
+++ b/src/System.Management.Automation/engine/remoting/commands/ReceivePSSession.cs
@@ -1166,7 +1166,7 @@ namespace Microsoft.PowerShell.Commands
/// PSSession disconnected runspace object.
private PSSession TryGetSessionFromServer(PSSession session)
{
- if (!(session.Runspace is RemoteRunspace remoteRunspace))
+ if (session.Runspace is not RemoteRunspace remoteRunspace)
{
return null;
}
diff --git a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs
index d9a6d0b317..5f25851337 100644
--- a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs
+++ b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs
@@ -1174,7 +1174,7 @@ namespace System.Management.Automation.Runspaces
internal static T ExtractPropertyAsWsManConnectionInfo(RunspaceConnectionInfo rsCI,
string property, T defaultValue)
{
- if (!(rsCI is WSManConnectionInfo wsCI))
+ if (rsCI is not WSManConnectionInfo wsCI)
{
return defaultValue;
}
diff --git a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs
index c7b06d4c74..e26f3421cd 100644
--- a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs
+++ b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs
@@ -1869,7 +1869,7 @@ namespace System.Management.Automation
/// PSInvocationInfo.
internal static PSInvocationStateInfo GetPowerShellStateInfo(object data)
{
- if (!(data is PSObject dataAsPSObject))
+ if (data is not PSObject dataAsPSObject)
{
throw new PSRemotingDataStructureException(
RemotingErrorIdStrings.DecodingErrorForPowerShellStateInfo);
@@ -2137,7 +2137,7 @@ namespace System.Management.Automation
/// RemoteSessionCapability object.
internal static RemoteSessionCapability GetSessionCapability(object data)
{
- if (!(data is PSObject dataAsPSObject))
+ if (data is not PSObject dataAsPSObject)
{
throw new PSRemotingDataStructureException(
RemotingErrorIdStrings.CantCastRemotingDataToPSObject, data.GetType().FullName);
diff --git a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs
index 94ffe3a68e..07e17e8b63 100644
--- a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs
+++ b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs
@@ -2836,7 +2836,7 @@ namespace System.Management.Automation.Remoting
for (int i = 0; i < hashArray.Length; i++)
{
- if (!(objArray[i] is Hashtable hash))
+ if (objArray[i] is not Hashtable hash)
{
return null;
}
diff --git a/src/System.Management.Automation/engine/remoting/server/ServerRemoteHost.cs b/src/System.Management.Automation/engine/remoting/server/ServerRemoteHost.cs
index 7e7aa767d5..71dda0d0b7 100644
--- a/src/System.Management.Automation/engine/remoting/server/ServerRemoteHost.cs
+++ b/src/System.Management.Automation/engine/remoting/server/ServerRemoteHost.cs
@@ -327,7 +327,7 @@ namespace System.Management.Automation.Remoting
throw new PSInvalidOperationException(RemotingErrorIdStrings.ServerDriverRemoteHostAlreadyPushed);
}
- if (!(runspace is RemoteRunspace remoteRunspace))
+ if (runspace is not RemoteRunspace remoteRunspace)
{
throw new PSInvalidOperationException(RemotingErrorIdStrings.ServerDriverRemoteHostNotRemoteRunspace);
}