I have the following code:
int i = 5;
Func<int> getValue = () => i + 1;
The C# compiler add a closure to automatically transform the variable i into a field, and then uses inside the delegate. I want to avoid this in my entire solution. Possibly getting a compiler error, like: "Variable 'i' is not declared."... Is this possible? Maybe a Rosyln Compiler validator?