Fix IDE0200

This commit is contained in:
RoosterDragon
2024-11-25 20:44:40 +00:00
committed by Gustas Kažukauskas
parent ce3ad6fbb3
commit 0338258b45
45 changed files with 64 additions and 64 deletions

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common
public static void NotifyBlocker(this Actor self, IEnumerable<CPos> positions)
{
NotifyBlocker(self, positions.SelectMany(p => self.World.ActorMap.GetActorsAt(p)));
NotifyBlocker(self, positions.SelectMany(self.World.ActorMap.GetActorsAt));
}
public static CPos ClosestCell(this Actor self, IEnumerable<CPos> cells)

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Lint
foreach (var w in modData.ObjectCreator.GetTypesImplementing<Widget>())
{
foreach (var m in w.GetMethods().Where(m => Utility.HasAttribute<CustomLintableHotkeyNames>(m)))
foreach (var m in w.GetMethods().Where(Utility.HasAttribute<CustomLintableHotkeyNames>))
{
var p = m.GetParameters();
if (p.Length == 3 && p[0].ParameterType == typeof(MiniYamlNode) && p[1].ParameterType == typeof(Action<string>)

View File

@@ -42,19 +42,19 @@ namespace OpenRA.Mods.Common.Lint
var properties = trait.GetType().GetProperties();
var fieldConsumed = fields
.Where(x => Utility.HasAttribute<ConsumedConditionReferenceAttribute>(x))
.Where(Utility.HasAttribute<ConsumedConditionReferenceAttribute>)
.SelectMany(f => LintExts.GetFieldValues(trait, f));
var propertyConsumed = properties
.Where(x => Utility.HasAttribute<ConsumedConditionReferenceAttribute>(x))
.Where(Utility.HasAttribute<ConsumedConditionReferenceAttribute>)
.SelectMany(p => LintExts.GetPropertyValues(trait, p));
var fieldGranted = fields
.Where(x => Utility.HasAttribute<GrantedConditionReferenceAttribute>(x))
.Where(Utility.HasAttribute<GrantedConditionReferenceAttribute>)
.SelectMany(f => LintExts.GetFieldValues(trait, f));
var propertyGranted = properties
.Where(x => Utility.HasAttribute<GrantedConditionReferenceAttribute>(x))
.Where(Utility.HasAttribute<GrantedConditionReferenceAttribute>)
.SelectMany(f => LintExts.GetPropertyValues(trait, f));
foreach (var c in fieldConsumed.Concat(propertyConsumed))

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Lint
{
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
{
var fields = Utility.GetFields(traitInfo.GetType()).Where(f => Utility.HasAttribute<LocomotorReferenceAttribute>(f));
var fields = Utility.GetFields(traitInfo.GetType()).Where(Utility.HasAttribute<LocomotorReferenceAttribute>);
foreach (var field in fields)
{
var locomotors = LintExts.GetFieldValues(traitInfo, field);

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Lint
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
{
var fields = Utility.GetFields(traitInfo.GetType());
foreach (var field in fields.Where(x => Utility.HasAttribute<NotificationReferenceAttribute>(x)))
foreach (var field in fields.Where(Utility.HasAttribute<NotificationReferenceAttribute>))
{
string type = null;
var notificationReference = Utility.GetCustomAttributes<NotificationReferenceAttribute>(field, true).First();

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Lint
const BindingFlags Flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly;
while (type != null)
{
if (((MemberInfo[])type.GetFields(Flags)).Concat(type.GetProperties(Flags)).Any(x => Utility.HasAttribute<SyncAttribute>(x)))
if (((MemberInfo[])type.GetFields(Flags)).Concat(type.GetProperties(Flags)).Any(Utility.HasAttribute<SyncAttribute>))
return true;
type = type.BaseType;
}

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Lint
{
foreach (var traitInfo in actorInfo.Value.TraitInfos<TraitInfo>())
{
var fields = Utility.GetFields(traitInfo.GetType()).Where(f => Utility.HasAttribute<VoiceSetReferenceAttribute>(f));
var fields = Utility.GetFields(traitInfo.GetType()).Where(Utility.HasAttribute<VoiceSetReferenceAttribute>);
foreach (var field in fields)
{
var voiceSets = LintExts.GetFieldValues(traitInfo, field);
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Lint
foreach (var traitInfo in actorInfo.TraitInfos<TraitInfo>())
{
var fields = Utility.GetFields(traitInfo.GetType()).Where(f => Utility.HasAttribute<VoiceReferenceAttribute>(f));
var fields = Utility.GetFields(traitInfo.GetType()).Where(Utility.HasAttribute<VoiceReferenceAttribute>);
foreach (var field in fields)
{
var voices = LintExts.GetFieldValues(traitInfo, field);

View File

@@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.MapGenerator
var templates = new List<TerrainTemplateInfo>();
var segments = Start.Union(Inner).Union(End).ToHashSet();
foreach (var template in TemplatedTerrainInfo.Templates.Values.OrderBy(tti => tti.Id))
if (template.Segments.Any(segment => segments.Contains(segment)))
if (template.Segments.Any(segments.Contains))
templates.Add(template);
return templates;
}

View File

@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Traits
: base(self, info)
{
Info = info;
coords = Exts.Lazy(() => self.Trait<BodyOrientation>());
coords = Exts.Lazy(self.Trait<BodyOrientation>);
armaments = new List<Armament>();
muzzles = new List<AnimationWithOffset>();
paxFacing = new Dictionary<Actor, IFacing>();

View File

@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits
if (minelayers.Length == 0)
return;
var enemies = world.Actors.Where(a => IsPreferredEnemyUnit(a)).ToArray();
var enemies = world.Actors.Where(IsPreferredEnemyUnit).ToArray();
if (enemies.Length == 0)
return;

View File

@@ -553,14 +553,14 @@ namespace OpenRA.Mods.Common.Traits
{
unitsHangingAroundTheBase.Clear();
unitsHangingAroundTheBase.AddRange(FieldLoader.GetValue<uint[]>("UnitsHangingAroundTheBase", unitsHangingAroundTheBaseNode.Value)
.Select(a => self.World.GetActorById(a)).Where(a => a != null));
.Select(self.World.GetActorById).Where(a => a != null));
}
if (nodes.TryGetValue("ActiveUnits", out var activeUnitsNode))
{
activeUnits.Clear();
activeUnits.UnionWith(FieldLoader.GetValue<uint[]>("ActiveUnits", activeUnitsNode.Value)
.Select(a => self.World.GetActorById(a)).Where(a => a != null));
.Select(self.World.GetActorById).Where(a => a != null));
}
if (nodes.TryGetValue("RushTicks", out var rushTicksNode))

View File

@@ -174,7 +174,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
var unitsNode = yaml.NodeWithKeyOrDefault("Units");
if (unitsNode != null)
squad.Units.UnionWith(FieldLoader.GetValue<uint[]>("Units", unitsNode.Value.Value)
.Select(a => squadManager.World.GetActorById(a)));
.Select(squadManager.World.GetActorById));
return squad;
}

View File

@@ -288,7 +288,7 @@ namespace OpenRA.Mods.Common.Traits
bool IDisableEnemyAutoTarget.DisableEnemyAutoTarget(Actor self, Actor attacker)
{
return info.PreventsAutoTarget && currentCaptors.Any(c => attacker.AppearsFriendlyTo(c));
return info.PreventsAutoTarget && currentCaptors.Any(attacker.AppearsFriendlyTo);
}
}
}

View File

@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Traits
if (runtimeCargoInit != null)
{
cargo = runtimeCargoInit.Value.ToList();
totalWeight = cargo.Sum(c => GetWeight(c));
totalWeight = cargo.Sum(GetWeight);
}
else if (cargoInit != null)
{
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits
cargo.Add(unit);
}
totalWeight = cargo.Sum(c => GetWeight(c));
totalWeight = cargo.Sum(GetWeight);
}
else
{
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.Common.Traits
cargo.Add(unit);
}
totalWeight = cargo.Sum(c => GetWeight(c));
totalWeight = cargo.Sum(GetWeight);
}
facing = Exts.Lazy(self.TraitOrDefault<IFacing>);

View File

@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits
if (buildingInfo != null)
{
var footprint = buildingInfo.PathableTiles(target.Location);
if (footprint.All(c => self.World.ShroudObscures(c)))
if (footprint.All(self.World.ShroudObscures))
return false;
}

View File

@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.Traits.Render
DefaultAnimation = new Animation(self.World, rs.GetImage(self), () => turreted.WorldOrientation.Yaw);
DefaultAnimation.PlayRepeating(NormalizeSequence(self, Info.Sequence));
rs.Add(new AnimationWithOffset(
DefaultAnimation, () => BarrelOffset(), () => IsTraitDisabled, p => RenderUtils.ZOffsetFromCenter(self, p, 0)));
DefaultAnimation, BarrelOffset, () => IsTraitDisabled, p => RenderUtils.ZOffsetFromCenter(self, p, 0)));
// Restrict turret facings to match the sprite
turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
{
this.self = self;
this.info = info;
health = Exts.Lazy(() => self.TraitOrDefault<IHealth>());
health = Exts.Lazy(self.TraitOrDefault<IHealth>);
}
public void ResolveOrder(Actor self, Order order)

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
public AnnounceOnSeen(Actor self, AnnounceOnSeenInfo info)
{
Info = info;
radarPings = Exts.Lazy(() => self.World.WorldActor.Trait<RadarPings>());
radarPings = Exts.Lazy(self.World.WorldActor.Trait<RadarPings>);
}
public void OnDiscovered(Actor self, Player discoverer, bool playNotification)

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
Self = init.Self;
DevMode = Self.Trait<DeveloperMode>();
TechTree = Self.Trait<TechTree>();
RadarPings = Exts.Lazy(() => Self.World.WorldActor.TraitOrDefault<RadarPings>());
RadarPings = Exts.Lazy(Self.World.WorldActor.TraitOrDefault<RadarPings>);
init.World.ActorAdded += ActorAdded;
init.World.ActorRemoved += ActorRemoved;

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
// All the map cells that visually overlap the current cell
var testCells = w.Map.ProjectedCellsCovering(uv)
.SelectMany(puv => w.Map.Unproject(puv));
.SelectMany(w.Map.Unproject);
if (testCells.Any(x => x.V >= uv.V + 4))
w.Map.CustomTerrain[uv] = tileType;
}

View File

@@ -141,7 +141,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var n in groupsNode.Value.Nodes)
{
var group = FieldLoader.GetValue<uint[]>(n.Key, n.Value.Value)
.Select(a => self.World.GetActorById(a)).Where(a => a != null);
.Select(self.World.GetActorById).Where(a => a != null);
controlGroups[Exts.ParseInt32Invariant(n.Key)].AddRange(group);
}
}

