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