Beispiel #1
0
        override public void LeaveBinaryExpression(BinaryExpression node)
        {
            if (CheckExpressionType(node.Right))
            {
                CheckExpressionType(node.Left);
            }

            if (BinaryOperatorType.ReferenceEquality == node.Operator)
            {
                if (IsTypeReference(node.Right))
                {
                    Warnings.Add(
                        CompilerWarningFactory.IsInsteadOfIsa(node));
                }
            }

            //check that the assignment or comparison is meaningful
            if (BinaryOperatorType.Assign == node.Operator ||
                AstUtil.GetBinaryOperatorKind(node) == BinaryOperatorKind.Comparison)
            {
                if (AreSameExpressions(node.Left, node.Right))
                {
                    Warnings.Add(
                        (BinaryOperatorType.Assign == node.Operator)
                                                ? CompilerWarningFactory.AssignmentToSameVariable(node)
                                                : CompilerWarningFactory.ComparisonWithSameVariable(node)
                        );
                }
                else if (BinaryOperatorType.Assign != node.Operator &&
                         AreConstantExpressions(node.Left, node.Right))
                {
                    WarnAboutConstantExpression(node);
                }
            }
        }
Beispiel #2
0
 override public void LeaveBinaryExpression(BinaryExpression node)
 {
     CheckExpressionType(node.Right);
     if (BinaryOperatorType.ReferenceEquality == node.Operator)
     {
         if (IsTypeReference(node.Right))
         {
             Warnings.Add(
                 CompilerWarningFactory.IsInsteadOfIsa(node));
         }
     }
 }