817 references to BinaryOperatorKind
GenerateDocumentationAndConfigFiles (60)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (47)
18private static readonly ImmutableDictionary<BinaryOperatorKind, BinaryOperatorKind> s_negatedBinaryMap =
19new Dictionary<BinaryOperatorKind, BinaryOperatorKind>
21{ BinaryOperatorKind.Equals, BinaryOperatorKind.NotEquals },
22{ BinaryOperatorKind.NotEquals, BinaryOperatorKind.Equals },
23{ BinaryOperatorKind.LessThan, BinaryOperatorKind.GreaterThanOrEqual },
24{ BinaryOperatorKind.GreaterThan, BinaryOperatorKind.LessThanOrEqual },
25{ BinaryOperatorKind.LessThanOrEqual, BinaryOperatorKind.GreaterThan },
26{ BinaryOperatorKind.GreaterThanOrEqual, BinaryOperatorKind.LessThan },
27{ BinaryOperatorKind.Or, BinaryOperatorKind.And },
28{ BinaryOperatorKind.And, BinaryOperatorKind.Or },
29{ BinaryOperatorKind.ConditionalOr, BinaryOperatorKind.ConditionalAnd },
30{ BinaryOperatorKind.ConditionalAnd, BinaryOperatorKind.ConditionalOr },
149if (!s_negatedBinaryMap.TryGetValue(binaryOperation.OperatorKind, out var negatedKind))
155&& binaryOperation.OperatorKind is BinaryOperatorKind.LessThan or
156BinaryOperatorKind.LessThanOrEqual or
157BinaryOperatorKind.GreaterThan or
158BinaryOperatorKind.GreaterThanOrEqual)
163if (binaryOperation.OperatorKind is BinaryOperatorKind.Or or
164BinaryOperatorKind.And or
165BinaryOperatorKind.ConditionalAnd or
166BinaryOperatorKind.ConditionalOr)
172var newBinaryExpressionSyntax = negatedKind is BinaryOperatorKind.Equals or BinaryOperatorKind.NotEquals
380BinaryOperatorKind operationKind,
385BinaryOperatorKind.LessThanOrEqual => IsSpecialCaseBinaryExpression(binaryOperation, operationKind)
388BinaryOperatorKind.GreaterThanOrEqual => IsSpecialCaseBinaryExpression(binaryOperation, operationKind)
391BinaryOperatorKind.LessThan => generator.LessThanExpression(leftOperand, rightOperand),
392BinaryOperatorKind.GreaterThan => generator.GreaterThanExpression(leftOperand, rightOperand),
393BinaryOperatorKind.Or => generator.BitwiseOrExpression(leftOperand, rightOperand),
394BinaryOperatorKind.And => generator.BitwiseAndExpression(leftOperand, rightOperand),
395BinaryOperatorKind.ConditionalOr => generator.LogicalOrExpression(leftOperand, rightOperand),
396BinaryOperatorKind.ConditionalAnd => generator.LogicalAndExpression(leftOperand, rightOperand),
408BinaryOperatorKind operationKind)
418BinaryOperatorKind.LessThanOrEqual when rightOperand.IsNumericLiteral()
420BinaryOperatorKind.GreaterThanOrEqual when leftOperand.IsNumericLiteral()
ILLink.RoslynAnalyzer (3)
Microsoft.AspNetCore.Mvc.Api.Analyzers (2)
Microsoft.CodeAnalysis (46)
Generated\Operations.Generated.cs (20)
1107BinaryOperatorKind OperatorKind { get; }
1516BinaryOperatorKind OperatorKind { get; }
2773BinaryOperatorKind Relation { get; }
2976BinaryOperatorKind OperatorKind { get; }
3531/// Kind of binary pattern; either <see cref="BinaryOperatorKind.And" /> or <see cref="BinaryOperatorKind.Or" />.
3533BinaryOperatorKind OperatorKind { get; }
3589BinaryOperatorKind OperatorKind { get; }
5682internal BinaryOperation(BinaryOperatorKind operatorKind, IOperation leftOperand, IOperation rightOperand, bool isLifted, bool isChecked, bool isCompareText, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, IMethodSymbol? unaryOperatorMethod, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5697public BinaryOperatorKind OperatorKind { get; }
6346internal CompoundAssignmentOperation(IConvertibleConversion inConversion, IConvertibleConversion outConversion, BinaryOperatorKind operatorKind, bool isLifted, bool isChecked, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, IOperation target, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6362public BinaryOperatorKind OperatorKind { get; }
8315internal RelationalCaseClauseOperation(IOperation value, BinaryOperatorKind relation, ILabelSymbol? label, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
8322public BinaryOperatorKind Relation { get; }
8632internal TupleBinaryOperation(BinaryOperatorKind operatorKind, IOperation leftOperand, IOperation rightOperand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
8640public BinaryOperatorKind OperatorKind { get; }
9929internal BinaryPatternOperation(BinaryOperatorKind operatorKind, IPatternOperation leftPattern, IPatternOperation rightPattern, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
9936public BinaryOperatorKind OperatorKind { get; }
10011internal RelationalPatternOperation(BinaryOperatorKind operatorKind, IOperation value, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
10017public BinaryOperatorKind OperatorKind { get; }
Operations\ControlFlowGraphBuilder.cs (26)
2166case BinaryOperatorKind.ConditionalOr:
2167case BinaryOperatorKind.ConditionalAnd:
2283case BinaryOperatorKind.ConditionalOr:
2287case BinaryOperatorKind.ConditionalAnd:
2549new BinaryOperation(isAndAlso ? BinaryOperatorKind.And : BinaryOperatorKind.Or,
2639new BinaryOperation(isAndAlso ? BinaryOperatorKind.And : BinaryOperatorKind.Or,
4971isUp = new BinaryOperation(BinaryOperatorKind.GreaterThanOrEqual,
5091var comparisonKind = BinaryOperatorKind.None;
5096comparisonKind = BinaryOperatorKind.LessThanOrEqual;
5103comparisonKind = BinaryOperatorKind.GreaterThanOrEqual;
5107comparisonKind = BinaryOperatorKind.LessThanOrEqual;
5114if (comparisonKind == BinaryOperatorKind.None && ITypeSymbolHelpers.IsSignedIntegralType(stepEnumUnderlyingTypeOrSelf))
5116comparisonKind = BinaryOperatorKind.LessThanOrEqual;
5123if (comparisonKind != BinaryOperatorKind.None)
5162eitherLimitOrControlVariableIsNull = new BinaryOperation(BinaryOperatorKind.Or,
5203condition = new BinaryOperation(BinaryOperatorKind.LessThanOrEqual,
5223condition = new BinaryOperation(BinaryOperatorKind.GreaterThanOrEqual,
5257var shiftedStep = new BinaryOperation(BinaryOperatorKind.RightShift,
5272return new BinaryOperation(BinaryOperatorKind.ExclusiveOr,
5344IOperation condition = new BinaryOperation(BinaryOperatorKind.Or,
5396IOperation increment = new BinaryOperation(BinaryOperatorKind.Add,
5590condition = new BinaryOperation(BinaryOperatorKind.Equals,
5640if (relationalValueClause.Relation == BinaryOperatorKind.Equals)
Microsoft.CodeAnalysis.Analyzers (77)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (47)
18private static readonly ImmutableDictionary<BinaryOperatorKind, BinaryOperatorKind> s_negatedBinaryMap =
19new Dictionary<BinaryOperatorKind, BinaryOperatorKind>
21{ BinaryOperatorKind.Equals, BinaryOperatorKind.NotEquals },
22{ BinaryOperatorKind.NotEquals, BinaryOperatorKind.Equals },
23{ BinaryOperatorKind.LessThan, BinaryOperatorKind.GreaterThanOrEqual },
24{ BinaryOperatorKind.GreaterThan, BinaryOperatorKind.LessThanOrEqual },
25{ BinaryOperatorKind.LessThanOrEqual, BinaryOperatorKind.GreaterThan },
26{ BinaryOperatorKind.GreaterThanOrEqual, BinaryOperatorKind.LessThan },
27{ BinaryOperatorKind.Or, BinaryOperatorKind.And },
28{ BinaryOperatorKind.And, BinaryOperatorKind.Or },
29{ BinaryOperatorKind.ConditionalOr, BinaryOperatorKind.ConditionalAnd },
30{ BinaryOperatorKind.ConditionalAnd, BinaryOperatorKind.ConditionalOr },
149if (!s_negatedBinaryMap.TryGetValue(binaryOperation.OperatorKind, out var negatedKind))
155&& binaryOperation.OperatorKind is BinaryOperatorKind.LessThan or
156BinaryOperatorKind.LessThanOrEqual or
157BinaryOperatorKind.GreaterThan or
158BinaryOperatorKind.GreaterThanOrEqual)
163if (binaryOperation.OperatorKind is BinaryOperatorKind.Or or
164BinaryOperatorKind.And or
165BinaryOperatorKind.ConditionalAnd or
166BinaryOperatorKind.ConditionalOr)
172var newBinaryExpressionSyntax = negatedKind is BinaryOperatorKind.Equals or BinaryOperatorKind.NotEquals
380BinaryOperatorKind operationKind,
385BinaryOperatorKind.LessThanOrEqual => IsSpecialCaseBinaryExpression(binaryOperation, operationKind)
388BinaryOperatorKind.GreaterThanOrEqual => IsSpecialCaseBinaryExpression(binaryOperation, operationKind)
391BinaryOperatorKind.LessThan => generator.LessThanExpression(leftOperand, rightOperand),
392BinaryOperatorKind.GreaterThan => generator.GreaterThanExpression(leftOperand, rightOperand),
393BinaryOperatorKind.Or => generator.BitwiseOrExpression(leftOperand, rightOperand),
394BinaryOperatorKind.And => generator.BitwiseAndExpression(leftOperand, rightOperand),
395BinaryOperatorKind.ConditionalOr => generator.LogicalOrExpression(leftOperand, rightOperand),
396BinaryOperatorKind.ConditionalAnd => generator.LogicalAndExpression(leftOperand, rightOperand),
408BinaryOperatorKind operationKind)
418BinaryOperatorKind.LessThanOrEqual when rightOperand.IsNumericLiteral()
420BinaryOperatorKind.GreaterThanOrEqual when leftOperand.IsNumericLiteral()
Microsoft.CodeAnalysis.AnalyzerUtilities (88)
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\ValueContentAnalysis\ValueContentAbstractValue.cs (46)
255BinaryOperatorKind binaryOperatorKind,
289private static bool TryMerge(object? value1, object? value2, BinaryOperatorKind binaryOperatorKind, ITypeSymbol? type1, ITypeSymbol? type2, ITypeSymbol? resultType, [NotNullWhen(returnValue: true)] out object? result)
408private static bool TryMerge(char value1, char value2, BinaryOperatorKind binaryOperatorKind, [NotNullWhen(returnValue: true)] out object? result)
412case BinaryOperatorKind.Add:
413case BinaryOperatorKind.Concatenate:
422private static bool TryMerge(string value1, string value2, BinaryOperatorKind binaryOperatorKind, [NotNullWhen(returnValue: true)] out object? result)
426case BinaryOperatorKind.Add:
427case BinaryOperatorKind.Concatenate:
436private static bool TryMerge(bool value1, bool value2, BinaryOperatorKind binaryOperatorKind, [NotNullWhen(returnValue: true)] out object? result)
440case BinaryOperatorKind.And:
441case BinaryOperatorKind.ConditionalAnd:
445case BinaryOperatorKind.Or:
446case BinaryOperatorKind.ConditionalOr:
450case BinaryOperatorKind.Equals:
454case BinaryOperatorKind.NotEquals:
463private static bool TryMerge(ulong value1, ulong value2, BinaryOperatorKind binaryOperatorKind, out ulong result)
467case BinaryOperatorKind.Add:
471case BinaryOperatorKind.Subtract:
475case BinaryOperatorKind.Multiply:
479case BinaryOperatorKind.Divide:
488case BinaryOperatorKind.And:
492case BinaryOperatorKind.Or:
496case BinaryOperatorKind.Remainder:
500case BinaryOperatorKind.Power:
504case BinaryOperatorKind.LeftShift:
513case BinaryOperatorKind.RightShift:
522case BinaryOperatorKind.ExclusiveOr:
526case BinaryOperatorKind.Equals:
530case BinaryOperatorKind.NotEquals:
534case BinaryOperatorKind.LessThan:
538case BinaryOperatorKind.LessThanOrEqual:
542case BinaryOperatorKind.GreaterThan:
546case BinaryOperatorKind.GreaterThanOrEqual:
555private static bool TryMerge(double value1, double value2, BinaryOperatorKind binaryOperatorKind, out double result)
559case BinaryOperatorKind.Add:
563case BinaryOperatorKind.Subtract:
567case BinaryOperatorKind.Multiply:
571case BinaryOperatorKind.Divide:
580case BinaryOperatorKind.Remainder:
584case BinaryOperatorKind.Power:
588case BinaryOperatorKind.Equals:
592case BinaryOperatorKind.NotEquals:
596case BinaryOperatorKind.LessThan:
600case BinaryOperatorKind.LessThanOrEqual:
604case BinaryOperatorKind.GreaterThan:
608case BinaryOperatorKind.GreaterThanOrEqual:
Microsoft.CodeAnalysis.CodeStyle (15)
Microsoft.CodeAnalysis.CodeStyle.Fixes (48)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (47)
18private static readonly ImmutableDictionary<BinaryOperatorKind, BinaryOperatorKind> s_negatedBinaryMap =
19new Dictionary<BinaryOperatorKind, BinaryOperatorKind>
21{ BinaryOperatorKind.Equals, BinaryOperatorKind.NotEquals },
22{ BinaryOperatorKind.NotEquals, BinaryOperatorKind.Equals },
23{ BinaryOperatorKind.LessThan, BinaryOperatorKind.GreaterThanOrEqual },
24{ BinaryOperatorKind.GreaterThan, BinaryOperatorKind.LessThanOrEqual },
25{ BinaryOperatorKind.LessThanOrEqual, BinaryOperatorKind.GreaterThan },
26{ BinaryOperatorKind.GreaterThanOrEqual, BinaryOperatorKind.LessThan },
27{ BinaryOperatorKind.Or, BinaryOperatorKind.And },
28{ BinaryOperatorKind.And, BinaryOperatorKind.Or },
29{ BinaryOperatorKind.ConditionalOr, BinaryOperatorKind.ConditionalAnd },
30{ BinaryOperatorKind.ConditionalAnd, BinaryOperatorKind.ConditionalOr },
149if (!s_negatedBinaryMap.TryGetValue(binaryOperation.OperatorKind, out var negatedKind))
155&& binaryOperation.OperatorKind is BinaryOperatorKind.LessThan or
156BinaryOperatorKind.LessThanOrEqual or
157BinaryOperatorKind.GreaterThan or
158BinaryOperatorKind.GreaterThanOrEqual)
163if (binaryOperation.OperatorKind is BinaryOperatorKind.Or or
164BinaryOperatorKind.And or
165BinaryOperatorKind.ConditionalAnd or
166BinaryOperatorKind.ConditionalOr)
172var newBinaryExpressionSyntax = negatedKind is BinaryOperatorKind.Equals or BinaryOperatorKind.NotEquals
380BinaryOperatorKind operationKind,
385BinaryOperatorKind.LessThanOrEqual => IsSpecialCaseBinaryExpression(binaryOperation, operationKind)
388BinaryOperatorKind.GreaterThanOrEqual => IsSpecialCaseBinaryExpression(binaryOperation, operationKind)
391BinaryOperatorKind.LessThan => generator.LessThanExpression(leftOperand, rightOperand),
392BinaryOperatorKind.GreaterThan => generator.GreaterThanExpression(leftOperand, rightOperand),
393BinaryOperatorKind.Or => generator.BitwiseOrExpression(leftOperand, rightOperand),
394BinaryOperatorKind.And => generator.BitwiseAndExpression(leftOperand, rightOperand),
395BinaryOperatorKind.ConditionalOr => generator.LogicalOrExpression(leftOperand, rightOperand),
396BinaryOperatorKind.ConditionalAnd => generator.LogicalAndExpression(leftOperand, rightOperand),
408BinaryOperatorKind operationKind)
418BinaryOperatorKind.LessThanOrEqual when rightOperand.IsNumericLiteral()
420BinaryOperatorKind.GreaterThanOrEqual when leftOperand.IsNumericLiteral()
Microsoft.CodeAnalysis.CSharp (28)
Microsoft.CodeAnalysis.CSharp.CodeStyle (20)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (18)
Microsoft.CodeAnalysis.CSharp.Features (38)
Microsoft.CodeAnalysis.CSharp.NetAnalyzers (1)
Microsoft.CodeAnalysis.CSharp.Workspaces (5)
Microsoft.CodeAnalysis.Features (26)
Microsoft.CodeAnalysis.NetAnalyzers (172)
Microsoft.NetCore.Analyzers\Performance\UseCountProperly.cs (19)
343if (negatedPattern.Pattern is IRelationalPatternOperation { OperatorKind: BinaryOperatorKind.GreaterThan, Value: ILiteralOperation { ConstantValue: { HasValue: true, Value: 0 } } }
344or IRelationalPatternOperation { OperatorKind: BinaryOperatorKind.GreaterThanOrEqual, Value: ILiteralOperation { ConstantValue: { HasValue: true, Value: 1 } } })
353or IRelationalPatternOperation { OperatorKind: BinaryOperatorKind.LessThanOrEqual, Value: ILiteralOperation { ConstantValue: { HasValue: true, Value: 0 } } };
368if (relationalPattern is { OperatorKind: BinaryOperatorKind.LessThan, Value: ILiteralOperation { ConstantValue: { HasValue: true, Value: 1 } } }
369or { OperatorKind: BinaryOperatorKind.LessThanOrEqual, Value: ILiteralOperation { ConstantValue: { HasValue: true, Value: 0 } } })
377return relationalPattern is { OperatorKind: BinaryOperatorKind.GreaterThan, Value: ILiteralOperation { ConstantValue: { HasValue: true, Value: 0 } } }
378or { OperatorKind: BinaryOperatorKind.GreaterThanOrEqual, Value: ILiteralOperation { ConstantValue: { HasValue: true, Value: 1 } } };
575case BinaryOperatorKind.Equals:
576case BinaryOperatorKind.LessThanOrEqual:
579case BinaryOperatorKind.NotEquals:
580case BinaryOperatorKind.GreaterThan:
591case BinaryOperatorKind.LessThan:
594case BinaryOperatorKind.GreaterThanOrEqual:
623case BinaryOperatorKind.Equals:
624case BinaryOperatorKind.GreaterThanOrEqual:
628case BinaryOperatorKind.LessThan:
629case BinaryOperatorKind.NotEquals:
641case BinaryOperatorKind.LessThanOrEqual:
645case BinaryOperatorKind.GreaterThan:
Microsoft.NetCore.Analyzers\Runtime\UseExceptionThrowHelpers.cs (26)
376else if (condition is IBinaryOperation { OperatorKind: BinaryOperatorKind.Equals } equalsOp)
407else if (condition is IBinaryOperation { OperatorKind: BinaryOperatorKind.ConditionalOr } orOp &&
409orOp.RightOperand is IBinaryOperation { OperatorKind: BinaryOperatorKind.Equals } lengthCheckOperation)
475case BinaryOperatorKind.Equals:
494case BinaryOperatorKind.LessThanOrEqual or BinaryOperatorKind.LessThan:
500methodName = binaryOperation.OperatorKind == BinaryOperatorKind.LessThanOrEqual ? ThrowIfNegativeOrZero : ThrowIfNegative;
507case BinaryOperatorKind.GreaterThanOrEqual or BinaryOperatorKind.GreaterThan:
513methodName = binaryOperation.OperatorKind == BinaryOperatorKind.GreaterThanOrEqual ? ThrowIfNegativeOrZero : ThrowIfNegative;
541case BinaryOperatorKind.GreaterThan or BinaryOperatorKind.GreaterThanOrEqual or BinaryOperatorKind.LessThan or BinaryOperatorKind.LessThanOrEqual or BinaryOperatorKind.Equals or BinaryOperatorKind.NotEquals:
552BinaryOperatorKind.GreaterThan => ThrowIfGreaterThan,
553BinaryOperatorKind.GreaterThanOrEqual => ThrowIfGreaterThanOrEqual,
554BinaryOperatorKind.LessThan => ThrowIfLessThan,
555BinaryOperatorKind.LessThanOrEqual => ThrowIfLessThanOrEqual,
556BinaryOperatorKind.Equals => ThrowIfEqual,
574BinaryOperatorKind.GreaterThan => ThrowIfLessThan,
575BinaryOperatorKind.GreaterThanOrEqual => ThrowIfLessThanOrEqual,
576BinaryOperatorKind.LessThan => ThrowIfGreaterThan,
577BinaryOperatorKind.LessThanOrEqual => ThrowIfGreaterThanOrEqual,
578BinaryOperatorKind.Equals => ThrowIfEqual,
src\440320f3f10733a8\ValueContentAbstractValue.cs (46)
254BinaryOperatorKind binaryOperatorKind,
288private static bool TryMerge(object? value1, object? value2, BinaryOperatorKind binaryOperatorKind, ITypeSymbol? type1, ITypeSymbol? type2, ITypeSymbol? resultType, [NotNullWhen(returnValue: true)] out object? result)
407private static bool TryMerge(char value1, char value2, BinaryOperatorKind binaryOperatorKind, [NotNullWhen(returnValue: true)] out object? result)
411case BinaryOperatorKind.Add:
412case BinaryOperatorKind.Concatenate:
421private static bool TryMerge(string value1, string value2, BinaryOperatorKind binaryOperatorKind, [NotNullWhen(returnValue: true)] out object? result)
425case BinaryOperatorKind.Add:
426case BinaryOperatorKind.Concatenate:
435private static bool TryMerge(bool value1, bool value2, BinaryOperatorKind binaryOperatorKind, [NotNullWhen(returnValue: true)] out object? result)
439case BinaryOperatorKind.And:
440case BinaryOperatorKind.ConditionalAnd:
444case BinaryOperatorKind.Or:
445case BinaryOperatorKind.ConditionalOr:
449case BinaryOperatorKind.Equals:
453case BinaryOperatorKind.NotEquals:
462private static bool TryMerge(ulong value1, ulong value2, BinaryOperatorKind binaryOperatorKind, out ulong result)
466case BinaryOperatorKind.Add:
470case BinaryOperatorKind.Subtract:
474case BinaryOperatorKind.Multiply:
478case BinaryOperatorKind.Divide:
487case BinaryOperatorKind.And:
491case BinaryOperatorKind.Or:
495case BinaryOperatorKind.Remainder:
499case BinaryOperatorKind.Power:
503case BinaryOperatorKind.LeftShift:
512case BinaryOperatorKind.RightShift:
521case BinaryOperatorKind.ExclusiveOr:
525case BinaryOperatorKind.Equals:
529case BinaryOperatorKind.NotEquals:
533case BinaryOperatorKind.LessThan:
537case BinaryOperatorKind.LessThanOrEqual:
541case BinaryOperatorKind.GreaterThan:
545case BinaryOperatorKind.GreaterThanOrEqual:
554private static bool TryMerge(double value1, double value2, BinaryOperatorKind binaryOperatorKind, out double result)
558case BinaryOperatorKind.Add:
562case BinaryOperatorKind.Subtract:
566case BinaryOperatorKind.Multiply:
570case BinaryOperatorKind.Divide:
579case BinaryOperatorKind.Remainder:
583case BinaryOperatorKind.Power:
587case BinaryOperatorKind.Equals:
591case BinaryOperatorKind.NotEquals:
595case BinaryOperatorKind.LessThan:
599case BinaryOperatorKind.LessThanOrEqual:
603case BinaryOperatorKind.GreaterThan:
607case BinaryOperatorKind.GreaterThanOrEqual:
Microsoft.CodeAnalysis.ResxSourceGenerator (24)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (3)
Microsoft.CodeAnalysis.VisualBasic.Features (7)
ConvertIfToSwitch\VisualBasicConvertIfToSwitchCodeRefactoringProvider.Rewriting.vb (7)
13Private Shared ReadOnly s_operatorMap As Dictionary(Of BinaryOperatorKind, (CaseClauseKind As SyntaxKind, OperatorTokenKind As SyntaxKind)) =
14New Dictionary(Of BinaryOperatorKind, (SyntaxKind, SyntaxKind))() From
16{BinaryOperatorKind.NotEquals, (SyntaxKind.CaseNotEqualsClause, SyntaxKind.LessThanGreaterThanToken)},
17{BinaryOperatorKind.LessThan, (SyntaxKind.CaseLessThanClause, SyntaxKind.LessThanToken)},
18{BinaryOperatorKind.GreaterThan, (SyntaxKind.CaseGreaterThanClause, SyntaxKind.GreaterThanToken)},
19{BinaryOperatorKind.LessThanOrEqual, (SyntaxKind.CaseLessThanOrEqualClause, SyntaxKind.LessThanEqualsToken)},
20{BinaryOperatorKind.GreaterThanOrEqual, (SyntaxKind.CaseGreaterThanOrEqualClause, SyntaxKind.GreaterThanEqualsToken)}
Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers (1)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (3)
Microsoft.CodeAnalysis.Workspaces (52)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (47)
18private static readonly ImmutableDictionary<BinaryOperatorKind, BinaryOperatorKind> s_negatedBinaryMap =
19new Dictionary<BinaryOperatorKind, BinaryOperatorKind>
21{ BinaryOperatorKind.Equals, BinaryOperatorKind.NotEquals },
22{ BinaryOperatorKind.NotEquals, BinaryOperatorKind.Equals },
23{ BinaryOperatorKind.LessThan, BinaryOperatorKind.GreaterThanOrEqual },
24{ BinaryOperatorKind.GreaterThan, BinaryOperatorKind.LessThanOrEqual },
25{ BinaryOperatorKind.LessThanOrEqual, BinaryOperatorKind.GreaterThan },
26{ BinaryOperatorKind.GreaterThanOrEqual, BinaryOperatorKind.LessThan },
27{ BinaryOperatorKind.Or, BinaryOperatorKind.And },
28{ BinaryOperatorKind.And, BinaryOperatorKind.Or },
29{ BinaryOperatorKind.ConditionalOr, BinaryOperatorKind.ConditionalAnd },
30{ BinaryOperatorKind.ConditionalAnd, BinaryOperatorKind.ConditionalOr },
149if (!s_negatedBinaryMap.TryGetValue(binaryOperation.OperatorKind, out var negatedKind))
155&& binaryOperation.OperatorKind is BinaryOperatorKind.LessThan or
156BinaryOperatorKind.LessThanOrEqual or
157BinaryOperatorKind.GreaterThan or
158BinaryOperatorKind.GreaterThanOrEqual)
163if (binaryOperation.OperatorKind is BinaryOperatorKind.Or or
164BinaryOperatorKind.And or
165BinaryOperatorKind.ConditionalAnd or
166BinaryOperatorKind.ConditionalOr)
172var newBinaryExpressionSyntax = negatedKind is BinaryOperatorKind.Equals or BinaryOperatorKind.NotEquals
380BinaryOperatorKind operationKind,
385BinaryOperatorKind.LessThanOrEqual => IsSpecialCaseBinaryExpression(binaryOperation, operationKind)
388BinaryOperatorKind.GreaterThanOrEqual => IsSpecialCaseBinaryExpression(binaryOperation, operationKind)
391BinaryOperatorKind.LessThan => generator.LessThanExpression(leftOperand, rightOperand),
392BinaryOperatorKind.GreaterThan => generator.GreaterThanExpression(leftOperand, rightOperand),
393BinaryOperatorKind.Or => generator.BitwiseOrExpression(leftOperand, rightOperand),
394BinaryOperatorKind.And => generator.BitwiseAndExpression(leftOperand, rightOperand),
395BinaryOperatorKind.ConditionalOr => generator.LogicalOrExpression(leftOperand, rightOperand),
396BinaryOperatorKind.ConditionalAnd => generator.LogicalAndExpression(leftOperand, rightOperand),
408BinaryOperatorKind operationKind)
418BinaryOperatorKind.LessThanOrEqual when rightOperand.IsNumericLiteral()
420BinaryOperatorKind.GreaterThanOrEqual when leftOperand.IsNumericLiteral()
Roslyn.Diagnostics.Analyzers (72)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (47)
18private static readonly ImmutableDictionary<BinaryOperatorKind, BinaryOperatorKind> s_negatedBinaryMap =
19new Dictionary<BinaryOperatorKind, BinaryOperatorKind>
21{ BinaryOperatorKind.Equals, BinaryOperatorKind.NotEquals },
22{ BinaryOperatorKind.NotEquals, BinaryOperatorKind.Equals },
23{ BinaryOperatorKind.LessThan, BinaryOperatorKind.GreaterThanOrEqual },
24{ BinaryOperatorKind.GreaterThan, BinaryOperatorKind.LessThanOrEqual },
25{ BinaryOperatorKind.LessThanOrEqual, BinaryOperatorKind.GreaterThan },
26{ BinaryOperatorKind.GreaterThanOrEqual, BinaryOperatorKind.LessThan },
27{ BinaryOperatorKind.Or, BinaryOperatorKind.And },
28{ BinaryOperatorKind.And, BinaryOperatorKind.Or },
29{ BinaryOperatorKind.ConditionalOr, BinaryOperatorKind.ConditionalAnd },
30{ BinaryOperatorKind.ConditionalAnd, BinaryOperatorKind.ConditionalOr },
149if (!s_negatedBinaryMap.TryGetValue(binaryOperation.OperatorKind, out var negatedKind))
155&& binaryOperation.OperatorKind is BinaryOperatorKind.LessThan or
156BinaryOperatorKind.LessThanOrEqual or
157BinaryOperatorKind.GreaterThan or
158BinaryOperatorKind.GreaterThanOrEqual)
163if (binaryOperation.OperatorKind is BinaryOperatorKind.Or or
164BinaryOperatorKind.And or
165BinaryOperatorKind.ConditionalAnd or
166BinaryOperatorKind.ConditionalOr)
172var newBinaryExpressionSyntax = negatedKind is BinaryOperatorKind.Equals or BinaryOperatorKind.NotEquals
380BinaryOperatorKind operationKind,
385BinaryOperatorKind.LessThanOrEqual => IsSpecialCaseBinaryExpression(binaryOperation, operationKind)
388BinaryOperatorKind.GreaterThanOrEqual => IsSpecialCaseBinaryExpression(binaryOperation, operationKind)
391BinaryOperatorKind.LessThan => generator.LessThanExpression(leftOperand, rightOperand),
392BinaryOperatorKind.GreaterThan => generator.GreaterThanExpression(leftOperand, rightOperand),
393BinaryOperatorKind.Or => generator.BitwiseOrExpression(leftOperand, rightOperand),
394BinaryOperatorKind.And => generator.BitwiseAndExpression(leftOperand, rightOperand),
395BinaryOperatorKind.ConditionalOr => generator.LogicalOrExpression(leftOperand, rightOperand),
396BinaryOperatorKind.ConditionalAnd => generator.LogicalAndExpression(leftOperand, rightOperand),
408BinaryOperatorKind operationKind)
418BinaryOperatorKind.LessThanOrEqual when rightOperand.IsNumericLiteral()
420BinaryOperatorKind.GreaterThanOrEqual when leftOperand.IsNumericLiteral()
Roslyn.Diagnostics.CSharp.Analyzers (5)
Roslyn.Diagnostics.VisualBasic.Analyzers (3)