dimanche 23 avril 2023

How can I determine if C# lambda captures outer variables?

I'm implementing framework where developers can add their own code as lambdas. I'd like to prevent them from sharing common state in those lambdas, but I don't know how to check if lambda uses variables from its scope. Is there a way to do it?

I've looked for a way to call lambda in the context of another object (like in JS), but apparently .NET doesn't work like that ;-) So I'm looking for different approach.





Aucun commentaire:

Enregistrer un commentaire