Closure in async lambda throw InvalidOperationException
See original GitHub issueThe following snippet throws InvalidOperationException
with message Cannot close over byref parameter '' referenced in lambda ''
var lambda = CodeGenerator.AsyncLambda<Func<Task<string>>>(_ =>
{
var hello = CodeGenerator.DeclareVariable<string>("hello");
var foo = CodeGenerator.DeclareVariable<Func<string>>("foo");
CodeGenerator.Statement(Expression.Assign(hello, Expression.Constant("hello")));
CodeGenerator.Statement(Expression.Assign(foo, Expression.Lambda<Func<string>>(hello)));
CodeGenerator.Return(Expression.Invoke(foo));
});
var compiled = lambda.Compile();
I want to use the AsyncLambda to generate async code from my own DSL but I havn’t been able to work around the above issue yet.
Issue Analytics
- State:
- Created a year ago
- Comments:9
Top Results From Across the Web
An exception thrown in an async lambda isn't being caught ...
If I use an async lambda in my Test, then what happens is the Exception is thrown at the expected target, and then...
Read more >AWS Lambda function errors in C# - ...
This page describes how to view Lambda function invocation errors for the C# ... In the initialization phase, exceptions can be thrown for...
Read more >Handling Async Await Exceptions
Next post I'll explore of using async lambdas and how you need to pay close attention in order to avoid creating a void...
Read more >Replacing ThrowsAsync with a composable async alternative
Today's Assert.ThrowsAsync and related methods do sync-over-async. This means they convert an async operation into a synchronous one.
Read more >Invalid operation. The connection is closed.
hello All, I am getting this error when calling a small function. I am calling this function twice. Below is my code: public...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A new package has been published: https://www.nuget.org/packages/DotNext.Metaprogramming/4.7.5
@sakno it works as expected. Thank you.