I understand that variable capture is done by the compiler, not by classes in the .NET platform itself. However, when DLR was introduced, part of this work certainly had to be done as part of the framework in order to defer it to execution time.
For example, in the code snippet below:
dynamic d = ... Func<int, bool> func = n => n > d;
Resolution of the type of the variable d and its verification that it is an integer must be performed at run time. And since d is a variable in the lambda containing method, it will be locked. This part will certainly be executed at runtime.
Therefore, I believe that in this part there should be a part of the DLR assembly ( System.Core.dll ) that performs this role.
I searched, and I could find some classes that look suspiciously reprehensible for this kind of task. In particular, ExpressionQuoter (despite the appearance of this class, this class does not quote lambda expressions like the Expression.Quote method), HoistedLocals , but VariableBinder .
I thought I would invite someone who knows best what to say.
Which class or part of the .NET environment converts locators that contain lambdas methods (or anonymous methods) to those individual classes that have static variables that represent them?
source share