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); }
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); }
public bool Contains(ParameterSyntax parameterSyntax) { return(ParametersInUse.OfType <ParameterReferenceArgument>().Any(x => x.ReferencedParameter.Equals(parameterSyntax))); }
public IReadOnlyList <TypeSyntax> GetContractEnsuresTypes() { return(ParametersInUse.OfType <ContractResultPredicateArgument>().Select(x => x.ResultType).ToList()); }