diff --git a/.editorconfig b/.editorconfig index e03d91d20c..4d110ef2b5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1016,6 +1016,9 @@ dotnet_diagnostic.RCS1107.severity = warning # Add 'static' modifier to all partial class declarations. dotnet_diagnostic.RCS1108.severity = warning +# Combine 'Enumerable.Where' method chain. +dotnet_diagnostic.RCS1112.severity = warning + # Use 'string.IsNullOrEmpty' method. dotnet_diagnostic.RCS1113.severity = warning diff --git a/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs index e2837f88f0..2cabc01f53 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs @@ -76,16 +76,18 @@ namespace OpenRA.Mods.Common.Traits.Render { // Per-actor production queues = self.TraitsImplementing() - .Where(q => productionInfos.Any(p => p.Produces.Contains(q.Info.Type))) - .Where(q => Info.Queues.Count == 0 || Info.Queues.Contains(q.Info.Type)) + .Where(q => + productionInfos.Any(p => p.Produces.Contains(q.Info.Type)) && + (Info.Queues.Count == 0 || Info.Queues.Contains(q.Info.Type))) .ToArray(); if (queues.Length == 0) { // Player-wide production queues = self.Owner.PlayerActor.TraitsImplementing() - .Where(q => productionInfos.Any(p => p.Produces.Contains(q.Info.Type))) - .Where(q => Info.Queues.Count == 0 || Info.Queues.Contains(q.Info.Type)) + .Where(q => + productionInfos.Any(p => p.Produces.Contains(q.Info.Type)) && + (Info.Queues.Count == 0 || Info.Queues.Contains(q.Info.Type))) .ToArray(); } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs index 7864cc6fdd..61f6db1bd9 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MapChooserLogic.cs @@ -323,11 +323,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic playerCountFilter = -1; var maps = tabMaps[tab] - .Where(m => category == null || m.Categories.Contains(category)) - .Where(m => mapFilter == null || + .Where(m => (category == null || m.Categories.Contains(category)) && + (mapFilter == null || (m.Title != null && m.Title.Contains(mapFilter, StringComparison.CurrentCultureIgnoreCase)) || (m.Author != null && m.Author.Contains(mapFilter, StringComparison.CurrentCultureIgnoreCase)) || - m.PlayerCount == playerCountFilter); + m.PlayerCount == playerCountFilter)); if (orderByFunc == null) maps = maps.OrderBy(m => m.Title);