Azure / Azure/azure-functions-dotnet-worker
Support ValueTask as asynchronous return type from functions
- Dominant language
- C#
- Stars
- 466
- Forks
- 215
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 7
Description
It appears that [DefaultMethodInvokerFactory](https://github.com/Azure/azure-functions-dotnet-worker/blob/main/src/DotNetWorker.Core/Invocation/DefaultMethodInvokerFactory.cs#L159-L178) only treats `Task` and `Task` as method return types that need to be `await`ed. This means that if you use `ValueTask` or `ValueTask`, you'll end up dealing with strange exceptions as your code will run to the first `await` and then the DI scope will be disposed, including all injected dependencies like DbContexts.
Personally, I'm a fan of [preferring ValueTask to Task](https://blog.marcgravell.com/2019/08/prefer-valuetask-to-task-always-and.html) so not being able to use `ValueTask` was a bit confusing at first, but we are able to work around this in the meantime by using `Task`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/DotNetWorker.Core/Invocation/DefaultMethodInvokerFactory.cs at lines 159-178 and inspect how asynchronous return types are identified and awaited. Verify the behavior for both ValueTask and ValueTask, including whether injected dependencies remain available until the function completes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- backend, cloud
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100