Replace F extension with string interpolation

This commit is contained in:
teinarss
2021-04-24 17:46:24 +02:00
committed by reaperrr
parent 1385aca783
commit 10676be377
300 changed files with 752 additions and 799 deletions

View File

@@ -156,7 +156,7 @@ namespace OpenRA.Network
this.target = target;
new Thread(NetworkConnectionConnect)
{
Name = "{0} (connect to {1})".F(GetType().Name, target),
Name = $"{GetType().Name} (connect to {target})",
IsBackground = true
}.Start();
}
@@ -189,11 +189,11 @@ namespace OpenRA.Network
catch (Exception ex)
{
errorMessage = "Failed to connect";
Log.Write("client", "Failed to connect to {0}: {1}".F(endpoint, ex.Message));
Log.Write("client", $"Failed to connect to {endpoint}: {ex.Message}");
}
})
{
Name = "{0} (connect to {1})".F(GetType().Name, endpoint),
Name = $"{GetType().Name} (connect to {endpoint})",
IsBackground = true
}.Start();
}
@@ -212,7 +212,7 @@ namespace OpenRA.Network
new Thread(NetworkConnectionReceive)
{
Name = "{0} (receive from {1})".F(GetType().Name, tcp.Client.RemoteEndPoint),
Name = $"{GetType().Name} (receive from {tcp.Client.RemoteEndPoint})",
IsBackground = true
}.Start();
}
@@ -235,9 +235,7 @@ namespace OpenRA.Network
var handshakeProtocol = reader.ReadInt32();
if (handshakeProtocol != ProtocolVersion.Handshake)
throw new InvalidOperationException(
"Handshake protocol version mismatch. Server={0} Client={1}"
.F(handshakeProtocol, ProtocolVersion.Handshake));
throw new InvalidOperationException($"Handshake protocol version mismatch. Server={handshakeProtocol} Client={ProtocolVersion.Handshake}");
clientId = reader.ReadInt32();
connectionState = ConnectionState.Connected;
@@ -255,7 +253,7 @@ namespace OpenRA.Network
catch (Exception ex)
{
errorMessage = "Connection failed";
Log.Write("client", "Connection to {0} failed: {1}".F(endpoint, ex.Message));
Log.Write("client", $"Connection to {endpoint} failed: {ex.Message}");
}
finally
{

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Network
public override string ToString()
{
return endpoints
.Select(e => "{0}:{1}".F(e.Host, e.Port))
.Select(e => $"{e.Host}:{e.Port}")
.JoinWith("/");
}
}

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Network
public override string ToString()
{
return "ClientId: {0} {1}".F(Client, Order);
return $"ClientId: {Client} {Order}";
}
}

View File

@@ -71,7 +71,7 @@ namespace OpenRA.Network
public MiniYamlNode Serialize(string key)
{
return new MiniYamlNode("SlotClient@{0}".F(key), FieldSaver.Save(this));
return new MiniYamlNode($"SlotClient@{key}", FieldSaver.Save(this));
}
}
@@ -195,7 +195,7 @@ namespace OpenRA.Network
{
if (data.Length != Order.SyncHashOrderLength)
{
Log.Write("debug", "Dropped sync order with length {0}. Expected length {1}.".F(data.Length, Order.SyncHashOrderLength));
Log.Write("debug", $"Dropped sync order with length {data.Length}. Expected length {Order.SyncHashOrderLength}.");
return;
}

View File

@@ -135,7 +135,7 @@ namespace OpenRA.Network
/// <summary>The list of spawnpoints that are disabled for this game</summary>
public readonly int[] DisabledSpawnPoints = { };
public string ModLabel => "{0} ({1})".F(ModTitle, Version);
public string ModLabel => $"{ModTitle} ({Version})";
static object LoadClients(MiniYaml yaml)
{
@@ -200,9 +200,9 @@ namespace OpenRA.Network
.FirstOrDefault(m => m.Id == Mod);
if (guessMod != null)
ModTitle = "{0}".F(guessMod.Title);
ModTitle = guessMod.Title;
else
ModTitle = "Unknown mod: {0}".F(Mod);
ModTitle = $"Unknown mod: {Mod}";
}
}

View File

