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

@@ -66,7 +66,7 @@ namespace OpenRA
{
var init = GetOrDefault<T>(info);
if (init == null)
throw new InvalidOperationException("TypeDictionary does not contain instance of type `{0}`".F(typeof(T)));
throw new InvalidOperationException($"TypeDictionary does not contain instance of type `{typeof(T)}`");
return init;
}

View File

@@ -42,7 +42,7 @@ namespace OpenRA
{
var init = LoadInit(i.Key, i.Value);
if (init is ISingleInstanceInit && dict.Contains(init.GetType()))
throw new InvalidDataException("Duplicate initializer '{0}'".F(init.GetType().Name));
throw new InvalidDataException($"Duplicate initializer '{init.GetType().Name}'");
dict.Add(init);
}
@@ -68,7 +68,7 @@ namespace OpenRA
var initInstance = initName.Split(ActorInfo.TraitInstanceSeparator);
var type = Game.ModData.ObjectCreator.FindType(initInstance[0] + "Init");
if (type == null)
throw new InvalidDataException("Unknown initializer type '{0}Init'".F(initInstance[0]));
throw new InvalidDataException($"Unknown initializer type '{initInstance[0]}Init'");
var init = (ActorInit)FormatterServices.GetUninitializedObject(type);
if (initInstance.Length > 1)
@@ -76,7 +76,7 @@ namespace OpenRA
var loader = type.GetMethod("Initialize", new[] { typeof(MiniYaml) });
if (loader == null)
throw new InvalidDataException("{0}Init does not define a yaml-assignable type.".F(initInstance[0]));
throw new InvalidDataException($"{initInstance[0]}Init does not define a yaml-assignable type.");
loader.Invoke(init, new[] { initYaml });
return init;
@@ -119,7 +119,7 @@ namespace OpenRA
public void Add(ActorInit init)
{
if (init is ISingleInstanceInit && InitDict.Contains(init.GetType()))
throw new InvalidDataException("Duplicate initializer '{0}'".F(init.GetType().Name));
throw new InvalidDataException($"Duplicate initializer '{init.GetType().Name}'");
InitDict.Add(init);
}
@@ -162,7 +162,7 @@ namespace OpenRA
{
var init = GetOrDefault<T>(info);
if (init == null)
throw new InvalidOperationException("TypeDictionary does not contain instance of type `{0}`".F(typeof(T)));
throw new InvalidOperationException($"TypeDictionary does not contain instance of type `{typeof(T)}`");
return init;
}

View File

@@ -53,7 +53,7 @@ namespace OpenRA
ResourcesOffset = s.ReadUInt32();
}
else
throw new InvalidDataException("Unknown binary map format '{0}'".F(Format));
throw new InvalidDataException($"Unknown binary map format '{Format}'");
}
}
@@ -100,7 +100,7 @@ namespace OpenRA
if (node == null)
{
if (required)
throw new YamlException("Required field `{0}` not found in map.yaml".F(key));
throw new YamlException($"Required field `{key}` not found in map.yaml");
return;
}
@@ -258,7 +258,7 @@ namespace OpenRA
var contents = package.Contents.ToList();
foreach (var required in requiredFiles)
if (!contents.Contains(required))
throw new FileNotFoundException("Required file {0} not present in this map".F(required));
throw new FileNotFoundException($"Required file {required} not present in this map");
var streams = new List<Stream>();
try
@@ -326,18 +326,18 @@ namespace OpenRA
Package = package;
if (!Package.Contains("map.yaml") || !Package.Contains("map.bin"))
throw new InvalidDataException("Not a valid map\n File: {0}".F(package.Name));
throw new InvalidDataException($"Not a valid map\n File: {package.Name}");
var yaml = new MiniYaml(null, MiniYaml.FromStream(Package.GetStream("map.yaml"), package.Name));
foreach (var field in YamlFields)
field.Deserialize(this, yaml.Nodes);
if (MapFormat != SupportedMapFormat)
throw new InvalidDataException("Map format {0} is not supported.\n File: {1}".F(MapFormat, package.Name));
throw new InvalidDataException($"Map format {MapFormat} is not supported.\n File: {package.Name}");
PlayerDefinitions = MiniYaml.NodesOrEmpty(yaml, "Players");
if (PlayerDefinitions.Count > 64)
throw new InvalidDataException("Maps must not define more than 64 players.\n File: {0}".F(package.Name));
throw new InvalidDataException($"Maps must not define more than 64 players.\n File: {package.Name}");
ActorDefinitions = MiniYaml.NodesOrEmpty(yaml, "Actors");
@@ -1251,7 +1251,7 @@ namespace OpenRA
if (maxRange >= Grid.TilesByDistance.Length)
throw new ArgumentOutOfRangeException(nameof(maxRange),
"The requested range ({0}) cannot exceed the value of MaximumTileSearchRange ({1})".F(maxRange, Grid.MaximumTileSearchRange));
$"The requested range ({maxRange}) cannot exceed the value of MaximumTileSearchRange ({Grid.MaximumTileSearchRange})");
for (var i = minRange; i <= maxRange; i++)
{

View File

@@ -50,7 +50,7 @@ namespace OpenRA
Name = "Creeps",
Faction = firstFaction,
NonCombatant = true,
Enemies = Exts.MakeArray(playerCount, i => "Multi{0}".F(i))
Enemies = Exts.MakeArray(playerCount, i => $"Multi{i}")
}
}
};
@@ -59,7 +59,7 @@ namespace OpenRA
{
var p = new PlayerReference
{
Name = "Multi{0}".F(index),
Name = $"Multi{index}",
Faction = "Random",
Playable = true,
Enemies = new[] { "Creeps" }
@@ -70,7 +70,7 @@ namespace OpenRA
public List<MiniYamlNode> ToMiniYaml()
{
return Players.Select(p => new MiniYamlNode("PlayerReference@{0}".F(p.Key),
return Players.Select(p => new MiniYamlNode($"PlayerReference@{p.Key}",
FieldSaver.SaveDifferences(p.Value, new PlayerReference()))).ToList();
}
}

View File

@@ -324,7 +324,7 @@ namespace OpenRA
{
var format = FieldLoader.GetValue<int>("MapFormat", temp.Value);
if (format != Map.SupportedMapFormat)
throw new InvalidDataException("Map format {0} is not supported.".F(format));
throw new InvalidDataException($"Map format {format} is not supported.");
}
if (yaml.TryGetValue("Title", out temp))