Fix IDE0042
This commit is contained in:
@@ -189,6 +189,9 @@ dotnet_diagnostic.IDE0040.severity = warning
|
||||
# Use 'is null' check.
|
||||
dotnet_diagnostic.IDE0041.severity = warning
|
||||
|
||||
# Deconstruct variable declaration.
|
||||
dotnet_diagnostic.IDE0042.severity = warning
|
||||
|
||||
# Make field readonly.
|
||||
dotnet_diagnostic.IDE0044.severity = warning
|
||||
|
||||
|
||||
@@ -57,19 +57,19 @@ namespace OpenRA.Mods.Common.Installer
|
||||
continue;
|
||||
}
|
||||
|
||||
var entry = entries[node.Value.Value];
|
||||
var (length, offset) = entries[node.Value.Value];
|
||||
|
||||
source.Position = entry.Offset;
|
||||
source.Position = offset;
|
||||
|
||||
extracted.Add(targetPath);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
|
||||
var displayFilename = Path.GetFileName(Path.GetFileName(targetPath));
|
||||
|
||||
Action<long> onProgress = null;
|
||||
if (entry.Length < InstallFromSourceLogic.ShowPercentageThreshold)
|
||||
if (length < InstallFromSourceLogic.ShowPercentageThreshold)
|
||||
updateMessage(modData.Translation.GetString(InstallFromSourceLogic.Extracing, Translation.Arguments("filename", displayFilename)));
|
||||
else
|
||||
onProgress = b => updateMessage(modData.Translation.GetString(InstallFromSourceLogic.ExtracingProgress, Translation.Arguments("filename", displayFilename, "progress", 100 * b / entry.Length)));
|
||||
onProgress = b => updateMessage(modData.Translation.GetString(InstallFromSourceLogic.ExtracingProgress, Translation.Arguments("filename", displayFilename, "progress", 100 * b / length)));
|
||||
|
||||
using (var target = File.OpenWrite(targetPath))
|
||||
{
|
||||
|
||||
@@ -161,9 +161,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
else if (baseBuilder.Info.RefineryTypes.Contains(actorInfo.Name))
|
||||
type = BuildingType.Refinery;
|
||||
|
||||
var pack = ChooseBuildLocation(currentBuilding.Item, true, type);
|
||||
location = pack.Location;
|
||||
actorVariant = pack.Variant;
|
||||
(location, actorVariant) = ChooseBuildLocation(currentBuilding.Item, true, type);
|
||||
}
|
||||
|
||||
if (location == null)
|
||||
|
||||
@@ -155,15 +155,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var totalShares = shares.Sum(a => a.Shares);
|
||||
var n = self.World.SharedRandom.Next(totalShares);
|
||||
|
||||
foreach (var s in shares)
|
||||
foreach (var (action, share) in shares)
|
||||
{
|
||||
if (n < s.Shares)
|
||||
if (n < share)
|
||||
{
|
||||
s.Action.Activate(crusher);
|
||||
action.Activate(crusher);
|
||||
return;
|
||||
}
|
||||
|
||||
n -= s.Shares;
|
||||
n -= share;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (rtl.TryGetTerrainColorPair(uv, out var c))
|
||||
return (c.Left.ToArgb(), c.Right.ToArgb());
|
||||
|
||||
var tc = map.GetTerrainColorPair(uv);
|
||||
return (tc.Left.ToArgb(), tc.Right.ToArgb());
|
||||
var (left, right) = map.GetTerrainColorPair(uv);
|
||||
return (left.ToArgb(), right.ToArgb());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||
{
|
||||
foreach (var field in traits)
|
||||
foreach (var traitNode in actorNode.ChildrenMatching(field.TraitName))
|
||||
traitNode.RenameChildrenMatching(field.OldName, field.NewName);
|
||||
foreach (var (traitName, oldName, newName) in traits)
|
||||
foreach (var traitNode in actorNode.ChildrenMatching(traitName))
|
||||
traitNode.RenameChildrenMatching(oldName, newName);
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
@@ -226,15 +226,15 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
return ScriptMemberWrapper.WrappableMembers(t).Select(memberInfo => (memberInfo, required));
|
||||
});
|
||||
|
||||
foreach (var property in properties)
|
||||
foreach (var (memberInfo, required) in properties)
|
||||
{
|
||||
Console.WriteLine();
|
||||
|
||||
var isActivity = property.memberInfo.HasAttribute<ScriptActorPropertyActivityAttribute>();
|
||||
var isActivity = memberInfo.HasAttribute<ScriptActorPropertyActivityAttribute>();
|
||||
|
||||
if (property.memberInfo.HasAttribute<DescAttribute>())
|
||||
if (memberInfo.HasAttribute<DescAttribute>())
|
||||
{
|
||||
var lines = property.memberInfo.GetCustomAttributes<DescAttribute>(true).First().Lines;
|
||||
var lines = memberInfo.GetCustomAttributes<DescAttribute>(true).First().Lines;
|
||||
foreach (var line in lines)
|
||||
Console.WriteLine($" --- {line}");
|
||||
}
|
||||
@@ -242,10 +242,10 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (isActivity)
|
||||
Console.WriteLine(" --- *Queued Activity*");
|
||||
|
||||
if (property.required.Any())
|
||||
Console.WriteLine($" --- **Requires {(property.required.Length == 1 ? "Trait" : "Traits")}:** {property.required.Select(GetDocumentationUrl).JoinWith(", ")}");
|
||||
if (required.Any())
|
||||
Console.WriteLine($" --- **Requires {(required.Length == 1 ? "Trait" : "Traits")}:** {required.Select(GetDocumentationUrl).JoinWith(", ")}");
|
||||
|
||||
if (property.memberInfo is MethodInfo methodInfo)
|
||||
if (memberInfo is MethodInfo methodInfo)
|
||||
{
|
||||
var attributes = methodInfo.GetCustomAttributes(false);
|
||||
foreach (var obsolete in attributes.OfType<ObsoleteAttribute>())
|
||||
@@ -264,7 +264,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
Console.WriteLine($" {methodInfo.Name} = function({parameterString}) end;");
|
||||
}
|
||||
|
||||
if (property.memberInfo is PropertyInfo propertyInfo)
|
||||
if (memberInfo is PropertyInfo propertyInfo)
|
||||
{
|
||||
Console.WriteLine($" ---@type {propertyInfo.PropertyType.EmmyLuaString()}");
|
||||
Console.WriteLine(" " + propertyInfo.Name + " = { };");
|
||||
|
||||
@@ -255,13 +255,13 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
Location: LocationFromMapOffset(Exts.ParseIntegerInvariant(kv.Value), MapSize)));
|
||||
|
||||
// Add waypoint actors skipping duplicate entries
|
||||
foreach (var kv in wps.DistinctBy(location => location.Location))
|
||||
foreach (var (waypointNumber, location) in wps.DistinctBy(location => location.Location))
|
||||
{
|
||||
if (!singlePlayer && kv.WaypointNumber <= 7)
|
||||
if (!singlePlayer && waypointNumber <= 7)
|
||||
{
|
||||
var ar = new ActorReference("mpspawn")
|
||||
{
|
||||
new LocationInit((CPos)kv.Location),
|
||||
new LocationInit((CPos)location),
|
||||
new OwnerInit("Neutral")
|
||||
};
|
||||
|
||||
@@ -272,11 +272,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
{
|
||||
var ar = new ActorReference("waypoint")
|
||||
{
|
||||
new LocationInit((CPos)kv.Location),
|
||||
new LocationInit((CPos)location),
|
||||
new OwnerInit("Neutral")
|
||||
};
|
||||
|
||||
SaveWaypoint(kv.WaypointNumber, ar);
|
||||
SaveWaypoint(waypointNumber, ar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,12 +101,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
for (var i = 0; i < numTabs; i++)
|
||||
{
|
||||
var type = visiblePanels[i];
|
||||
var info = panels[type];
|
||||
var (panel, label, setup) = panels[type];
|
||||
var tabButton = tabContainer?.Get<ButtonWidget>($"BUTTON{i + 1}");
|
||||
|
||||
if (tabButton != null)
|
||||
{
|
||||
tabButton.Text = modData.Translation.GetString(info.Label);
|
||||
tabButton.Text = modData.Translation.GetString(label);
|
||||
tabButton.OnClick = () =>
|
||||
{
|
||||
if (activePanel == IngameInfoPanel.Chat)
|
||||
@@ -117,9 +117,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
tabButton.IsHighlighted = () => activePanel == type;
|
||||
}
|
||||
|
||||
var panelContainer = widget.Get<ContainerWidget>(info.Panel);
|
||||
var panelContainer = widget.Get<ContainerWidget>(panel);
|
||||
panelContainer.IsVisible = () => activePanel == type;
|
||||
info.Setup(tabButton, panelContainer);
|
||||
setup(tabButton, panelContainer);
|
||||
|
||||
if (activePanel == IngameInfoPanel.AutoSelect)
|
||||
activePanel = type;
|
||||
|
||||
@@ -228,9 +228,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
flag.GetImageCollection = () => "flags";
|
||||
flag.GetImageName = () => factionId;
|
||||
|
||||
var tooltip = SplitOnFirstToken(faction.Description);
|
||||
item.GetTooltipText = () => tooltip.First;
|
||||
item.GetTooltipDesc = () => tooltip.Second;
|
||||
var (text, desc) = SplitOnFirstToken(faction.Description);
|
||||
item.GetTooltipText = () => text;
|
||||
item.GetTooltipDesc = () => desc;
|
||||
|
||||
return item;
|
||||
}
|
||||
@@ -566,9 +566,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
dropdown.IsDisabled = () => s.LockFaction || orderManager.LocalClient.IsReady;
|
||||
dropdown.OnMouseDown = _ => ShowFactionDropDown(dropdown, c, orderManager, factions);
|
||||
|
||||
var tooltip = SplitOnFirstToken(factions[c.Faction].Description);
|
||||
dropdown.GetTooltipText = () => tooltip.First;
|
||||
dropdown.GetTooltipDesc = () => tooltip.Second;
|
||||
var (text, desc) = SplitOnFirstToken(factions[c.Faction].Description);
|
||||
dropdown.GetTooltipText = () => text;
|
||||
dropdown.GetTooltipDesc = () => desc;
|
||||
|
||||
SetupFactionWidget(dropdown, c, factions);
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var template = sysInfoData.Get<LabelWidget>("DATA_TEMPLATE");
|
||||
sysInfoData.RemoveChildren();
|
||||
|
||||
foreach (var info in GetSystemInformation().Values)
|
||||
foreach (var (name, value) in GetSystemInformation().Values)
|
||||
{
|
||||
var label = template.Clone() as LabelWidget;
|
||||
var text = info.Label + ": " + info.Value;
|
||||
var text = name + ": " + value;
|
||||
label.GetText = () => text;
|
||||
sysInfoData.AddChild(label);
|
||||
}
|
||||
|
||||
@@ -222,10 +222,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
void UpdateTerrainColor(MPos uv)
|
||||
{
|
||||
var colorPair = playerRadarTerrain != null && playerRadarTerrain.IsInitialized ?
|
||||
var (leftColor, rightColor) = playerRadarTerrain != null && playerRadarTerrain.IsInitialized ?
|
||||
playerRadarTerrain[uv] : PlayerRadarTerrain.GetColor(world.Map, radarTerrainLayers, uv);
|
||||
var leftColor = colorPair.Left;
|
||||
var rightColor = colorPair.Right;
|
||||
|
||||
var stride = radarSheet.Size.Width;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user