View File

@@ -191,7 +191,7 @@ namespace OpenRA.Mods.Common.Traits
if (selectionNode != null)
{
var selected = FieldLoader.GetValue<uint[]>("Selection", selectionNode.Value.Value)
.Select(a => self.World.GetActorById(a)).Where(a => a != null);
.Select(self.World.GetActorById).Where(a => a != null);
Combine(self.World, selected, false, false);
}
}

View File

@@ -303,7 +303,7 @@ namespace OpenRA.Mods.Common.Traits
if (newShroud != null)
{
cellVisibility = puv => newShroud.GetVisibility(puv);
cellVisibility = newShroud.GetVisibility;
newShroud.OnShroudChanged += UpdateShroudCell;
}
else

View File

@@ -193,7 +193,7 @@ namespace OpenRA.Mods.Common
public static IEnumerable<CPos> AdjacentCells(World w, in Target target)
{
var cells = target.Positions.Select(p => w.Map.CellContaining(p)).Distinct();
var cells = target.Positions.Select(w.Map.CellContaining).Distinct();
return ExpandFootprint(cells, true);
}

View File

@@ -191,7 +191,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
filenameInput = panel.Get<TextFieldWidget>("FILENAME_INPUT");
filenameInput.OnTextEdited = () => ApplyFilter();
filenameInput.OnTextEdited = ApplyFilter;
filenameInput.OnEscKey = _ =>
{
if (string.IsNullOrEmpty(filenameInput.Text))

View File

@@ -265,7 +265,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
slider.GetValue = () => so.GetValue(SelectedActor);
slider.OnChange += value => so.OnChange(SelectedActor, value);
slider.OnChange += value => editorActionHandle.OnChange(value);
slider.OnChange += editorActionHandle.OnChange;
var valueField = sliderContainer.GetOrNull<TextFieldWidget>("VALUE");
if (valueField != null)

View File

@@ -48,9 +48,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{
var actionManager = world.WorldActor.Trait<EditorActionManager>();
undoButton.IsDisabled = () => !actionManager.HasUndos();
undoButton.OnClick = () => actionManager.Undo();
undoButton.OnClick = actionManager.Undo;
redoButton.IsDisabled = () => !actionManager.HasRedos();
redoButton.OnClick = () => actionManager.Redo();
redoButton.OnClick = actionManager.Redo;
}
}
}

