Skip to content

Commit 754fb00

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

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/Cake.Issues/IssuesReader.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public IEnumerable<IIssue> ReadIssues()
4646
{
4747
var stopwatch = Stopwatch.StartNew();
4848

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

5251
// Process providers in parallel
53-
_ = Parallel.ForEach(this.issueProviders, issueProvider =>
52+
_ = Parallel.For(0, this.issueProviders.Count, i =>
5453
{
54+
var issueProvider = this.issueProviders[i];
5555
var providerName = issueProvider.GetType().Name;
5656
this.log.Verbose("Initialize issue provider {0}...", providerName);
5757

@@ -76,21 +76,18 @@ public IEnumerable<IIssue> ReadIssues()
7676
}
7777
});
7878

79-
// Add to thread-safe collection
80-
foreach (var issue in currentIssues)
81-
{
82-
allIssues.Add(issue);
83-
}
79+
results[i] = currentIssues;
8480
}
8581
else
8682
{
8783
this.log.Warning("Error initializing issue provider {0}.", providerName);
84+
results[i] = [];
8885
}
8986
});
9087

9188
stopwatch.Stop();
9289

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

0 commit comments

Comments
 (0)