mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix IDE0083: UseNotPattern (#26213)
This commit is contained in:
@@ -133,7 +133,7 @@ namespace System.Management.Automation.Remoting
|
||||
/// </summary>
|
||||
private static bool IsRunspacePushed(PSHost host)
|
||||
{
|
||||
if (!(host is IHostSupportsInteractiveSession host2))
|
||||
if (host is not IHostSupportsInteractiveSession host2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1166,7 +1166,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <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;
|
||||
}
|
||||
|
||||
@@ -1174,7 +1174,7 @@ namespace System.Management.Automation.Runspaces
|
||||
internal static T ExtractPropertyAsWsManConnectionInfo<T>(RunspaceConnectionInfo rsCI,
|
||||
string property, T defaultValue)
|
||||
{
|
||||
if (!(rsCI is WSManConnectionInfo wsCI))
|
||||
if (rsCI is not WSManConnectionInfo wsCI)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1869,7 +1869,7 @@ namespace System.Management.Automation
|
||||
/// <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);
|
||||
@@ -2137,7 +2137,7 @@ namespace System.Management.Automation
|
||||
/// <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);
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user