Skip to content

Commit 250144e

Browse files
authored
Fix IDE0083: UseNotPattern (#26209)
1 parent d2d0def commit 250144e

51 files changed

Lines changed: 131 additions & 131 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Microsoft.Management.Infrastructure.CimCmdlets/CimAsyncOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ protected object GetReferenceOrReferenceArrayObject(object value, ref CimType re
381381
if (value is PSReference cimReference)
382382
{
383383
object baseObject = GetBaseObject(cimReference.Value);
384-
if (!(baseObject is CimInstance cimInstance))
384+
if (baseObject is not CimInstance cimInstance)
385385
{
386386
return null;
387387
}
@@ -403,7 +403,7 @@ protected object GetReferenceOrReferenceArrayObject(object value, ref CimType re
403403
CimInstance[] cimInstanceArray = new CimInstance[cimReferenceArray.Length];
404404
for (int i = 0; i < cimReferenceArray.Length; i++)
405405
{
406-
if (!(cimReferenceArray[i] is PSReference tempCimReference))
406+
if (cimReferenceArray[i] is not PSReference tempCimReference)
407407
{
408408
return null;
409409
}

src/Microsoft.Management.Infrastructure.CimCmdlets/CimSessionProxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,7 @@ protected override bool PreNewActionEvent(CmdletActionEventArgs args)
20412041
}
20422042

20432043
CimWriteResultObject writeResultObject = args.Action as CimWriteResultObject;
2044-
if (!(writeResultObject.Result is CimClass cimClass))
2044+
if (writeResultObject.Result is not CimClass cimClass)
20452045
{
20462046
return true;
20472047
}
@@ -2200,7 +2200,7 @@ protected override bool PreNewActionEvent(CmdletActionEventArgs args)
22002200
}
22012201

22022202
CimWriteResultObject writeResultObject = args.Action as CimWriteResultObject;
2203-
if (!(writeResultObject.Result is CimInstance cimInstance))
2203+
if (writeResultObject.Result is not CimInstance cimInstance)
22042204
{
22052205
return true;
22062206
}

src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimChildJobBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private enum WsManErrorCode : uint
8484

8585
private static bool IsWsManQuotaReached(Exception exception)
8686
{
87-
if (!(exception is CimException cimException))
87+
if (exception is not CimException cimException)
8888
{
8989
return false;
9090
}
@@ -1002,7 +1002,7 @@ private CimResponseType PromptUserCallback(string message, CimPromptType promptT
10021002
internal static bool IsShowComputerNameMarkerPresent(CimInstance cimInstance)
10031003
{
10041004
PSObject pso = PSObject.AsPSObject(cimInstance);
1005-
if (!(pso.InstanceMembers[RemotingConstants.ShowComputerNameNoteProperty] is PSPropertyInfo psShowComputerNameProperty))
1005+
if (pso.InstanceMembers[RemotingConstants.ShowComputerNameNoteProperty] is not PSPropertyInfo psShowComputerNameProperty)
10061006
{
10071007
return false;
10081008
}

src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimWrapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private CimJobContext CreateJobContext(CimSession session, object targetObject)
168168
/// <returns><see cref="System.Management.Automation.Job"/> object that performs a query against the wrapped object model.</returns>
169169
internal override StartableJob CreateQueryJob(CimSession session, QueryBuilder baseQuery)
170170
{
171-
if (!(baseQuery is CimQuery query))
171+
if (baseQuery is not CimQuery query)
172172
{
173173
throw new ArgumentNullException(nameof(baseQuery));
174174
}

src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/clientSideQuery.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ private static bool ActualValueGreaterThanOrEqualToExpectedValue(string property
569569
{
570570
try
571571
{
572-
if (!(expectedPropertyValue is IComparable expectedComparable))
572+
if (expectedPropertyValue is not IComparable expectedComparable)
573573
{
574574
return false;
575575
}
@@ -604,7 +604,7 @@ private static bool ActualValueLessThanOrEqualToExpectedValue(string propertyNam
604604
{
605605
try
606606
{
607-
if (!(actualPropertyValue is IComparable actualComparable))
607+
if (actualPropertyValue is not IComparable actualComparable)
608608
{
609609
return false;
610610
}

src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ private void WriteMemberInfoCollection(
704704
continue;
705705
}
706706

707-
if (!(info is PSPropertyInfo property))
707+
if (info is not PSPropertyInfo property)
708708
{
709709
continue;
710710
}

src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/ColumnInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ internal Type GetValueType(PSObject liveObject, out object columnValue)
4848
/// <returns>The source string limited in the number of lines.</returns>
4949
internal static object LimitString(object src)
5050
{
51-
if (!(src is string srcString))
51+
if (src is not string srcString)
5252
{
5353
return src;
5454
}

src/Microsoft.PowerShell.Commands.Utility/commands/utility/Get-PSBreakpoint.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ protected override void ProcessRecord()
115115
Command,
116116
(Breakpoint breakpoint, string command) =>
117117
{
118-
if (!(breakpoint is CommandBreakpoint commandBreakpoint))
118+
if (breakpoint is not CommandBreakpoint commandBreakpoint)
119119
{
120120
return false;
121121
}
@@ -130,7 +130,7 @@ protected override void ProcessRecord()
130130
Variable,
131131
(Breakpoint breakpoint, string variable) =>
132132
{
133-
if (!(breakpoint is VariableBreakpoint variableBreakpoint))
133+
if (breakpoint is not VariableBreakpoint variableBreakpoint)
134134
{
135135
return false;
136136
}

src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,7 +2620,7 @@ private string GenerateConnectionStringForNewRunspace()
26202620

26212621
private string GenerateAllowRedirectionParameter()
26222622
{
2623-
if (!(_remoteRunspaceInfo.Runspace.ConnectionInfo is WSManConnectionInfo wsmanConnectionInfo))
2623+
if (_remoteRunspaceInfo.Runspace.ConnectionInfo is not WSManConnectionInfo wsmanConnectionInfo)
26242624
{
26252625
return string.Empty;
26262626
}
@@ -2646,7 +2646,7 @@ private string GenerateAuthenticationMechanismParameter()
26462646
return string.Empty;
26472647
}
26482648

2649-
if (!(_remoteRunspaceInfo.Runspace.ConnectionInfo is WSManConnectionInfo wsmanConnectionInfo))
2649+
if (_remoteRunspaceInfo.Runspace.ConnectionInfo is not WSManConnectionInfo wsmanConnectionInfo)
26502650
{
26512651
return string.Empty;
26522652
}

src/Microsoft.PowerShell.Commands.Utility/commands/utility/ObjectCommandComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ internal CultureInfo Culture
7777
/// <returns>True if both the objects are same or else returns false.</returns>
7878
public override bool Equals(object inputObject)
7979
{
80-
if (!(inputObject is ObjectCommandPropertyValue objectCommandPropertyValueObject))
80+
if (inputObject is not ObjectCommandPropertyValue objectCommandPropertyValueObject)
8181
{
8282
return false;
8383
}

0 commit comments

Comments
 (0)