Is it possible to create something like a MethodCallExpression without knowing the types of the related expressions?

Viewed 340

I am playing with the Roslyn CTP nuget package and thought I would acquainted with the SyntaxVisitor<> class so I am creating a Roslyn.Compilers.CSharp.SyntaxNode to System.Linq.Expression converter (which appears to work for any code that doesn't involve semantic knowledge unknown to the AST or provided outside of the visit call).

Anyway, I have the following code:

public override Expression VisitInvocationExpression(InvocationExpressionSyntax node) {
    ???
}

And I've got nothing. node has an Expression property which can be resolved by visiting it as long as it isn't a method call:

return Expression.Invoke(
    Visit(node.Expression), 
    node.ArgumentList.Arguments.Select(a => Visit(a.Expression))
)

This seems to work as long as Expression is not a method call. If it is a method call though (static, instance or extension), the first Visit winds up calling VisitMemberAccessExpression where I then fail (due to the nature of these not being members).

Is there a way around this?

1 Answers
Related