Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ internal static void Dispatch(
/// </summary>
private static bool IsRunspacePushed(PSHost host)
{
if (!(host is IHostSupportsInteractiveSession host2))
if (host is not IHostSupportsInteractiveSession host2)
{
return false;
}
Expand Down
10 changes: 5 additions & 5 deletions src/System.Management.Automation/engine/remoting/client/Job.cs
Original file line number Diff line number Diff line change
Expand Up @@ -752,10 +752,10 @@ private void WriteError(Cmdlet cmdlet, ErrorRecord errorRecord)

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 =
Expand Down Expand Up @@ -1911,7 +1911,7 @@ internal List<Job> GetJobsForComputer(string computerName)

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))
{
Expand All @@ -1934,7 +1934,7 @@ internal List<Job> GetJobsForRunspace(PSSession runspace)

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);
Expand All @@ -1957,7 +1957,7 @@ internal List<Job> GetJobsForOperation(IThrottleOperation operation)

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public void StoreJobIdForReuse(Job2 job, bool recurse)
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);
}
}
Expand All @@ -429,7 +429,7 @@ private void StoreJobIdForReuseHelper(Hashtable duplicateDetector, Job2 job, boo
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ public override RunspacePoolCapability GetCapabilities()

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public static PSSession Create(
string transportName,
PSCmdlet psCmdlet)
{
if (!(runspace is RemoteRunspace remoteRunspace))
if (runspace is not RemoteRunspace remoteRunspace)
{
throw new PSArgumentException(RemotingErrorIdStrings.InvalidPSSessionArgument);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ internal static string CreateConditionalACEFromConfig(
}

StringBuilder conditionalACE = new StringBuilder();
if (!(configTable[ConfigFileConstants.RequiredGroups] is Hashtable requiredGroupsHash))
if (configTable[ConfigFileConstants.RequiredGroups] is not Hashtable requiredGroupsHash)
{
throw new PSInvalidOperationException(RemotingErrorIdStrings.RequiredGroupsNotHashTable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ protected override void BeginProcessing()
// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ private static PSSession ConnectSession(PSSession session, out Exception ex)
/// <returns>PSSession disconnected runspace object.</returns>
private PSSession TryGetSessionFromServer(PSSession session)
{
if (!(session.Runspace is RemoteRunspace remoteRunspace))
if (session.Runspace is not RemoteRunspace remoteRunspace)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ private static string ResolveShellUri(string shell)
internal static T ExtractPropertyAsWsManConnectionInfo<T>(RunspaceConnectionInfo rsCI,
string property, T defaultValue)
{
if (!(rsCI is WSManConnectionInfo wsCI))
if (rsCI is not WSManConnectionInfo wsCI)
{
return defaultValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ internal static object GetPowerShellOutput(object data)
/// <returns>PSInvocationInfo.</returns>
internal static PSInvocationStateInfo GetPowerShellStateInfo(object data)
{
if (!(data is PSObject dataAsPSObject))
if (data is not PSObject dataAsPSObject)
{
throw new PSRemotingDataStructureException(
RemotingErrorIdStrings.DecodingErrorForPowerShellStateInfo);
Expand Down Expand Up @@ -2137,7 +2137,7 @@ internal static RemoteStreamOptions GetRemoteStreamOptions(object data)
/// <returns>RemoteSessionCapability object.</returns>
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2836,7 +2836,7 @@ internal static Hashtable[] TryGetHashtableArray(object hashObj)

for (int i = 0; i < hashArray.Length; i++)
{
if (!(objArray[i] is Hashtable hash))
if (objArray[i] is not Hashtable hash)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public override void PushRunspace(Runspace runspace)
throw new PSInvalidOperationException(RemotingErrorIdStrings.ServerDriverRemoteHostAlreadyPushed);
}

if (!(runspace is RemoteRunspace remoteRunspace))
if (runspace is not RemoteRunspace remoteRunspace)
{
throw new PSInvalidOperationException(RemotingErrorIdStrings.ServerDriverRemoteHostNotRemoteRunspace);
}
Expand Down
Loading