Show / Hide Table of Contents

Class SafeExpressionVisitor

Expression visitor that protects against rewrites of expression nodes that violate typing requirements.

Inheritance
System.Object
SafeExpressionVisitor
LvalExpressionVisitor
Namespace: System.Linq.Expressions
Assembly: Nuqleon.Linq.Expressions.Optimizers.dll
Syntax
public class SafeExpressionVisitor : ExpressionVisitor
Examples

The following nodes have typing requirements:

Constructors

SafeExpressionVisitor()

Declaration
public SafeExpressionVisitor()

Methods

VisitBinary(BinaryExpression)

Visits a binary expression with a strongly typed visit to System.Linq.Expressions.BinaryExpression.Conversion using VisitBinaryConversion(LambdaExpression).

Declaration
protected override sealed Expression VisitBinary(BinaryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.BinaryExpression node

The binary expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the binary expression.

Remarks

This method is sealed in order to guarantee expression rewrite safety by avoiding dangerous rewrites that don't take constraints on the rewrite of System.Linq.Expressions.BinaryExpression.Conversion into consideration.

In order to guarantee expression rewrite safety, override VisitBinaryWithoutConversion(BinaryExpression) and VisitBinaryConversion(LambdaExpression) instead.

In case safety checks should be ignored by derived types, override VisitBinaryUnsafe(BinaryExpression) instead.

VisitBinaryConversion(LambdaExpression)

Visits the System.Linq.Expressions.BinaryExpression.Conversion node in a strongly typed manner.

Declaration
protected virtual LambdaExpression VisitBinaryConversion(LambdaExpression node)
Parameters
Type Name Description
System.Linq.Expressions.LambdaExpression node

The lambda expression to visit.

Returns
Type Description
System.Linq.Expressions.LambdaExpression

The result of visiting the lambda expression.

VisitBinaryUnsafe(BinaryExpression)

Visits a binary expression without any safety checks. See remarks on VisitBinary(BinaryExpression) for more information.

Declaration
protected virtual Expression VisitBinaryUnsafe(BinaryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.BinaryExpression node

The binary expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the binary expression.

VisitBinaryWithConversion(BinaryExpression)

Visits a binary expression that has a System.Linq.Expressions.BinaryExpression.Conversion.

Declaration
protected virtual Expression VisitBinaryWithConversion(BinaryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.BinaryExpression node

The binary expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the binary expression.

Remarks

When overriding this method, derived implementations should take care to ensure a strongly-typed visit to the System.Linq.Expressions.BinaryExpression.Conversion property. To ensure strong typing, a call to VisitBinaryConversion(LambdaExpression) can be made.

VisitBinaryWithoutConversion(BinaryExpression)

Visits a binary expression that has no System.Linq.Expressions.BinaryExpression.Conversion.

Declaration
protected virtual Expression VisitBinaryWithoutConversion(BinaryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.BinaryExpression node

The binary expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the binary expression.

VisitListInit(ListInitExpression)

Visits a list initialization expression with a strongly typed visit to System.Linq.Expressions.ListInitExpression.NewExpression using VisitListInitNew(NewExpression).

Declaration
protected override sealed Expression VisitListInit(ListInitExpression node)
Parameters
Type Name Description
System.Linq.Expressions.ListInitExpression node

The list initialization expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the list initialization expression.

Remarks

This method is sealed in order to guarantee expression rewrite safety by avoiding dangerous rewrites that don't take constraints on the rewrite of System.Linq.Expressions.ListInitExpression.NewExpression into consideration.

In order to guarantee expression rewrite safety, override VisitListInitNew(NewExpression) and System.Linq.Expressions.ExpressionVisitor.VisitElementInit(System.Linq.Expressions.ElementInit) instead.

In case safety checks should be ignored by derived types, override VisitListInitUnsafe(ListInitExpression) instead.

VisitListInitNew(NewExpression)

Visits the System.Linq.Expressions.ListInitExpression.NewExpression node in a strongly typed manner.

Declaration
protected virtual NewExpression VisitListInitNew(NewExpression node)
Parameters
Type Name Description
System.Linq.Expressions.NewExpression node

The new expression to visit.

Returns
Type Description
System.Linq.Expressions.NewExpression

The result of visiting the new expression.

VisitListInitUnsafe(ListInitExpression)

Visits a list initialization expression without any safety checks. See remarks on VisitListInit(ListInitExpression) for more information.

Declaration
protected virtual Expression VisitListInitUnsafe(ListInitExpression node)
Parameters
Type Name Description
System.Linq.Expressions.ListInitExpression node

The list initialization expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the list initialization expression.

VisitMemberInit(MemberInitExpression)

Visits a member initialization expression with a strongly typed visit to System.Linq.Expressions.MemberInitExpression.NewExpression using VisitMemberInitNew(NewExpression).

Declaration
protected override sealed Expression VisitMemberInit(MemberInitExpression node)
Parameters
Type Name Description
System.Linq.Expressions.MemberInitExpression node

The member initialization expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the member initialization expression.

Remarks

This method is sealed in order to guarantee expression rewrite safety by avoiding dangerous rewrites that don't take constraints on the rewrite of System.Linq.Expressions.MemberInitExpression.NewExpression into consideration.

In order to guarantee expression rewrite safety, override VisitMemberInitNew(NewExpression) and System.Linq.Expressions.ExpressionVisitor.VisitMemberBinding(System.Linq.Expressions.MemberBinding) instead.

In case safety checks should be ignored by derived types, override VisitMemberInitUnsafe(MemberInitExpression) instead.

VisitMemberInitNew(NewExpression)

Visits the System.Linq.Expressions.MemberInitExpression.NewExpression node in a strongly typed manner.

Declaration
protected virtual NewExpression VisitMemberInitNew(NewExpression node)
Parameters
Type Name Description
System.Linq.Expressions.NewExpression node

The new expression to visit.

Returns
Type Description
System.Linq.Expressions.NewExpression

The result of visiting the new expression.

VisitMemberInitUnsafe(MemberInitExpression)

Visits a member initialization expression without any safety checks. See remarks on VisitMemberInit(MemberInitExpression) for more information.

Declaration
protected virtual Expression VisitMemberInitUnsafe(MemberInitExpression node)
Parameters
Type Name Description
System.Linq.Expressions.MemberInitExpression node

The member initialization expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the member initialization expression.

VisitRuntimeVariable(ParameterExpression)

Visits a variable that occurs in a System.Linq.Expressions.RuntimeVariablesExpression.

Declaration
protected virtual ParameterExpression VisitRuntimeVariable(ParameterExpression node)
Parameters
Type Name Description
System.Linq.Expressions.ParameterExpression node

The variable to visit.

Returns
Type Description
System.Linq.Expressions.ParameterExpression

The result of visiting the variable.

VisitRuntimeVariables(RuntimeVariablesExpression)

Visits a runtime variables expression with a strongly typed visit to System.Linq.Expressions.RuntimeVariablesExpression.Variables using VisitRuntimeVariable(ParameterExpression).

Declaration
protected override sealed Expression VisitRuntimeVariables(RuntimeVariablesExpression node)
Parameters
Type Name Description
System.Linq.Expressions.RuntimeVariablesExpression node

The runtime variables expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the runtime variables expression.

Remarks

This method is sealed in order to guarantee expression rewrite safety by avoiding dangerous rewrites that don't take constraints on the rewrite of System.Linq.Expressions.RuntimeVariablesExpression.Variables into consideration.

In order to guarantee expression rewrite safety, override VisitRuntimeVariable(ParameterExpression) instead.

In case safety checks should be ignored by derived types, override VisitRuntimeVariablesUnsafe(RuntimeVariablesExpression) instead.

VisitRuntimeVariablesUnsafe(RuntimeVariablesExpression)

Visits a runtime variables expression without any safety checks. See remarks on VisitRuntimeVariables(RuntimeVariablesExpression) for more information.

Declaration
protected virtual Expression VisitRuntimeVariablesUnsafe(RuntimeVariablesExpression node)
Parameters
Type Name Description
System.Linq.Expressions.RuntimeVariablesExpression node

The runtime variables expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the runtime variables expression.

VisitUnary(UnaryExpression)

Visits a unary expression with a strongly typed visit to System.Linq.Expressions.UnaryExpression.Operand for nodes of type System.Linq.Expressions.ExpressionType.Quote using VisitUnaryQuoteOperand(LambdaExpression).

Declaration
protected override sealed Expression VisitUnary(UnaryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.UnaryExpression node

The unary expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the unary expression.

Remarks

This method is sealed in order to guarantee expression rewrite safety by avoiding dangerous rewrites that don't take constraints on the rewrite of System.Linq.Expressions.UnaryExpression.Operand into consideration.

In order to guarantee expression rewrite safety, override VisitUnaryNonQuote(UnaryExpression) and VisitUnaryQuoteOperand(LambdaExpression) instead.

In case safety checks should be ignored by derived types, override VisitUnaryUnsafe(UnaryExpression) instead.

VisitUnaryNonQuote(UnaryExpression)

Visits a unary expression that is not of type System.Linq.Expressions.ExpressionType.Quote.

Declaration
protected virtual Expression VisitUnaryNonQuote(UnaryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.UnaryExpression node

The unary expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the unary expression.

VisitUnaryQuote(UnaryExpression)

Visits a unary expression of type System.Linq.Expressions.ExpressionType.Quote.

Declaration
protected virtual Expression VisitUnaryQuote(UnaryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.UnaryExpression node

The unary expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the unary expression.

Remarks

When overriding this method, derived implementations should take care to ensure a strongly-typed visit to the System.Linq.Expressions.UnaryExpression.Operand property. To ensure strong typing, a call to VisitUnaryQuoteOperand(LambdaExpression) can be made.

VisitUnaryQuoteOperand(LambdaExpression)

Visits the System.Linq.Expressions.UnaryExpression.Operand node of a System.Linq.Expressions.ExpressionType.Quote in a strongly typed manner.

Declaration
protected virtual LambdaExpression VisitUnaryQuoteOperand(LambdaExpression node)
Parameters
Type Name Description
System.Linq.Expressions.LambdaExpression node

The lambda expression to visit.

Returns
Type Description
System.Linq.Expressions.LambdaExpression

The result of visiting the lambda expression.

VisitUnaryUnsafe(UnaryExpression)

Visits a unary expression without any safety checks. See remarks on VisitUnary(UnaryExpression) for more information.

Declaration
protected virtual Expression VisitUnaryUnsafe(UnaryExpression node)
Parameters
Type Name Description
System.Linq.Expressions.UnaryExpression node

The unary expression to visit.

Returns
Type Description
System.Linq.Expressions.Expression

The result of visiting the unary expression.

In This Article
Back to top Generated by DocFX