Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style fixes (.NET 8 SDK) #21211

Merged
merged 6 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ dotnet_diagnostic.CA2231.severity = warning

# Provide correct arguments to formatting methods.
#dotnet_code_quality.CA2241.additional_string_formatting_methods =
dotnet_code_quality.CA2241.try_determine_additional_string_formatting_methods_automatically = true
#dotnet_code_quality.CA2241.try_determine_additional_string_formatting_methods_automatically = false
dotnet_diagnostic.CA2241.severity = warning

# Test for NaN correctly.
Expand Down
16 changes: 8 additions & 8 deletions OpenRA.Game/CVec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ public CVec Clamp(Rectangle r)

public static readonly CVec[] Directions =
{
new CVec(-1, -1),
new CVec(-1, 0),
new CVec(-1, 1),
new CVec(0, -1),
new CVec(0, 1),
new CVec(1, -1),
new CVec(1, 0),
new CVec(1, 1),
new(-1, -1),
new(-1, 0),
new(-1, 1),
new(0, -1),
new(0, 1),
new(1, -1),
new(1, 0),
new(1, 1),
};

#region Scripting interface
Expand Down
6 changes: 3 additions & 3 deletions OpenRA.Game/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,8 @@ public static ConnectionTarget CreateServer(ServerSettings settings)
{
var endpoints = new List<IPEndPoint>
{
new IPEndPoint(IPAddress.IPv6Any, settings.ListenPort),
new IPEndPoint(IPAddress.Any, settings.ListenPort)
new(IPAddress.IPv6Any, settings.ListenPort),
new(IPAddress.Any, settings.ListenPort)
};
server = new Server.Server(endpoints, settings, ModData, ServerType.Multiplayer);

Expand All @@ -950,7 +950,7 @@ public static ConnectionTarget CreateLocalServer(string map)
// This would break the Restart button, which relies on the PlayerIndex always being the same for local servers
var endpoints = new List<IPEndPoint>
{
new IPEndPoint(IPAddress.Loopback, 0)
new(IPAddress.Loopback, 0)
};
server = new Server.Server(endpoints, settings, ModData, ServerType.Local);

Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/GameInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public string Serialize()
{
var nodes = new List<MiniYamlNode>
{
new MiniYamlNode("Root", FieldSaver.Save(this))
new("Root", FieldSaver.Save(this))
};

for (var i = 0; i < Players.Count; i++)
Expand Down
40 changes: 20 additions & 20 deletions OpenRA.Game/Map/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,26 +159,26 @@ public sealed class Map : IReadOnlyFileSystem, IDisposable
/// <summary>Defines the order of the fields in map.yaml.</summary>
static readonly MapField[] YamlFields =
{
new MapField("MapFormat"),
new MapField("RequiresMod"),
new MapField("Title"),
new MapField("Author"),
new MapField("Tileset"),
new MapField("MapSize"),
new MapField("Bounds"),
new MapField("Visibility"),
new MapField("Categories"),
new MapField("LockPreview", required: false, ignoreIfValue: "False"),
new MapField("Players", "PlayerDefinitions"),
new MapField("Actors", "ActorDefinitions"),
new MapField("Rules", "RuleDefinitions", required: false),
new MapField("Translations", "TranslationDefinitions", required: false),
new MapField("Sequences", "SequenceDefinitions", required: false),
new MapField("ModelSequences", "ModelSequenceDefinitions", required: false),
new MapField("Weapons", "WeaponDefinitions", required: false),
new MapField("Voices", "VoiceDefinitions", required: false),
new MapField("Music", "MusicDefinitions", required: false),
new MapField("Notifications", "NotificationDefinitions", required: false),
new("MapFormat"),
new("RequiresMod"),
new("Title"),
new("Author"),
new("Tileset"),
new("MapSize"),
new("Bounds"),
new("Visibility"),
new("Categories"),
new("LockPreview", required: false, ignoreIfValue: "False"),
new("Players", "PlayerDefinitions"),
new("Actors", "ActorDefinitions"),
new("Rules", "RuleDefinitions", required: false),
new("Translations", "TranslationDefinitions", required: false),
new("Sequences", "SequenceDefinitions", required: false),
new("ModelSequences", "ModelSequenceDefinitions", required: false),
new("Weapons", "WeaponDefinitions", required: false),
new("Voices", "VoiceDefinitions", required: false),
new("Music", "MusicDefinitions", required: false),
new("Notifications", "NotificationDefinitions", required: false),
};

// Format versions
Expand Down
12 changes: 6 additions & 6 deletions OpenRA.Game/Map/MapGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ public class MapGrid : IGlobalModData

public readonly WVec[] SubCellOffsets =
{
new WVec(0, 0, 0), // full cell - index 0
new WVec(-299, -256, 0), // top left - index 1
new WVec(256, -256, 0), // top right - index 2
new WVec(0, 0, 0), // center - index 3
new WVec(-299, 256, 0), // bottom left - index 4
new WVec(256, 256, 0), // bottom right - index 5
new(0, 0, 0), // full cell - index 0
new(-299, -256, 0), // top left - index 1
new(256, -256, 0), // top right - index 2
new(0, 0, 0), // center - index 3
new(-299, 256, 0), // bottom left - index 4
new(256, 256, 0), // bottom right - index 5
};

public CellRamp[] Ramps { get; }
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/MiniYaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static List<MiniYamlNode> FromLines(IEnumerable<ReadOnlyMemory<char>> lines, str

var result = new List<List<MiniYamlNode>>
{
new List<MiniYamlNode>()
new()
};
var parsedLines = new List<(int Level, string Key, string Value, string Comment, MiniYamlNode.SourceLocation Location)>();

Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Network/GameSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public void ParseOrders(Session lobbyInfo, Action<int, int, byte[]> packetFn)
// Send the trait data first to guarantee that it is available when needed
foreach (var kv in TraitData)
{
var data = new List<MiniYamlNode>() { new MiniYamlNode(kv.Key.ToStringInvariant(), kv.Value) }.WriteToString();
var data = new List<MiniYamlNode>() { new(kv.Key.ToStringInvariant(), kv.Value) }.WriteToString();
packetFn(0, 0, Order.FromTargetString("SaveTraitData", data, true).Serialize());
}

Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Network/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public GameServer(Server.Server server)

public string ToPOSTData(bool lanGame)
{
var root = new List<MiniYamlNode>() { new MiniYamlNode("Protocol", ProtocolVersion.ToStringInvariant()) };
var root = new List<MiniYamlNode>() { new("Protocol", ProtocolVersion.ToStringInvariant()) };
foreach (var field in SerializeFields)
root.Add(FieldSaver.SaveField(this, field));

Expand Down
6 changes: 3 additions & 3 deletions OpenRA.Game/Network/Handshake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static HandshakeRequest Deserialize(string data)

public string Serialize()
{
var data = new List<MiniYamlNode> { new MiniYamlNode("Handshake", FieldSaver.Save(this)) };
var data = new List<MiniYamlNode> { new("Handshake", FieldSaver.Save(this)) };
return data.WriteToString();
}
}
Expand Down Expand Up @@ -79,9 +79,9 @@ public string Serialize()
{
var data = new List<MiniYamlNode>
{
new MiniYamlNode("Handshake", null,
new("Handshake", null,
new[] { "Mod", "Version", "Password", "Fingerprint", "AuthSignature", "OrdersProtocol" }.Select(p => FieldSaver.SaveField(this, p)).ToList()),
new MiniYamlNode("Client", FieldSaver.Save(Client))
new("Client", FieldSaver.Save(Client))
};

return data.WriteToString();
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Game/Network/LocalizedMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public static string Serialize(string key, Dictionary<string, object> arguments
{
var root = new List<MiniYamlNode>
{
new MiniYamlNode("Protocol", ProtocolVersion.ToStringInvariant()),
new MiniYamlNode("Key", key)
new("Protocol", ProtocolVersion.ToStringInvariant()),
new("Key", key)
};

if (arguments != null)
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/Network/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public string Serialize()
{
var sessionData = new List<MiniYamlNode>()
{
new MiniYamlNode("DisabledSpawnPoints", FieldSaver.FormatValue(DisabledSpawnPoints))
new("DisabledSpawnPoints", FieldSaver.FormatValue(DisabledSpawnPoints))
};

foreach (var client in Clients)
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Game/Server/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,8 +1365,8 @@ public void StartGame()
{
startGameData = new List<MiniYamlNode>()
{
new MiniYamlNode("SaveLastOrdersFrame", GameSave.LastOrdersFrame.ToStringInvariant()),
new MiniYamlNode("SaveSyncFrame", GameSave.LastSyncFrame.ToStringInvariant())
new("SaveLastOrdersFrame", GameSave.LastOrdersFrame.ToStringInvariant()),
new("SaveSyncFrame", GameSave.LastSyncFrame.ToStringInvariant())
}.WriteToString();
}
}
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Game/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public void RequestGameSave(string filename)
var data = tp.Trait.IssueTraitData(tp.Actor);
if (data != null)
{
var yaml = new List<MiniYamlNode>() { new MiniYamlNode(i.ToStringInvariant(), new MiniYaml("", data)) };
var yaml = new List<MiniYamlNode>() { new(i.ToStringInvariant(), new MiniYaml("", data)) };
IssueOrder(Order.FromTargetString("GameSaveTraitData", yaml.WriteToString(), true));
}

Expand Down
12 changes: 6 additions & 6 deletions OpenRA.Mods.Cnc/Graphics/VoxelLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ ModelVertex[] GenerateSlicePlane(int su, int sv, Func<int, int, VxlElement?> fir
var channelC = ChannelSelect[(int)t.Channel];
return new ModelVertex[6]
{
new ModelVertex(coord(0, 0), s.Left, s.Top, t.Left, t.Top, channelP, channelC),
new ModelVertex(coord(su, 0), s.Right, s.Top, t.Right, t.Top, channelP, channelC),
new ModelVertex(coord(su, sv), s.Right, s.Bottom, t.Right, t.Bottom, channelP, channelC),
new ModelVertex(coord(su, sv), s.Right, s.Bottom, t.Right, t.Bottom, channelP, channelC),
new ModelVertex(coord(0, sv), s.Left, s.Bottom, t.Left, t.Bottom, channelP, channelC),
new ModelVertex(coord(0, 0), s.Left, s.Top, t.Left, t.Top, channelP, channelC)
new(coord(0, 0), s.Left, s.Top, t.Left, t.Top, channelP, channelC),
new(coord(su, 0), s.Right, s.Top, t.Right, t.Top, channelP, channelC),
new(coord(su, sv), s.Right, s.Bottom, t.Right, t.Bottom, channelP, channelC),
new(coord(su, sv), s.Right, s.Bottom, t.Right, t.Bottom, channelP, channelC),
new(coord(0, sv), s.Left, s.Bottom, t.Left, t.Bottom, channelP, channelC),
new(coord(0, 0), s.Left, s.Top, t.Left, t.Top, channelP, channelC)
};
}

Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Cnc/Traits/Disguise.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void DisguiseAs(Actor target)
{
var tooltip = target.TraitsImplementing<ITooltip>().FirstEnabledTraitOrDefault();
if (tooltip == null)
throw new ArgumentNullException("tooltip", "Missing tooltip or invalid target.");
throw new ArgumentException("Missing tooltip or invalid target.", nameof(target));

AsPlayer = tooltip.Owner;
AsActor = target.Info;
Expand Down
8 changes: 4 additions & 4 deletions OpenRA.Mods.Cnc/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public static class Util
// The actual facing associated with each sprite frame.
static readonly WAngle[] SpriteFacings =
{
WAngle.Zero, new WAngle(40), new WAngle(74), new WAngle(112), new WAngle(146), new WAngle(172), new WAngle(200), new WAngle(228),
new WAngle(256), new WAngle(284), new WAngle(312), new WAngle(340), new WAngle(370), new WAngle(402), new WAngle(436), new WAngle(472),
new WAngle(512), new WAngle(552), new WAngle(588), new WAngle(626), new WAngle(658), new WAngle(684), new WAngle(712), new WAngle(740),
new WAngle(768), new WAngle(796), new WAngle(824), new WAngle(852), new WAngle(882), new WAngle(914), new WAngle(948), new WAngle(984)
WAngle.Zero, new(40), new(74), new(112), new(146), new(172), new(200), new(228),
new(256), new(284), new(312), new(340), new(370), new(402), new(436), new(472),
new(512), new(552), new(588), new(626), new(658), new(684), new(712), new(740),
new(768), new(796), new(824), new(852), new(882), new(914), new(948), new(984)
};

/// <summary>
Expand Down
32 changes: 16 additions & 16 deletions OpenRA.Mods.Common/HitShapes/Rectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,34 @@ public void Initialize()

combatOverlayVertsTop = new WVec[]
{
new WVec(TopLeft.X, TopLeft.Y, VerticalTopOffset),
new WVec(BottomRight.X, TopLeft.Y, VerticalTopOffset),
new WVec(BottomRight.X, BottomRight.Y, VerticalTopOffset),
new WVec(TopLeft.X, BottomRight.Y, VerticalTopOffset),
new(TopLeft.X, TopLeft.Y, VerticalTopOffset),
new(BottomRight.X, TopLeft.Y, VerticalTopOffset),
new(BottomRight.X, BottomRight.Y, VerticalTopOffset),
new(TopLeft.X, BottomRight.Y, VerticalTopOffset),
};

combatOverlayVertsBottom = new WVec[]
{
new WVec(TopLeft.X, TopLeft.Y, VerticalBottomOffset),
new WVec(BottomRight.X, TopLeft.Y, VerticalBottomOffset),
new WVec(BottomRight.X, BottomRight.Y, VerticalBottomOffset),
new WVec(TopLeft.X, BottomRight.Y, VerticalBottomOffset),
new(TopLeft.X, TopLeft.Y, VerticalBottomOffset),
new(BottomRight.X, TopLeft.Y, VerticalBottomOffset),
new(BottomRight.X, BottomRight.Y, VerticalBottomOffset),
new(TopLeft.X, BottomRight.Y, VerticalBottomOffset),
};

combatOverlayVertsSide1 = new WVec[]
{
new WVec(TopLeft.X, TopLeft.Y, VerticalBottomOffset),
new WVec(TopLeft.X, TopLeft.Y, VerticalTopOffset),
new WVec(TopLeft.X, BottomRight.Y, VerticalTopOffset),
new WVec(TopLeft.X, BottomRight.Y, VerticalBottomOffset),
new(TopLeft.X, TopLeft.Y, VerticalBottomOffset),
new(TopLeft.X, TopLeft.Y, VerticalTopOffset),
new(TopLeft.X, BottomRight.Y, VerticalTopOffset),
new(TopLeft.X, BottomRight.Y, VerticalBottomOffset),
};

combatOverlayVertsSide2 = new WVec[]
{
new WVec(BottomRight.X, TopLeft.Y, VerticalBottomOffset),
new WVec(BottomRight.X, TopLeft.Y, VerticalTopOffset),
new WVec(BottomRight.X, BottomRight.Y, VerticalTopOffset),
new WVec(BottomRight.X, BottomRight.Y, VerticalBottomOffset),
new(BottomRight.X, TopLeft.Y, VerticalBottomOffset),
new(BottomRight.X, TopLeft.Y, VerticalTopOffset),
new(BottomRight.X, BottomRight.Y, VerticalTopOffset),
new(BottomRight.X, BottomRight.Y, VerticalBottomOffset),
};
}

Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Lint/CheckChromeHotkeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void Run(Action<string> emitError, Action<string> emitWarning, ModData mo
}
}

void CheckInner(ModData modData, string[] namedKeys, (string Widget, string Field)[] checkWidgetFields, Dictionary<string, List<string>> customLintMethods,
static void CheckInner(ModData modData, string[] namedKeys, (string Widget, string Field)[] checkWidgetFields, Dictionary<string, List<string>> customLintMethods,
IEnumerable<MiniYamlNode> nodes, string filename, MiniYamlNode parent, Action<string> emitError)
{
foreach (var node in nodes)
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Lint/CheckChromeIntegerExpressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Run(Action<string> emitError, Action<string> emitWarning, ModData mo
CheckInner(MiniYaml.FromStream(modData.DefaultFileSystem.Open(filename), filename), filename, emitError);
}

void CheckInner(IEnumerable<MiniYamlNode> nodes, string filename, Action<string> emitError)
static void CheckInner(IEnumerable<MiniYamlNode> nodes, string filename, Action<string> emitError)
{
var substitutions = new Dictionary<string, int>();
var readOnlySubstitutions = new ReadOnlyDictionary<string, int>(substitutions);
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Lint/CheckChromeLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void Run(Action<string> emitError, Action<string> emitWarning, ModData mo
CheckInner(MiniYaml.FromStream(modData.DefaultFileSystem.Open(filename), filename), filename, emitError);
}

void CheckInner(IEnumerable<MiniYamlNode> nodes, string filename, Action<string> emitError)
static void CheckInner(IEnumerable<MiniYamlNode> nodes, string filename, Action<string> emitError)
{
foreach (var node in nodes)
{
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public PlaceBuildingOrderGenerator(ProductionQueue queue, string name, WorldRend

var variants = new List<VariantWrapper>()
{
new VariantWrapper(worldRenderer, queue, world.Map.Rules.Actors[name])
new(worldRenderer, queue, world.Map.Rules.Actors[name])
};

foreach (var v in variants[0].ActorInfo.TraitInfos<PlaceBuildingVariantsInfo>())
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Mods.Common/Projectiles/AreaBeam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Projectiles
public class AreaBeamInfo : IProjectileInfo
{
[Desc("Projectile speed in WDist / tick, two values indicate a randomly picked velocity per beam.")]
public readonly WDist[] Speed = { new WDist(128) };
public readonly WDist[] Speed = { new(128) };

[Desc("The maximum duration (in ticks) of each beam burst.")]
public readonly int Duration = 10;
Expand All @@ -49,7 +49,7 @@ public class AreaBeamInfo : IProjectileInfo
public readonly int[] Falloff = { 100, 100 };

[Desc("Ranges at which each Falloff step is defined.")]
public readonly WDist[] Range = { WDist.Zero, new WDist(int.MaxValue) };
public readonly WDist[] Range = { WDist.Zero, new(int.MaxValue) };

[Desc("The maximum/constant/incremental inaccuracy used in conjunction with the InaccuracyType property.")]
public readonly WDist Inaccuracy = WDist.Zero;
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/Projectiles/Bullet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Projectiles
public class BulletInfo : IProjectileInfo
{
[Desc("Projectile speed in WDist / tick, two values indicate variable velocity.")]
public readonly WDist[] Speed = { new WDist(17) };
public readonly WDist[] Speed = { new(17) };

[Desc("The maximum/constant/incremental inaccuracy used in conjunction with the InaccuracyType property.")]
public readonly WDist Inaccuracy = WDist.Zero;
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ List<MiniYamlNode> IGameSaveTraitData.IssueTraitData(Actor self)

return new List<MiniYamlNode>()
{
new MiniYamlNode("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter)),
new MiniYamlNode("DefenseCenter", FieldSaver.FormatValue(DefenseCenter))
new("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter)),
new("DefenseCenter", FieldSaver.FormatValue(DefenseCenter))
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ List<MiniYamlNode> IGameSaveTraitData.IssueTraitData(Actor self)

return new List<MiniYamlNode>()
{
new MiniYamlNode("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter))
new("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter))
};
}

Expand Down