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

@@ -54,8 +54,8 @@ namespace OpenRA.Mods.Cnc.FileSystem
entries = ParseHeader(s, isCncMix ? 0 : 4, out dataStart);
index = ParseIndex(entries.ToDictionaryWithConflictLog(x => x.Hash,
"{0} ({1} format, Encrypted: {2}, DataStart: {3})".F(filename, isCncMix ? "C&C" : "RA/TS/RA2", isEncrypted, dataStart),
null, x => "(offs={0}, len={1})".F(x.Offset, x.Length)), allPossibleFilenames);
$"{filename} ({(isCncMix ? "C&C" : "RA/TS/RA2")} format, Encrypted: {isEncrypted}, DataStart: {dataStart})",
null, x => $"(offs={x.Offset}, len={x.Length})"), allPossibleFilenames);
}
catch (Exception)
{
@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
var unknown = entries.Count - bestIndex.Count;
if (unknown > 0)
Log.Write("debug", "{0}: failed to resolve filenames for {1} unknown hashes".F(Name, unknown));
Log.Write("debug", $"{Name}: failed to resolve filenames for {unknown} unknown hashes");
return bestIndex;
}
@@ -165,7 +165,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
throw new ArgumentOutOfRangeException(nameof(count), "Non-negative number required.");
if (offset + (count * 2) > s.Length)
throw new ArgumentException("Bytes to read {0} and offset {1} greater than stream length {2}.".F(count * 2, offset, s.Length));
throw new ArgumentException($"Bytes to read {count * 2} and offset {offset} greater than stream length {s.Length}.");
s.Seek(offset, SeekOrigin.Begin);

View File

@@ -50,9 +50,9 @@ namespace OpenRA.Mods.Cnc.FileSystem
public override string ToString()
{
if (names.TryGetValue(Hash, out var filename))
return "{0} - offset 0x{1:x8} - length 0x{2:x8}".F(filename, Offset, Length);
return $"{filename} - offset 0x{Offset:x8} - length 0x{Length:x8}";
else
return "0x{0:x8} - offset 0x{1:x8} - length 0x{2:x8}".F(Hash, Offset, Length);
return $"0x{Hash:x8} - offset 0x{Offset:x8} - length 0x{Length:x8}";
}
public static uint HashFilename(string name, PackageHashType type)
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
return CRC32.Calculate(Encoding.ASCII.GetBytes(name));
}
default: throw new NotImplementedException("Unknown hash type `{0}`".F(type));
default: throw new NotImplementedException($"Unknown hash type `{type}`");
}
}