Table of Contents

Class ExpressionPrinter

Namespace
LinqToDB.Internal.Expressions
Assembly
linq2db.dll

A class to create a printable string representation of expression.

public sealed class ExpressionPrinter : ExpressionVisitorBase
Inheritance
object
ExpressionPrinter
Inherited Members
Extension Methods

Constructors

ExpressionPrinter()

Creates a new instance of the ExpressionPrinter class.

public ExpressionPrinter()

Methods

Append(string)

Appends the given string to current output being built.

public ExpressionPrinter Append(string value)

Parameters

value string

The string to append.

Returns

ExpressionPrinter

This printer so additional calls can be chained.

AppendLine()

Appends a new line to current output being built.

public ExpressionPrinter AppendLine()

Returns

ExpressionPrinter

This printer so additional calls can be chained.

AppendLine(string)

Appends the given string and a new line to current output being built.

public ExpressionVisitor AppendLine(string value)

Parameters

value string

The string to append.

Returns

ExpressionVisitor

This printer so additional calls can be chained.

AppendLines(string)

Appends all the lines to current output being built.

public ExpressionPrinter AppendLines(string value)

Parameters

value string

The string to append.

Returns

ExpressionPrinter

This printer so additional calls can be chained.

GenerateBinaryOperator(ExpressionType)

Returns binary operator string corresponding to given ExpressionType.

public string GenerateBinaryOperator(ExpressionType expressionType)

Parameters

expressionType ExpressionType

The expression type to generate binary operator for.

Returns

string

The binary operator string.

Indent()

Creates a scoped indenter that will increment the indent, then decrement it when disposed.

public IDisposable Indent()

Returns

IDisposable

An indenter.

Print(Expression)

Creates a printable string representation of the given expression.

public static string Print(Expression expression)

Parameters

expression Expression

The expression to print.

Returns

string

The printable representation.

PrintDebug(Expression)

Creates a printable verbose string representation of the given expression.

public static string PrintDebug(Expression expression)

Parameters

expression Expression

The expression to print.

Returns

string

The printable representation.

PrintExpression(Expression, int?)

Creates a printable string representation of the given expression.

public string PrintExpression(Expression expression, int? characterLimit = null)

Parameters

expression Expression

The expression to print.

characterLimit int?

An optional limit to the number of characters included. Additional output will be truncated.

Returns

string

The printable representation.

PrintExpressionDebug(Expression)

Creates a printable verbose string representation of the given expression.

public string PrintExpressionDebug(Expression expression)

Parameters

expression Expression

The expression to print.

Returns

string

The printable representation.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Visit(Expression?)

Dispatches the expression to one of the more specialized visit methods in this class.

public override Expression? Visit(Expression? expression)

Parameters

expression Expression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitBinary(BinaryExpression)

Visits the children of the BinaryExpression.

protected override Expression VisitBinary(BinaryExpression binaryExpression)

Parameters

binaryExpression BinaryExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitBlock(BlockExpression)

Visits the children of the BlockExpression.

protected override Expression VisitBlock(BlockExpression blockExpression)

Parameters

blockExpression BlockExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitCollection<T>(IReadOnlyCollection<T>, Action<ExpressionPrinter>?)

Visit given readonly collection of expression for printing.

public void VisitCollection<T>(IReadOnlyCollection<T> items, Action<ExpressionPrinter>? joinAction = null) where T : Expression

Parameters

items IReadOnlyCollection<T>

A collection of items to print.

joinAction Action<ExpressionPrinter>

A join action to use when joining printout of individual item in the collection.

Type Parameters

T

VisitConditional(ConditionalExpression)

Visits the children of the ConditionalExpression.

protected override Expression VisitConditional(ConditionalExpression conditionalExpression)

Parameters

conditionalExpression ConditionalExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitConstant(ConstantExpression)

Visits the ConstantExpression.

protected override Expression VisitConstant(ConstantExpression constantExpression)

Parameters

constantExpression ConstantExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitDefault(DefaultExpression)

Visits the DefaultExpression.

protected override Expression VisitDefault(DefaultExpression defaultExpression)

Parameters

defaultExpression DefaultExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitExtension(Expression)

Visits the children of the extension expression.

protected override Expression VisitExtension(Expression extensionExpression)

Parameters

extensionExpression Expression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitGoto(GotoExpression)

Visits the children of the GotoExpression.

protected override Expression VisitGoto(GotoExpression gotoExpression)

Parameters

gotoExpression GotoExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitIndex(IndexExpression)

Visits the children of the IndexExpression.

protected override Expression VisitIndex(IndexExpression indexExpression)

Parameters

indexExpression IndexExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitInvocation(InvocationExpression)

Visits the children of the InvocationExpression.

protected override Expression VisitInvocation(InvocationExpression invocationExpression)

Parameters

invocationExpression InvocationExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitLabel(LabelExpression)

Visits the children of the LabelExpression.

protected override Expression VisitLabel(LabelExpression labelExpression)

Parameters

labelExpression LabelExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitLambda<T>(Expression<T>)

Visits the children of the Expression<TDelegate>.

protected override Expression VisitLambda<T>(Expression<T> lambdaExpression)

Parameters

lambdaExpression Expression<T>

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

Type Parameters

T

The type of the delegate.

VisitLoop(LoopExpression)

Visits the children of the LoopExpression.

protected override Expression VisitLoop(LoopExpression loopExpression)

Parameters

loopExpression LoopExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitMember(MemberExpression)

Visits the children of the MemberExpression.

protected override Expression VisitMember(MemberExpression memberExpression)

Parameters

memberExpression MemberExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitMemberInit(MemberInitExpression)

Visits the children of the MemberInitExpression.

protected override Expression VisitMemberInit(MemberInitExpression memberInitExpression)

Parameters

memberInitExpression MemberInitExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitMethodCall(MethodCallExpression)

Visits the children of the MethodCallExpression.

protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)

Parameters

methodCallExpression MethodCallExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitNew(NewExpression)

Visits the children of the NewExpression.

protected override Expression VisitNew(NewExpression newExpression)

Parameters

newExpression NewExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitNewArray(NewArrayExpression)

Visits the children of the NewArrayExpression.

protected override Expression VisitNewArray(NewArrayExpression newArrayExpression)

Parameters

newArrayExpression NewArrayExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitParameter(ParameterExpression)

Visits the ParameterExpression.

protected override Expression VisitParameter(ParameterExpression parameterExpression)

Parameters

parameterExpression ParameterExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitSwitch(SwitchExpression)

Visits the children of the SwitchExpression.

protected override Expression VisitSwitch(SwitchExpression switchExpression)

Parameters

switchExpression SwitchExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitTry(TryExpression)

Visits the children of the TryExpression.

protected override Expression VisitTry(TryExpression tryExpression)

Parameters

tryExpression TryExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitTypeBinary(TypeBinaryExpression)

Visits the children of the TypeBinaryExpression.

protected override Expression VisitTypeBinary(TypeBinaryExpression typeBinaryExpression)

Parameters

typeBinaryExpression TypeBinaryExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.

VisitUnary(UnaryExpression)

Visits the children of the UnaryExpression.

protected override Expression VisitUnary(UnaryExpression unaryExpression)

Parameters

unaryExpression UnaryExpression

Returns

Expression

The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.