diff --git a/.editorconfig b/.editorconfig index f7308edf37..c52f82d2c4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -959,6 +959,9 @@ dotnet_diagnostic.RCS1034.severity = warning # Remove argument list from attribute. dotnet_diagnostic.RCS1039.severity = warning +# Remove empty initializer. +dotnet_diagnostic.RCS1041.severity = warning + # Remove enum default underlying type. dotnet_diagnostic.RCS1042.severity = warning diff --git a/OpenRA.Game/Primitives/BitSet.cs b/OpenRA.Game/Primitives/BitSet.cs index bd7d2ff77e..a12611aa6b 100644 --- a/OpenRA.Game/Primitives/BitSet.cs +++ b/OpenRA.Game/Primitives/BitSet.cs @@ -86,7 +86,7 @@ namespace OpenRA.Primitives public static BitSet FromStringsNoAlloc(string[] values) { - return new BitSet(BitSetAllocator.GetBitsNoAlloc(values)) { }; + return new BitSet(BitSetAllocator.GetBitsNoAlloc(values)); } public override string ToString() diff --git a/OpenRA.Game/Primitives/LongBitSet.cs b/OpenRA.Game/Primitives/LongBitSet.cs index 8395c1bb40..2566b577a6 100644 --- a/OpenRA.Game/Primitives/LongBitSet.cs +++ b/OpenRA.Game/Primitives/LongBitSet.cs @@ -99,7 +99,7 @@ namespace OpenRA.Primitives public static LongBitSet FromStringsNoAlloc(string[] values) { - return new LongBitSet(LongBitSetAllocator.GetBitsNoAlloc(values)) { }; + return new LongBitSet(LongBitSetAllocator.GetBitsNoAlloc(values)); } public static void Reset() diff --git a/OpenRA.Mods.Cnc/SpriteLoaders/ShpTDLoader.cs b/OpenRA.Mods.Cnc/SpriteLoaders/ShpTDLoader.cs index 1bb58c7899..a989e718d9 100644 --- a/OpenRA.Mods.Cnc/SpriteLoaders/ShpTDLoader.cs +++ b/OpenRA.Mods.Cnc/SpriteLoaders/ShpTDLoader.cs @@ -232,7 +232,7 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders var eof = new ImageHeader { FileOffset = (uint)dataOffset }; eof.WriteTo(bw); - var allZeroes = new ImageHeader { }; + var allZeroes = new ImageHeader(); allZeroes.WriteTo(bw); foreach (var f in compressedFrames) diff --git a/OpenRA.Mods.Cnc/Traits/World/TSEditorResourceLayer.cs b/OpenRA.Mods.Cnc/Traits/World/TSEditorResourceLayer.cs index 162c347e5a..3b3e7ed294 100644 --- a/OpenRA.Mods.Cnc/Traits/World/TSEditorResourceLayer.cs +++ b/OpenRA.Mods.Cnc/Traits/World/TSEditorResourceLayer.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.Cnc.Traits [ActorReference] [Desc("Actor types that should be treated as veins for adjacency.")] - public readonly HashSet VeinholeActors = new() { }; + public readonly HashSet VeinholeActors = new(); public override object Create(ActorInitializer init) { return new TSEditorResourceLayer(init.Self, this); } } diff --git a/OpenRA.Mods.Cnc/Traits/World/TSResourceLayer.cs b/OpenRA.Mods.Cnc/Traits/World/TSResourceLayer.cs index 0e3177c1b9..c99e332304 100644 --- a/OpenRA.Mods.Cnc/Traits/World/TSResourceLayer.cs +++ b/OpenRA.Mods.Cnc/Traits/World/TSResourceLayer.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc.Traits [ActorReference] [Desc("Actor types that should be treated as veins for adjacency.")] - public readonly HashSet VeinholeActors = new() { }; + public readonly HashSet VeinholeActors = new(); public override object Create(ActorInitializer init) { return new TSResourceLayer(init.Self, this); } } diff --git a/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs b/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs index 8230e89fb7..776fdfb49c 100644 --- a/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs +++ b/OpenRA.Mods.Cnc/Traits/World/TSVeinsRenderer.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Cnc.Traits [ActorReference] [Desc("Actor types that should be treated as veins for adjacency.")] - public readonly HashSet VeinholeActors = new() { }; + public readonly HashSet VeinholeActors = new(); void IMapPreviewSignatureInfo.PopulateMapPreviewSignatureCells(Map map, ActorInfo ai, ActorReference s, List<(MPos Uv, Color Color)> destinationBuffer) { diff --git a/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs b/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs index 102d0f62b3..8ce304d8b8 100644 --- a/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs +++ b/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Effects readonly Animation flag; readonly Animation circles; - readonly List targetLineNodes = new() { }; + readonly List targetLineNodes = new(); List cachedLocations; public RallyPointIndicator(Actor building, RallyPoint rp) diff --git a/OpenRA.Mods.Common/Traits/ActorSpawner.cs b/OpenRA.Mods.Common/Traits/ActorSpawner.cs index 33eaea3ca3..e71f4e11de 100644 --- a/OpenRA.Mods.Common/Traits/ActorSpawner.cs +++ b/OpenRA.Mods.Common/Traits/ActorSpawner.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits public class ActorSpawnerInfo : ConditionalTraitInfo { [Desc("Type of ActorSpawner with which it connects.")] - public readonly HashSet Types = new() { }; + public readonly HashSet Types = new(); public override object Create(ActorInitializer init) { return new ActorSpawner(this); } } diff --git a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs index 031e37808d..7d4333c418 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoAircraft.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits [ActorReference] [FieldLoader.Require] - public readonly HashSet DockActors = new() { }; + public readonly HashSet DockActors = new(); [VoiceReference] public readonly string Voice = "Action"; diff --git a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoRepairable.cs b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoRepairable.cs index 1435cd0554..e569dce002 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoRepairable.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoRepairable.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits { [ActorReference] [FieldLoader.Require] - public readonly HashSet RepairActors = new() { }; + public readonly HashSet RepairActors = new(); [VoiceReference] public readonly string Voice = "Action"; diff --git a/OpenRA.Mods.Common/Traits/Rearmable.cs b/OpenRA.Mods.Common/Traits/Rearmable.cs index c3031564a5..f6b9ed9f66 100644 --- a/OpenRA.Mods.Common/Traits/Rearmable.cs +++ b/OpenRA.Mods.Common/Traits/Rearmable.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits [ActorReference] [FieldLoader.Require] [Desc("Actors that this actor can dock to and get rearmed by.")] - public readonly HashSet RearmActors = new() { }; + public readonly HashSet RearmActors = new(); [Desc("Name(s) of AmmoPool(s) that use this trait to rearm.")] public readonly HashSet AmmoPools = new() { "primary" }; diff --git a/OpenRA.Mods.Common/Traits/Repairable.cs b/OpenRA.Mods.Common/Traits/Repairable.cs index 7fe00bc9ea..ca00f98720 100644 --- a/OpenRA.Mods.Common/Traits/Repairable.cs +++ b/OpenRA.Mods.Common/Traits/Repairable.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits { [ActorReference] [FieldLoader.Require] - public readonly HashSet RepairActors = new() { }; + public readonly HashSet RepairActors = new(); [VoiceReference] public readonly string Voice = "Action"; diff --git a/OpenRA.Mods.Common/Traits/RepairableNear.cs b/OpenRA.Mods.Common/Traits/RepairableNear.cs index 86726f580b..616b67739f 100644 --- a/OpenRA.Mods.Common/Traits/RepairableNear.cs +++ b/OpenRA.Mods.Common/Traits/RepairableNear.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits { [ActorReference] [FieldLoader.Require] - public readonly HashSet RepairActors = new() { }; + public readonly HashSet RepairActors = new(); public readonly WDist CloseEnough = WDist.FromCells(4); diff --git a/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs b/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs index 35d00497dd..37ce2f94d4 100644 --- a/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs +++ b/OpenRA.Mods.Common/Traits/World/ActorSpawnManager.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string Owner = "Creeps"; [Desc("Type of ActorSpawner with which it connects.")] - public readonly HashSet Types = new() { }; + public readonly HashSet Types = new(); public override void RulesetLoaded(Ruleset rules, ActorInfo ai) {