Fix IDE0053
This commit is contained in:
committed by
Pavel Penev
parent
37afd6094e
commit
939f715e3c
@@ -121,9 +121,12 @@ dotnet_style_predefined_type_for_member_access = true
|
||||
# IDE0049, IDE-only counterpart of StyleCopAnalyzers - SA1121: UseBuiltInTypeAlias.
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true
|
||||
|
||||
# Use expression body if a local function is a single line.
|
||||
# Use expression body for some items if on a single line.
|
||||
csharp_style_expression_bodied_local_functions = when_on_single_line
|
||||
|
||||
# This rule is buggy and not enforced for builds. ':warning' will at least enforce it in the IDE.
|
||||
csharp_style_expression_bodied_lambdas = when_on_single_line:warning
|
||||
|
||||
# Remove unused parameters on non public methods, ignore unused parameters on public methods.
|
||||
dotnet_code_quality_unused_parameters = non_public
|
||||
|
||||
@@ -216,6 +219,9 @@ dotnet_diagnostic.IDE0051.severity = warning
|
||||
# Remove unread private member.
|
||||
dotnet_diagnostic.IDE0052.severity = warning
|
||||
|
||||
# Use expression body for lambdas.
|
||||
dotnet_diagnostic.IDE0053.severity = warning
|
||||
|
||||
# Use compound assignment.
|
||||
dotnet_diagnostic.IDE0054.severity = warning
|
||||
|
||||
|
||||
@@ -56,14 +56,10 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
public static Func<string, Type, string, object> InvalidValueAction = (s, t, f) =>
|
||||
{
|
||||
throw new YamlException($"FieldLoader: Cannot parse `{s}` into `{f}.{t}` ");
|
||||
};
|
||||
|
||||
public static Action<string, Type> UnknownFieldAction = (s, f) =>
|
||||
{
|
||||
throw new NotImplementedException($"FieldLoader: Missing field `{s}` on `{f.Name}`");
|
||||
};
|
||||
|
||||
static readonly ConcurrentCache<Type, FieldLoadInfo[]> TypeLoadInfo =
|
||||
new ConcurrentCache<Type, FieldLoadInfo[]>(BuildTypeLoadInfo);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA
|
||||
{
|
||||
var newConnection = new NetworkConnection(endpoint);
|
||||
if (recordReplay)
|
||||
newConnection.StartRecording(() => { return TimestampedFilename(); });
|
||||
newConnection.StartRecording(() => TimestampedFilename());
|
||||
|
||||
var om = new OrderManager(newConnection);
|
||||
JoinInner(om);
|
||||
@@ -618,10 +618,7 @@ namespace OpenRA
|
||||
|
||||
if (orderManager.TryTick())
|
||||
{
|
||||
Sync.RunUnsynced(world, () =>
|
||||
{
|
||||
world.OrderGenerator.Tick(world);
|
||||
});
|
||||
Sync.RunUnsynced(world, () => world.OrderGenerator.Tick(world));
|
||||
|
||||
world.Tick();
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ namespace OpenRA.Server
|
||||
|
||||
if (Settings.RecordReplays && Type == ServerType.Dedicated)
|
||||
{
|
||||
recorder = new ReplayRecorder(() => { return Game.TimestampedFilename(extra: "-Server"); });
|
||||
recorder = new ReplayRecorder(() => Game.TimestampedFilename(extra: "-Server"));
|
||||
|
||||
// We only need one handshake to initialize the replay.
|
||||
// Add it now, then ignore the redundant handshakes from each client
|
||||
|
||||
@@ -97,10 +97,7 @@ namespace OpenRA.Mods.Common
|
||||
return;
|
||||
|
||||
var server = args.Secret.Split('|');
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
Game.RemoteDirectConnect(new ConnectionTarget(server[0], int.Parse(server[1])));
|
||||
});
|
||||
Game.RunAfterTick(() => Game.RemoteDirectConnect(new ConnectionTarget(server[0], int.Parse(server[1]))));
|
||||
}
|
||||
|
||||
void SetStatus(DiscordState state, string details = null, string secret = null, int? players = null, int? slots = null)
|
||||
|
||||
@@ -36,10 +36,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
this.interval = interval;
|
||||
tick = -delay;
|
||||
|
||||
target.World.RemoveAll(effect =>
|
||||
{
|
||||
return effect is FlashTarget flashTarget && flashTarget.target == target;
|
||||
});
|
||||
target.World.RemoveAll(effect => effect is FlashTarget flashTarget && flashTarget.target == target);
|
||||
}
|
||||
|
||||
public FlashTarget(Actor target, Color color, float alpha = 0.5f, int count = 2, int interval = 2, int delay = 0)
|
||||
|
||||
@@ -47,10 +47,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
return true;
|
||||
},
|
||||
(actor, value) =>
|
||||
{
|
||||
actor.ReplaceInit(new FreeActorInit(this, value), this);
|
||||
});
|
||||
(actor, value) => actor.ReplaceInit(new FreeActorInit(this, value), this));
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new FreeActor(init, this); }
|
||||
|
||||
@@ -125,9 +125,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
checkTerrainType = info.UnloadTerrainTypes.Count > 0;
|
||||
|
||||
currentAdjacentCells = new CachedTransform<CPos, IEnumerable<CPos>>(loc =>
|
||||
{
|
||||
return Util.AdjacentCells(self.World, Target.FromActor(self)).Where(c => loc != c);
|
||||
});
|
||||
Util.AdjacentCells(self.World, Target.FromActor(self)).Where(c => loc != c));
|
||||
|
||||
var runtimeCargoInit = init.GetOrDefault<RuntimeCargoInit>(info);
|
||||
var cargoInit = init.GetOrDefault<CargoInit>(info);
|
||||
|
||||
@@ -81,9 +81,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return false;
|
||||
},
|
||||
(actor, value) =>
|
||||
{
|
||||
actor.ReplaceInit(new DeployStateInit(value ? DeployState.Deployed : DeployState.Undeployed));
|
||||
});
|
||||
actor.ReplaceInit(new DeployStateInit(value ? DeployState.Deployed : DeployState.Undeployed)));
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new GrantConditionOnDeploy(init, this); }
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
MarkFailed(player, id);
|
||||
}
|
||||
|
||||
public event Action<Player, bool> ObjectiveAdded = (player, inhibitAnnouncement) => { player.HasObjectives = true; };
|
||||
public event Action<Player, bool> ObjectiveAdded = (player, inhibitAnnouncement) => player.HasObjectives = true;
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
|
||||
@@ -61,9 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
base.Created(self);
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
remainingTicks = Util.ApplyPercentageModifiers(Info.Delay, modifiers.Select(m => m.GetReloadAmmoModifier()));
|
||||
});
|
||||
remainingTicks = Util.ApplyPercentageModifiers(Info.Delay, modifiers.Select(m => m.GetReloadAmmoModifier())));
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
|
||||
|
||||
@@ -230,10 +230,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (beacon == null)
|
||||
return;
|
||||
|
||||
Self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Remove(beacon);
|
||||
});
|
||||
Self.World.AddFrameEndTask(w => w.Remove(beacon));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,10 +204,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Info.BeaconDelay,
|
||||
info.FlightDelay - info.BeaconRemoveAdvance);
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Add(beacon);
|
||||
});
|
||||
self.World.AddFrameEndTask(w => w.Add(beacon));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -283,10 +283,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (beacon == null)
|
||||
return;
|
||||
|
||||
Self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Remove(beacon);
|
||||
});
|
||||
Self.World.AddFrameEndTask(w => w.Remove(beacon));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,10 +284,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
for (var i = (byte)SubCell.First; i < map.Grid.SubCellOffsets.Length; i++)
|
||||
{
|
||||
var blocked = previews.Any(p =>
|
||||
{
|
||||
return p.Footprint.TryGetValue(cell, out var s) && s == (SubCell)i;
|
||||
});
|
||||
var blocked = previews.Any(p => p.Footprint.TryGetValue(cell, out var s) && s == (SubCell)i);
|
||||
|
||||
if (!blocked)
|
||||
return (SubCell)i;
|
||||
|
||||
@@ -86,15 +86,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
Console.WriteLine(" },");
|
||||
}
|
||||
|
||||
var actorProperties = utility.ModData.ObjectCreator.GetTypesImplementing<ScriptActorProperties>().SelectMany(cg =>
|
||||
{
|
||||
return ScriptMemberWrapper.WrappableMembers(cg);
|
||||
});
|
||||
var actorProperties = utility.ModData.ObjectCreator.GetTypesImplementing<ScriptActorProperties>()
|
||||
.SelectMany(ScriptMemberWrapper.WrappableMembers);
|
||||
|
||||
var scriptProperties = utility.ModData.ObjectCreator.GetTypesImplementing<ScriptPlayerProperties>().SelectMany(cg =>
|
||||
{
|
||||
return ScriptMemberWrapper.WrappableMembers(cg);
|
||||
});
|
||||
var scriptProperties = utility.ModData.ObjectCreator.GetTypesImplementing<ScriptPlayerProperties>()
|
||||
.SelectMany(ScriptMemberWrapper.WrappableMembers);
|
||||
|
||||
var properties = actorProperties.Concat(scriptProperties);
|
||||
foreach (var property in properties.OrderBy(m => m.Name))
|
||||
|
||||
@@ -94,10 +94,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
otherButton.Visible = true;
|
||||
otherButton.Bounds.Y += headerHeight;
|
||||
otherButton.OnClick = () =>
|
||||
{
|
||||
onOther();
|
||||
};
|
||||
otherButton.OnClick = onOther;
|
||||
|
||||
if (!string.IsNullOrEmpty(otherText))
|
||||
{
|
||||
|
||||
@@ -452,7 +452,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(template,
|
||||
() => currentFilename == filepath && currentPackage == package,
|
||||
() => { LoadAsset(package, filepath); });
|
||||
() => LoadAsset(package, filepath));
|
||||
|
||||
var label = item.Get<LabelWithTooltipWidget>("TITLE");
|
||||
WidgetUtils.TruncateLabelToTooltip(label, filepath);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var tab = tabContainer.Get<ButtonWidget>(buttonId);
|
||||
tab.IsHighlighted = () => menuType == tabType;
|
||||
tab.OnClick = () => { menuType = tabType; };
|
||||
tab.OnClick = () => menuType = tabType;
|
||||
|
||||
var container = widget.Parent.Get<ContainerWidget>(tabId);
|
||||
container.IsVisible = () => menuType == tabType;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(template,
|
||||
() => tilesetDropDown.Text == option,
|
||||
() => { tilesetDropDown.Text = option; });
|
||||
() => tilesetDropDown.Text = option);
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option;
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var saveButton = panel.Get<ButtonWidget>("SAVE_BUTTON");
|
||||
saveButton.IsDisabled = () => string.IsNullOrWhiteSpace(saveTextField.Text);
|
||||
saveButton.OnClick = () => { Save(world); };
|
||||
saveButton.OnClick = () => Save(world);
|
||||
saveButton.IsVisible = () => true;
|
||||
|
||||
var saveWidgets = panel.Get("SAVE_WIDGETS");
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var loadButton = panel.Get<ButtonWidget>("LOAD_BUTTON");
|
||||
loadButton.IsVisible = () => true;
|
||||
loadButton.IsDisabled = () => selectedSave == null;
|
||||
loadButton.OnClick = () => { Load(); };
|
||||
loadButton.OnClick = Load;
|
||||
}
|
||||
|
||||
if (Directory.Exists(baseSavePath))
|
||||
|
||||
@@ -333,9 +333,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
catch (Exception e)
|
||||
{
|
||||
Game.RunAfterTick(() => // run on the main thread
|
||||
{
|
||||
SetNewsStatus(modData.Translation.GetString(NewsRetrivalFailed, Translation.Arguments("message", e.Message)));
|
||||
});
|
||||
SetNewsStatus(modData.Translation.GetString(NewsRetrivalFailed, Translation.Arguments("message", e.Message))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -434,10 +434,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var fsPlayer = fullscreenVideoPlayer.Get<VideoPlayerWidget>("PLAYER");
|
||||
fullscreenVideoPlayer.Visible = true;
|
||||
PlayVideo(fsPlayer, missionData.StartVideo, PlayingVideo.GameStart, () =>
|
||||
{
|
||||
Game.CreateAndStartLocalServer(selectedMap.Uid, orders);
|
||||
});
|
||||
PlayVideo(fsPlayer, missionData.StartVideo, PlayingVideo.GameStart,
|
||||
() => Game.CreateAndStartLocalServer(selectedMap.Uid, orders));
|
||||
}
|
||||
else
|
||||
Game.CreateAndStartLocalServer(selectedMap.Uid, orders);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
pauseButton.IsVisible = () => Game.Sound.MusicPlaying;
|
||||
|
||||
var stopButton = panel.Get<ButtonWidget>("BUTTON_STOP");
|
||||
stopButton.OnClick = () => { musicPlaylist.Stop(); };
|
||||
stopButton.OnClick = musicPlaylist.Stop;
|
||||
stopButton.IsDisabled = NoMusic;
|
||||
|
||||
var nextButton = panel.Get<ButtonWidget>("BUTTON_NEXT");
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var watch = panel.Get<ButtonWidget>("WATCH_BUTTON");
|
||||
watch.IsDisabled = () => selectedReplay == null || map.Status != MapStatus.Available;
|
||||
watch.OnClick = () => { WatchReplay(); };
|
||||
watch.OnClick = WatchReplay;
|
||||
|
||||
var mapPreviewRoot = panel.Get("MAP_PREVIEW_ROOT");
|
||||
mapPreviewRoot.IsVisible = () => selectedReplay != null;
|
||||
|
||||
@@ -68,10 +68,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var hotkeyValidColor = ChromeMetrics.Get<Color>("HotkeyColor");
|
||||
var hotkeyInvalidColor = ChromeMetrics.Get<Color>("HotkeyColorInvalid");
|
||||
|
||||
remapButton.GetColor = () =>
|
||||
{
|
||||
return hd.HasDuplicates ? hotkeyInvalidColor : hotkeyValidColor;
|
||||
};
|
||||
remapButton.GetColor = () => hd.HasDuplicates ? hotkeyInvalidColor : hotkeyValidColor;
|
||||
|
||||
if (selectedHotkeyDefinition == hd)
|
||||
{
|
||||
@@ -253,9 +250,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
hotkeyEntryWidget.IsValid = () => isHotkeyValid;
|
||||
hotkeyEntryWidget.OnLoseFocus = ValidateHotkey;
|
||||
hotkeyEntryWidget.OnEscKey = _ =>
|
||||
{
|
||||
hotkeyEntryWidget.Key = modData.Hotkeys[selectedHotkeyDefinition.Name].GetValue();
|
||||
};
|
||||
hotkeyEntryWidget.IsDisabled = () => selectedHotkeyDefinition.Readonly;
|
||||
|
||||
validHotkeyEntryWidth = hotkeyEntryWidget.Bounds.Width;
|
||||
|
||||
@@ -285,10 +285,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
public void ScrollToItem(string itemKey, bool smooth = false)
|
||||
{
|
||||
var item = Children.FirstOrDefault(c =>
|
||||
{
|
||||
return c is ScrollItemWidget si && si.ItemKey == itemKey;
|
||||
});
|
||||
var item = Children.FirstOrDefault(c => c is ScrollItemWidget si && si.ItemKey == itemKey);
|
||||
|
||||
if (item != null)
|
||||
ScrollToItem(item, smooth);
|
||||
@@ -296,10 +293,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
public void ScrollToSelectedItem()
|
||||
{
|
||||
var item = Children.FirstOrDefault(c =>
|
||||
{
|
||||
return c is ScrollItemWidget si && si.IsSelected();
|
||||
});
|
||||
var item = Children.FirstOrDefault(c => c is ScrollItemWidget si && si.IsSelected());
|
||||
|
||||
if (item != null)
|
||||
ScrollToItem(item);
|
||||
|
||||
@@ -106,8 +106,8 @@ namespace OpenRA.Platforms.Default
|
||||
var t = (ValueTuple<int, int, int, int>)tuple;
|
||||
context.EnableScissor(t.Item1, t.Item2, t.Item3, t.Item4);
|
||||
};
|
||||
doSetBlendMode = mode => { context.SetBlendMode((BlendMode)mode); };
|
||||
doSetVSync = enabled => { context.SetVSyncEnabled((bool)enabled); };
|
||||
doSetBlendMode = mode => context.SetBlendMode((BlendMode)mode);
|
||||
doSetVSync = enabled => context.SetVSyncEnabled((bool)enabled);
|
||||
|
||||
Monitor.Pulse(syncObject);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user