Exemple #1
0
        public bool HasNotNullCheck(ParameterSyntax parameterSyntax)
        {
            foreach (var p in ParametersInUse.OfType <ParameterReferenceArgument>().Where(x => x.ReferencedParameter.Equals(parameterSyntax)))
            {
                return
                    (p.Argument.DescendantNodesAndSelf().OfType <BinaryExpressionSyntax>()
                     .Any(be => be.OperatorToken.ToString() == "!=" &&
                          // null literal could on both side of the expression
                          (be.Right.ToString() == "null" || be.Left.ToString() == "null")));
            }

            return(false);
        }
Exemple #2
0
        public bool HasNotNullCheckWithContractResult()
        {
            foreach (var p in ParametersInUse.OfType <ContractResultPredicateArgument>())
            {
                // Super naive!! Should be added a check for other side of the expression!
                return
                    (p.Argument.DescendantNodesAndSelf().OfType <BinaryExpressionSyntax>()
                     .Any(be => be.OperatorToken.ToString() == "!=" &&
                          // null literal could on both side of the expression
                          (be.Right.ToString() == "null" || be.Left.ToString() == "null")));
            }

            return(false);
        }
Exemple #3
0
 public bool Contains(ParameterSyntax parameterSyntax)
 {
     return(ParametersInUse.OfType <ParameterReferenceArgument>().Any(x => x.ReferencedParameter.Equals(parameterSyntax)));
 }
Exemple #4
0
 public IReadOnlyList <TypeSyntax> GetContractEnsuresTypes()
 {
     return(ParametersInUse.OfType <ContractResultPredicateArgument>().Select(x => x.ResultType).ToList());
 }