Skip to content
Open
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
2 changes: 1 addition & 1 deletion .globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ dotnet_diagnostic.IDE0082.severity = warning

# IDE0083: UseNotPattern
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0083
dotnet_diagnostic.IDE0083.severity = silent
dotnet_diagnostic.IDE0083.severity = warning

# IDE0084: UseIsNotExpression
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0084
Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/parser/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5975,12 +5975,12 @@ public object VisitBinaryExpression(BinaryExpressionAst binaryExpressionAst)

private static Expression GetLikeRHSOperand(WildcardOptions options, Expression expr)
{
if (!(expr is ConstantExpression constExpr))
if (expr is not ConstantExpression constExpr)
{
return expr;
}

if (!(constExpr.Value is string val))
if (constExpr.Value is not string val)
{
return expr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public object VisitPipeline(PipelineAst pipelineAst)

private static bool IsNullDivisor(ExpressionAst operand)
{
if (!(operand is VariableExpressionAst varExpr))
if (operand is not VariableExpressionAst varExpr)
{
return false;
}
Expand Down Expand Up @@ -281,7 +281,7 @@ public object VisitMemberExpression(MemberExpressionAst memberExpressionAst)
return false;
}

if (!(memberExpressionAst.Member is StringConstantExpressionAst member))
if (memberExpressionAst.Member is not StringConstantExpressionAst member)
{
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/parser/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ internal static bool TryParseAsConstantHashtable(string input, out Hashtable res
return false;
}

if (!(statements[0] is PipelineAst pipelineAst))
if (statements[0] is not PipelineAst pipelineAst)
{
return false;
}
Expand All @@ -748,7 +748,7 @@ internal static bool TryParseAsConstantHashtable(string input, out Hashtable res
return false;
}

if (!(expr is HashtableAst hashTableAst))
if (expr is not HashtableAst hashTableAst)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ internal sealed class EmptyScriptExtent : IScriptExtent

public override bool Equals(object obj)
{
if (!(obj is IScriptExtent otherPosition))
if (obj is not IScriptExtent otherPosition)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ public override AstVisitAction VisitContinueStatement(ContinueStatementAst conti

private void CheckForReturnStatement(ReturnStatementAst ast)
{
if (!(_memberScopeStack.Peek() is FunctionMemberAst functionMemberAst))
if (_memberScopeStack.Peek() is not FunctionMemberAst functionMemberAst)
{
return;
}
Expand Down Expand Up @@ -1631,7 +1631,7 @@ private static void LookupRequiredMembers(Parser parser, TypeDefinitionAst typeD

foreach (var baseType in typeDefinitionAst.BaseTypes)
{
if (!(baseType.TypeName is TypeName baseTypeName))
if (baseType.TypeName is not TypeName baseTypeName)
{
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ internal void AddMembersByInferredTypeDefinitionAst(
// iterate through bases/interfaces
foreach (var baseType in typename.TypeDefinitionAst.BaseTypes)
{
if (!(baseType.TypeName is TypeName baseTypeName))
if (baseType.TypeName is not TypeName baseTypeName)
{
continue;
}
Expand Down Expand Up @@ -1914,7 +1914,7 @@ private IEnumerable<PSTypeName> InferTypesFrom(MemberExpressionAst memberExpress
var expression = memberExpressionAst.Expression;

// If the member name isn't simple, don't even try.
if (!(memberCommandElement is StringConstantExpressionAst memberAsStringConst))
if (memberCommandElement is not StringConstantExpressionAst memberAsStringConst)
{
return Array.Empty<PSTypeName>();
}
Expand Down Expand Up @@ -2239,7 +2239,7 @@ private PSTypeName[] GetExpressionType(ExpressionAst expression, bool isStatic)
PSTypeName[] exprType;
if (isStatic)
{
if (!(expression is TypeExpressionAst exprAsType))
if (expression is not TypeExpressionAst exprAsType)
{
return null;
}
Expand Down Expand Up @@ -2814,7 +2814,7 @@ internal static IEnumerable<PSTypeName> GetInferredEnumeratedTypes(IEnumerable<P
private void GetInferredTypeFromScriptBlockParameter(AstParameterArgumentPair argument, List<PSTypeName> inferredTypes)
{
var argumentPair = argument as AstPair;
if (!(argumentPair?.Argument is ScriptBlockExpressionAst scriptBlockExpressionAst))
if (argumentPair?.Argument is not ScriptBlockExpressionAst scriptBlockExpressionAst)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ public override bool Equals(object obj)
if (object.ReferenceEquals(this, obj))
return true;

if (!(obj is TypeResolutionState other))
if (obj is not TypeResolutionState other)
return false;

if (this.attribute != other.attribute)
Expand Down
12 changes: 6 additions & 6 deletions src/System.Management.Automation/engine/parser/ast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7376,7 +7376,7 @@ internal virtual bool ShouldPreserveOutputInCaseOfException()
PSTraceSource.NewInvalidOperationException();
}

if (!(this.Parent is CommandExpressionAst commandExpr))
if (this.Parent is not CommandExpressionAst commandExpr)
{
return false;
}
Expand Down Expand Up @@ -7889,7 +7889,7 @@ Expression IAssignableValue.SetValue(Compiler compiler, Expression rhs)
var attributes = GetAttributes();
var assignableValue = GetActualAssignableAst().GetAssignableValue();

if (!(assignableValue is VariableExpressionAst variableExpr))
if (assignableValue is not VariableExpressionAst variableExpr)
{
return assignableValue.SetValue(compiler, Compiler.ConvertValue(rhs, attributes));
}
Expand Down Expand Up @@ -8666,7 +8666,7 @@ public override string ToString()
/// <summary/>
public override bool Equals(object obj)
{
if (!(obj is TypeName other))
if (obj is not TypeName other)
return false;

if (!_name.Equals(other._name, StringComparison.OrdinalIgnoreCase))
Expand Down Expand Up @@ -8994,7 +8994,7 @@ public override string ToString()
/// <summary/>
public override bool Equals(object obj)
{
if (!(obj is GenericTypeName other))
if (obj is not GenericTypeName other)
return false;

if (!TypeName.Equals(other.TypeName))
Expand Down Expand Up @@ -9219,7 +9219,7 @@ public override string ToString()
/// <summary/>
public override bool Equals(object obj)
{
if (!(obj is ArrayTypeName other))
if (obj is not ArrayTypeName other)
return false;

return ElementType.Equals(other.ElementType) && Rank == other.Rank;
Expand Down Expand Up @@ -9320,7 +9320,7 @@ public override string ToString()
/// <summary/>
public override bool Equals(object obj)
{
if (!(obj is ReflectionTypeName other))
if (obj is not ReflectionTypeName other)
return false;
return _type == other._type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ private void ProcessUserDefinedHelpData(string mshSnapInId, UserDefinedHelpData
if (helpInfo == null)
return;

if (!(helpInfo is MamlCommandHelpInfo commandHelpInfo))
if (helpInfo is not MamlCommandHelpInfo commandHelpInfo)
return;

commandHelpInfo.AddUserDefinedData(userDefinedHelpData);
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/help/ProviderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ internal MamlCommandHelpInfo GetProviderSpecificHelpInfo(string helpItemName)

// Does the provider know how to generate MAML.
CmdletProvider cmdletProvider = providerInfo.CreateInstance();
if (!(cmdletProvider is ICmdletProviderSupportsHelp provider))
if (cmdletProvider is not ICmdletProviderSupportsHelp provider)
{
// Under JEA sessions the resolvedProviderPath will be null, we should allow get-help to continue.
return null;
Expand Down