Fix IDE0055
This rule no longer appears to be buggy, so enforce it. Some of the automated fixes are adjusted in order to improve the result. #pragma directives have no option to control indentation, so remove them where possible.
This commit is contained in:
committed by
Pavel Penev
parent
60cbf79c9b
commit
360f24f609
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
|
||||
|
||||
try
|
||||
{
|
||||
/* var signature = */ s.ReadASCII(4);
|
||||
s.ReadASCII(4); // signature
|
||||
|
||||
// Total archive size.
|
||||
s.ReadUInt32();
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
|
||||
{
|
||||
s.Seek(offset, SeekOrigin.Begin);
|
||||
var numFiles = s.ReadUInt16();
|
||||
/*uint dataSize = */s.ReadUInt32();
|
||||
s.ReadUInt32(); // dataSize
|
||||
|
||||
var items = new List<PackageEntry>();
|
||||
for (var i = 0; i < numFiles; i++)
|
||||
|
||||
@@ -69,38 +69,38 @@ namespace OpenRA.Mods.Cnc.FileSystem
|
||||
switch (type)
|
||||
{
|
||||
case PackageHashType.Classic:
|
||||
{
|
||||
for (var p = 0; p < padding; p++)
|
||||
upperPaddedName[paddedLength - 1 - p] = '\0';
|
||||
{
|
||||
for (var p = 0; p < padding; p++)
|
||||
upperPaddedName[paddedLength - 1 - p] = '\0';
|
||||
|
||||
var asciiBytes = paddedLength < 64 ? stackalloc byte[paddedLength] : new byte[paddedLength];
|
||||
Encoding.ASCII.GetBytes(upperPaddedName, asciiBytes);
|
||||
var asciiBytes = paddedLength < 64 ? stackalloc byte[paddedLength] : new byte[paddedLength];
|
||||
Encoding.ASCII.GetBytes(upperPaddedName, asciiBytes);
|
||||
|
||||
var data = MemoryMarshal.Cast<byte, uint>(asciiBytes);
|
||||
var result = 0u;
|
||||
foreach (var next in data)
|
||||
result = ((result << 1) | (result >> 31)) + next;
|
||||
var data = MemoryMarshal.Cast<byte, uint>(asciiBytes);
|
||||
var result = 0u;
|
||||
foreach (var next in data)
|
||||
result = ((result << 1) | (result >> 31)) + next;
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
case PackageHashType.CRC32:
|
||||
{
|
||||
var length = name.Length;
|
||||
var lengthRoundedDownToFour = length / 4 * 4;
|
||||
if (length != lengthRoundedDownToFour)
|
||||
{
|
||||
var length = name.Length;
|
||||
var lengthRoundedDownToFour = length / 4 * 4;
|
||||
if (length != lengthRoundedDownToFour)
|
||||
{
|
||||
upperPaddedName[length] = (char)(length - lengthRoundedDownToFour);
|
||||
for (var p = 1; p < padding; p++)
|
||||
upperPaddedName[length + p] = upperPaddedName[lengthRoundedDownToFour];
|
||||
}
|
||||
|
||||
var asciiBytes = paddedLength < 64 ? stackalloc byte[paddedLength] : new byte[paddedLength];
|
||||
Encoding.ASCII.GetBytes(upperPaddedName, asciiBytes);
|
||||
|
||||
return CRC32.Calculate(asciiBytes);
|
||||
upperPaddedName[length] = (char)(length - lengthRoundedDownToFour);
|
||||
for (var p = 1; p < padding; p++)
|
||||
upperPaddedName[length + p] = upperPaddedName[lengthRoundedDownToFour];
|
||||
}
|
||||
|
||||
var asciiBytes = paddedLength < 64 ? stackalloc byte[paddedLength] : new byte[paddedLength];
|
||||
Encoding.ASCII.GetBytes(upperPaddedName, asciiBytes);
|
||||
|
||||
return CRC32.Calculate(asciiBytes);
|
||||
}
|
||||
|
||||
default: throw new NotImplementedException($"Unknown hash type `{type}`");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user