Fix CA1825 warnings on empty array initialisation.

This commit is contained in:
Matthias Mailänder
2021-12-05 13:26:40 +01:00
committed by abcdefg30
parent 727084c5fc
commit 07815143f1
85 changed files with 171 additions and 117 deletions

View File

@@ -270,7 +270,7 @@ namespace OpenRA
// Take the SHA1
if (streams.Count == 0)
return CryptoUtil.SHA1Hash(new byte[0]);
return CryptoUtil.SHA1Hash(Array.Empty<byte>());
var merged = streams[0];
for (var i = 1; i < streams.Count; i++)
@@ -471,7 +471,7 @@ namespace OpenRA
foreach (var cell in AllCells)
{
var uv = cell.ToMPos(Grid.Type);
cellProjection[uv] = new PPos[0];
cellProjection[uv] = Array.Empty<PPos>();
inverseCellProjection[uv] = new List<MPos>(1);
}
@@ -973,7 +973,7 @@ namespace OpenRA
return (PPos)CellContaining(projectedPos).ToMPos(Grid.Type);
}
static readonly PPos[] NoProjectedCells = { };
static readonly PPos[] NoProjectedCells = Array.Empty<PPos>();
public PPos[] ProjectedCellsCovering(MPos uv)
{
if (!initializedCellProjection)

View File

@@ -54,7 +54,7 @@ namespace OpenRA
public readonly string[] categories;
public readonly int players;
public readonly Rectangle bounds;
public readonly short[] spawnpoints = { };
public readonly short[] spawnpoints = Array.Empty<short>();
public readonly MapGridType map_grid_type;
public readonly string minimap;
public readonly bool downloading;
@@ -160,7 +160,7 @@ namespace OpenRA
}
}
static readonly CPos[] NoSpawns = { };
static readonly CPos[] NoSpawns = Array.Empty<CPos>();
readonly MapCache cache;
readonly ModData modData;

View File

@@ -9,6 +9,7 @@
*/
#endregion
using System;
using OpenRA.Primitives;
namespace OpenRA
@@ -53,8 +54,8 @@ namespace OpenRA
public bool LockHandicap = false;
public int Handicap = 0;
public string[] Allies = { };
public string[] Enemies = { };
public string[] Allies = Array.Empty<string>();
public string[] Enemies = Array.Empty<string>();
public PlayerReference() { }
public PlayerReference(MiniYaml my) { FieldLoader.Load(this, my); }