private Branch FindBranch(SyntaxNode expression, out Condition inlineCondition) { // First search any lambdas. Those are kept separate since they could run at any time. foreach (var lambda in Lambdas) { Branch branch = lambda.FindBranch(expression, out inlineCondition); if (branch != null) { return(branch); } } // If not in a lambda, then search the full method body. return(BranchTree.FindBranch(expression, out inlineCondition)); }
/// <summary> /// Checks if there were any assignments to null on the symbol that is being checked in <paramref name="expression"/> /// </summary> /// <param name="expression">The expression containing the symbol being validated</param> /// <param name="assignmentsForExpression">All assignments to the symbol being validated</param> /// <param name="branchWithMatchingCondition">The branch with the condition that proves the expression is valid</param> /// <returns></returns> private bool NullAssignmentsAreInPath( SyntaxNode expression, List <Assignment> assignmentsForExpression, Branch branchWithMatchingCondition) { foreach (var assignment in assignmentsForExpression.Where(i => i.Value != ValueType.NotNull)) { var assignmentBranch = BranchTree.FindBranch(assignment.Expression, out var trash); if (assignmentBranch != null) { if (branchWithMatchingCondition == assignmentBranch || branchWithMatchingCondition.IsParentOf(assignmentBranch)) { if (branchWithMatchingCondition.Condition.IsWhile(assignment.Symbol, model)) { return(assignment.Expression.SpanStart < expression.SpanStart); } return(true); } } } return(false); }