To be sure that I understand could someone confirm that lambda expressions use reflection?
To be sure that I understand could someone confirm that lambda expressions use reflection?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
They can, but they are not required to. If they are compiled to a delegate, then no reflection is necessary: however, if they are compiled to ab expression tree, then an expression tree is absolutely reflection-based. Some parts of expression trees can be assembled directly from metadata tokens (ldtoken) – in particular methods (including operators and getters/setters, and types) – but some other parts cannot . This includes properties (
PropertyInfocannot be loaded by token) – so the IL for a compiled lambda can explicitly includeGetPropertyetc.But however it is loaded (token or reflection), an expression tree is expressed in terms of reflection (
MemberInfo, etc). This might later be compiled, or might be analysed by a provider.To help performance, the expression compiler may cache some or all of the expression tree, and re-use it.