Fix CA1825 warnings on empty array initialisation.
This commit is contained in:
committed by
abcdefg30
parent
727084c5fc
commit
07815143f1
@@ -322,7 +322,7 @@ namespace OpenRA
|
||||
// Special case handling of Game.Mod argument: if it matches a real filesystem path
|
||||
// then we use this to override the mod search path, and replace it with the mod id
|
||||
var modID = args.GetValue("Game.Mod", null);
|
||||
var explicitModPaths = new string[0];
|
||||
var explicitModPaths = Array.Empty<string>();
|
||||
if (modID != null && (File.Exists(modID) || Directory.Exists(modID)))
|
||||
{
|
||||
explicitModPaths = new[] { modID };
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.GameRules
|
||||
public class WarheadArgs
|
||||
{
|
||||
public WeaponInfo Weapon;
|
||||
public int[] DamageModifiers = { };
|
||||
public int[] DamageModifiers = Array.Empty<int>();
|
||||
public WPos? Source;
|
||||
public WRot ImpactOrientation;
|
||||
public WPos ImpactPosition;
|
||||
|
||||
@@ -80,10 +80,10 @@ namespace OpenRA
|
||||
public readonly IReadOnlyDictionary<string, string> MapFolders;
|
||||
public readonly MiniYaml LoadScreen;
|
||||
|
||||
public readonly string[] SoundFormats = { };
|
||||
public readonly string[] SpriteFormats = { };
|
||||
public readonly string[] PackageFormats = { };
|
||||
public readonly string[] VideoFormats = { };
|
||||
public readonly string[] SoundFormats = Array.Empty<string>();
|
||||
public readonly string[] SpriteFormats = Array.Empty<string>();
|
||||
public readonly string[] PackageFormats = Array.Empty<string>();
|
||||
public readonly string[] VideoFormats = Array.Empty<string>();
|
||||
|
||||
readonly string[] reservedModuleNames =
|
||||
{
|
||||
@@ -208,7 +208,7 @@ namespace OpenRA
|
||||
static string[] YamlList(Dictionary<string, MiniYaml> yaml, string key, bool parsePaths = false)
|
||||
{
|
||||
if (!yaml.ContainsKey(key))
|
||||
return new string[] { };
|
||||
return Array.Empty<string>();
|
||||
|
||||
return yaml[key].ToDictionary().Keys.ToArray();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA
|
||||
|
||||
public ModData(Manifest mod, InstalledMods mods, bool useLoadScreen = false)
|
||||
{
|
||||
Languages = new string[0];
|
||||
Languages = Array.Empty<string>();
|
||||
|
||||
// Take a local copy of the manifest
|
||||
Manifest = new Manifest(mod.Id, mod.Package);
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace OpenRA.Network
|
||||
// Loaded from file and updated during gameplay
|
||||
public int LastOrdersFrame { get; private set; }
|
||||
public int LastSyncFrame { get; private set; }
|
||||
byte[] lastSyncPacket = new byte[0];
|
||||
byte[] lastSyncPacket = Array.Empty<byte>();
|
||||
|
||||
// Loaded from file or set on game start
|
||||
public Session.Global GlobalSettings { get; private set; }
|
||||
@@ -95,7 +95,7 @@ namespace OpenRA.Network
|
||||
public Dictionary<int, MiniYaml> TraitData = new Dictionary<int, MiniYaml>();
|
||||
|
||||
// Set on game start
|
||||
int[] clientsBySlotIndex = { };
|
||||
int[] clientsBySlotIndex = Array.Empty<int>();
|
||||
int firstBotSlotIndex = -1;
|
||||
|
||||
public GameSave()
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace OpenRA.Network
|
||||
public readonly GameClient[] Clients;
|
||||
|
||||
/// <summary>The list of spawnpoints that are disabled for this game</summary>
|
||||
public readonly int[] DisabledSpawnPoints = { };
|
||||
public readonly int[] DisabledSpawnPoints = Array.Empty<int>();
|
||||
|
||||
public string ModLabel => $"{ModTitle} ({Version})";
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace OpenRA
|
||||
|
||||
public object CreateBasic(Type type)
|
||||
{
|
||||
return type.GetConstructor(new Type[0]).Invoke(new object[0]);
|
||||
return type.GetConstructor(Array.Empty<Type>()).Invoke(Array.Empty<object>());
|
||||
}
|
||||
|
||||
public object CreateUsingArgs(ConstructorInfo ctor, Dictionary<string, object> args)
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Traits
|
||||
return info.SelectionPriority(modifiers) - (long)pixelDistance << 16;
|
||||
}
|
||||
|
||||
static readonly Actor[] NoActors = { };
|
||||
static readonly Actor[] NoActors = Array.Empty<Actor>();
|
||||
|
||||
public static IEnumerable<Actor> SubsetWithHighestSelectionPriority(this IEnumerable<Actor> actors, Modifiers modifiers)
|
||||
{
|
||||
|
||||
@@ -66,16 +66,16 @@ namespace OpenRA
|
||||
public string Map = null;
|
||||
|
||||
[Desc("Takes a comma separated list of IP addresses that are not allowed to join.")]
|
||||
public string[] Ban = { };
|
||||
public string[] Ban = Array.Empty<string>();
|
||||
|
||||
[Desc("For dedicated servers only, allow anonymous clients to join.")]
|
||||
public bool RequireAuthentication = false;
|
||||
|
||||
[Desc("For dedicated servers only, if non-empty, only allow authenticated players with these profile IDs to join.")]
|
||||
public int[] ProfileIDWhitelist = { };
|
||||
public int[] ProfileIDWhitelist = Array.Empty<int>();
|
||||
|
||||
[Desc("For dedicated servers only, if non-empty, always reject players with these user IDs from joining.")]
|
||||
public int[] ProfileIDBlacklist = { };
|
||||
public int[] ProfileIDBlacklist = Array.Empty<int>();
|
||||
|
||||
[Desc("For dedicated servers only, controls whether a game can be started with just one human player in the lobby.")]
|
||||
public bool EnableSingleplayer = false;
|
||||
@@ -227,7 +227,7 @@ namespace OpenRA
|
||||
public string Name = "Commander";
|
||||
public Color Color = Color.FromArgb(200, 32, 32);
|
||||
public string LastServer = "localhost:1234";
|
||||
public Color[] CustomColors = { };
|
||||
public Color[] CustomColors = Array.Empty<Color>();
|
||||
public string Language = "en";
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Traits
|
||||
public enum TargetType : byte { Invalid, Actor, Terrain, FrozenActor }
|
||||
public readonly struct Target
|
||||
{
|
||||
public static readonly Target[] None = { };
|
||||
public static readonly Target[] None = Array.Empty<Target>();
|
||||
public static readonly Target Invalid = default(Target);
|
||||
|
||||
readonly TargetType type;
|
||||
@@ -175,7 +175,7 @@ namespace OpenRA.Traits
|
||||
}
|
||||
|
||||
// Positions available to target for range checks
|
||||
static readonly WPos[] NoPositions = { };
|
||||
static readonly WPos[] NoPositions = Array.Empty<WPos>();
|
||||
public IEnumerable<WPos> Positions
|
||||
{
|
||||
get
|
||||
|
||||
Reference in New Issue
Block a user