Skip to content

Commit f94e4bc

Browse files
committed
Maintain order of issues
1 parent 9bd321e commit f94e4bc

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/Cake.Issues/IssuesReader.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace Cake.Issues;
22

3-
using System.Collections.Concurrent;
43
using System.Collections.Generic;
54
using System.Diagnostics;
65
using System.Linq;
@@ -46,12 +45,12 @@ public IEnumerable<IIssue> ReadIssues()
4645
{
4746
var stopwatch = Stopwatch.StartNew();
4847

49-
// Use thread-safe collection for collecting results
50-
var allIssues = new ConcurrentBag<IIssue>();
48+
var results = new List<IIssue>[this.issueProviders.Count];
5149

5250
// Process providers in parallel
53-
_ = Parallel.ForEach(this.issueProviders, issueProvider =>
51+
_ = Parallel.For(0, this.issueProviders.Count, i =>
5452
{
53+
var issueProvider = this.issueProviders[i];
5554
var providerName = issueProvider.GetType().Name;
5655
this.log.Verbose("Initialize issue provider {0}...", providerName);
5756

@@ -76,21 +75,18 @@ public IEnumerable<IIssue> ReadIssues()
7675
}
7776
});
7877

79-
// Add to thread-safe collection
80-
foreach (var issue in currentIssues)
81-
{
82-
allIssues.Add(issue);
83-
}
78+
results[i] = currentIssues;
8479
}
8580
else
8681
{
8782
this.log.Warning("Error initializing issue provider {0}.", providerName);
83+
results[i] = [];
8884
}
8985
});
9086

9187
stopwatch.Stop();
9288

93-
var issuesList = allIssues.ToList();
89+
var issuesList = results.SelectMany(r => r).ToList();
9490
this.log.Verbose(
9591
"Reading {0} issues from {1} providers took {2} ms",
9692
issuesList.Count,

0 commit comments

Comments
 (0)