An async lambda is started with Task.Factory.StartNew, whose task ends at the lambda's first await
What it finds
Task.Factory.StartNew does not understand async delegates: given an async lambda it returns a Task<Task> whose outer task completes as soon as the lambda reaches its first await. Awaiting that outer task does not wait for the work, and its exceptions are lost in the inner task. Task.Run unwraps the inner task; so does .Unwrap().
From the rule's source, start_new_async_lambda.rs.
using System.Threading.Tasks; class Workers{ async Task Run() { await Task.Factory.StartNew(async () => await Task.Delay(10));tx0 reports: StartNew with an async lambda gives a task that ends at the first await await Task.Factory.StartNew(async () => await Task.Delay(10)).Unwrap(); await Task.Run(async () => await Task.Delay(10)); }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/csharp:start-new-async-lambda" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:start-new-async-lambda] reason="..."tx0 explain tx0/csharp:start-new-async-lambda shows the same in the terminal. Found a false positive? Report it.