Use collection expressions

This commit is contained in:
Alex Barney 2023-12-09 18:48:56 -07:00
parent f19b219e84
commit 03bf56f26c
33 changed files with 257 additions and 257 deletions

View file

@ -387,8 +387,8 @@ public static class ResultCodeGen
sb.AppendLine("internal partial class ResultNameResolver");
sb.AppendLineAndIncrease("{");
sb.AppendLine("private static ReadOnlySpan<byte> ArchiveData => new byte[]");
sb.AppendLineAndIncrease("{");
sb.AppendLine("private static ReadOnlySpan<byte> ArchiveData =>");
sb.AppendLineAndIncrease("[");
for (int i = 0; i < data.Length; i++)
{
@ -403,7 +403,7 @@ public static class ResultCodeGen
}
sb.AppendLine();
sb.DecreaseAndAppendLine("};");
sb.DecreaseAndAppendLine("];");
sb.DecreaseAndAppend("}");
return sb.ToString();
@ -457,8 +457,8 @@ public static class ResultCodeGen
public static string PrintEnum(ResultSet resultSet)
{
var sb = new StringBuilder();
int[] printUnknownResultsForModules = { 2 };
int[] skipModules = { 428 };
int[] printUnknownResultsForModules = [2];
int[] skipModules = [428];
foreach (ModuleInfo module in resultSet.Modules.Where(x => !skipModules.Contains(x.Id)))
{

View file

@ -61,16 +61,16 @@ public static class KeysCodeGen
private static void BuildArray(IndentingStringBuilder sb, string name, ReadOnlySpan<byte> data)
{
sb.AppendSpacerLine();
sb.Append($"private static ReadOnlySpan<byte> {name} => new byte[]");
sb.Append($"private static ReadOnlySpan<byte> {name} =>");
if (data.IsZeros())
{
sb.AppendLine(" { };");
sb.AppendLine(" [];");
return;
}
sb.AppendLine();
sb.AppendLineAndIncrease("{");
sb.AppendLineAndIncrease("[");
for (int i = 0; i < data.Length; i++)
{
@ -85,7 +85,7 @@ public static class KeysCodeGen
}
sb.AppendLine();
sb.DecreaseAndAppendLine("};");
sb.DecreaseAndAppendLine("];");
}
private static KeySet CreateKeySet()
@ -147,13 +147,13 @@ public static class KeysCodeGen
return keySet;
}
private static ReadOnlySpan<byte> StandardPublicExponent => new byte[]
{
private static ReadOnlySpan<byte> StandardPublicExponent =>
[
0x00, 0x01, 0x00, 0x01
};
];
private static ReadOnlySpan<byte> BetaNca0Modulus => new byte[]
{
private static ReadOnlySpan<byte> BetaNca0Modulus =>
[
0xAD, 0x58, 0xEE, 0x97, 0xF9, 0x47, 0x90, 0x7D, 0xF9, 0x29, 0x5F, 0x1F, 0x39, 0x68, 0xEE, 0x49,
0x4C, 0x1E, 0x8D, 0x84, 0x91, 0x31, 0x5D, 0xE5, 0x96, 0x27, 0xB2, 0xB3, 0x59, 0x7B, 0xDE, 0xFD,
0xB7, 0xEB, 0x40, 0xA1, 0xE7, 0xEB, 0xDC, 0x60, 0xD0, 0x3D, 0xC5, 0x50, 0x92, 0xAD, 0x3D, 0xC4,
@ -170,10 +170,10 @@ public static class KeysCodeGen
0xB4, 0x4F, 0xD7, 0x5B, 0x4D, 0x7B, 0x43, 0xB0, 0x3A, 0x9A, 0x60, 0x22, 0x47, 0x91, 0x78, 0xC7,
0x10, 0x64, 0xE0, 0x2C, 0x69, 0xD1, 0x66, 0x3C, 0x42, 0x2E, 0xEF, 0x19, 0x21, 0x89, 0x8E, 0xE1,
0xB0, 0xB4, 0xD0, 0x17, 0xA1, 0x0F, 0x73, 0x98, 0x5A, 0xF6, 0xEE, 0xC0, 0x2F, 0x9E, 0xCE, 0xC5
};
];
private static ReadOnlySpan<byte> BetaNca0Exponent => new byte[]
{
private static ReadOnlySpan<byte> BetaNca0Exponent =>
[
0x3C, 0x66, 0x37, 0x44, 0x26, 0xAC, 0x63, 0xD1, 0x30, 0xE6, 0xD4, 0x68, 0xF9, 0xC4, 0xF0, 0xFA,
0x03, 0x16, 0xC6, 0x32, 0x81, 0xB0, 0x94, 0xC9, 0xF1, 0x26, 0xC5, 0xE2, 0x2D, 0xF4, 0xB6, 0x3E,
0xEB, 0x3D, 0x82, 0x18, 0xA7, 0xC9, 0x8B, 0xD1, 0x03, 0xDD, 0xF2, 0x09, 0x60, 0x02, 0x12, 0xFA,
@ -190,10 +190,10 @@ public static class KeysCodeGen
0xEF, 0xCB, 0x2F, 0x2C, 0x90, 0xE6, 0x4B, 0x2D, 0x94, 0x62, 0xE8, 0xEC, 0x54, 0x7B, 0x94, 0xB7,
0xFB, 0x72, 0x05, 0xFB, 0xB3, 0x23, 0xCA, 0xF8, 0xD4, 0x5C, 0xF6, 0xAC, 0x7D, 0xEC, 0x47, 0xC6,
0xD3, 0x22, 0x5D, 0x7C, 0x15, 0xDD, 0x48, 0xE9, 0xBF, 0xA8, 0x99, 0x33, 0x02, 0x79, 0xD3, 0x65
};
];
private static ReadOnlySpan<byte> NcaHdrFixedKeyModulus0Prod => new byte[]
{
private static ReadOnlySpan<byte> NcaHdrFixedKeyModulus0Prod =>
[
0xBF, 0xBE, 0x40, 0x6C, 0xF4, 0xA7, 0x80, 0xE9, 0xF0, 0x7D, 0x0C, 0x99, 0x61, 0x1D, 0x77, 0x2F,
0x96, 0xBC, 0x4B, 0x9E, 0x58, 0x38, 0x1B, 0x03, 0xAB, 0xB1, 0x75, 0x49, 0x9F, 0x2B, 0x4D, 0x58,
0x34, 0xB0, 0x05, 0xA3, 0x75, 0x22, 0xBE, 0x1A, 0x3F, 0x03, 0x73, 0xAC, 0x70, 0x68, 0xD1, 0x16,
@ -210,10 +210,10 @@ public static class KeysCodeGen
0x02, 0x79, 0xEA, 0xD2, 0xA7, 0xAF, 0x35, 0x28, 0x32, 0x1C, 0x7B, 0xE6, 0x2F, 0x1A, 0xAA, 0x40,
0x7E, 0x32, 0x8C, 0x27, 0x42, 0xFE, 0x82, 0x78, 0xEC, 0x0D, 0xEB, 0xE6, 0x83, 0x4B, 0x6D, 0x81,
0x04, 0x40, 0x1A, 0x9E, 0x9A, 0x67, 0xF6, 0x72, 0x29, 0xFA, 0x04, 0xF0, 0x9D, 0xE4, 0xF4, 0x03
};
];
private static ReadOnlySpan<byte> NcaHdrFixedKeyModulus1Prod => new byte[]
{
private static ReadOnlySpan<byte> NcaHdrFixedKeyModulus1Prod =>
[
0xAD, 0xE3, 0xE1, 0xFA, 0x04, 0x35, 0xE5, 0xB6, 0xDD, 0x49, 0xEA, 0x89, 0x29, 0xB1, 0xFF, 0xB6,
0x43, 0xDF, 0xCA, 0x96, 0xA0, 0x4A, 0x13, 0xDF, 0x43, 0xD9, 0x94, 0x97, 0x96, 0x43, 0x65, 0x48,
0x70, 0x58, 0x33, 0xA2, 0x7D, 0x35, 0x7B, 0x96, 0x74, 0x5E, 0x0B, 0x5C, 0x32, 0x18, 0x14, 0x24,
@ -230,10 +230,10 @@ public static class KeysCodeGen
0x3A, 0xFE, 0xEA, 0x61, 0x84, 0x5B, 0x7D, 0x4B, 0x23, 0x12, 0x0B, 0x83, 0x12, 0xF2, 0x22, 0x6B,
0xB9, 0x22, 0x96, 0x4B, 0x26, 0x0B, 0x63, 0x5E, 0x96, 0x57, 0x52, 0xA3, 0x67, 0x64, 0x22, 0xCA,
0xD0, 0x56, 0x3E, 0x74, 0xB5, 0x98, 0x1F, 0x0D, 0xF8, 0xB3, 0x34, 0xE6, 0x98, 0x68, 0x5A, 0xAD
};
];
private static ReadOnlySpan<byte> AcidFixedKeyModulus0Prod => new byte[]
{
private static ReadOnlySpan<byte> AcidFixedKeyModulus0Prod =>
[
0xDD, 0xC8, 0xDD, 0xF2, 0x4E, 0x6D, 0xF0, 0xCA, 0x9E, 0xC7, 0x5D, 0xC7, 0x7B, 0xAD, 0xFE, 0x7D,
0x23, 0x89, 0x69, 0xB6, 0xF2, 0x06, 0xA2, 0x02, 0x88, 0xE1, 0x55, 0x91, 0xAB, 0xCB, 0x4D, 0x50,
0x2E, 0xFC, 0x9D, 0x94, 0x76, 0xD6, 0x4C, 0xD8, 0xFF, 0x10, 0xFA, 0x5E, 0x93, 0x0A, 0xB4, 0x57,
@ -250,10 +250,10 @@ public static class KeysCodeGen
0xB7, 0x88, 0x4A, 0x14, 0x84, 0x80, 0x33, 0x3C, 0x9D, 0x44, 0xB7, 0x3F, 0x4C, 0xE1, 0x75, 0xEA,
0x37, 0xEA, 0xE8, 0x1E, 0x7C, 0x77, 0xB7, 0xC6, 0x1A, 0xA2, 0xF0, 0x9F, 0x10, 0x61, 0xCD, 0x7B,
0x5B, 0x32, 0x4C, 0x37, 0xEF, 0xB1, 0x71, 0x68, 0x53, 0x0A, 0xED, 0x51, 0x7D, 0x35, 0x22, 0xFD
};
];
private static ReadOnlySpan<byte> AcidFixedKeyModulus1Prod => new byte[]
{
private static ReadOnlySpan<byte> AcidFixedKeyModulus1Prod =>
[
0xE7, 0xAA, 0x25, 0xC8, 0x01, 0xA5, 0x14, 0x6B, 0x01, 0x60, 0x3E, 0xD9, 0x96, 0x5A, 0xBF, 0x90,
0xAC, 0xA7, 0xFD, 0x9B, 0x5B, 0xBD, 0x8A, 0x26, 0xB0, 0xCB, 0x20, 0x28, 0x9A, 0x72, 0x12, 0xF5,
0x20, 0x65, 0xB3, 0xB9, 0x84, 0x58, 0x1F, 0x27, 0xBC, 0x7C, 0xA2, 0xC9, 0x9E, 0x18, 0x95, 0xCF,
@ -270,10 +270,10 @@ public static class KeysCodeGen
0x30, 0x9A, 0x1A, 0x0F, 0xEA, 0xA7, 0x66, 0x55, 0xF7, 0xCB, 0x28, 0xE2, 0xBB, 0x99, 0xE4, 0x83,
0xC3, 0x43, 0x03, 0xEE, 0xDC, 0x1F, 0x02, 0x23, 0xDD, 0xD1, 0x2D, 0x39, 0xA4, 0x65, 0x75, 0x03,
0xEF, 0x37, 0x9C, 0x06, 0xD6, 0xFA, 0xA1, 0x15, 0xF0, 0xDB, 0x17, 0x47, 0x26, 0x4F, 0x49, 0x03
};
];
private static ReadOnlySpan<byte> Package2FixedKeyModulusProd => new byte[]
{
private static ReadOnlySpan<byte> Package2FixedKeyModulusProd =>
[
0x8D, 0x13, 0xA7, 0x77, 0x6A, 0xE5, 0xDC, 0xC0, 0x3B, 0x25, 0xD0, 0x58, 0xE4, 0x20, 0x69, 0x59,
0x55, 0x4B, 0xAB, 0x70, 0x40, 0x08, 0x28, 0x07, 0xA8, 0xA7, 0xFD, 0x0F, 0x31, 0x2E, 0x11, 0xFE,
0x47, 0xA0, 0xF9, 0x9D, 0xDF, 0x80, 0xDB, 0x86, 0x5A, 0x27, 0x89, 0xCD, 0x97, 0x6C, 0x85, 0xC5,
@ -290,10 +290,10 @@ public static class KeysCodeGen
0x97, 0x3F, 0x0F, 0x35, 0x39, 0x53, 0xFB, 0xFA, 0xCD, 0xAB, 0xA8, 0x7A, 0x62, 0x9A, 0x3F, 0xF2,
0x09, 0x27, 0x96, 0x3F, 0x07, 0x9A, 0x91, 0xF7, 0x16, 0xBF, 0xC6, 0x3A, 0x82, 0x5A, 0x4B, 0xCF,
0x49, 0x50, 0x95, 0x8C, 0x55, 0x80, 0x7E, 0x39, 0xB1, 0x48, 0x05, 0x1E, 0x21, 0xC7, 0x24, 0x4F
};
];
private static ReadOnlySpan<byte> NcaHdrFixedKeyModulus0Dev => new byte[]
{
private static ReadOnlySpan<byte> NcaHdrFixedKeyModulus0Dev =>
[
0xD8, 0xF1, 0x18, 0xEF, 0x32, 0x72, 0x4C, 0xA7, 0x47, 0x4C, 0xB9, 0xEA, 0xB3, 0x04, 0xA8, 0xA4,
0xAC, 0x99, 0x08, 0x08, 0x04, 0xBF, 0x68, 0x57, 0xB8, 0x43, 0x94, 0x2B, 0xC7, 0xB9, 0x66, 0x49,
0x85, 0xE5, 0x8A, 0x9B, 0xC1, 0x00, 0x9A, 0x6A, 0x8D, 0xD0, 0xEF, 0xCE, 0xFF, 0x86, 0xC8, 0x5C,
@ -310,10 +310,10 @@ public static class KeysCodeGen
0x15, 0xD9, 0xFB, 0x2F, 0x50, 0xF0, 0x9D, 0x1D, 0x52, 0x4C, 0x1C, 0x4D, 0x8D, 0xAE, 0x85, 0x1E,
0xEA, 0x7F, 0x86, 0xF3, 0x0B, 0x7B, 0x87, 0x81, 0x98, 0x23, 0x80, 0x63, 0x4F, 0x2F, 0xB0, 0x62,
0xCC, 0x6E, 0xD2, 0x46, 0x13, 0x65, 0x2B, 0xD6, 0x44, 0x33, 0x59, 0xB5, 0x8F, 0xB9, 0x4A, 0xA9
};
];
private static ReadOnlySpan<byte> NcaHdrFixedKeyModulus1Dev => new byte[]
{
private static ReadOnlySpan<byte> NcaHdrFixedKeyModulus1Dev =>
[
0x9A, 0xBC, 0x88, 0xBD, 0x0A, 0xBE, 0xD7, 0x0C, 0x9B, 0x42, 0x75, 0x65, 0x38, 0x5E, 0xD1, 0x01,
0xCD, 0x12, 0xAE, 0xEA, 0xE9, 0x4B, 0xDB, 0xB4, 0x5E, 0x36, 0x10, 0x96, 0xDA, 0x3D, 0x2E, 0x66,
0xD3, 0x99, 0x13, 0x8A, 0xBE, 0x67, 0x41, 0xC8, 0x93, 0xD9, 0x3E, 0x42, 0xCE, 0x34, 0xCE, 0x96,
@ -330,10 +330,10 @@ public static class KeysCodeGen
0x6A, 0x09, 0xF0, 0xE9, 0x73, 0xA3, 0xBE, 0x10, 0x06, 0x02, 0xE9, 0xFB, 0x85, 0xFA, 0x5F, 0x01,
0xAC, 0x60, 0xE0, 0xED, 0x7D, 0xB9, 0x49, 0xA8, 0x9E, 0x98, 0x7D, 0x91, 0x40, 0x05, 0xCF, 0xF9,
0x1A, 0xFC, 0x40, 0x22, 0xA8, 0x96, 0x5B, 0xB0, 0xDC, 0x7A, 0xF5, 0xB7, 0xE9, 0x91, 0x4C, 0x49
};
];
private static ReadOnlySpan<byte> AcidFixedKeyModulus0Dev => new byte[]
{
private static ReadOnlySpan<byte> AcidFixedKeyModulus0Dev =>
[
0xD6, 0x34, 0xA5, 0x78, 0x6C, 0x68, 0xCE, 0x5A, 0xC2, 0x37, 0x17, 0xF3, 0x82, 0x45, 0xC6, 0x89,
0xE1, 0x2D, 0x06, 0x67, 0xBF, 0xB4, 0x06, 0x19, 0x55, 0x6B, 0x27, 0x66, 0x0C, 0xA4, 0xB5, 0x87,
0x81, 0x25, 0xF4, 0x30, 0xBC, 0x53, 0x08, 0x68, 0xA2, 0x48, 0x49, 0x8C, 0x3F, 0x38, 0x40, 0x9C,
@ -350,10 +350,10 @@ public static class KeysCodeGen
0xB5, 0x99, 0xA5, 0x9F, 0x49, 0xF2, 0xD7, 0x58, 0xFA, 0xF9, 0xC0, 0x25, 0x7D, 0xD6, 0xCB, 0xF3,
0xD8, 0x6C, 0xA2, 0x69, 0x91, 0x68, 0x73, 0xB1, 0x94, 0x6F, 0xA3, 0xF3, 0xB9, 0x7D, 0xF8, 0xE0,
0x72, 0x9E, 0x93, 0x7B, 0x7A, 0xA2, 0x57, 0x60, 0xB7, 0x5B, 0xA9, 0x84, 0xAE, 0x64, 0x88, 0x69
};
];
private static ReadOnlySpan<byte> AcidFixedKeyModulus1Dev => new byte[]
{
private static ReadOnlySpan<byte> AcidFixedKeyModulus1Dev =>
[
0xBC, 0xA5, 0x6A, 0x7E, 0xEA, 0x38, 0x34, 0x62, 0xA6, 0x10, 0x18, 0x3C, 0xE1, 0x63, 0x7B, 0xF0,
0xD3, 0x08, 0x8C, 0xF5, 0xC5, 0xC4, 0xC7, 0x93, 0xE9, 0xD9, 0xE6, 0x32, 0xF3, 0xA0, 0xF6, 0x6E,
0x8A, 0x98, 0x76, 0x47, 0x33, 0x47, 0x65, 0x02, 0x70, 0xDC, 0x86, 0x5F, 0x3D, 0x61, 0x5A, 0x70,
@ -370,10 +370,10 @@ public static class KeysCodeGen
0x6C, 0x32, 0xA7, 0xDF, 0x85, 0x1C, 0x03, 0xC3, 0x6D, 0xA9, 0xE9, 0x68, 0xF4, 0x17, 0x1E, 0xB2,
0x70, 0x2A, 0xA1, 0xE5, 0xE1, 0xF3, 0x8F, 0x6F, 0x63, 0xAC, 0xEB, 0x72, 0x0B, 0x4C, 0x4A, 0x36,
0x3C, 0x60, 0x91, 0x9F, 0x6E, 0x1C, 0x71, 0xEA, 0xD0, 0x78, 0x78, 0xA0, 0x2E, 0xC6, 0x32, 0x6B
};
];
private static ReadOnlySpan<byte> Package2FixedKeyModulusDev => new byte[]
{
private static ReadOnlySpan<byte> Package2FixedKeyModulusDev =>
[
0xB3, 0x65, 0x54, 0xFB, 0x0A, 0xB0, 0x1E, 0x85, 0xA7, 0xF6, 0xCF, 0x91, 0x8E, 0xBA, 0x96, 0x99,
0x0D, 0x8B, 0x91, 0x69, 0x2A, 0xEE, 0x01, 0x20, 0x4F, 0x34, 0x5C, 0x2C, 0x4F, 0x4E, 0x37, 0xC7,
0xF1, 0x0B, 0xD4, 0xCD, 0xA1, 0x7F, 0x93, 0xF1, 0x33, 0x59, 0xCE, 0xB1, 0xE9, 0xDD, 0x26, 0xE6,
@ -390,5 +390,5 @@ public static class KeysCodeGen
0xF3, 0x56, 0x8E, 0xEC, 0x8D, 0x51, 0x8A, 0x63, 0x3C, 0x04, 0x78, 0x23, 0x0E, 0x90, 0x0C, 0xB4,
0xE7, 0x86, 0x3B, 0x4F, 0x8E, 0x13, 0x09, 0x47, 0x32, 0x0E, 0x04, 0xB8, 0x4D, 0x5B, 0xB0, 0x46,
0x71, 0xB0, 0x5C, 0xF4, 0xAD, 0x63, 0x4F, 0xC5, 0xE2, 0xAC, 0x1E, 0xC4, 0x33, 0x96, 0x09, 0x7B
};
];
}

