ExpressionTreeToString
ExpressionTreeToString copied to clipboard
Extensibility: allow for types not derived from Expression or other types in System.Linq.Expressions
Currently, in order to figure out which object is a node while visiting, we use a List<Type> for node types:
public readonly static List<Type> NodeTypes = new List<Type>() {
typeof(Expression),
typeof(MemberBinding),
typeof(ElementInit),
typeof(SwitchCase),
typeof(CatchBlock),
typeof(LabelTarget)
};
and a corresponding List<Type> which includes IEnumerable<> variants of each of these types. This allows visitors to treat non-Expression-derived types (such as SwitchCase or ElementInit) as nodes.
Authors of third-party extension visitors might have similar custom nodes which don't derive from Expression.