示例#1
0
        public static string ToCodeString(ExpressionToCodeConfiguration config, Expression e)
        {
            var sb = new StringBuilder();
            var ignoreInitialSpace = true;
            var stringifiedExpr    = new ExpressionToCodeImpl(config).ExpressionDispatch(e);

            AppendTo(sb, ref ignoreInitialSpace, stringifiedExpr);
            return(sb.ToString());
        }
            public static ExpressionWithSubExpressions Create(ExpressionToCodeConfiguration config, Expression e, bool hideOutermostValue)
            {
                var sb = new StringBuilder();
                var ignoreInitialSpace = true;
                var node = new ExpressionToCodeImpl(config).ExpressionDispatch(e);

                AppendNodeToStringBuilder(sb, node, ref ignoreInitialSpace);
                var fullExprText        = sb.ToString();
                var subExpressionValues = new List <SubExpressionValue>();

                FindSubExpressionValues(config, node, node, subExpressionValues, hideOutermostValue);
                return(new ExpressionWithSubExpressions {
                    ExpressionString = fullExprText, SubExpressions = subExpressionValues.Distinct().ToArray()
                });
            }
示例#3
0
        static SplitExpressionLine ExpressionToStringWithValues(ExpressionToCodeConfiguration config, Expression e, bool outerValueIsAssertionFailure)
        {
            var nodeInfos          = new List <SubExpressionInfo>();
            var sb                 = new StringBuilder();
            var ignoreInitialSpace = true;
            var node               = new ExpressionToCodeImpl(config).ExpressionDispatch(e);

            AppendTo(config, sb, nodeInfos, node, ref ignoreInitialSpace, !outerValueIsAssertionFailure);
            nodeInfos.Add(new SubExpressionInfo {
                Location = sb.Length, Value = null
            });
            return(new SplitExpressionLine {
                Line = sb.ToString().TrimEnd(), Nodes = nodeInfos.ToArray()
            });
        }
示例#4
0
            public static ExpressionWithSubExpressions Create(ExpressionToCodeConfiguration config, Expression e, bool outerValueIsAssertionFailure)
            {
                var sb = new StringBuilder();
                var ignoreInitialSpace = true;
                var node = new ExpressionToCodeImpl(config).ExpressionDispatch(e);

                AppendNodeToStringBuilder(sb, node, ref ignoreInitialSpace);
                var fullExprText        = sb.ToString();
                var subExpressionValues = new List <SubExpressionValue>();

                FindSubExpressionValues(config, node, node, subExpressionValues, outerValueIsAssertionFailure);
                var assertionValue = outerValueIsAssertionFailure? OutermostValue(config, node) : null;

                return(new ExpressionWithSubExpressions {
                    ExpressionString = fullExprText
                                       + (assertionValue != null ? "\n" + spacedArrow + assertionValue + " (caused assertion failure)\n" :""),
                    SubExpressions = subExpressionValues.Distinct().ToArray()
                });
            }