From 0801bc9d7b9436f6b0c6985040f1566f6d9b9b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Mon, 23 May 2022 19:00:57 +0200 Subject: [PATCH] Fix NRE when coverage merge tool is not found --- .../CodeCoverageDataAttachmentsHandler.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs index 8b1ca0b31f..8e2043e5c0 100644 --- a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs +++ b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs @@ -72,12 +72,15 @@ public async Task> ProcessAttachmentSetsAsync(XmlElem if (coverageReportFilePaths.Count > 1) { - var mergedCoverageReports = await MergeCodeCoverageFilesAsync(coverageReportFilePaths, progressReporter, cancellationToken).ConfigureAwait(false); var resultAttachmentSet = new AttachmentSet(CodeCoverageDataCollectorUri, CoverageFriendlyName); - foreach (var coverageReport in mergedCoverageReports) + var mergedCoverageReports = await MergeCodeCoverageFilesAsync(coverageReportFilePaths, progressReporter, cancellationToken).ConfigureAwait(false); + if (mergedCoverageReports is not null) { - resultAttachmentSet.Attachments.Add(UriDataAttachment.CreateFrom(coverageReport, CoverageFriendlyName)); + foreach (var coverageReport in mergedCoverageReports) + { + resultAttachmentSet.Attachments.Add(UriDataAttachment.CreateFrom(coverageReport, CoverageFriendlyName)); + } } foreach (var coverageOtherFilePath in coverageOtherFilePaths)