@@ -405,7 +405,7 @@ namespace OpenRA
}
default:
throw new InvalidDataException("Cannot serialize order type {0}".F(Type));
throw new InvalidDataException($"Cannot serialize order type {Type}");
}
return ret.ToArray();
@@ -413,10 +413,8 @@ namespace OpenRA
public override string ToString()
{
return ("OrderString: \"{0}\" \n\t Type: \"{1}\". \n\t Subject: \"{2}\". \n\t Target: \"{3}\"." +
"\n\t TargetString: \"{4}\".\n\t IsImmediate: {5}.\n\t Player(PlayerName): {6}\n").F(
OrderString, Type, Subject, Target, TargetString, IsImmediate,
Player != null ? Player.PlayerName : null);
return $"OrderString: \"{OrderString}\" \n\t Type: \"{Type}\". \n\t Subject: \"{Subject}\". \n\t Target: \"{Target}\"." +
$"\n\t TargetString: \"{TargetString}\".\n\t IsImmediate: {IsImmediate}.\n\t Player(PlayerName): {Player?.PlayerName}\n";
}
}
}

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Network
void OutOfSync(int frame)
{
syncReport.DumpSyncReport(frame, frameData.OrdersForFrame(World, frame));
throw new InvalidOperationException("Out of sync in frame {0}.\n Compare syncreport.log with other players.".F(frame));
throw new InvalidOperationException($"Out of sync in frame {frame}.\n Compare syncreport.log with other players.");
}
public void StartGame()
@@ -126,7 +126,7 @@ namespace OpenRA.Network
{
if (packet.Length != 4 + Order.SyncHashOrderLength)
{
Log.Write("debug", "Dropped sync order with length {0}. Expected length {1}.".F(packet.Length, 4 + Order.SyncHashOrderLength));
Log.Write("debug", $"Dropped sync order with length {packet.Length}. Expected length {4 + Order.SyncHashOrderLength}.");
return;
}

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Network
var id = -1;
while (file == null)
{
var fullFilename = Path.Combine(dir, id < 0 ? "{0}.orarep".F(filename) : "{0}-{1}.orarep".F(filename, id));
var fullFilename = Path.Combine(dir, id < 0 ? $"{filename}.orarep" : $"{filename}-{id}.orarep");
id++;
try
{
@@ -65,8 +65,7 @@ namespace OpenRA.Network
catch (IOException ex)
{
if (id > CreateReplayFileMaxRetryCount)
throw new ArgumentException(
"Error creating replay file \"{0}.orarep\"".F(filename), ex);
throw new ArgumentException($"Error creating replay file \"{filename}.orarep\"", ex);
}
}

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Network
{
// Follow convention used by Google Analytics: remove last octet
var b = ip.GetAddressBytes();
return "{0}.{1}.{2}.*".F(b[0], b[1], b[2]);
return $"{b[0]}.{b[1]}.{b[2]}.*";
}
return null;
@@ -82,11 +82,11 @@ namespace OpenRA.Network
}
catch (YamlException)
{
throw new YamlException("Session deserialized invalid MiniYaml:\n{0}".F(data));
throw new YamlException($"Session deserialized invalid MiniYaml:\n{data}");
}
catch (InvalidOperationException)
{
throw new YamlException("Session deserialized invalid MiniYaml:\n{0}".F(data));
throw new YamlException($"Session deserialized invalid MiniYaml:\n{data}");
}
}
@@ -159,7 +159,7 @@ namespace OpenRA.Network
public MiniYamlNode Serialize()
{
return new MiniYamlNode("Client@{0}".F(Index), FieldSaver.Save(this));
return new MiniYamlNode($"Client@{Index}", FieldSaver.Save(this));
}
}
@@ -182,7 +182,7 @@ namespace OpenRA.Network
public MiniYamlNode Serialize()
{
return new MiniYamlNode("ClientPing@{0}".F(Index), FieldSaver.Save(this));
return new MiniYamlNode($"ClientPing@{Index}", FieldSaver.Save(this));
}
}
@@ -206,7 +206,7 @@ namespace OpenRA.Network
public MiniYamlNode Serialize()
{
return new MiniYamlNode("Slot@{0}".F(PlayerReference), FieldSaver.Save(this));
return new MiniYamlNode($"Slot@{PlayerReference}", FieldSaver.Save(this));
}
}

View File

@@ -117,12 +117,12 @@ namespace OpenRA.Network
Log.Write("sync", "Synced Traits:");
foreach (var a in r.Traits)
{
Log.Write("sync", "\t {0} {1} {2} {3} ({4})".F(a.ActorID, a.Type, a.Owner, a.Trait, a.Hash));
Log.Write("sync", $"\t {a.ActorID} {a.Type} {a.Owner} {a.Trait} ({a.Hash})");
var nvp = a.NamesValues;
for (int i = 0; i < nvp.Names.Length; i++)
if (nvp.Values[i] != null)
Log.Write("sync", "\t\t {0}: {1}".F(nvp.Names[i], nvp.Values[i]));
Log.Write("sync", $"\t\t {nvp.Names[i]}: {nvp.Values[i]}");
}
Log.Write("sync", "Synced Effects:");
@@ -133,7 +133,7 @@ namespace OpenRA.Network
var nvp = e.NamesValues;
for (int i = 0; i < nvp.Names.Length; i++)
if (nvp.Values[i] != null)
Log.Write("sync", "\t\t {0}: {1}".F(nvp.Names[i], nvp.Values[i]));
Log.Write("sync", $"\t\t {nvp.Names[i]}: {nvp.Values[i]}");
}
Log.Write("sync", "Orders Issued:");

View File

@@ -170,7 +170,7 @@ namespace OpenRA.Network
if (orderManager.World.Paused != pause && world != null && world.LobbyInfo.NonBotClients.Count() > 1)
{
var pausetext = "The game is {0} by {1}".F(pause ? "paused" : "un-paused", client.Name);
var pausetext = $"The game is {(pause ? "paused" : "un-paused")} by {client.Name}";
Game.AddSystemLine(pausetext);
}