The fragment below shows a PR diff in a service that builds a resource bundle from a list of identifiers and returns a short summary. After the update, complaints appeared: sometimes the call fails in the middle of processing, and in other cases the summary looks successful even though data reading did not complete correctly.
BuildAsync method must process input identifiers one by one and return BundleSummary.Skipped.IResourceSessionFactory, read the contents, and add the string length to TotalBytes.IResourceSession must correctly end its lifetime after processing the item, including on exceptions.Failed, but must not turn the whole call into a successful processing of that item.BundleService after the changes in the PR.BuildAsync for two scenarios:
"A", then for "B";IResourceSession instance must be released within the processing of the corresponding item.Failed, not in Processed.IResourceSession contract:
IDisposableTask<string> ReadAsync(CancellationToken cancellationToken) reads the resource contentsIResourceSessionFactory contract:
IResourceSession Open(string resourceId) returns a new session instance for a single resourceUse line comments to explain the problem, its impact, the fix and how to test it.