The fragment below shows a PR diff for a service that runs a set of user jobs and returns a short results summary. After the changes, discrepancies appeared between the actual processing and what the calling code receives.
A review is needed: find defects in after, explain their impact, and propose correct fixes without changing the public contract of RunAsync.
RunAsync accepts a set of job identifiers and processes them in order.JobRunSummary, where:
Completed — the number of successfully completed jobs;Failed — the number of items that ended with an error or were canceled during execution;AttemptedIds — the identifiers for which an execution attempt was actually started, in processing order.JobRunner instance must work independently of one another.new[] { "A", " ", "B" } and a token without cancellation.new[] { "C" }.after.Failed, but must not terminate the entire method with an exception..NET 8.0C# 12Task-based async with no external librariesTask<JobRunSummary> RunAsync(IEnumerable<string?> jobIds, CancellationToken cancellationToken = default)Use line comments to explain the problem, its impact, the fix and how to test it.