Ejemplo n.º 1
0
        /// <summary>
        /// Checks if a boolean expression is resolved, knowing that function parameters
        /// (from an optional filtering set, if provided) are non-<c>null</c>.
        /// Might return the valuation of this expression, if that is the case, otherwise returns <c>null</c>.
        /// </summary>
        /// <param name="context">Syntax node analysis context</param>
        /// <param name="expression">Expression to check</param>
        /// <param name="affectedParams">Outputs parameters being compared to null</param>
        /// <returns>If a boolean expression is resolved, knowing that function parameters are non-<c>null</c>,
        /// might return its valuation. Otherwise returns <c>null</c>.</returns>
        static internal bool?ValidateParamNullCheck(
            SyntaxNodeAnalysisContext context, ExpressionSyntax expression,
            out List <IParameterSymbol> affectedParams
            )
        {
            var provider = new BoolValuationProvider <NullCheckContext, NullCheckState>(
                new EitherValuationProvider <bool, NullCheckContext, NullCheckState>(
                    new IValuationProvider <bool, NullCheckContext, NullCheckState>[]
            {
                new CallValuationProvider(), new EqualsValuationProvider()
            }
                    )
                );
            var valContext = new NullCheckContext(context, provider);
            var state      = new NullCheckState();
            var res        = provider.Valuate(valContext, expression, state);

            affectedParams = state.affectedParams;
            return(res);
        }
 public void SetUp()
 {
     Context = new NullCheckContext();
 }