Fix CA1851, assume_method_enumerates_parameters = true

This commit is contained in:
RoosterDragon
2023-07-14 20:30:08 +01:00
committed by abcdefg30
parent 3275875ae5
commit 93a97d5d6f
37 changed files with 108 additions and 96 deletions

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
.SelectMany(t => t.Value.RestrictedPlayerColors)
.Distinct()
.ToList();
var playerColors = Enumerable.Empty<Color>();
var playerColors = Array.Empty<Color>();
randomButton.OnClick = () =>
{
var randomColor = colorManager.RandomValidColor(world.LocalRandom, terrainColors, playerColors);
@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var colorIndex = j * paletteCols + i;
var newSwatch = (ColorBlockWidget)customColorTemplate.Clone();
var getColor = new CachedTransform<Color, Color>(c => colorManager.MakeValid(c, world.LocalRandom, Enumerable.Empty<Color>(), Enumerable.Empty<Color>()));
var getColor = new CachedTransform<Color, Color>(c => colorManager.MakeValid(c, world.LocalRandom, Array.Empty<Color>(), Array.Empty<Color>()));
newSwatch.GetColor = () => getColor.Update(Game.Settings.Player.CustomColors[colorIndex]);
newSwatch.IsVisible = () => Game.Settings.Player.CustomColors.Length > colorIndex;

View File

@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
};
}
IEnumerable<KeyValuePair<ActorInfo, EncyclopediaInfo>> GetFilteredActorEncyclopediaPairs()
IReadOnlyCollection<KeyValuePair<ActorInfo, EncyclopediaInfo>> GetFilteredActorEncyclopediaPairs()
{
var actors = new List<KeyValuePair<ActorInfo, EncyclopediaInfo>>();
foreach (var actor in modData.DefaultRules.Actors.Values)
@@ -149,9 +149,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var buildable = actor.TraitInfoOrDefault<BuildableInfo>();
if (buildable != null)
{
var prerequisites = buildable.Prerequisites.Select(a => ActorName(modData.DefaultRules, a))
.Where(s => !s.StartsWith('~') && !s.StartsWith('!'));
if (prerequisites.Any())
var prerequisites = buildable.Prerequisites
.Select(a => ActorName(modData.DefaultRules, a))
.Where(s => !s.StartsWith('~') && !s.StartsWith('!'))
.ToList();
if (prerequisites.Count != 0)
text += $"Requires {prerequisites.JoinWith(", ")}\n\n";
}

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
var newSelection = SelectionUtils.SelectActorsOnScreen(world, worldRenderer, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList();
// Check if selecting actors on the screen has selected new units
if (newSelection.Count > selection.Actors.Count())
if (newSelection.Count > selection.Actors.Count)
TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, Translation.Arguments("units", newSelection.Count));
else
{

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
if (world.IsGameOver)
return false;
if (!selection.Actors.Any())
if (selection.Actors.Count == 0)
{
TextNotificationsManager.AddFeedbackLine(NothingSelected);
Game.Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Sounds", ClickDisabledSound, null);
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
var newSelection = SelectionUtils.SelectActorsOnScreen(world, worldRenderer, selectedClasses, eligiblePlayers).ToList();
// Check if selecting actors on the screen has selected new units
if (newSelection.Count > selection.Actors.Count())
if (newSelection.Count > selection.Actors.Count)
TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, Translation.Arguments("units", newSelection.Count));
else
{

View File

@@ -112,9 +112,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
requiredWidget.IsVisible = () => p.Value.Required;
var sourceWidget = container.Get<ImageWidget>("SOURCE");
var sourceTitles = p.Value.Sources.Select(s => sources[s].Title).Distinct();
var sourceTitles = p.Value.Sources.Select(s => sources[s].Title).Distinct().ToList();
var sourceList = sourceTitles.JoinWith("\n");
var isSourceAvailable = sourceTitles.Any();
var isSourceAvailable = sourceTitles.Count != 0;
sourceWidget.GetTooltipText = () => sourceList;
sourceWidget.IsVisible = () => isSourceAvailable;

View File

@@ -136,9 +136,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
})
.Where(x => x.Index != -1)
.OrderBy(x => x.Index)
.Select(x => x.Preview);
.Select(x => x.Preview)
.ToList();
if (previews.Any())
if (previews.Count != 0)
{
CreateMissionGroup(kv.Key, previews, onExit);
allPreviews.AddRange(previews);
@@ -148,9 +149,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
// Add an additional group for loose missions
var loosePreviews = modData.MapCache
.Where(p => p.Status == MapStatus.Available && p.Visibility.HasFlag(MapVisibility.MissionSelector) && !allPreviews.Any(a => a.Uid == p.Uid));
.Where(p => p.Status == MapStatus.Available &&
p.Visibility.HasFlag(MapVisibility.MissionSelector) &&
!allPreviews.Any(a => a.Uid == p.Uid))
.ToList();
if (loosePreviews.Any())
if (loosePreviews.Count != 0)
{
CreateMissionGroup("Missions", loosePreviews, onExit);
allPreviews.AddRange(loosePreviews);

View File

@@ -443,7 +443,7 @@ namespace OpenRA.Mods.Common.Widgets
if (facility == null || facility.OccupiesSpace == null)
return true;
if (selection.Actors.Count() == 1 && selection.Contains(facility))
if (selection.Actors.Count == 1 && selection.Contains(facility))
viewport.Center(selection.Actors);
else
selection.Combine(World, new[] { facility }, false, true);

View File

@@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.Widgets
{
if (useClassicMouseStyle && HasMouseFocus)
{
if (!IsValidDragbox && World.Selection.Actors.Any() && !multiClick && uog.InputOverridesSelection(World, mousePos, mi))
if (!IsValidDragbox && World.Selection.Actors.Count != 0 && !multiClick && uog.InputOverridesSelection(World, mousePos, mi))
{
// Order units instead of selecting
ApplyOrders(World, mi);