View File

@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
void CreateCategoryPanel(MapBlitFilters copyFilter, CheckboxWidget checkbox)
{
checkbox.GetText = () => copyFilter.ToString();
checkbox.GetText = copyFilter.ToString;
checkbox.IsChecked = () => selectionFilters.HasFlag(copyFilter);
checkbox.IsVisible = () => true;
checkbox.OnClick = () => selectionFilters ^= copyFilter;

View File

@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
foreach (var cat in allCategories)
{
var category = categoryTemplate.Clone();
category.GetText = () => cat.ToString();
category.GetText = cat.ToString;
category.IsVisible = () => true;
if (cat.HasFlag(MapOverlays.Grid))

View File

@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
continue;
var checkbox = visOptionTemplate.Clone();
checkbox.GetText = () => visibilityOption.ToString();
checkbox.GetText = visibilityOption.ToString;
checkbox.IsChecked = () => map.Visibility.HasFlag(visibilityOption);
checkbox.OnClick = () => map.Visibility ^= visibilityOption;
visibilityPanel.AddChild(checkbox);

View File

@@ -118,8 +118,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
saveWidgets.IsVisible = () => true;
saveTextField = saveWidgets.Get<TextFieldWidget>("SAVE_TEXTFIELD");
saveTextField.OnEnterKey = input => saveButton.HandleKeyPress(input);
saveTextField.OnEscKey = input => cancelButton.HandleKeyPress(input);
saveTextField.OnEnterKey = saveButton.HandleKeyPress;
saveTextField.OnEscKey = cancelButton.HandleKeyPress;
}
else
{
@@ -226,7 +226,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
var savePaths = Directory.GetFiles(baseSavePath, "*.orasav", SearchOption.AllDirectories)
.OrderByDescending(p => File.GetLastWriteTime(p))
.OrderByDescending(File.GetLastWriteTime)
.ToList();
foreach (var savePath in savePaths)

View File

@@ -196,8 +196,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
CreateStatsOption(SupportPowers, ObserverStatsPanel.SupportPowers, supportPowersPlayerTemplate, () => DisplayStats(SupportPowerStats)),
CreateStatsOption(Combat, ObserverStatsPanel.Combat, combatPlayerTemplate, () => DisplayStats(CombatStats)),
CreateStatsOption(Army, ObserverStatsPanel.Army, armyPlayerTemplate, () => DisplayStats(ArmyStats)),
CreateStatsOption(EarningsGraph, ObserverStatsPanel.Graph, null, () => IncomeGraph()),
CreateStatsOption(ArmyGraph, ObserverStatsPanel.ArmyGraph, null, () => ArmyValueGraph()),
CreateStatsOption(EarningsGraph, ObserverStatsPanel.Graph, null, IncomeGraph),
CreateStatsOption(ArmyGraph, ObserverStatsPanel.ArmyGraph, null, ArmyValueGraph),
};
ScrollItemWidget SetupItem(StatsDropDownOption option, ScrollItemWidget template)
@@ -352,7 +352,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var armyText = new CachedTransform<int, string>(i => "$" + i.ToString(NumberFormatInfo.CurrentInfo));
template.Get<LabelWidget>("ARMY_VALUE").GetText = () => armyText.Update(stats.ArmyValue);
var visionText = new CachedTransform<int, string>(i => Vision(i));
var visionText = new CachedTransform<int, string>(Vision);
template.Get<LabelWidget>("VISION").GetText = () => player.Shroud.Disabled ? "100%" : visionText.Update(player.Shroud.RevealedCells);
return template;
@@ -520,7 +520,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var experienceText = new CachedTransform<int, string>(i => i.ToString(NumberFormatInfo.CurrentInfo));
template.Get<LabelWidget>("EXPERIENCE").GetText = () => experienceText.Update(stats.Experience);
var actionsText = new CachedTransform<double, string>(d => AverageOrdersPerMinute(d));
var actionsText = new CachedTransform<double, string>(AverageOrdersPerMinute);
template.Get<LabelWidget>("ACTIONS_MIN").GetText = () => actionsText.Update(stats.OrderCount);
return template;

View File

@@ -793,7 +793,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var item = ScrollItemWidget.Setup(template,
() => selectedReplay == replay,
() => SelectReplay(replay),
() => WatchReplay());
WatchReplay);
replayState[replay] = new ReplayState
{

View File

@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
contexts.UnionWith(hd.Contexts);
filterInput = panel.Get<TextFieldWidget>("FILTER_INPUT");
filterInput.OnTextEdited = () => InitHotkeyList();
filterInput.OnTextEdited = InitHotkeyList;
filterInput.OnEscKey = _ =>
{
if (string.IsNullOrEmpty(filterInput.Text))

View File

@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var mouseScrollDropdown = panel.Get<DropDownButtonWidget>("MOUSE_SCROLL_TYPE_DROPDOWN");
mouseScrollDropdown.OnMouseDown = _ => ShowMouseScrollDropdown(mouseScrollDropdown, gs);
mouseScrollDropdown.GetText = () => gs.MouseScroll.ToString();
mouseScrollDropdown.GetText = gs.MouseScroll.ToString;
var mouseControlDescClassic = panel.Get("MOUSE_CONTROL_DESC_CLASSIC");
mouseControlDescClassic.IsVisible = () => gs.UseClassicMouseStyle;
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var zoomModifierDropdown = panel.Get<DropDownButtonWidget>("ZOOM_MODIFIER");
zoomModifierDropdown.OnMouseDown = _ => ShowZoomModifierDropdown(zoomModifierDropdown, gs);
zoomModifierDropdown.GetText = () => gs.ZoomModifier.ToString();
zoomModifierDropdown.GetText = gs.ZoomModifier.ToString;
SettingsUtils.AdjustSettingsScrollPanelLayout(scrollPanel);

View File

@@ -198,7 +198,7 @@ namespace OpenRA.Mods.Common.Widgets
}
case TextFieldType.Integer:
return new string(input.Where(c => char.IsDigit(c)).ToArray());
return new string(input.Where(char.IsDigit).ToArray());
default:
return input;