Fix IDE0090

This commit is contained in:
RoosterDragon
2023-04-05 19:34:12 +01:00
committed by Pavel Penev
parent 164abfdae1
commit 8a285f9b19
385 changed files with 790 additions and 794 deletions

View File

@@ -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<OrderPacket> immediateOrders = new Queue<OrderPacket>();
readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sync = new();
readonly Queue<(int Frame, OrderPacket Orders)> orders = new();
readonly Queue<OrderPacket> 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<OrderPacket> sentImmediateOrders = new Queue<OrderPacket>();
readonly ConcurrentQueue<(int FromClient, byte[] Data)> receivedPackets = new ConcurrentQueue<(int, byte[])>();
readonly Queue<(int Frame, OrderPacket Orders)> sentOrders = new();
readonly Queue<OrderPacket> sentImmediateOrders = new();
readonly ConcurrentQueue<(int FromClient, byte[] Data)> receivedPackets = new();
TcpClient tcp;
volatile ConnectionState connectionState = ConnectionState.Connecting;
volatile int clientId;

View File

@@ -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<string, Session.Slot> Slots { get; private set; }
public Dictionary<string, SlotClient> SlotClients { get; private set; }
public Dictionary<int, MiniYaml> TraitData = new Dictionary<int, MiniYaml>();
public Dictionary<int, MiniYaml> TraitData = new();
// Set on game start
int[] clientsBySlotIndex = Array.Empty<int>();

View File

@@ -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)
{

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Network
public static class OrderIO
{
static readonly OrderPacket NoOrders = new OrderPacket(Array.Empty<Order>());
static readonly OrderPacket NoOrders = new(Array.Empty<Order>());
public static byte[] SerializeSync((int Frame, int SyncHash, ulong DefeatState) data)
{

View File

@@ -23,10 +23,10 @@ namespace OpenRA.Network
const OrderPacket ClientDisconnected = null;
readonly SyncReport syncReport;
readonly Dictionary<int, Queue<(int Frame, OrderPacket Orders)>> pendingOrders = new Dictionary<int, Queue<(int, OrderPacket)>>();
readonly Dictionary<int, (int SyncHash, ulong DefeatState)> syncForFrame = new Dictionary<int, (int, ulong)>();
readonly Dictionary<int, Queue<(int Frame, OrderPacket Orders)>> pendingOrders = new();
readonly Dictionary<int, (int SyncHash, ulong DefeatState)> syncForFrame = new();
public Session LobbyInfo = new Session();
public Session LobbyInfo = new();
/// <summary>Null when watching a replay.</summary>
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<Order> localOrders = new List<Order>();
readonly List<Order> localImmediateOrders = new List<Order>();
readonly List<Order> localOrders = new();
readonly List<Order> localImmediateOrders = new();
readonly List<ClientOrder> processClientOrders = new List<ClientOrder>();
readonly List<int> processClientsToRemove = new List<int>();
readonly List<ClientOrder> processClientOrders = new();
readonly List<int> processClientsToRemove = new();
bool disposed;
bool generateSyncReport = false;

View File

@@ -24,8 +24,8 @@ namespace OpenRA.Network
public (int ClientId, byte[] Packet)[] Packets;
}
readonly Queue<Chunk> chunks = new Queue<Chunk>();
readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sync = new Queue<(int, int, ulong)>();
readonly Queue<Chunk> chunks = new();
readonly Queue<(int Frame, int SyncHash, ulong DefeatState)> sync = new();
readonly int orderLatency;
public readonly int TickCount;

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Network
public ReplayMetadata Metadata;
BinaryWriter writer;
readonly Func<string> chooseFilename;
MemoryStream preStartBuffer = new MemoryStream();
MemoryStream preStartBuffer = new();
static bool IsGameStart(byte[] data)
{

View File

@@ -20,14 +20,14 @@ namespace OpenRA.Network
{
public class Session
{
public List<Client> Clients = new List<Client>();
public List<Client> Clients = new();
// Keyed by the PlayerReference id that the slot corresponds to
public Dictionary<string, Slot> Slots = new Dictionary<string, Slot>();
public Dictionary<string, Slot> Slots = new();
public HashSet<int> DisabledSpawnPoints = new HashSet<int>();
public HashSet<int> 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<string, LobbyOptionState> LobbyOptions = new Dictionary<string, LobbyOptionState>();
public Dictionary<string, LobbyOptionState> LobbyOptions = new();
public static Global Deserialize(MiniYaml data)
{

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Network
class SyncReport
{
const int NumSyncReports = 7;
static readonly Cache<Type, TypeInfo> TypeInfoCache = new Cache<Type, TypeInfo>(t => new TypeInfo(t));
static readonly Cache<Type, TypeInfo> 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<TraitReport> Traits = new List<TraitReport>();
public readonly List<EffectReport> Effects = new List<EffectReport>();
public readonly List<OrderManager.ClientOrder> Orders = new List<OrderManager.ClientOrder>();
public readonly List<TraitReport> Traits = new();
public readonly List<EffectReport> Effects = new();
public readonly List<OrderManager.ClientOrder> Orders = new();
}
struct TraitReport
@@ -278,7 +278,7 @@ namespace OpenRA.Network
/// </summary>
struct Values
{
static readonly object Sentinel = new object();
static readonly object Sentinel = new();
object item1OrArray;
object item2OrSentinel;