Implement a workaround for the mono 5.0 cursor enumerator bug.

This commit is contained in:
Paul Chote
2017-05-18 08:58:52 +01:00
committed by reaperrr
parent 3258d89651
commit b74141666b

View File

@@ -139,8 +139,15 @@ namespace OpenRA.Orders
if (mi.Modifiers.HasModifier(Modifiers.Alt))
modifiers |= TargetModifiers.ForceMove;
// The Select(x => x) is required to work around an issue on mono 5.0
// where calling OrderBy* on SelectManySingleSelectorIterator can in some
// circumstances (which we were unable to identify) replace entries in the
// enumeration with duplicates of other entries.
// Other action that replace the SelectManySingleSelectorIterator with a
// different enumerator type (e.g. .Where(true) or .ToList()) also work.
var orders = self.TraitsImplementing<IIssueOrder>()
.SelectMany(trait => trait.Orders.Select(x => new { Trait = trait, Order = x }))
.Select(x => x)
.OrderByDescending(x => x.Order.OrderPriority);
for (var i = 0; i < 2; i++)