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() }); }
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() }); }
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() }); }