View file

@ -14,7 +14,7 @@ public struct Package2Header
internal const int PayloadCount = 3;
internal const int SignatureSize = 0x100;
private static ReadOnlySpan<byte> RsaPublicKeyExponent => new byte[] { 0x00, 0x01, 0x00, 0x01 };
private static ReadOnlySpan<byte> RsaPublicKeyExponent => [0x00, 0x01, 0x00, 0x01];
public Array256<byte> Signature;
public Package2Meta Meta;

View file

@ -292,8 +292,8 @@ internal static class KeyDerivation
? MasterKeyVectorsDev
: MasterKeyVectorsProd);
private static ReadOnlySpan<byte> MasterKeyVectorsDev => new byte[]
{
private static ReadOnlySpan<byte> MasterKeyVectorsDev =>
[
0x46, 0x22, 0xB4, 0x51, 0x9A, 0x7E, 0xA7, 0x7F, 0x62, 0xA1, 0x1F, 0x8F, 0xC5, 0x3A, 0xDB, 0xFE, // Zeroes encrypted with Master Key 00.
0x39, 0x33, 0xF9, 0x31, 0xBA, 0xE4, 0xA7, 0x21, 0x2C, 0xDD, 0xB7, 0xD8, 0xB4, 0x4E, 0x37, 0x23, // Master key 00 encrypted with Master key 01.
0x97, 0x29, 0xB0, 0x32, 0x43, 0x14, 0x8C, 0xA6, 0x85, 0xE9, 0x5A, 0x94, 0x99, 0x39, 0xAC, 0x5D, // Master key 01 encrypted with Master key 02.
@ -311,10 +311,10 @@ internal static class KeyDerivation
0xD6, 0x80, 0x98, 0xC0, 0xFA, 0xC7, 0x13, 0xCB, 0x93, 0xD2, 0x0B, 0x82, 0x4C, 0xA1, 0x7B, 0x8D, // Master key 0D encrypted with Master key 0E.
0x78, 0x66, 0x19, 0xBD, 0x86, 0xE7, 0xC1, 0x09, 0x9B, 0x6F, 0x92, 0xB2, 0x58, 0x7D, 0xCF, 0x26, // Master key 0E encrypted with Master key 0F.
0x39, 0x1E, 0x7E, 0xF8, 0x7E, 0x73, 0xEA, 0x6F, 0xAF, 0x00, 0x3A, 0xB4, 0xAA, 0xB8, 0xB7, 0x59, // Master key 0F encrypted with Master key 10.
};
];
private static ReadOnlySpan<byte> MasterKeyVectorsProd => new byte[]
{
private static ReadOnlySpan<byte> MasterKeyVectorsProd =>
[
0x0C, 0xF0, 0x59, 0xAC, 0x85, 0xF6, 0x26, 0x65, 0xE1, 0xE9, 0x19, 0x55, 0xE6, 0xF2, 0x67, 0x3D, // Zeroes encrypted with Master Key 00.
0x29, 0x4C, 0x04, 0xC8, 0xEB, 0x10, 0xED, 0x9D, 0x51, 0x64, 0x97, 0xFB, 0xF3, 0x4D, 0x50, 0xDD, // Master key 00 encrypted with Master key 01.
0xDE, 0xCF, 0xEB, 0xEB, 0x10, 0xAE, 0x74, 0xD8, 0xAD, 0x7C, 0xF4, 0x9E, 0x62, 0xE0, 0xE8, 0x72, // Master key 01 encrypted with Master key 02.
@ -332,7 +332,7 @@ internal static class KeyDerivation
0xB1, 0x81, 0xA6, 0x0D, 0x72, 0xC7, 0xEE, 0x15, 0x21, 0xF3, 0xC0, 0xB5, 0x6B, 0x61, 0x6D, 0xE7, // Master key 0D encrypted with Master key 0E.
0xAF, 0x11, 0x4C, 0x67, 0x17, 0x7A, 0x52, 0x43, 0xF7, 0x70, 0x2F, 0xC7, 0xEF, 0x81, 0x72, 0x16, // Master key 0E encrypted with Master key 0F.
0x25, 0x12, 0x8B, 0xCB, 0xB5, 0x46, 0xA1, 0xF8, 0xE0, 0x52, 0x15, 0xB7, 0x0B, 0x57, 0x00, 0xBD, // Master key 0F encrypted with Master key 10.
};
];
private static void DerivePerConsoleKeys(KeySet s)
{

View file

@ -103,7 +103,7 @@ public ref struct Path
[DebuggerDisplay("{" + nameof(ToString) + "(),nq}")]
public struct Stored : IDisposable
{
private static readonly byte[] EmptyBuffer = { 0 };
private static readonly byte[] EmptyBuffer = [0];
private byte[] _buffer;
private int _length;
@ -190,7 +190,7 @@ public ref struct Path
private const int SeparatorLength = 1;
private const int NullTerminatorLength = 1;
private const int WriteBufferAlignmentLength = 8;
private static ReadOnlySpan<byte> EmptyPath => new byte[] { 0 };
private static ReadOnlySpan<byte> EmptyPath => [0];
private ReadOnlySpan<byte> _string;
private byte[] _writeBuffer;

View file

@ -105,16 +105,16 @@ public class ProgramInfo
return g.ProgramInfoForInitialProcess;
}
private static ReadOnlySpan<byte> InitialProcessAccessControlDataHeader => new byte[]
{
private static ReadOnlySpan<byte> InitialProcessAccessControlDataHeader =>
[
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1C, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
];
private static ReadOnlySpan<byte> InitialProcessAccessControlDescriptor => new byte[]
{
private static ReadOnlySpan<byte> InitialProcessAccessControlDescriptor =>
[
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
];
}

View file

@ -344,7 +344,7 @@ public class HierarchicalIntegrityVerificationStorage : IStorage
private FileSystemServer _fsServer;
private static readonly byte[][] KeyArray =
{ MasterKey.ToArray(), L1Key.ToArray(), L2Key.ToArray(), L3Key.ToArray(), L4Key.ToArray(), L5Key.ToArray() };
[MasterKey.ToArray(), L1Key.ToArray(), L2Key.ToArray(), L3Key.ToArray(), L4Key.ToArray(), L5Key.ToArray()];
public HierarchicalIntegrityVerificationStorage(FileSystemServer fsServer)
{

View file

@ -1018,7 +1018,7 @@ public class LocalFileSystem : IAttributeFileSystem
return path1 + path2.Substring(1);
}
private static readonly char[] SplitChars = { (char)DirectorySeparator, (char)AltDirectorySeparator };
private static readonly char[] SplitChars = [(char)DirectorySeparator, (char)AltDirectorySeparator];
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

View file

@ -12,8 +12,8 @@ namespace LibHac.Gc;
public sealed class GameCardEmulated : IGcApi
{
private static ReadOnlySpan<byte> CardHeaderKey => new byte[]
{ 0x01, 0xC5, 0x8F, 0xE7, 0x00, 0x2D, 0x13, 0x5A, 0xB2, 0x9A, 0x3F, 0x69, 0x33, 0x95, 0x74, 0xB1 };
private static ReadOnlySpan<byte> CardHeaderKey =>
[0x01, 0xC5, 0x8F, 0xE7, 0x00, 0x2D, 0x13, 0x5A, 0xB2, 0x9A, 0x3F, 0x69, 0x33, 0x95, 0x74, 0xB1];
private const string LibNotInitializedMessage = "Error: Gc lib is not initialized\n";

View file

@ -8,12 +8,12 @@ namespace LibHac.Tools.Crypto;
public static class CryptoOld
{
public static Validity Rsa2048Pkcs1Verify(byte[] data, byte[] signature, byte[] modulus) =>
Rsa.VerifyRsa2048Pkcs1Sha256(signature, modulus, new byte[] { 1, 0, 1 }, data)
Rsa.VerifyRsa2048Pkcs1Sha256(signature, modulus, [1, 0, 1], data)
? Validity.Valid
: Validity.Invalid;
public static Validity Rsa2048PssVerify(byte[] data, byte[] signature, byte[] modulus) =>
Rsa.VerifyRsa2048PssSha256(signature, modulus, new byte[] { 1, 0, 1 }, data)
Rsa.VerifyRsa2048PssSha256(signature, modulus, [1, 0, 1], data)
? Validity.Valid
: Validity.Invalid;

View file

@ -32,10 +32,10 @@ public class Ticket
public byte[] File { get; }
internal static readonly byte[] LabelHash =
{
[
0xE3, 0xB0, 0xC4, 0x42, 0x98, 0xFC, 0x1C, 0x14, 0x9A, 0xFB, 0xF4, 0xC8, 0x99, 0x6F, 0xB9, 0x24,
0x27, 0xAE, 0x41, 0xE4, 0x64, 0x9B, 0x93, 0x4C, 0xA4, 0x95, 0x99, 0x1B, 0x78, 0x52, 0xB8, 0x55
};
];
public Ticket() { }

View file

@ -23,7 +23,7 @@ public class XciHeader
private const int GcTitleKeyKekIndexMax = 0x10;
private static readonly byte[] XciHeaderPubk =
{
[
0x98, 0xC7, 0x26, 0xB6, 0x0D, 0x0A, 0x50, 0xA7, 0x39, 0x21, 0x0A, 0xE3, 0x2F, 0xE4, 0x3E, 0x2E,
0x5B, 0xA2, 0x86, 0x75, 0xAA, 0x5C, 0xEE, 0x34, 0xF1, 0xA3, 0x3A, 0x7E, 0xBD, 0x90, 0x4E, 0xF7,
0x8D, 0xFA, 0x17, 0xAA, 0x6B, 0xC6, 0x36, 0x6D, 0x4C, 0x9A, 0x6D, 0x57, 0x2F, 0x80, 0xA2, 0xBC,
@ -40,7 +40,7 @@ public class XciHeader
0xCB, 0xAD, 0x6E, 0x93, 0xE2, 0x19, 0x72, 0x6B, 0xD3, 0x45, 0xF8, 0x73, 0x3D, 0x2B, 0x6A, 0x55,
0xD2, 0x3A, 0x8B, 0xB0, 0x8A, 0x42, 0xE3, 0x3D, 0xF1, 0x92, 0x23, 0x42, 0x2E, 0xBA, 0xCC, 0x9C,
0x9A, 0xC1, 0xDD, 0x62, 0x86, 0x9C, 0x2E, 0xE1, 0x2D, 0x6F, 0x62, 0x67, 0x51, 0x08, 0x0E, 0xCF
};
];
public byte[] Signature { get; set; }
public string Magic { get; set; }

View file

@ -191,14 +191,14 @@ public class HierarchicalIntegrityVerificationStorage : IStorage
}
private static readonly string[] SaltSources =
{
[
"HierarchicalIntegrityVerificationStorage::Master",
"HierarchicalIntegrityVerificationStorage::L1",
"HierarchicalIntegrityVerificationStorage::L2",
"HierarchicalIntegrityVerificationStorage::L3",
"HierarchicalIntegrityVerificationStorage::L4",
"HierarchicalIntegrityVerificationStorage::L5"
};
];
}
public static class HierarchicalIntegrityVerificationStorageExtensions

View file

@ -63,7 +63,7 @@ public class Nca
return decryptedKey;
}
private static readonly string[] KakNames = { "application", "ocean", "system" };
private static readonly string[] KakNames = ["application", "ocean", "system"];
public byte[] GetEncryptedTitleKey()
{

View file

@ -321,11 +321,11 @@ public struct NcaHeader
public bool IsNca0() => FormatVersion >= NcaVersion.Nca0;
private static ReadOnlySpan<byte> Nca0FixedBodyKeySha256Hash => new byte[]
{
private static ReadOnlySpan<byte> Nca0FixedBodyKeySha256Hash =>
[
0x9A, 0xBB, 0xD2, 0x11, 0x86, 0x00, 0x21, 0x9D, 0x7A, 0xDC, 0x5B, 0x43, 0x95, 0xF8, 0x4E, 0xFD,
0xFF, 0x6B, 0x25, 0xEF, 0x9F, 0x96, 0x85, 0x28, 0x18, 0x9E, 0x76, 0xB0, 0x92, 0xF0, 0x6A, 0xCB
};
];
[StructLayout(LayoutKind.Explicit, Size = 0xC00)]
private struct NcaHeaderStruct

View file

@ -30,14 +30,14 @@ internal static class HashHelpers
// h1(key) + i*h2(key), 0 <= i < size. h2 and the size must be relatively prime.
// We prefer the low computation costs of higher prime numbers over the increased
// memory allocation of a fixed prime number i.e. when right sizing a HashSet.
public static readonly int[] Primes =
{
public static ReadOnlySpan<int> Primes =>
[
3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919,
1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591,
17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, 90523, 108631, 130363, 156437,
187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263,
1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369
};
];
public static bool IsPrime(int candidate)
{

View file

@ -14,8 +14,8 @@ public enum CharacterEncodingResult
public static class CharacterEncoding
{
private static ReadOnlySpan<sbyte> Utf8NBytesInnerTable => new sbyte[]
{
private static ReadOnlySpan<sbyte> Utf8NBytesInnerTable =>
[
-1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -33,7 +33,7 @@ public static class CharacterEncoding
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8
};
];
private static ReadOnlySpan<sbyte> Utf8NBytesTable => Utf8NBytesInnerTable.Slice(1);

View file

@ -219,8 +219,8 @@ internal static class HexConverter
}
/// <summary>Map from an ASCII char to its hex value, e.g. arr['b'] == 11. 0xFF means it's not a hex digit.</summary>
public static ReadOnlySpan<byte> CharToHexLookup => new byte[]
{
public static ReadOnlySpan<byte> CharToHexLookup =>
[
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 15
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 31
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 47
@ -237,5 +237,5 @@ internal static class HexConverter
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 223
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 239
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF // 255
};
];
}

View file

@ -12,8 +12,8 @@ namespace LibHac.Util;
/// <remarks>Based on nnSdk 13.4.0</remarks>
public static class Utf8StringUtil
{
private static ReadOnlySpan<byte> CodePointByteLengthTable => new byte[]
{
private static ReadOnlySpan<byte> CodePointByteLengthTable =>
[
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -30,7 +30,7 @@ public static class Utf8StringUtil
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
];
public static bool VerifyUtf8String(U8Span str)
{

View file

@ -165,7 +165,7 @@ internal static class ProcessPackage
}
}
private static readonly string[] Package2SectionNames = { "Kernel", "INI1", "Empty" };
private static readonly string[] Package2SectionNames = ["Kernel", "INI1", "Empty"];
private static string Print(this Package2StorageReader package2)
{

View file

@ -22,7 +22,7 @@ public class RsaTests
}
public readonly byte[] Modulus =
{
[
0xAD, 0x58, 0xEE, 0x97, 0xF9, 0x47, 0x90, 0x7D, 0xF9, 0x29, 0x5F, 0x1F, 0x39, 0x68, 0xEE, 0x49,
0x4C, 0x1E, 0x8D, 0x84, 0x91, 0x31, 0x5D, 0xE5, 0x96, 0x27, 0xB2, 0xB3, 0x59, 0x7B, 0xDE, 0xFD,
0xB7, 0xEB, 0x40, 0xA1, 0xE7, 0xEB, 0xDC, 0x60, 0xD0, 0x3D, 0xC5, 0x50, 0x92, 0xAD, 0x3D, 0xC4,
@ -39,10 +39,10 @@ public class RsaTests
0xB4, 0x4F, 0xD7, 0x5B, 0x4D, 0x7B, 0x43, 0xB0, 0x3A, 0x9A, 0x60, 0x22, 0x47, 0x91, 0x78, 0xC7,
0x10, 0x64, 0xE0, 0x2C, 0x69, 0xD1, 0x66, 0x3C, 0x42, 0x2E, 0xEF, 0x19, 0x21, 0x89, 0x8E, 0xE1,
0xB0, 0xB4, 0xD0, 0x17, 0xA1, 0x0F, 0x73, 0x98, 0x5A, 0xF6, 0xEE, 0xC0, 0x2F, 0x9E, 0xCE, 0xC5
};
];
public readonly byte[] PrivateExponent =
{
[
0x3C, 0x66, 0x37, 0x44, 0x26, 0xAC, 0x63, 0xD1, 0x30, 0xE6, 0xD4, 0x68, 0xF9, 0xC4, 0xF0, 0xFA,
0x03, 0x16, 0xC6, 0x32, 0x81, 0xB0, 0x94, 0xC9, 0xF1, 0x26, 0xC5, 0xE2, 0x2D, 0xF4, 0xB6, 0x3E,
0xEB, 0x3D, 0x82, 0x18, 0xA7, 0xC9, 0x8B, 0xD1, 0x03, 0xDD, 0xF2, 0x09, 0x60, 0x02, 0x12, 0xFA,
@ -59,15 +59,15 @@ public class RsaTests
0xEF, 0xCB, 0x2F, 0x2C, 0x90, 0xE6, 0x4B, 0x2D, 0x94, 0x62, 0xE8, 0xEC, 0x54, 0x7B, 0x94, 0xB7,
0xFB, 0x72, 0x05, 0xFB, 0xB3, 0x23, 0xCA, 0xF8, 0xD4, 0x5C, 0xF6, 0xAC, 0x7D, 0xEC, 0x47, 0xC6,
0xD3, 0x22, 0x5D, 0x7C, 0x15, 0xDD, 0x48, 0xE9, 0xBF, 0xA8, 0x99, 0x33, 0x02, 0x79, 0xD3, 0x65
};
];
public readonly byte[] PublicExponent =
{
[
0x01, 0x00, 0x01
};
];
public readonly byte[] ExpectedDp =
{
[
0x80, 0x1f, 0x3e, 0xe6, 0xed, 0xa2, 0xff, 0x60, 0x0e, 0xc3, 0xb7, 0xf3, 0xed, 0x73, 0x95, 0x05,
0x6d, 0x1f, 0x8a, 0xab, 0x14, 0x42, 0xa0, 0x21, 0x07, 0xe9, 0x92, 0xc7, 0x38, 0x26, 0x84, 0x60,
0xf9, 0xb3, 0x54, 0xad, 0x13, 0xf0, 0xc7, 0xd5, 0xfb, 0xac, 0xe2, 0x40, 0x68, 0x65, 0xf5, 0xb8,
@ -76,10 +76,10 @@ public class RsaTests
0x38, 0x08, 0x64, 0xff, 0xb7, 0xe9, 0x4c, 0x4d, 0xae, 0x2c, 0xfe, 0xb0, 0xe6, 0x66, 0x63, 0x14,
0x26, 0x85, 0x88, 0xe6, 0xc4, 0xe2, 0xe9, 0x15, 0xfa, 0xbb, 0xd1, 0x58, 0x70, 0x73, 0xe2, 0xbb,
0x3d, 0x4d, 0x28, 0x8b, 0xa9, 0x04, 0x7c, 0x16, 0xc6, 0xd1, 0x8e, 0x5b, 0x6b, 0xad, 0x4d, 0xdb
};
];
public readonly byte[] ExpectedDq =
{
[
0x84, 0x03, 0x42, 0x57, 0x72, 0xa5, 0x7a, 0x5a, 0x71, 0x1e, 0xb6, 0xba, 0x94, 0xd1, 0xfe, 0xea,
0x91, 0x2f, 0xce, 0x75, 0x22, 0xb3, 0x0a, 0xd1, 0x39, 0xce, 0xab, 0xe2, 0xee, 0x14, 0xa4, 0x24,
0xc2, 0x12, 0x74, 0xdd, 0xa8, 0x4d, 0xae, 0x2f, 0x99, 0xd7, 0x34, 0x2e, 0x5a, 0xe9, 0xfc, 0x5e,
@ -88,10 +88,10 @@ public class RsaTests
0xf4, 0x76, 0x00, 0xb6, 0x12, 0xc0, 0x7f, 0x86, 0x2b, 0xbb, 0xd8, 0x91, 0xcd, 0x49, 0x32, 0xad,
0x52, 0x11, 0x9c, 0x56, 0x7a, 0x28, 0xc6, 0x97, 0x80, 0x3e, 0xfa, 0xb1, 0x34, 0x9e, 0xb2, 0xb8,
0x1d, 0x16, 0xee, 0xa9, 0x22, 0xdc, 0x77, 0x5a, 0xde, 0x0b, 0xeb, 0xeb, 0x4e, 0xe8, 0x03, 0x41
};
];
public readonly byte[] ExpectedInverseQ =
{
[
0xb5, 0x71, 0x24, 0x42, 0xf4, 0x4c, 0xbd, 0xe2, 0x27, 0x6a, 0x22, 0x32, 0x9f, 0xe6, 0x88, 0x3e,
0xcf, 0xc8, 0x5d, 0x15, 0x04, 0x2c, 0x88, 0xac, 0x4f, 0xb9, 0xf1, 0x70, 0xef, 0x04, 0x07, 0xb4,
0x51, 0xd6, 0xab, 0x48, 0xa2, 0x70, 0x0b, 0xbc, 0xb9, 0xd9, 0xbc, 0xd8, 0x81, 0x29, 0x80, 0x6e,
@ -100,10 +100,10 @@ public class RsaTests
0x1d, 0x94, 0x58, 0xd3, 0x4b, 0xe8, 0x5e, 0x73, 0x02, 0x54, 0x88, 0x02, 0xc6, 0x8d, 0x62, 0xfd,
0xf1, 0x56, 0x35, 0x06, 0x81, 0x57, 0x79, 0x00, 0xc1, 0x7c, 0x9e, 0xd3, 0x61, 0x81, 0x65, 0xae,
0x70, 0x56, 0x24, 0x32, 0xfc, 0x92, 0x17, 0xc4, 0xed, 0x09, 0x27, 0xe3, 0x40, 0xc5, 0xfe, 0xe4
};
];
public readonly byte[] ExpectedP =
{
[
0xd2, 0x96, 0x44, 0xee, 0x2c, 0x8e, 0x97, 0x24, 0x83, 0x7c, 0xf0, 0x59, 0xeb, 0x8a, 0xa0, 0x24,
0xca, 0x2b, 0xd9, 0x92, 0x51, 0xf2, 0xa9, 0x33, 0x5b, 0x5f, 0x53, 0xf0, 0x53, 0xcf, 0x5c, 0xd0,
0xf5, 0x56, 0x73, 0xf1, 0x22, 0x64, 0xa1, 0xb5, 0x6e, 0x36, 0x22, 0xde, 0xf8, 0xa6, 0xa9, 0x3e,
@ -112,10 +112,10 @@ public class RsaTests
0xf5, 0xe9, 0x3d, 0x6c, 0xaf, 0x06, 0xb5, 0xef, 0x2e, 0x81, 0xd6, 0xad, 0x7f, 0xa6, 0xe5, 0x01,
0x77, 0xbb, 0x52, 0xe8, 0x8b, 0x83, 0x4d, 0x98, 0x97, 0x95, 0x7f, 0xc9, 0x5c, 0x79, 0x92, 0x37,
0xf9, 0x1e, 0xb1, 0xe3, 0x70, 0x77, 0x80, 0xd8, 0x90, 0xbe, 0x48, 0x35, 0xbd, 0x24, 0x8c, 0x5b
};
];
public readonly byte[] ExpectedQ =
{
[
0xd2, 0xba, 0xcd, 0x49, 0x28, 0xe2, 0x8c, 0xde, 0x8c, 0xd3, 0xc0, 0xb4, 0xd9, 0x2b, 0x6b, 0xec,
0xf1, 0xff, 0x66, 0x30, 0xfe, 0x0e, 0x40, 0x46, 0xa9, 0xcd, 0x27, 0x9d, 0xfd, 0xf3, 0xbe, 0x1c,
0xf8, 0x90, 0x01, 0x7f, 0x48, 0xb3, 0x51, 0xfd, 0xa7, 0xd9, 0x60, 0xce, 0xcf, 0x44, 0x2f, 0x8a,
@ -124,5 +124,5 @@ public class RsaTests
0xc3, 0x94, 0x2f, 0x5d, 0x4d, 0x8f, 0x2d, 0xbc, 0x07, 0x98, 0x45, 0x1f, 0x90, 0x07, 0xfb, 0x26,
0xf0, 0x3a, 0xf3, 0xad, 0xee, 0xd5, 0xe7, 0x42, 0x7c, 0xa5, 0xfa, 0xb6, 0xaa, 0xe6, 0x1b, 0x47,
0x54, 0xe5, 0x22, 0xeb, 0x28, 0x8a, 0x3d, 0x66, 0xe4, 0x81, 0xc2, 0x17, 0x1d, 0x0d, 0x7b, 0x5f
};
];
}

View file

@ -87,7 +87,7 @@ public class SaveDataManagement
Assert.Equal(applicationId, info[0].ProgramId);
Assert.Equal(applicationId, info[1].ProgramId);
ushort[] expectedIndexes = { 0, 1 };
ushort[] expectedIndexes = [0, 1];
ushort[] actualIndexes = info.Take(2).Select(x => x.Index).OrderBy(x => x).ToArray();
Assert.Equal(expectedIndexes, actualIndexes);

View file

@ -11,8 +11,8 @@ public abstract partial class CommittableIFileSystemTests
public void Commit_AfterSuccessfulCommit_CanReadCommittedData()
{
// "Random" test data
byte[] data1 = { 7, 4, 1, 0, 8, 5, 2, 9, 6, 3 };
byte[] data2 = { 6, 1, 6, 8, 0, 3, 9, 7, 5, 1 };
byte[] data1 = [7, 4, 1, 0, 8, 5, 2, 9, 6, 3];
byte[] data2 = [6, 1, 6, 8, 0, 3, 9, 7, 5, 1];
IReopenableFileSystemCreator fsCreator = GetFileSystemCreator();
IFileSystem fs = fsCreator.Create();
@ -99,8 +99,8 @@ public abstract partial class CommittableIFileSystemTests
public void Rollback_AfterChangingExistingFiles_GoesBackToOriginalData()
{
// "Random" test data
byte[] data1 = { 7, 4, 1, 0, 8, 5, 2, 9, 6, 3 };
byte[] data2 = { 6, 1, 6, 8, 0, 3, 9, 7, 5, 1 };
byte[] data1 = [7, 4, 1, 0, 8, 5, 2, 9, 6, 3];
byte[] data2 = [6, 1, 6, 8, 0, 3, 9, 7, 5, 1];
IReopenableFileSystemCreator fsCreator = GetFileSystemCreator();
IFileSystem fs = fsCreator.Create();

View file

@ -11,7 +11,7 @@ public abstract partial class IFileSystemTests
[Fact]
public void IFileWrite_CanReadBackWrittenData()
{
byte[] data = { 7, 4, 1, 0, 8, 5, 2, 9, 6, 3 };
byte[] data = [7, 4, 1, 0, 8, 5, 2, 9, 6, 3];
IFileSystem fs = CreateFileSystem();

View file

@ -92,7 +92,7 @@ public abstract partial class IFileSystemTests
[Fact]
public void RenameFile_DataIsUnmodified()
{
byte[] data = { 7, 4, 1, 0, 8, 5, 2, 9, 6, 3 };
byte[] data = [7, 4, 1, 0, 8, 5, 2, 9, 6, 3];
IFileSystem fs = CreateFileSystem();

View file

@ -424,7 +424,7 @@ public class PathFormatterTests
[Fact]
public static void IsNormalized_InvalidUtf8()
{
ReadOnlySpan<byte> invalidUtf8 = new byte[] { 0x44, 0xE3, 0xAA, 0x55, 0x50 };
ReadOnlySpan<byte> invalidUtf8 = [0x44, 0xE3, 0xAA, 0x55, 0x50];
Result result = PathFormatter.IsNormalized(out _, out _, invalidUtf8, new PathFlags());

View file

@ -23,7 +23,7 @@ public class BucketTreeBuilderTests
// Bucket tree builder parameters and output digests that have been verified manually
private static readonly BucketTreeBuilderTestConfig[] BucketTreeBuilderTestData =
{
[
// Tiny tree
new()
{
@ -79,7 +79,7 @@ public class BucketTreeBuilderTests
NodeSize = 0x400,
EntryCount = 793_800
}
};
];
public static TheoryData<int> BucketTreeBuilderTestTheoryData =
TheoryDataCreator.CreateSequence(0, BucketTreeBuilderTestData.Length);

View file

@ -41,13 +41,13 @@ public class BucketTreeTests : IClassFixture<BucketTreeBuffers>
}
public static readonly (int nodeSize, int entryCount)[] BucketTreeTestParams =
{
[
(0x4000, 5),
(0x4000, 10000),
(0x4000, 2_000_000),
(0x400, 50_000),
(0x400, 793_800)
};
];
public static TheoryData<int> BucketTreeTestTheoryData =
TheoryDataCreator.CreateSequence(0, BucketTreeTestParams.Length);

View file

@ -51,13 +51,13 @@ public class BufferedStorageTests
}
public static AccessTestConfig[] AccessTestConfigs =
{
[
new()
{
SizeClassProbs = new[] { 50, 50, 5 },
SizeClassMaxSizes = new[] { 0x4000, 0x80000, 0x800000 }, // 16 KB, 512 KB, 8 MB
TaskProbs = new[] { 50, 50, 1 }, // Read, Write, Flush
AccessTypeProbs = new[] { 10, 10, 5 }, // Random, Sequential, Frequent block
SizeClassProbs = [50, 50, 5],
SizeClassMaxSizes = [0x4000, 0x80000, 0x800000], // 16 KB, 512 KB, 8 MB
TaskProbs = [50, 50, 1], // Read, Write, Flush
AccessTypeProbs = [10, 10, 5], // Random, Sequential, Frequent block
RngSeed = 35467,
FrequentAccessBlockCount = 6,
BlockSize = 0x4000,
@ -70,10 +70,10 @@ public class BufferedStorageTests
},
new()
{
SizeClassProbs = new[] { 50, 50, 5 },
SizeClassMaxSizes = new[] { 0x4000, 0x80000, 0x800000 }, // 16 KB, 512 KB, 8 MB
TaskProbs = new[] { 50, 50, 1 }, // Read, Write, Flush
AccessTypeProbs = new[] { 10, 10, 5 }, // Random, Sequential, Frequent block
SizeClassProbs = [50, 50, 5],
SizeClassMaxSizes = [0x4000, 0x80000, 0x800000], // 16 KB, 512 KB, 8 MB
TaskProbs = [50, 50, 1], // Read, Write, Flush
AccessTypeProbs = [10, 10, 5], // Random, Sequential, Frequent block
RngSeed = 6548433,
FrequentAccessBlockCount = 6,
BlockSize = 0x4000,
@ -86,10 +86,10 @@ public class BufferedStorageTests
},
new()
{
SizeClassProbs = new[] { 50, 50, 0 },
SizeClassMaxSizes = new[] { 0x4000, 0x80000, 0x800000 }, // 16 KB, 512 KB, 8 MB
TaskProbs = new[] { 50, 0, 0 },
AccessTypeProbs = new[] { 10, 10, 5 }, // Random, Sequential, Frequent block
SizeClassProbs = [50, 50, 0],
SizeClassMaxSizes = [0x4000, 0x80000, 0x800000], // 16 KB, 512 KB, 8 MB
TaskProbs = [50, 0, 0],
AccessTypeProbs = [10, 10, 5], // Random, Sequential, Frequent block
RngSeed = 756478,
FrequentAccessBlockCount = 16,
BlockSize = 0x4000,
@ -102,10 +102,10 @@ public class BufferedStorageTests
},
new()
{
SizeClassProbs = new[] { 50, 50, 0 },
SizeClassMaxSizes = new[] { 0x4000, 0x80000, 0x800000 }, // 16 KB, 512 KB, 8 MB
TaskProbs = new[] { 50, 0, 0 },
AccessTypeProbs = new[] { 0, 0, 5 }, // Random, Sequential, Frequent block
SizeClassProbs = [50, 50, 0],
SizeClassMaxSizes = [0x4000, 0x80000, 0x800000], // 16 KB, 512 KB, 8 MB
TaskProbs = [50, 0, 0],
AccessTypeProbs = [0, 0, 5], // Random, Sequential, Frequent block
RngSeed = 38197549,
FrequentAccessBlockCount = 16,
BlockSize = 0x4000,
@ -118,10 +118,10 @@ public class BufferedStorageTests
},
new()
{
SizeClassProbs = new[] { 50, 50, 0 },
SizeClassMaxSizes = new[] { 0x4000, 0x80000, 0x800000 }, // 16 KB, 512 KB, 8 MB
TaskProbs = new[] { 50, 50, 1 }, // Read, Write, Flush
AccessTypeProbs = new[] { 10, 10, 5 }, // Random, Sequential, Frequent block
SizeClassProbs = [50, 50, 0],
SizeClassMaxSizes = [0x4000, 0x80000, 0x800000], // 16 KB, 512 KB, 8 MB
TaskProbs = [50, 50, 1], // Read, Write, Flush
AccessTypeProbs = [10, 10, 5], // Random, Sequential, Frequent block
RngSeed = 567365,
FrequentAccessBlockCount = 6,
BlockSize = 0x4000,
@ -134,10 +134,10 @@ public class BufferedStorageTests
},
new()
{
SizeClassProbs = new[] { 50, 50, 0 },
SizeClassMaxSizes = new[] { 0x4000, 0x80000, 0x800000 }, // 16 KB, 512 KB, 8 MB
TaskProbs = new[] { 50, 50, 1 }, // Read, Write, Flush
AccessTypeProbs = new[] { 10, 10, 5 }, // Random, Sequential, Frequent block
SizeClassProbs = [50, 50, 0],
SizeClassMaxSizes = [0x4000, 0x80000, 0x800000], // 16 KB, 512 KB, 8 MB
TaskProbs = [50, 50, 1], // Read, Write, Flush
AccessTypeProbs = [10, 10, 5], // Random, Sequential, Frequent block
RngSeed = 949365,
FrequentAccessBlockCount = 6,
BlockSize = 0x4000,
@ -150,10 +150,10 @@ public class BufferedStorageTests
},
new()
{
SizeClassProbs = new[] { 50, 50, 10 },
SizeClassMaxSizes = new[] { 0x4000, 0x80000, 0x800000 }, // 16 KB, 512 KB, 8 MB
TaskProbs = new[] { 50, 50, 1 }, // Read, Write, Flush
AccessTypeProbs = new[] { 10, 10, 5 }, // Random, Sequential, Frequent block
SizeClassProbs = [50, 50, 10],
SizeClassMaxSizes = [0x4000, 0x80000, 0x800000], // 16 KB, 512 KB, 8 MB
TaskProbs = [50, 50, 1], // Read, Write, Flush
AccessTypeProbs = [10, 10, 5], // Random, Sequential, Frequent block
RngSeed = 670670,
FrequentAccessBlockCount = 16,
BlockSize = 0x4000,
@ -164,7 +164,7 @@ public class BufferedStorageTests
HeapBlockSize = 0x4000,
BufferManagerCacheCount = 0x400
}
};
];
private static TheoryData<T> CreateTheoryData<T>(IEnumerable<T> items)
{
@ -211,7 +211,7 @@ public class BufferedStorageTests
var testerConfig = new StorageTester.Configuration()
{
Entries = new[] { memoryStorageEntry, bufferedStorageEntry },
Entries = [memoryStorageEntry, bufferedStorageEntry],
SizeClassProbs = config.SizeClassProbs,
SizeClassMaxSizes = config.SizeClassMaxSizes,
TaskProbs = config.TaskProbs,

View file

@ -517,7 +517,7 @@ public class DirectorySaveDataFileSystemTests : CommittableIFileSystemTests
private class RandomGenerator
{
private static readonly int[] Values = { 2, 0, 3, 3, 6, 0 };
private static readonly int[] Values = [2, 0, 3, 3, 6, 0];
private int _index;

View file

@ -63,7 +63,7 @@ public class IndirectStorageTests : IClassFixture<IndirectStorageBuffers>
}
public static readonly IndirectStorageTestConfig[] IndirectStorageTestData =
{
[
// Small patched regions to force continuous reading
new()
{
@ -93,28 +93,28 @@ public class IndirectStorageTests : IClassFixture<IndirectStorageBuffers>
OriginalEntrySizeRange = new SizeRange(0x10000, 10, 50),
StorageSize = 1024 * 1024 * 10
}
};
];
private static readonly RandomAccessTestConfig[] AccessTestConfigs =
{
[
new()
{
SizeClassProbs = new[] { 50, 50, 5 },
SizeClassMaxSizes = new[] { 0x4000, 0x80000, 0x800000 }, // 16 KB, 512 KB, 8 MB
TaskProbs = new[] { 1, 0, 0 }, // Read, Write, Flush
AccessTypeProbs = new[] { 10, 10, 5 }, // Random, Sequential, Frequent block
SizeClassProbs = [50, 50, 5],
SizeClassMaxSizes = [0x4000, 0x80000, 0x800000], // 16 KB, 512 KB, 8 MB
TaskProbs = [1, 0, 0], // Read, Write, Flush
AccessTypeProbs = [10, 10, 5], // Random, Sequential, Frequent block
RngSeed = 35467,
FrequentAccessBlockCount = 6,
},
new()
{
SizeClassProbs = new[] { 50, 50, 5 },
SizeClassMaxSizes = new[] { 0x800, 0x1000, 0x8000 }, // 2 KB, 4 KB, 32 KB
TaskProbs = new[] { 1, 0, 0 }, // Read, Write, Flush
AccessTypeProbs = new[] { 1, 10, 0 }, // Random, Sequential, Frequent block
SizeClassProbs = [50, 50, 5],
SizeClassMaxSizes = [0x800, 0x1000, 0x8000], // 2 KB, 4 KB, 32 KB
TaskProbs = [1, 0, 0], // Read, Write, Flush
AccessTypeProbs = [1, 10, 0], // Random, Sequential, Frequent block
RngSeed = 13579
},
};
];
public static TheoryData<int> IndirectStorageTestTheoryData =
TheoryDataCreator.CreateSequence(0, IndirectStorageTestData.Length);
@ -342,7 +342,7 @@ public class IndirectStorageTests : IClassFixture<IndirectStorageBuffers>
var testerConfig = new StorageTester.Configuration()
{
Entries = new[] { memoryStorageEntry, indirectStorageEntry },
Entries = [memoryStorageEntry, indirectStorageEntry],
SizeClassProbs = accessConfig.SizeClassProbs,
SizeClassMaxSizes = accessConfig.SizeClassMaxSizes,
TaskProbs = accessConfig.TaskProbs,

View file

@ -19,7 +19,7 @@ public class LibHacTestFramework : XunitTestFramework
}
// Todo: Catch assertions in PathToolTestGenerator.cpp
private static readonly string[] SkipAbortFunctions = { "Normalize" };
private static readonly string[] SkipAbortFunctions = ["Normalize"];
private static void SetDebugHandler()
{

View file

@ -11,93 +11,93 @@ namespace LibHac.Tests;
public class PathToolsTests
{
public static object[][] NormalizedPathTestItems =
{
new object[] { "", "/" },
new object[] { "/", "/" },
new object[] { "/.", "/" },
new object[] { "/a/b/c", "/a/b/c" },
new object[] { "/a/b/../c", "/a/c" },
new object[] { "/a/b/c/..", "/a/b" },
new object[] { "/a/b/c/.", "/a/b/c" },
new object[] { "/a/../../..", "/" },
new object[] { "/a/../../../a/b/c", "/a/b/c" },
new object[] { "//a/b//.//c", "/a/b/c" },
new object[] { "/../a/b/c/.", "/a/b/c" },
new object[] { "/./aaa/bbb/ccc/.", "/aaa/bbb/ccc" },
[
["", "/"],
["/", "/"],
["/.", "/"],
["/a/b/c", "/a/b/c"],
["/a/b/../c", "/a/c"],
["/a/b/c/..", "/a/b"],
["/a/b/c/.", "/a/b/c"],
["/a/../../..", "/"],
["/a/../../../a/b/c", "/a/b/c"],
["//a/b//.//c", "/a/b/c"],
["/../a/b/c/.", "/a/b/c"],
["/./aaa/bbb/ccc/.", "/aaa/bbb/ccc"],
new object[] { "/a/b/c/", "/a/b/c/" },
new object[] { "a/b/c/", "/a/b/c/" },
new object[] { "/aa/./bb/../cc/", "/aa/cc/" },
new object[] { "/./b/../c/", "/c/" },
new object[] { "/a/../../../", "/" },
new object[] { "//a/b//.//c/", "/a/b/c/" },
new object[] { "/tmp/../", "/" },
["/a/b/c/", "/a/b/c/"],
["a/b/c/", "/a/b/c/"],
["/aa/./bb/../cc/", "/aa/cc/"],
["/./b/../c/", "/c/"],
["/a/../../../", "/"],
["//a/b//.//c/", "/a/b/c/"],
["/tmp/../", "/"],
new object[] { "a", "/a" },
new object[] { "a/../../../a/b/c", "/a/b/c" },
new object[] { "./b/../c/", "/c/" },
new object[] { ".", "/" },
new object[] { "..", "/" },
new object[] { "../a/b/c/.", "/a/b/c" },
new object[] { "./a/b/c/.", "/a/b/c" },
["a", "/a"],
["a/../../../a/b/c", "/a/b/c"],
["./b/../c/", "/c/"],
[".", "/"],
["..", "/"],
["../a/b/c/.", "/a/b/c"],
["./a/b/c/.", "/a/b/c"],
new object[] { "a:/a/b/c", "a:/a/b/c" },
new object[] { "mount:/a/b/../c", "mount:/a/c" },
new object[] { "mount:", "mount:/" },
new object[] { "abc:/a/../../../a/b/c", "abc:/a/b/c" },
new object[] { "abc:/./b/../c/", "abc:/c/" },
new object[] { "abc:/.", "abc:/" },
new object[] { "abc:/..", "abc:/" },
new object[] { "abc:/", "abc:/" },
new object[] { "abc://a/b//.//c", "abc:/a/b/c" },
new object[] { "abc:/././/././a/b//.//c", "abc:/a/b/c" },
new object[] { "mount:/d./aa", "mount:/d./aa" },
};
["a:/a/b/c", "a:/a/b/c"],
["mount:/a/b/../c", "mount:/a/c"],
["mount:", "mount:/"],
["abc:/a/../../../a/b/c", "abc:/a/b/c"],
["abc:/./b/../c/", "abc:/c/"],
["abc:/.", "abc:/"],
["abc:/..", "abc:/"],
["abc:/", "abc:/"],
["abc://a/b//.//c", "abc:/a/b/c"],
["abc:/././/././a/b//.//c", "abc:/a/b/c"],
["mount:/d./aa", "mount:/d./aa"],
];
public static object[][] SubPathTestItems =
{
new object[] { "/", "/", false },
new object[] { "/", "/a", true },
new object[] { "/", "/a/", true },
[
["/", "/", false],
["/", "/a", true],
["/", "/a/", true],
new object[] { "/a/b/c", "/a/b/c/d", true },
new object[] { "/a/b/c/", "/a/b/c/d", true },
["/a/b/c", "/a/b/c/d", true],
["/a/b/c/", "/a/b/c/d", true],
new object[] { "/a/b/c", "/a/b/c", false },
new object[] { "/a/b/c/", "/a/b/c/", false },
new object[] { "/a/b/c/", "/a/b/c", false },
new object[] { "/a/b/c", "/a/b/c/", false },
["/a/b/c", "/a/b/c", false],
["/a/b/c/", "/a/b/c/", false],
["/a/b/c/", "/a/b/c", false],
["/a/b/c", "/a/b/c/", false],
new object[] { "/a/b/c/", "/a/b/cdef", false },
new object[] { "/a/b/c", "/a/b/cdef", false },
new object[] { "/a/b/c/", "/a/b/cd", false },
["/a/b/c/", "/a/b/cdef", false],
["/a/b/c", "/a/b/cdef", false],
["/a/b/c/", "/a/b/cd", false],
new object[] { "mount:/", "mount:/", false },
new object[] { "mount:/", "mount:/a", true },
new object[] { "mount:/", "mount:/a/", true },
["mount:/", "mount:/", false],
["mount:/", "mount:/a", true],
["mount:/", "mount:/a/", true],
new object[] { "mount:/a/b/c", "mount:/a/b/c/d", true },
new object[] { "mount:/a/b/c/", "mount:/a/b/c/d", true },
["mount:/a/b/c", "mount:/a/b/c/d", true],
["mount:/a/b/c/", "mount:/a/b/c/d", true],
new object[] { "mount:/a/b/c", "mount:/a/b/c", false },
new object[] { "mount:/a/b/c/", "mount:/a/b/c/", false },
new object[] { "mount:/a/b/c/", "mount:/a/b/c", false },
new object[] { "mount:/a/b/c", "mount:/a/b/c/", false },
["mount:/a/b/c", "mount:/a/b/c", false],
["mount:/a/b/c/", "mount:/a/b/c/", false],
["mount:/a/b/c/", "mount:/a/b/c", false],
["mount:/a/b/c", "mount:/a/b/c/", false],
new object[] { "mount:/a/b/c/", "mount:/a/b/cdef", false },
new object[] { "mount:/a/b/c", "mount:/a/b/cdef", false },
new object[] { "mount:/a/b/c/", "mount:/a/b/cd", false },
};
["mount:/a/b/c/", "mount:/a/b/cdef", false],
["mount:/a/b/c", "mount:/a/b/cdef", false],
["mount:/a/b/c/", "mount:/a/b/cd", false],
];
public static object[][] ParentDirectoryTestItems =
{
new object[] { "/", "" },
new object[] { "/a", "/" },
new object[] { "/aa/aabc/f", "/aa/aabc" },
new object[] { "mount:/", "" },
new object[] { "mount:/a", "mount:/" },
new object[] { "mount:/aa/aabc/f", "mount:/aa/aabc" }
};
[
["/", ""],
["/a", "/"],
["/aa/aabc/f", "/aa/aabc"],
["mount:/", ""],
["mount:/a", "mount:/"],
["mount:/aa/aabc/f", "mount:/aa/aabc"]
];
public static object[][] IsNormalizedTestItems = GetNormalizedPaths(true);
@ -173,15 +173,15 @@ public class PathToolsTests
}
public static object[][] GetFileNameTestItems =
{
new object[] { "/a/bb/ccc", "ccc" },
new object[] { "/a/bb/ccc/", "" },
new object[] { "/a/bb", "bb" },
new object[] { "/a/bb/", "" },
new object[] { "/a", "a" },
new object[] { "/a/", "" },
new object[] { "/", "" },
};
[
["/a/bb/ccc", "ccc"],
["/a/bb/ccc/", ""],
["/a/bb", "bb"],
["/a/bb/", ""],
["/a", "a"],
["/a/", ""],
["/", ""],
];
[Theory]
[MemberData(nameof(GetFileNameTestItems))]
@ -197,15 +197,15 @@ public class PathToolsTests
}
public static object[][] GetLastSegmentTestItems =
{
new object[] { "/a/bb/ccc", "ccc" },
new object[] { "/a/bb/ccc/", "ccc" },
new object[] { "/a/bb", "bb" },
new object[] { "/a/bb/", "bb" },
new object[] { "/a", "a" },
new object[] { "/a/", "a" },
new object[] { "/", "" },
};
[
["/a/bb/ccc", "ccc"],
["/a/bb/ccc/", "ccc"],
["/a/bb", "bb"],
["/a/bb/", "bb"],
["/a", "a"],
["/a/", "a"],
["/", ""],
];
[Theory]
[MemberData(nameof(GetLastSegmentTestItems))]