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

I play with the nlyget package from Roslyn CTP and think SyntaxVisitor<>I'm getting to know the class , so I create a Roslyn.Compilers.CSharp.SyntaxNodeto converter System.Linq.Expression(which seems to work for any code that does not include semantic knowledge unknown to AST or provided outside of the visit).

Anyway, I have the following code:

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

And I have nothing. nodehas a property Expressionthat can be resolved by visiting it if it is not a method call:

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

, , , Expression . , (, ), VisitMemberAccessExpression, (- , ).

?

+4
1

Expression.Call - . , MethodInfo.

:

  • , Compilation.Create(...) : API Roslyn
  • SemanticModel , GetSemanticModel(ast)
  • TypeInfo, GetTypeInfo ()

...

Compilation.Create(...).GetSemanticModel(ast).GetTypeInfo(expression);
+2

All Articles