diff --git a/.editorconfig b/.editorconfig
index 5829347320..9c3da7f7aa 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -169,7 +169,7 @@ dotnet_diagnostic.IDE0082.severity = warning
# IDE0090 Simplify 'new' expression
#csharp_style_implicit_object_creation_when_type_is_apparent = true
-dotnet_diagnostic.IDE0090.severity = silent # Requires C# 9 - TODO Consider enabling
+dotnet_diagnostic.IDE0090.severity = warning
# IDE0180 Use tuple to swap values
#csharp_style_prefer_tuple_swap = true
diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs
index 88762c1d49..c43e698778 100644
--- a/OpenRA.Game/Actor.cs
+++ b/OpenRA.Game/Actor.cs
@@ -84,21 +84,21 @@ namespace OpenRA
class ConditionState
{
/// Delegates that have registered to be notified when this condition changes.
- public readonly List Notifiers = new List();
+ public readonly List Notifiers = new();
/// Unique integers identifying granted instances of the condition.
- public readonly HashSet Tokens = new HashSet();
+ public readonly HashSet Tokens = new();
}
- readonly Dictionary conditionStates = new Dictionary();
+ readonly Dictionary conditionStates = new();
/// Each granted condition receives a unique token that is used when revoking.
- readonly Dictionary conditionTokens = new Dictionary();
+ readonly Dictionary conditionTokens = new();
int nextConditionToken = 1;
/// Cache of condition -> enabled state for quick evaluation of token counter conditions.
- readonly Dictionary conditionCache = new Dictionary();
+ readonly Dictionary conditionCache = new();
/// Read-only version of conditionCache that is passed to IConditionConsumers.
readonly IReadOnlyDictionary readOnlyConditionCache;
diff --git a/OpenRA.Game/CPos.cs b/OpenRA.Game/CPos.cs
index 396c150810..3a2be3e763 100644
--- a/OpenRA.Game/CPos.cs
+++ b/OpenRA.Game/CPos.cs
@@ -41,7 +41,7 @@ namespace OpenRA
Bits = (x & 0xFFF) << 20 | (y & 0xFFF) << 8 | layer;
}
- public static readonly CPos Zero = new CPos(0, 0, 0);
+ public static readonly CPos Zero = new(0, 0, 0);
public static explicit operator CPos(int2 a) { return new CPos(a.X, a.Y); }
diff --git a/OpenRA.Game/CVec.cs b/OpenRA.Game/CVec.cs
index d4f13b5f04..e934870fd4 100644
--- a/OpenRA.Game/CVec.cs
+++ b/OpenRA.Game/CVec.cs
@@ -22,7 +22,7 @@ namespace OpenRA
public readonly int X, Y;
public CVec(int x, int y) { X = x; Y = y; }
- public static readonly CVec Zero = new CVec(0, 0);
+ public static readonly CVec Zero = new(0, 0);
public static CVec operator +(CVec a, CVec b) { return new CVec(a.X + b.X, a.Y + b.Y); }
public static CVec operator -(CVec a, CVec b) { return new CVec(a.X - b.X, a.Y - b.Y); }
diff --git a/OpenRA.Game/ExternalMods.cs b/OpenRA.Game/ExternalMods.cs
index 6c8ecf1c15..8ef0b13c36 100644
--- a/OpenRA.Game/ExternalMods.cs
+++ b/OpenRA.Game/ExternalMods.cs
@@ -41,7 +41,7 @@ namespace OpenRA
public class ExternalMods : IReadOnlyDictionary
{
- readonly Dictionary mods = new Dictionary();
+ readonly Dictionary mods = new();
readonly SheetBuilder sheetBuilder;
Sheet CreateSheet()
diff --git a/OpenRA.Game/FieldLoader.cs b/OpenRA.Game/FieldLoader.cs
index 6b14cbdbaf..f7e68aebbb 100644
--- a/OpenRA.Game/FieldLoader.cs
+++ b/OpenRA.Game/FieldLoader.cs
@@ -62,14 +62,14 @@ namespace OpenRA
throw new NotImplementedException($"FieldLoader: Missing field `{s}` on `{f.Name}`");
static readonly ConcurrentCache TypeLoadInfo =
- new ConcurrentCache(BuildTypeLoadInfo);
+ new(BuildTypeLoadInfo);
static readonly ConcurrentCache BooleanExpressionCache =
- new ConcurrentCache(expression => new BooleanExpression(expression));
+ new(expression => new BooleanExpression(expression));
static readonly ConcurrentCache IntegerExpressionCache =
- new ConcurrentCache(expression => new IntegerExpression(expression));
+ new(expression => new IntegerExpression(expression));
static readonly Dictionary> TypeParsers =
- new Dictionary>()
+ new()
{
{ typeof(int), ParseInt },
{ typeof(ushort), ParseUShort },
@@ -103,7 +103,7 @@ namespace OpenRA
};
static readonly Dictionary> GenericTypeParsers =
- new Dictionary>()
+ new()
{
{ typeof(HashSet<>), ParseHashSetOrList },
{ typeof(List<>), ParseHashSetOrList },
@@ -749,7 +749,7 @@ namespace OpenRA
[AttributeUsage(AttributeTargets.Field)]
public class SerializeAttribute : Attribute
{
- public static readonly SerializeAttribute Default = new SerializeAttribute(true);
+ public static readonly SerializeAttribute Default = new(true);
public bool IsDefault => this == Default;
diff --git a/OpenRA.Game/FileFormats/Png.cs b/OpenRA.Game/FileFormats/Png.cs
index c91be945a8..ef69d7d2b9 100644
--- a/OpenRA.Game/FileFormats/Png.cs
+++ b/OpenRA.Game/FileFormats/Png.cs
@@ -31,7 +31,7 @@ namespace OpenRA.FileFormats
public Color[] Palette { get; }
public byte[] Data { get; }
public SpriteFrameType Type { get; }
- public Dictionary EmbeddedData = new Dictionary();
+ public Dictionary EmbeddedData = new();
public int PixelStride => Type == SpriteFrameType.Indexed8 ? 1 : Type == SpriteFrameType.Rgb24 ? 3 : 4;
diff --git a/OpenRA.Game/FileSystem/FileSystem.cs b/OpenRA.Game/FileSystem/FileSystem.cs
index d08d13acfd..7ac45d0a8e 100644
--- a/OpenRA.Game/FileSystem/FileSystem.cs
+++ b/OpenRA.Game/FileSystem/FileSystem.cs
@@ -29,16 +29,16 @@ namespace OpenRA.FileSystem
public class FileSystem : IReadOnlyFileSystem
{
public IEnumerable MountedPackages => mountedPackages.Keys;
- readonly Dictionary mountedPackages = new Dictionary();
- readonly Dictionary explicitMounts = new Dictionary();
+ readonly Dictionary mountedPackages = new();
+ readonly Dictionary explicitMounts = new();
readonly string modID;
// Mod packages that should not be disposed
- readonly List modPackages = new List();
+ readonly List modPackages = new();
readonly IReadOnlyDictionary installedMods;
readonly IPackageLoader[] packageLoaders;
- Cache> fileIndex = new Cache>(_ => new List());
+ Cache> fileIndex = new(_ => new List());
public FileSystem(string modID, IReadOnlyDictionary installedMods, IPackageLoader[] packageLoaders)
{
diff --git a/OpenRA.Game/FileSystem/ZipFile.cs b/OpenRA.Game/FileSystem/ZipFile.cs
index 60356b778c..cf6709f088 100644
--- a/OpenRA.Game/FileSystem/ZipFile.cs
+++ b/OpenRA.Game/FileSystem/ZipFile.cs
@@ -95,7 +95,7 @@ namespace OpenRA.FileSystem
sealed class ReadWriteZipFile : ReadOnlyZipFile, IReadWritePackage
{
- readonly MemoryStream pkgStream = new MemoryStream();
+ readonly MemoryStream pkgStream = new();
public ReadWriteZipFile(string filename, bool create = false)
{
diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs
index 0f69d542f7..32a2d0b36d 100644
--- a/OpenRA.Game/Game.cs
+++ b/OpenRA.Game/Game.cs
@@ -48,7 +48,7 @@ namespace OpenRA
internal static OrderManager OrderManager;
static Server.Server server;
- public static MersenneTwister CosmeticRandom = new MersenneTwister(); // not synced
+ public static MersenneTwister CosmeticRandom = new(); // not synced
public static Renderer Renderer;
public static Sound Sound;
@@ -563,7 +563,7 @@ namespace OpenRA
// Note: These delayed actions should only be used by widgets or disposing objects
// - things that depend on a particular world should be queuing them on the world actor.
- static volatile ActionQueue delayedActions = new ActionQueue();
+ static volatile ActionQueue delayedActions = new();
public static void RunAfterTick(Action a) { delayedActions.Add(a, RunTime); }
public static void RunAfterDelay(int delayMilliseconds, Action a) { delayedActions.Add(a, RunTime + delayMilliseconds); }
diff --git a/OpenRA.Game/GameInformation.cs b/OpenRA.Game/GameInformation.cs
index c41783eb3a..287deaa162 100644
--- a/OpenRA.Game/GameInformation.cs
+++ b/OpenRA.Game/GameInformation.cs
@@ -36,7 +36,7 @@ namespace OpenRA
public TimeSpan Duration => EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero;
public IList Players { get; }
- public HashSet DisabledSpawnPoints = new HashSet();
+ public HashSet DisabledSpawnPoints = new();
public MapPreview MapPreview => Game.ModData.MapCache[MapUid];
public IEnumerable HumanPlayers { get { return Players.Where(p => p.IsHuman); } }
public bool IsSinglePlayer => HumanPlayers.Count() == 1;
diff --git a/OpenRA.Game/GameRules/ActorInfo.cs b/OpenRA.Game/GameRules/ActorInfo.cs
index 41d34fb36f..2a29f1a532 100644
--- a/OpenRA.Game/GameRules/ActorInfo.cs
+++ b/OpenRA.Game/GameRules/ActorInfo.cs
@@ -32,7 +32,7 @@ namespace OpenRA
/// You can remove inherited traits by adding a - in front of them as in -TraitName: to inherit everything, but this trait.
///
public readonly string Name;
- readonly TypeDictionary traits = new TypeDictionary();
+ readonly TypeDictionary traits = new();
List constructOrderCache = null;
public ActorInfo(ObjectCreator creator, string name, MiniYaml node)
diff --git a/OpenRA.Game/GameRules/SoundInfo.cs b/OpenRA.Game/GameRules/SoundInfo.cs
index ae375f9bae..b42fd281f2 100644
--- a/OpenRA.Game/GameRules/SoundInfo.cs
+++ b/OpenRA.Game/GameRules/SoundInfo.cs
@@ -17,14 +17,14 @@ namespace OpenRA.GameRules
{
public class SoundInfo
{
- public readonly Dictionary Variants = new Dictionary();
- public readonly Dictionary Prefixes = new Dictionary();
- public readonly Dictionary Voices = new Dictionary();
- public readonly Dictionary Notifications = new Dictionary();
+ public readonly Dictionary Variants = new();
+ public readonly Dictionary Prefixes = new();
+ public readonly Dictionary Voices = new();
+ public readonly Dictionary Notifications = new();
public readonly string DefaultVariant = ".aud";
public readonly string DefaultPrefix = "";
- public readonly HashSet DisableVariants = new HashSet();
- public readonly HashSet DisablePrefixes = new HashSet();
+ public readonly HashSet DisableVariants = new();
+ public readonly HashSet DisablePrefixes = new();
public readonly Lazy> VoicePools;
public readonly Lazy> NotificationsPools;
@@ -69,7 +69,7 @@ namespace OpenRA.GameRules
public readonly float VolumeModifier;
public readonly InterruptType Type;
readonly string[] clips;
- readonly List liveclips = new List();
+ readonly List liveclips = new();
public SoundPool(float volumeModifier, InterruptType interruptType, params string[] clips)
{
diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs
index cbbc97d071..5322c6de14 100644
--- a/OpenRA.Game/GameRules/WeaponInfo.cs
+++ b/OpenRA.Game/GameRules/WeaponInfo.cs
@@ -103,16 +103,16 @@ namespace OpenRA.GameRules
public readonly bool CanTargetSelf = false;
[Desc("What types of targets are affected.")]
- public readonly BitSet ValidTargets = new BitSet("Ground", "Water");
+ public readonly BitSet ValidTargets = new("Ground", "Water");
[Desc("What types of targets are unaffected.", "Overrules ValidTargets.")]
public readonly BitSet InvalidTargets;
- static readonly BitSet TargetTypeAir = new BitSet("Air");
+ static readonly BitSet TargetTypeAir = new("Air");
[Desc("If weapon is not directly targeting an actor and targeted position is above this altitude,",
"the weapon will ignore terrain target types and only check TargetTypeAir for validity.")]
- public readonly WDist AirThreshold = new WDist(128);
+ public readonly WDist AirThreshold = new(128);
[Desc("Delay in ticks between firing shots from the same ammo magazine. If one entry, it will be used for all bursts.",
"If multiple entries, their number needs to match Burst - 1.")]
@@ -128,7 +128,7 @@ namespace OpenRA.GameRules
public readonly IProjectileInfo Projectile;
[FieldLoader.LoadUsing(nameof(LoadWarheads))]
- public readonly List Warheads = new List();
+ public readonly List Warheads = new();
///
/// This constructor is used solely for documentation generation.
diff --git a/OpenRA.Game/Graphics/ChromeProvider.cs b/OpenRA.Game/Graphics/ChromeProvider.cs
index 8bb8a4a7e9..a4a132eb06 100644
--- a/OpenRA.Game/Graphics/ChromeProvider.cs
+++ b/OpenRA.Game/Graphics/ChromeProvider.cs
@@ -49,7 +49,7 @@ namespace OpenRA.Graphics
public readonly int[] PanelRegion = null;
public readonly PanelSides PanelSides = PanelSides.All;
- public readonly Dictionary Regions = new Dictionary();
+ public readonly Dictionary Regions = new();
}
public static IReadOnlyDictionary Collections => collections;
diff --git a/OpenRA.Game/Graphics/CursorManager.cs b/OpenRA.Game/Graphics/CursorManager.cs
index 1976679204..425a2b33cf 100644
--- a/OpenRA.Game/Graphics/CursorManager.cs
+++ b/OpenRA.Game/Graphics/CursorManager.cs
@@ -28,7 +28,7 @@ namespace OpenRA.Graphics
public IHardwareCursor[] Cursors;
}
- readonly Dictionary cursors = new Dictionary();
+ readonly Dictionary cursors = new();
readonly SheetBuilder sheetBuilder;
readonly GraphicSettings graphicSettings;
diff --git a/OpenRA.Game/Graphics/HardwarePalette.cs b/OpenRA.Game/Graphics/HardwarePalette.cs
index d39113edd9..b168258a19 100644
--- a/OpenRA.Game/Graphics/HardwarePalette.cs
+++ b/OpenRA.Game/Graphics/HardwarePalette.cs
@@ -21,9 +21,9 @@ namespace OpenRA.Graphics
public ITexture ColorShifts { get; }
public int Height { get; private set; }
- readonly Dictionary palettes = new Dictionary();
- readonly Dictionary mutablePalettes = new Dictionary();
- readonly Dictionary indices = new Dictionary();
+ readonly Dictionary palettes = new();
+ readonly Dictionary mutablePalettes = new();
+ readonly Dictionary indices = new();
byte[] buffer = Array.Empty();
float[] colorShiftBuffer = Array.Empty();
diff --git a/OpenRA.Game/Graphics/ModelRenderer.cs b/OpenRA.Game/Graphics/ModelRenderer.cs
index 3d143e71b5..fd01ad8f5d 100644
--- a/OpenRA.Game/Graphics/ModelRenderer.cs
+++ b/OpenRA.Game/Graphics/ModelRenderer.cs
@@ -37,7 +37,7 @@ namespace OpenRA.Graphics
// Static constants
static readonly float[] ShadowDiffuse = new float[] { 0, 0, 0 };
static readonly float[] ShadowAmbient = new float[] { 1, 1, 1 };
- static readonly float2 SpritePadding = new float2(2, 2);
+ static readonly float2 SpritePadding = new(2, 2);
static readonly float[] ZeroVector = new float[] { 0, 0, 0, 1 };
static readonly float[] ZVector = new float[] { 0, 0, 1, 1 };
static readonly float[] FlipMtx = Util.ScaleMatrix(1, -1, 1);
@@ -47,9 +47,9 @@ namespace OpenRA.Graphics
readonly Renderer renderer;
readonly IShader shader;
- readonly Dictionary mappedBuffers = new Dictionary();
- readonly Stack> unmappedBuffers = new Stack>();
- readonly List<(Sheet Sheet, Action Func)> doRender = new List<(Sheet, Action)>();
+ readonly Dictionary mappedBuffers = new();
+ readonly Stack> unmappedBuffers = new();
+ readonly List<(Sheet Sheet, Action Func)> doRender = new();
SheetBuilder sheetBuilderForFrame;
bool isInFrame;
diff --git a/OpenRA.Game/Graphics/RgbaColorRenderer.cs b/OpenRA.Game/Graphics/RgbaColorRenderer.cs
index 0b4c63d5d0..3c032e3ae2 100644
--- a/OpenRA.Game/Graphics/RgbaColorRenderer.cs
+++ b/OpenRA.Game/Graphics/RgbaColorRenderer.cs
@@ -18,7 +18,7 @@ namespace OpenRA.Graphics
{
public class RgbaColorRenderer
{
- static readonly float3 Offset = new float3(0.5f, 0.5f, 0f);
+ static readonly float3 Offset = new(0.5f, 0.5f, 0f);
readonly SpriteRenderer parent;
readonly Vertex[] vertices = new Vertex[6];
diff --git a/OpenRA.Game/Graphics/SheetBuilder.cs b/OpenRA.Game/Graphics/SheetBuilder.cs
index 0c99b57cdc..c96bddaf0f 100644
--- a/OpenRA.Game/Graphics/SheetBuilder.cs
+++ b/OpenRA.Game/Graphics/SheetBuilder.cs
@@ -34,7 +34,7 @@ namespace OpenRA.Graphics
public sealed class SheetBuilder : IDisposable
{
public readonly SheetType Type;
- readonly List sheets = new List();
+ readonly List sheets = new();
readonly Func allocateSheet;
readonly int margin;
int rowHeight = 0;
diff --git a/OpenRA.Game/Graphics/SpriteCache.cs b/OpenRA.Game/Graphics/SpriteCache.cs
index dc703d7458..bbe6bd3403 100644
--- a/OpenRA.Game/Graphics/SpriteCache.cs
+++ b/OpenRA.Game/Graphics/SpriteCache.cs
@@ -24,14 +24,14 @@ namespace OpenRA.Graphics
readonly ISpriteLoader[] loaders;
readonly IReadOnlyFileSystem fileSystem;
- readonly Dictionary spriteReservations = new Dictionary();
- readonly Dictionary frameReservations = new Dictionary();
- readonly Dictionary> reservationsByFilename = new Dictionary>();
+ readonly Dictionary spriteReservations = new();
+ readonly Dictionary frameReservations = new();
+ readonly Dictionary> reservationsByFilename = new();
- readonly Dictionary resolvedFrames = new Dictionary();
- readonly Dictionary resolvedSprites = new Dictionary();
+ readonly Dictionary resolvedFrames = new();
+ readonly Dictionary resolvedSprites = new();
- readonly Dictionary missingFiles = new Dictionary();
+ readonly Dictionary missingFiles = new();
int nextReservationToken = 1;
diff --git a/OpenRA.Game/Graphics/TerrainSpriteLayer.cs b/OpenRA.Game/Graphics/TerrainSpriteLayer.cs
index 941285517e..29492f93d1 100644
--- a/OpenRA.Game/Graphics/TerrainSpriteLayer.cs
+++ b/OpenRA.Game/Graphics/TerrainSpriteLayer.cs
@@ -27,7 +27,7 @@ namespace OpenRA.Graphics
readonly IVertexBuffer vertexBuffer;
readonly Vertex[] vertices;
readonly bool[] ignoreTint;
- readonly HashSet dirtyRows = new HashSet();
+ readonly HashSet dirtyRows = new();
readonly int rowStride;
readonly bool restrictToBounds;
diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs
index d51cc90671..f0787c1354 100644
--- a/OpenRA.Game/Graphics/Viewport.cs
+++ b/OpenRA.Game/Graphics/Viewport.cs
@@ -53,7 +53,7 @@ namespace OpenRA.Graphics
public WPos CenterPosition => worldRenderer.ProjectedPosition(CenterLocation);
- public Rectangle Rectangle => new Rectangle(TopLeft, new Size(viewportSize.X, viewportSize.Y));
+ public Rectangle Rectangle => new(TopLeft, new Size(viewportSize.X, viewportSize.Y));
public int2 TopLeft => CenterLocation - viewportSize / 2;
public int2 BottomRight => CenterLocation + viewportSize / 2;
int2 viewportSize;
diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs
index ae385670ee..a83b0ab1d1 100644
--- a/OpenRA.Game/Graphics/WorldRenderer.cs
+++ b/OpenRA.Game/Graphics/WorldRenderer.cs
@@ -31,19 +31,19 @@ namespace OpenRA.Graphics
public event Action PaletteInvalidated = null;
- readonly HashSet onScreenActors = new HashSet();
- readonly HardwarePalette palette = new HardwarePalette();
- readonly Dictionary palettes = new Dictionary();
+ readonly HashSet onScreenActors = new();
+ readonly HardwarePalette palette = new();
+ readonly Dictionary palettes = new();
readonly IRenderTerrain terrainRenderer;
readonly Lazy debugVis;
readonly Func createPaletteReference;
readonly bool enableDepthBuffer;
- readonly List preparedRenderables = new List();
- readonly List preparedOverlayRenderables = new List();
- readonly List preparedAnnotationRenderables = new List();
+ readonly List preparedRenderables = new();
+ readonly List preparedOverlayRenderables = new();
+ readonly List preparedAnnotationRenderables = new();
- readonly List renderablesBuffer = new List();
+ readonly List renderablesBuffer = new();
internal WorldRenderer(ModData modData, World world)
{
diff --git a/OpenRA.Game/HotkeyDefinition.cs b/OpenRA.Game/HotkeyDefinition.cs
index 974564a585..84eef05295 100644
--- a/OpenRA.Game/HotkeyDefinition.cs
+++ b/OpenRA.Game/HotkeyDefinition.cs
@@ -19,8 +19,8 @@ namespace OpenRA
public readonly string Name;
public readonly Hotkey Default = Hotkey.Invalid;
public readonly string Description = "";
- public readonly HashSet Types = new HashSet();
- public readonly HashSet Contexts = new HashSet();
+ public readonly HashSet Types = new();
+ public readonly HashSet Contexts = new();
public readonly bool Readonly = false;
public bool HasDuplicates { get; internal set; }
diff --git a/OpenRA.Game/HotkeyManager.cs b/OpenRA.Game/HotkeyManager.cs
index 770521b2c9..70ca85a545 100644
--- a/OpenRA.Game/HotkeyManager.cs
+++ b/OpenRA.Game/HotkeyManager.cs
@@ -18,8 +18,8 @@ namespace OpenRA
public sealed class HotkeyManager
{
readonly Dictionary settings;
- readonly Dictionary definitions = new Dictionary();
- readonly Dictionary keys = new Dictionary();
+ readonly Dictionary definitions = new();
+ readonly Dictionary keys = new();
public HotkeyManager(IReadOnlyFileSystem fileSystem, Dictionary settings, Manifest manifest)
{
@@ -102,7 +102,7 @@ namespace OpenRA
return null;
}
- public HotkeyReference this[string name] => new HotkeyReference(GetHotkeyReference(name));
+ public HotkeyReference this[string name] => new(GetHotkeyReference(name));
public IEnumerable Definitions => definitions.Values;
}
diff --git a/OpenRA.Game/IUtilityCommand.cs b/OpenRA.Game/IUtilityCommand.cs
index 32667b98a9..6f46f37963 100644
--- a/OpenRA.Game/IUtilityCommand.cs
+++ b/OpenRA.Game/IUtilityCommand.cs
@@ -19,15 +19,13 @@ namespace OpenRA
public class Utility
{
static readonly ConcurrentCache TypeFields =
- new ConcurrentCache(type => type.GetFields());
+ new(type => type.GetFields());
static readonly ConcurrentCache<(MemberInfo Member, Type AttributeType), bool> MemberHasAttribute =
- new ConcurrentCache<(MemberInfo Member, Type AttributeType), bool>(
- x => Attribute.IsDefined(x.Member, x.AttributeType));
+ new(x => Attribute.IsDefined(x.Member, x.AttributeType));
static readonly ConcurrentCache<(MemberInfo Member, Type AttributeType, bool Inherit), object[]> MemberCustomAttributes =
- new ConcurrentCache<(MemberInfo Member, Type AttributeType, bool Inherit), object[]>(
- x => x.Member.GetCustomAttributes(x.AttributeType, x.Inherit));
+ new(x => x.Member.GetCustomAttributes(x.AttributeType, x.Inherit));
public static FieldInfo[] GetFields(Type type)
{
diff --git a/OpenRA.Game/Input/Hotkey.cs b/OpenRA.Game/Input/Hotkey.cs
index 995887847e..f7bf45b742 100644
--- a/OpenRA.Game/Input/Hotkey.cs
+++ b/OpenRA.Game/Input/Hotkey.cs
@@ -15,7 +15,7 @@ namespace OpenRA
{
public readonly struct Hotkey : IEquatable
{
- public static Hotkey Invalid = new Hotkey(Keycode.UNKNOWN, Modifiers.None);
+ public static Hotkey Invalid = new(Keycode.UNKNOWN, Modifiers.None);
public bool IsValid()
{
return Key != Keycode.UNKNOWN;
diff --git a/OpenRA.Game/Input/Keycode.cs b/OpenRA.Game/Input/Keycode.cs
index db42098b1b..1ff8284492 100644
--- a/OpenRA.Game/Input/Keycode.cs
+++ b/OpenRA.Game/Input/Keycode.cs
@@ -256,7 +256,7 @@ namespace OpenRA
public static class KeycodeExts
{
- static readonly Dictionary KeyNames = new Dictionary
+ static readonly Dictionary KeyNames = new()
{
{ Keycode.UNKNOWN, "Undefined" },
{ Keycode.RETURN, "Return" },
diff --git a/OpenRA.Game/MPos.cs b/OpenRA.Game/MPos.cs
index 51f2701942..aa11754b72 100644
--- a/OpenRA.Game/MPos.cs
+++ b/OpenRA.Game/MPos.cs
@@ -19,7 +19,7 @@ namespace OpenRA
public readonly int U, V;
public MPos(int u, int v) { U = u; V = v; }
- public static readonly MPos Zero = new MPos(0, 0);
+ public static readonly MPos Zero = new(0, 0);
public static bool operator ==(MPos me, MPos other) { return me.U == other.U && me.V == other.V; }
public static bool operator !=(MPos me, MPos other) { return !(me == other); }
@@ -71,7 +71,7 @@ namespace OpenRA
public readonly int U, V;
public PPos(int u, int v) { U = u; V = v; }
- public static readonly PPos Zero = new PPos(0, 0);
+ public static readonly PPos Zero = new(0, 0);
public static bool operator ==(PPos me, PPos other) { return me.U == other.U && me.V == other.V; }
public static bool operator !=(PPos me, PPos other) { return !(me == other); }
diff --git a/OpenRA.Game/Manifest.cs b/OpenRA.Game/Manifest.cs
index ae29309b29..01d8106164 100644
--- a/OpenRA.Game/Manifest.cs
+++ b/OpenRA.Game/Manifest.cs
@@ -95,7 +95,7 @@ namespace OpenRA
"RequiresMods", "PackageFormats"
};
- readonly TypeDictionary modules = new TypeDictionary();
+ readonly TypeDictionary modules = new();
readonly Dictionary yaml;
bool customDataLoaded;
diff --git a/OpenRA.Game/Map/CellRegion.cs b/OpenRA.Game/Map/CellRegion.cs
index 5d2433df78..0beeb5b811 100644
--- a/OpenRA.Game/Map/CellRegion.cs
+++ b/OpenRA.Game/Map/CellRegion.cs
@@ -102,7 +102,7 @@ namespace OpenRA
return uv.U >= mapTopLeft.U && uv.U <= mapBottomRight.U && uv.V >= mapTopLeft.V && uv.V <= mapBottomRight.V;
}
- public MapCoordsRegion MapCoords => new MapCoordsRegion(mapTopLeft, mapBottomRight);
+ public MapCoordsRegion MapCoords => new(mapTopLeft, mapBottomRight);
public CellRegionEnumerator GetEnumerator()
{
diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs
index 7daedfec73..c25e7c108c 100644
--- a/OpenRA.Game/Map/Map.cs
+++ b/OpenRA.Game/Map/Map.cs
@@ -198,8 +198,8 @@ namespace OpenRA
public int2 MapSize { get; private set; }
// Player and actor yaml. Public for access by the map importers and lint checks.
- public List PlayerDefinitions = new List();
- public List ActorDefinitions = new List();
+ public List PlayerDefinitions = new();
+ public List ActorDefinitions = new();
// Custom map yaml. Public for access by the map importers and lint checks
public readonly MiniYaml RuleDefinitions;
@@ -210,7 +210,7 @@ namespace OpenRA
public readonly MiniYaml MusicDefinitions;
public readonly MiniYaml NotificationDefinitions;
- public readonly Dictionary ReplacedInvalidTerrainTiles = new Dictionary();
+ public readonly Dictionary ReplacedInvalidTerrainTiles = new();
// Generated data
public readonly MapGrid Grid;
@@ -997,7 +997,7 @@ namespace OpenRA
///
/// RectangularIsometric defines 1024 units along the diagonal axis,
/// giving a half-tile height step of sqrt(2) * 512
- public WDist CellHeightStep => new WDist(Grid.Type == MapGridType.RectangularIsometric ? 724 : 512);
+ public WDist CellHeightStep => new(Grid.Type == MapGridType.RectangularIsometric ? 724 : 512);
public CPos CellContaining(WPos pos)
{
diff --git a/OpenRA.Game/Map/MapCache.cs b/OpenRA.Game/Map/MapCache.cs
index 064cdfec1d..c76de9e229 100644
--- a/OpenRA.Game/Map/MapCache.cs
+++ b/OpenRA.Game/Map/MapCache.cs
@@ -25,9 +25,9 @@ namespace OpenRA
{
public sealed class MapCache : IEnumerable, IDisposable
{
- public static readonly MapPreview UnknownMap = new MapPreview(null, null, MapGridType.Rectangular, null);
+ public static readonly MapPreview UnknownMap = new(null, null, MapGridType.Rectangular, null);
public IReadOnlyDictionary MapLocations => mapLocations;
- readonly Dictionary mapLocations = new Dictionary();
+ readonly Dictionary mapLocations = new();
public bool LoadPreviewImages = true;
readonly Cache previews;
@@ -35,18 +35,18 @@ namespace OpenRA
readonly SheetBuilder sheetBuilder;
Thread previewLoaderThread;
bool previewLoaderThreadShutDown = true;
- readonly object syncRoot = new object();
- readonly Queue generateMinimap = new Queue();
+ readonly object syncRoot = new();
+ readonly Queue generateMinimap = new();
public Dictionary StringPool { get; } = new Dictionary();
- readonly List mapDirectoryTrackers = new List();
+ readonly List mapDirectoryTrackers = new();
///
/// The most recently modified or loaded map at runtime.
///
public string LastModifiedMap { get; private set; } = null;
- readonly Dictionary mapUpdates = new Dictionary();
+ readonly Dictionary mapUpdates = new();
string lastLoadedLastModifiedMap;
diff --git a/OpenRA.Game/Map/MapDirectoryTracker.cs b/OpenRA.Game/Map/MapDirectoryTracker.cs
index 0137f1ed96..ea579960dc 100644
--- a/OpenRA.Game/Map/MapDirectoryTracker.cs
+++ b/OpenRA.Game/Map/MapDirectoryTracker.cs
@@ -25,7 +25,7 @@ namespace OpenRA
readonly MapClassification classification;
enum MapAction { Add, Delete, Update }
- readonly Dictionary mapActionQueue = new Dictionary();
+ readonly Dictionary mapActionQueue = new();
bool dirty = false;
diff --git a/OpenRA.Game/Map/MapGrid.cs b/OpenRA.Game/Map/MapGrid.cs
index 5af9ff279d..24e38090be 100644
--- a/OpenRA.Game/Map/MapGrid.cs
+++ b/OpenRA.Game/Map/MapGrid.cs
@@ -106,7 +106,7 @@ namespace OpenRA
public class MapGrid : IGlobalModData
{
public readonly MapGridType Type = MapGridType.Rectangular;
- public readonly Size TileSize = new Size(24, 24);
+ public readonly Size TileSize = new(24, 24);
public readonly byte MaximumTerrainHeight = 0;
public readonly SubCell DefaultSubCell = (SubCell)byte.MaxValue;
diff --git a/OpenRA.Game/Map/ProjectedCellRegion.cs b/OpenRA.Game/Map/ProjectedCellRegion.cs
index e484e4b984..8978fda7fe 100644
--- a/OpenRA.Game/Map/ProjectedCellRegion.cs
+++ b/OpenRA.Game/Map/ProjectedCellRegion.cs
@@ -59,7 +59,7 @@ namespace OpenRA
/// this does not validate whether individual map cells are actually
/// projected inside the region.
///
- public MapCoordsRegion CandidateMapCoords => new MapCoordsRegion(mapTopLeft, mapBottomRight);
+ public MapCoordsRegion CandidateMapCoords => new(mapTopLeft, mapBottomRight);
public ProjectedCellRegionEnumerator GetEnumerator()
{
diff --git a/OpenRA.Game/Map/TerrainInfo.cs b/OpenRA.Game/Map/TerrainInfo.cs
index 3081e9a327..e1ccc343b6 100644
--- a/OpenRA.Game/Map/TerrainInfo.cs
+++ b/OpenRA.Game/Map/TerrainInfo.cs
@@ -60,7 +60,7 @@ namespace OpenRA
{
public readonly string Type;
public readonly BitSet TargetTypes;
- public readonly HashSet AcceptsSmudgeType = new HashSet();
+ public readonly HashSet AcceptsSmudgeType = new();
public readonly Color Color;
public readonly bool RestrictPlayerColor = false;
diff --git a/OpenRA.Game/Network/Connection.cs b/OpenRA.Game/Network/Connection.cs
index 67fc236955..d37429b346 100644
--- a/OpenRA.Game/Network/Connection.cs
+++ b/OpenRA.Game/Network/Connection.cs
@@ -42,9 +42,9 @@ namespace OpenRA.Network
public sealed class EchoConnection : IConnection
{
const int LocalClientId = 1;
- readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sync = new Queue<(int, int, ulong)>();
- readonly Queue<(int Frame, OrderPacket Orders)> orders = new Queue<(int, OrderPacket)>();
- readonly Queue immediateOrders = new Queue();
+ readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sync = new();
+ readonly Queue<(int Frame, OrderPacket Orders)> orders = new();
+ readonly Queue immediateOrders = new();
bool disposed;
int IConnection.LocalClientId => LocalClientId;
@@ -100,12 +100,12 @@ namespace OpenRA.Network
{
public readonly ConnectionTarget Target;
internal ReplayRecorder Recorder { get; private set; }
- readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sentSync = new Queue<(int, int, ulong)>();
- readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> queuedSyncPackets = new Queue<(int, int, ulong)>();
+ readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sentSync = new();
+ readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> queuedSyncPackets = new();
- readonly Queue<(int Frame, OrderPacket Orders)> sentOrders = new Queue<(int, OrderPacket)>();
- readonly Queue sentImmediateOrders = new Queue();
- readonly ConcurrentQueue<(int FromClient, byte[] Data)> receivedPackets = new ConcurrentQueue<(int, byte[])>();
+ readonly Queue<(int Frame, OrderPacket Orders)> sentOrders = new();
+ readonly Queue sentImmediateOrders = new();
+ readonly ConcurrentQueue<(int FromClient, byte[] Data)> receivedPackets = new();
TcpClient tcp;
volatile ConnectionState connectionState = ConnectionState.Connecting;
volatile int clientId;
diff --git a/OpenRA.Game/Network/GameSave.cs b/OpenRA.Game/Network/GameSave.cs
index 6873052ee7..016cb91128 100644
--- a/OpenRA.Game/Network/GameSave.cs
+++ b/OpenRA.Game/Network/GameSave.cs
@@ -81,7 +81,7 @@ namespace OpenRA.Network
public const int MetadataMarker = -1;
public const int TraitDataMarker = -3;
- readonly MemoryStream ordersStream = new MemoryStream();
+ readonly MemoryStream ordersStream = new();
// Loaded from file and updated during gameplay
public int LastOrdersFrame { get; private set; }
@@ -92,7 +92,7 @@ namespace OpenRA.Network
public Session.Global GlobalSettings { get; private set; }
public Dictionary Slots { get; private set; }
public Dictionary SlotClients { get; private set; }
- public Dictionary TraitData = new Dictionary();
+ public Dictionary TraitData = new();
// Set on game start
int[] clientsBySlotIndex = Array.Empty();
diff --git a/OpenRA.Game/Network/Nat.cs b/OpenRA.Game/Network/Nat.cs
index 610ba1eaf9..8358b05cc3 100644
--- a/OpenRA.Game/Network/Nat.cs
+++ b/OpenRA.Game/Network/Nat.cs
@@ -39,7 +39,7 @@ namespace OpenRA.Network
initialized = true;
}
- static readonly SemaphoreSlim Locker = new SemaphoreSlim(1, 1);
+ static readonly SemaphoreSlim Locker = new(1, 1);
static async void DeviceFound(object sender, DeviceEventArgs args)
{
diff --git a/OpenRA.Game/Network/OrderIO.cs b/OpenRA.Game/Network/OrderIO.cs
index ac4ad7ca11..dee56ab733 100644
--- a/OpenRA.Game/Network/OrderIO.cs
+++ b/OpenRA.Game/Network/OrderIO.cs
@@ -78,7 +78,7 @@ namespace OpenRA.Network
public static class OrderIO
{
- static readonly OrderPacket NoOrders = new OrderPacket(Array.Empty());
+ static readonly OrderPacket NoOrders = new(Array.Empty());
public static byte[] SerializeSync((int Frame, int SyncHash, ulong DefeatState) data)
{
diff --git a/OpenRA.Game/Network/OrderManager.cs b/OpenRA.Game/Network/OrderManager.cs
index aa7687f6e2..0bce45df07 100644
--- a/OpenRA.Game/Network/OrderManager.cs
+++ b/OpenRA.Game/Network/OrderManager.cs
@@ -23,10 +23,10 @@ namespace OpenRA.Network
const OrderPacket ClientDisconnected = null;
readonly SyncReport syncReport;
- readonly Dictionary> pendingOrders = new Dictionary>();
- readonly Dictionary syncForFrame = new Dictionary();
+ readonly Dictionary> pendingOrders = new();
+ readonly Dictionary syncForFrame = new();
- public Session LobbyInfo = new Session();
+ public Session LobbyInfo = new();
/// Null when watching a replay.
public Session.Client LocalClient => LobbyInfo.ClientWithIndex(Connection.LocalClientId);
@@ -47,11 +47,11 @@ namespace OpenRA.Network
internal int GameSaveLastFrame = -1;
internal int GameSaveLastSyncFrame = -1;
- readonly List localOrders = new List();
- readonly List localImmediateOrders = new List();
+ readonly List localOrders = new();
+ readonly List localImmediateOrders = new();
- readonly List processClientOrders = new List();
- readonly List processClientsToRemove = new List();
+ readonly List processClientOrders = new();
+ readonly List processClientsToRemove = new();
bool disposed;
bool generateSyncReport = false;
diff --git a/OpenRA.Game/Network/ReplayConnection.cs b/OpenRA.Game/Network/ReplayConnection.cs
index 228323d592..38d0b20eb5 100644
--- a/OpenRA.Game/Network/ReplayConnection.cs
+++ b/OpenRA.Game/Network/ReplayConnection.cs
@@ -24,8 +24,8 @@ namespace OpenRA.Network
public (int ClientId, byte[] Packet)[] Packets;
}
- readonly Queue chunks = new Queue();
- readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sync = new Queue<(int, int, ulong)>();
+ readonly Queue chunks = new();
+ readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sync = new();
readonly int orderLatency;
public readonly int TickCount;
diff --git a/OpenRA.Game/Network/ReplayRecorder.cs b/OpenRA.Game/Network/ReplayRecorder.cs
index 5ab26daafb..b8949ea5cc 100644
--- a/OpenRA.Game/Network/ReplayRecorder.cs
+++ b/OpenRA.Game/Network/ReplayRecorder.cs
@@ -24,7 +24,7 @@ namespace OpenRA.Network
public ReplayMetadata Metadata;
BinaryWriter writer;
readonly Func chooseFilename;
- MemoryStream preStartBuffer = new MemoryStream();
+ MemoryStream preStartBuffer = new();
static bool IsGameStart(byte[] data)
{
diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs
index 551b1c91b9..8e30a6b265 100644
--- a/OpenRA.Game/Network/Session.cs
+++ b/OpenRA.Game/Network/Session.cs
@@ -20,14 +20,14 @@ namespace OpenRA.Network
{
public class Session
{
- public List Clients = new List();
+ public List Clients = new();
// Keyed by the PlayerReference id that the slot corresponds to
- public Dictionary Slots = new Dictionary();
+ public Dictionary Slots = new();
- public HashSet DisabledSpawnPoints = new HashSet();
+ public HashSet DisabledSpawnPoints = new();
- public Global GlobalSettings = new Global();
+ public Global GlobalSettings = new();
public static string AnonymizeIP(IPAddress ip)
{
@@ -221,7 +221,7 @@ namespace OpenRA.Network
public int NetFrameInterval = 3;
[FieldLoader.Ignore]
- public Dictionary LobbyOptions = new Dictionary();
+ public Dictionary LobbyOptions = new();
public static Global Deserialize(MiniYaml data)
{
diff --git a/OpenRA.Game/Network/SyncReport.cs b/OpenRA.Game/Network/SyncReport.cs
index eb7be5f125..4f0520fdcb 100644
--- a/OpenRA.Game/Network/SyncReport.cs
+++ b/OpenRA.Game/Network/SyncReport.cs
@@ -22,7 +22,7 @@ namespace OpenRA.Network
class SyncReport
{
const int NumSyncReports = 7;
- static readonly Cache TypeInfoCache = new Cache(t => new TypeInfo(t));
+ static readonly Cache TypeInfoCache = new(t => new TypeInfo(t));
readonly OrderManager orderManager;
@@ -166,9 +166,9 @@ namespace OpenRA.Network
public int Frame;
public int SyncedRandom;
public int TotalCount;
- public readonly List Traits = new List();
- public readonly List Effects = new List();
- public readonly List Orders = new List();
+ public readonly List Traits = new();
+ public readonly List Effects = new();
+ public readonly List Orders = new();
}
struct TraitReport
@@ -278,7 +278,7 @@ namespace OpenRA.Network
///
struct Values
{
- static readonly object Sentinel = new object();
+ static readonly object Sentinel = new();
object item1OrArray;
object item2OrSentinel;
diff --git a/OpenRA.Game/ObjectCreator.cs b/OpenRA.Game/ObjectCreator.cs
index 9c7d4e3d56..a4d9ef2124 100644
--- a/OpenRA.Game/ObjectCreator.cs
+++ b/OpenRA.Game/ObjectCreator.cs
@@ -22,7 +22,7 @@ namespace OpenRA
{
// .NET does not support unloading assemblies, so mod libraries will leak across mod changes.
// This tracks the assemblies that have been loaded since game start so that we don't load multiple copies
- static readonly Dictionary ResolvedAssemblies = new Dictionary();
+ static readonly Dictionary ResolvedAssemblies = new();
readonly Cache typeCache;
readonly Cache ctorCache;
diff --git a/OpenRA.Game/Primitives/ActionQueue.cs b/OpenRA.Game/Primitives/ActionQueue.cs
index 5778c9cc6e..2f9337de49 100644
--- a/OpenRA.Game/Primitives/ActionQueue.cs
+++ b/OpenRA.Game/Primitives/ActionQueue.cs
@@ -19,7 +19,7 @@ namespace OpenRA.Primitives
///
public class ActionQueue
{
- readonly List actions = new List();
+ readonly List actions = new();
public void Add(Action a, long desiredTime)
{
diff --git a/OpenRA.Game/Primitives/BitSet.cs b/OpenRA.Game/Primitives/BitSet.cs
index 2be8a97b17..bd7d2ff77e 100644
--- a/OpenRA.Game/Primitives/BitSet.cs
+++ b/OpenRA.Game/Primitives/BitSet.cs
@@ -18,7 +18,7 @@ namespace OpenRA.Primitives
{
static class BitSetAllocator where T : class
{
- static readonly Cache Bits = new Cache(Allocate);
+ static readonly Cache Bits = new(Allocate);
static BitSetIndex nextBits = 1;
static BitSetIndex Allocate(string value)
diff --git a/OpenRA.Game/Primitives/LongBitSet.cs b/OpenRA.Game/Primitives/LongBitSet.cs
index a1fe2a55b7..8395c1bb40 100644
--- a/OpenRA.Game/Primitives/LongBitSet.cs
+++ b/OpenRA.Game/Primitives/LongBitSet.cs
@@ -17,7 +17,7 @@ namespace OpenRA.Primitives
{
static class LongBitSetAllocator where T : class
{
- static readonly Cache Bits = new Cache(Allocate);
+ static readonly Cache Bits = new(Allocate);
static long nextBits = 1;
static long Allocate(string value)
diff --git a/OpenRA.Game/Primitives/Polygon.cs b/OpenRA.Game/Primitives/Polygon.cs
index fc39d889fe..9a370c1994 100644
--- a/OpenRA.Game/Primitives/Polygon.cs
+++ b/OpenRA.Game/Primitives/Polygon.cs
@@ -16,7 +16,7 @@ namespace OpenRA.Primitives
{
public readonly struct Polygon
{
- public static readonly Polygon Empty = new Polygon(Rectangle.Empty);
+ public static readonly Polygon Empty = new(Rectangle.Empty);
public readonly Rectangle BoundingRect;
public readonly int2[] Vertices;
diff --git a/OpenRA.Game/Primitives/ReadOnlyAdapterStream.cs b/OpenRA.Game/Primitives/ReadOnlyAdapterStream.cs
index 85144f6eaa..c8f2f39817 100644
--- a/OpenRA.Game/Primitives/ReadOnlyAdapterStream.cs
+++ b/OpenRA.Game/Primitives/ReadOnlyAdapterStream.cs
@@ -21,7 +21,7 @@ namespace OpenRA.Primitives
///
public abstract class ReadOnlyAdapterStream : Stream
{
- readonly Queue data = new Queue(1024);
+ readonly Queue data = new(1024);
readonly Stream baseStream;
bool baseStreamEmpty;
diff --git a/OpenRA.Game/Primitives/Rectangle.cs b/OpenRA.Game/Primitives/Rectangle.cs
index 37eec0e5bf..884c6eb69b 100644
--- a/OpenRA.Game/Primitives/Rectangle.cs
+++ b/OpenRA.Game/Primitives/Rectangle.cs
@@ -63,13 +63,13 @@ namespace OpenRA.Primitives
public int Top => Y;
public int Bottom => Y + Height;
public bool IsEmpty => X == 0 && Y == 0 && Width == 0 && Height == 0;
- public int2 Location => new int2(X, Y);
- public Size Size => new Size(Width, Height);
+ public int2 Location => new(X, Y);
+ public Size Size => new(Width, Height);
public int2 TopLeft => Location;
- public int2 TopRight => new int2(X + Width, Y);
- public int2 BottomLeft => new int2(X, Y + Height);
- public int2 BottomRight => new int2(X + Width, Y + Height);
+ public int2 TopRight => new(X + Width, Y);
+ public int2 BottomLeft => new(X, Y + Height);
+ public int2 BottomRight => new(X + Width, Y + Height);
public bool Contains(int x, int y)
{
diff --git a/OpenRA.Game/Primitives/SpatiallyPartitioned.cs b/OpenRA.Game/Primitives/SpatiallyPartitioned.cs
index 92a17a05d2..6c414da5ed 100644
--- a/OpenRA.Game/Primitives/SpatiallyPartitioned.cs
+++ b/OpenRA.Game/Primitives/SpatiallyPartitioned.cs
@@ -18,7 +18,7 @@ namespace OpenRA.Primitives
{
readonly int rows, cols, binSize;
readonly Dictionary[] itemBoundsBins;
- readonly Dictionary itemBounds = new Dictionary();
+ readonly Dictionary itemBounds = new();
readonly Action, T, Rectangle> addItem = (bin, actor, bounds) => bin.Add(actor, bounds);
readonly Action, T, Rectangle> removeItem = (bin, actor, bounds) => bin.Remove(actor);
diff --git a/OpenRA.Game/Primitives/TypeDictionary.cs b/OpenRA.Game/Primitives/TypeDictionary.cs
index b7e62d2f1a..f200fc45b9 100644
--- a/OpenRA.Game/Primitives/TypeDictionary.cs
+++ b/OpenRA.Game/Primitives/TypeDictionary.cs
@@ -19,7 +19,7 @@ namespace OpenRA.Primitives
public class TypeDictionary : IEnumerable
{
static readonly Func> CreateList = type => new List