Skip to content

Commit 27786c2

Browse files
jakubch1Jakub Chocholowicz
and
Jakub Chocholowicz
authored
Generating cc attachments with correct uri (#2750) (#2754)
* Generating cc attachments with correct uri * Remove constructor Co-authored-by: Jakub Chocholowicz <[email protected]> Co-authored-by: Jakub Chocholowicz <[email protected]>
1 parent bae1c7e commit 27786c2

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionAttachmentManager.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,9 @@ private void AddNewFileTransfer(FileTransferInformation fileTransferInfo, AsyncC
328328
{
329329
if (t.Exception == null)
330330
{
331-
// Uri doesn't recognize file paths in unix. See https://github.com/dotnet/corefx/issues/1745
332-
var attachmentUri = new UriBuilder() { Scheme = "file", Host = "", Path = localFilePath }.Uri;
333331
lock (attachmentTaskLock)
334332
{
335-
this.AttachmentSets[fileTransferInfo.Context][uri].Attachments.Add(new UriDataAttachment(attachmentUri, fileTransferInfo.Description));
333+
this.AttachmentSets[fileTransferInfo.Context][uri].Attachments.Add(UriDataAttachment.CreateFrom(localFilePath, fileTransferInfo.Description));
336334
}
337335
}
338336

src/Microsoft.TestPlatform.ObjectModel/AttachmentSet.cs

+6
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,11 @@ public override string ToString()
7777
{
7878
return $"{nameof(Uri)}: {Uri.AbsoluteUri}, {nameof(Description)}: {Description}";
7979
}
80+
81+
public static UriDataAttachment CreateFrom(string localFilePath, string description)
82+
{
83+
var uri = new UriBuilder() { Scheme = "file", Host = "", Path = localFilePath }.Uri;
84+
return new UriDataAttachment(uri, description);
85+
}
8086
}
8187
}

src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ public async Task<ICollection<AttachmentSet>> ProcessAttachmentSetsAsync(ICollec
5959
if (!string.IsNullOrEmpty(mergedCoverageReportFilePath))
6060
{
6161
var resultAttachmentSet = new AttachmentSet(CodeCoverageDataCollectorUri, CoverageFriendlyName);
62-
resultAttachmentSet.Attachments.Add(new UriDataAttachment(new Uri(mergedCoverageReportFilePath), CoverageFriendlyName));
62+
resultAttachmentSet.Attachments.Add(UriDataAttachment.CreateFrom(mergedCoverageReportFilePath, CoverageFriendlyName));
6363

6464
foreach (var coverageOtherFilePath in coverageOtherFilePaths)
6565
{
66-
resultAttachmentSet.Attachments.Add(new UriDataAttachment(new Uri(coverageOtherFilePath), string.Empty));
66+
resultAttachmentSet.Attachments.Add(UriDataAttachment.CreateFrom(coverageOtherFilePath, string.Empty));
6767
}
6868

6969
return new Collection<AttachmentSet> { resultAttachmentSet };

0 commit comments

Comments
 (0)