Currently, (except for BinaryExpression and UnaryExpression which return the method based on the expression's NodeType) all factory methods which return the same object type as the node are displayed. For example, MemberExpression displays:
- Field
- MakeMemberAccess
- Property
- PropertyOrField
It might be better to show only the specific method that applies to this node, duplicating the logic of the factory methods formatter.
OTOH, as long as there aren't too many, it might be better to show all these possibilities.
Useful LINQPad query:
var groups = typeof(System.Linq.Expressions.Expression).GetMethods()
.Where(x => x.IsStatic)
.GroupBy(
x => x.ReturnType.Name,
(key, grp) => grp.GroupBy(
x => x.Name,
(name, innerGrp) => (key, name, string.Join(", ", innerGrp.Select(mthd => mthd.GetParameters().Length).OrderBy(x => x)))
).OrderBy(x => x.Item1)
);
foreach (var grp in groups.Where(x => x.First().Item1 is not "BinaryExpression" and not "UnaryExpression")) {
grp.Dump();
}
| NewExpression |
New |
1, 1, 2, 2, 3, 3 |
| ParameterExpression |
Parameter |
1, 2 |
| ParameterExpression |
Variable |
1, 2 |
| RuntimeVariablesExpression |
RuntimeVariables |
1, 1 |
| SwitchCase |
SwitchCase |
2, 2 |
| SwitchExpression |
Switch |
2, 3, 4, 4, 5, 5 |
| SymbolDocumentInfo |
SymbolDocument |
1, 2, 3, 4 |
| TryExpression |
TryFault |
2 |
| TryExpression |
TryFinally |
2 |
| TryExpression |
TryCatch |
2 |
| TryExpression |
TryCatchFinally |
3 |
| TryExpression |
MakeTry |
5 |
| TypeBinaryExpression |
TypeIs |
2 |
| TypeBinaryExpression |
TypeEqual |
2 |
| LoopExpression |
Loop |
1, 2, 3 |
| MemberAssignment |
Bind |
2, 2 |
| MemberExpression |
Field |
2, 2, 3 |
| MemberExpression |
Property |
2, 2, 2, 3 |
| MemberExpression |
PropertyOrField |
2 |
| MemberExpression |
MakeMemberAccess |
2 |
| MemberInitExpression |
MemberInit |
2, 2 |
| MemberListBinding |
ListBind |
2, 2, 2, 2 |
| MemberMemberBinding |
MemberBind |
2, 2, 2, 2 |
| MethodCallExpression |
Call |
2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6 |
| MethodCallExpression |
ArrayIndex |
2, 2 |
| NewArrayExpression |
NewArrayInit |
2, 2 |
| NewArrayExpression |
NewArrayBounds |
2, 2 |
| IndexExpression |
MakeIndex |
3 |
| IndexExpression |
ArrayAccess |
2, 2 |
| IndexExpression |
Property |
3, 3, 3 |
| InvocationExpression |
Invoke |
2, 2 |
| LabelExpression |
Label |
1, 2 |
| LabelTarget |
Label |
0, 1, 1, 2 |
| Expression`1 |
Lambda |
2, 2, 3, 3, 3, 4 |
| LambdaExpression |
Lambda |
2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5 |
| Type |
GetFuncType |
1 |
| Type |
GetActionType |
1 |
| Type |
GetDelegateType |
1 |
| Boolean |
TryGetFuncType |
2 |
| Boolean |
TryGetActionType |
2 |
| ListInitExpression |
ListInit |
2, 2, 2, 2, 3, 3 |
| BlockExpression |
Block |
1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 5 |
| CatchBlock |
Catch |
2, 2, 3, 3 |
| CatchBlock |
MakeCatchBlock |
4 |
| ConditionalExpression |
Condition |
3, 4 |
| ConditionalExpression |
IfThen |
2 |
| ConditionalExpression |
IfThenElse |
3 |
| ConstantExpression |
Constant |
1, 2 |
| DebugInfoExpression |
DebugInfo |
5 |
| DebugInfoExpression |
ClearDebugInfo |
1 |
| DefaultExpression |
Empty |
0 |
| DefaultExpression |
Default |
1 |
| ElementInit |
ElementInit |
2, 2 |
| DynamicExpression |
Dynamic |
3, 3, 3, 4, 5, 6 |
| DynamicExpression |
MakeDynamic |
3, 3, 3, 4, 5, 6 |
| GotoExpression |
Break |
1, 2, 2, 3 |
| GotoExpression |
Continue |
1, 2 |
| GotoExpression |
Return |
1, 2, 2, 3 |
| GotoExpression |
Goto |
1, 2, 2, 3 |
| GotoExpression |
MakeGoto |
4 |