diff --git a/build/CodeGen/Stage2/KeysCodeGen.cs b/build/CodeGen/Stage2/KeysCodeGen.cs index add61f45..fef27dd4 100644 --- a/build/CodeGen/Stage2/KeysCodeGen.cs +++ b/build/CodeGen/Stage2/KeysCodeGen.cs @@ -103,46 +103,46 @@ public static class KeysCodeGen RSAParameters betaNca0Params = Rsa.RecoverParameters(BetaNca0Modulus, StandardPublicExponent, BetaNca0Exponent); - betaNca0Params.D.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.PrivateExponent.Items); - betaNca0Params.DP.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Dp.Items); - betaNca0Params.DQ.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Dq.Items); - betaNca0Params.Exponent.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.PublicExponent.Items); - betaNca0Params.InverseQ.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.InverseQ.Items); - betaNca0Params.Modulus.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Modulus.Items); - betaNca0Params.P.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.P.Items); - betaNca0Params.Q.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Q.Items); + betaNca0Params.D.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.PrivateExponent); + betaNca0Params.DP.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Dp); + betaNca0Params.DQ.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Dq); + betaNca0Params.Exponent.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.PublicExponent); + betaNca0Params.InverseQ.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.InverseQ); + betaNca0Params.Modulus.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Modulus); + betaNca0Params.P.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.P); + betaNca0Params.Q.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Q); // First populate the prod RSA keys keySet.SetMode(KeySet.Mode.Prod); - StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[0].PublicExponent.Items); - StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[1].PublicExponent.Items); - NcaHdrFixedKeyModulus0Prod.CopyTo(keySet.NcaHeaderSigningKeys[0].Modulus.Items); - NcaHdrFixedKeyModulus1Prod.CopyTo(keySet.NcaHeaderSigningKeys[1].Modulus.Items); + StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[0].PublicExponent); + StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[1].PublicExponent); + NcaHdrFixedKeyModulus0Prod.CopyTo(keySet.NcaHeaderSigningKeys[0].Modulus); + NcaHdrFixedKeyModulus1Prod.CopyTo(keySet.NcaHeaderSigningKeys[1].Modulus); - StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[0].PublicExponent.Items); - StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[1].PublicExponent.Items); - AcidFixedKeyModulus0Prod.CopyTo(keySet.AcidSigningKeys[0].Modulus.Items); - AcidFixedKeyModulus1Prod.CopyTo(keySet.AcidSigningKeys[1].Modulus.Items); + StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[0].PublicExponent); + StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[1].PublicExponent); + AcidFixedKeyModulus0Prod.CopyTo(keySet.AcidSigningKeys[0].Modulus); + AcidFixedKeyModulus1Prod.CopyTo(keySet.AcidSigningKeys[1].Modulus); - StandardPublicExponent.CopyTo(keySet.Package2SigningKey.PublicExponent.Items); - Package2FixedKeyModulusProd.CopyTo(keySet.Package2SigningKey.Modulus.Items); + StandardPublicExponent.CopyTo(keySet.Package2SigningKey.PublicExponent); + Package2FixedKeyModulusProd.CopyTo(keySet.Package2SigningKey.Modulus); // Populate the dev RSA keys keySet.SetMode(KeySet.Mode.Dev); - StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[0].PublicExponent.Items); - StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[1].PublicExponent.Items); - NcaHdrFixedKeyModulus0Dev.CopyTo(keySet.NcaHeaderSigningKeys[0].Modulus.Items); - NcaHdrFixedKeyModulus1Dev.CopyTo(keySet.NcaHeaderSigningKeys[1].Modulus.Items); + StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[0].PublicExponent); + StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[1].PublicExponent); + NcaHdrFixedKeyModulus0Dev.CopyTo(keySet.NcaHeaderSigningKeys[0].Modulus); + NcaHdrFixedKeyModulus1Dev.CopyTo(keySet.NcaHeaderSigningKeys[1].Modulus); - StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[0].PublicExponent.Items); - StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[1].PublicExponent.Items); - AcidFixedKeyModulus0Dev.CopyTo(keySet.AcidSigningKeys[0].Modulus.Items); - AcidFixedKeyModulus1Dev.CopyTo(keySet.AcidSigningKeys[1].Modulus.Items); + StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[0].PublicExponent); + StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[1].PublicExponent); + AcidFixedKeyModulus0Dev.CopyTo(keySet.AcidSigningKeys[0].Modulus); + AcidFixedKeyModulus1Dev.CopyTo(keySet.AcidSigningKeys[1].Modulus); - StandardPublicExponent.CopyTo(keySet.Package2SigningKey.PublicExponent.Items); - Package2FixedKeyModulusDev.CopyTo(keySet.Package2SigningKey.Modulus.Items); + StandardPublicExponent.CopyTo(keySet.Package2SigningKey.PublicExponent); + Package2FixedKeyModulusDev.CopyTo(keySet.Package2SigningKey.Modulus); return keySet; } diff --git a/src/LibHac/Bcat/Digest.cs b/src/LibHac/Bcat/Digest.cs index b4f23f23..f481e55f 100644 --- a/src/LibHac/Bcat/Digest.cs +++ b/src/LibHac/Bcat/Digest.cs @@ -9,6 +9,6 @@ public struct Digest public readonly override string ToString() { - return Value.ItemsRo.ToHexString(); + return Value[..].ToHexString(); } } \ No newline at end of file diff --git a/src/LibHac/Bcat/DirectoryName.cs b/src/LibHac/Bcat/DirectoryName.cs index 5d0ad5c9..b1050b25 100644 --- a/src/LibHac/Bcat/DirectoryName.cs +++ b/src/LibHac/Bcat/DirectoryName.cs @@ -12,7 +12,7 @@ public struct DirectoryName public readonly bool IsValid() { - ReadOnlySpan name = Value.ItemsRo; + ReadOnlySpan name = Value; int i; for (i = 0; i < name.Length; i++) @@ -32,6 +32,6 @@ public struct DirectoryName public readonly override string ToString() { - return StringUtils.Utf8ZToString(Value.ItemsRo); + return StringUtils.Utf8ZToString(Value); } } \ No newline at end of file diff --git a/src/LibHac/Bcat/FileName.cs b/src/LibHac/Bcat/FileName.cs index 0fbfac18..f76319c5 100644 --- a/src/LibHac/Bcat/FileName.cs +++ b/src/LibHac/Bcat/FileName.cs @@ -12,7 +12,7 @@ public struct FileName public readonly bool IsValid() { - ReadOnlySpan name = Value.ItemsRo; + ReadOnlySpan name = Value; int i; for (i = 0; i < name.Length; i++) @@ -35,6 +35,6 @@ public struct FileName public readonly override string ToString() { - return StringUtils.Utf8ZToString(Value.ItemsRo); + return StringUtils.Utf8ZToString(Value); } } \ No newline at end of file diff --git a/src/LibHac/Bcat/Impl/Service/DeliveryCacheStorageService.cs b/src/LibHac/Bcat/Impl/Service/DeliveryCacheStorageService.cs index 9cd5bfec..29679812 100644 --- a/src/LibHac/Bcat/Impl/Service/DeliveryCacheStorageService.cs +++ b/src/LibHac/Bcat/Impl/Service/DeliveryCacheStorageService.cs @@ -76,7 +76,7 @@ internal class DeliveryCacheStorageService : IDeliveryCacheStorageService break; } - StringUtils.Copy(nameBuffer[i].Value.Items, entry.Name.Value); + StringUtils.Copy(nameBuffer[i].Value, entry.Name.Value); } namesRead = i; diff --git a/src/LibHac/Boot/Package1.cs b/src/LibHac/Boot/Package1.cs index d75dc763..3565950e 100644 --- a/src/LibHac/Boot/Package1.cs +++ b/src/LibHac/Boot/Package1.cs @@ -39,7 +39,7 @@ public struct Package1MetaData public byte Version; [UnscopedRef] public U8Span BuildDate => new U8Span(_buildDate); - [UnscopedRef] public ReadOnlySpan Iv => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_buildDate.Items), 0x10); + [UnscopedRef] public ReadOnlySpan Iv => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_buildDate[..]), 0x10); } public struct Package1Stage1Footer @@ -283,7 +283,7 @@ public class Package1 private Result ReadModernEristaMac() { - return _baseStorage.Get.Read(ModernStage1Size + Pk11Size, _pk11Mac.Items); + return _baseStorage.Get.Read(ModernStage1Size + Pk11Size, _pk11Mac); } private Result SetPk11Storage() @@ -319,7 +319,7 @@ public class Package1 else { decPk11Storage = new Aes128CtrStorage(encPk11Storage, - KeySet.Package1Keys[KeyRevision].DataRo.ToArray(), _stage1Footer.Iv.ItemsRo.ToArray(), true); + KeySet.Package1Keys[KeyRevision].DataRo.ToArray(), _stage1Footer.Iv[..].ToArray(), true); } _pk11Storage = new SubStorage(new CachedStorage(decPk11Storage, 0x4000, 1, true), 0, Pk11Size); @@ -383,7 +383,7 @@ public class Package1 // MarikoOemHeader must be read first private bool IsMarikoImpl() { - return MarikoOemHeader.AesMac.ItemsRo.IsZeros() && MarikoOemHeader.Reserved.ItemsRo.IsZeros(); + return MarikoOemHeader.AesMac[..].IsZeros() && MarikoOemHeader.Reserved[..].IsZeros(); } /// @@ -416,7 +416,7 @@ public class Package1 if (IsModern) { - storages.Add(new MemoryStorage(_pk11Mac.ItemsRo.ToArray())); + storages.Add(new MemoryStorage(_pk11Mac[..].ToArray())); } } diff --git a/src/LibHac/Boot/Package2StorageReader.cs b/src/LibHac/Boot/Package2StorageReader.cs index 0114089a..9b4c0f0d 100644 --- a/src/LibHac/Boot/Package2StorageReader.cs +++ b/src/LibHac/Boot/Package2StorageReader.cs @@ -73,7 +73,7 @@ public class Package2StorageReader : IDisposable return Result.Success; } - byte[] iv = _header.Meta.PayloadIvs[index].ItemsRo.ToArray(); + byte[] iv = _header.Meta.PayloadIvs[index][..].ToArray(); outPayloadStorage.Reset(new CachedStorage(new Aes128CtrStorage(payloadSubStorage, _key.DataRo.ToArray(), iv, true), 0x4000, 1, true)); return Result.Success; } @@ -231,7 +231,7 @@ public class Package2StorageReader : IDisposable // The counter starts counting at the beginning of the meta struct, but the first block in // the struct isn't encrypted. Increase the counter by one to skip that block. - byte[] iv = _header.Meta.HeaderIv.ItemsRo.ToArray(); + byte[] iv = _header.Meta.HeaderIv[..].ToArray(); Utilities.IncrementByteArray(iv); storages.Add(new CachedStorage(new Aes128CtrStorage(encMetaStorage, _key.DataRo.ToArray(), iv, true), 0x100, 1, true)); diff --git a/src/LibHac/Common/FixedArrays/Array1.cs b/src/LibHac/Common/FixedArrays/Array1.cs deleted file mode 100644 index b26a5a2d..00000000 --- a/src/LibHac/Common/FixedArrays/Array1.cs +++ /dev/null @@ -1,21 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array1 -{ - public const int Length = 1; - - private T _0; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] public Span Items => SpanHelpers.CreateSpan(ref _0, Length); - [UnscopedRef] public readonly ReadOnlySpan ItemsRo => SpanHelpers.CreateReadOnlySpan(in _0, Length); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array1 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array100.cs b/src/LibHac/Common/FixedArrays/Array100.cs deleted file mode 100644 index 341845ae..00000000 --- a/src/LibHac/Common/FixedArrays/Array100.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array100 -{ - public const int Length = 100; - - private Array64 _0; - private Array36 _64; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array100 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array1024.cs b/src/LibHac/Common/FixedArrays/Array1024.cs deleted file mode 100644 index 7773952a..00000000 --- a/src/LibHac/Common/FixedArrays/Array1024.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array1024 -{ - public const int Length = 1024; - - private Array512 _0; - private Array512 _512; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array1024 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array11.cs b/src/LibHac/Common/FixedArrays/Array11.cs deleted file mode 100644 index e3543171..00000000 --- a/src/LibHac/Common/FixedArrays/Array11.cs +++ /dev/null @@ -1,31 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array11 -{ - public const int Length = 11; - - private T _0; - private T _1; - private T _2; - private T _3; - private T _4; - private T _5; - private T _6; - private T _7; - private T _8; - private T _9; - private T _10; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] public Span Items => SpanHelpers.CreateSpan(ref _0, Length); - [UnscopedRef] public readonly ReadOnlySpan ItemsRo => SpanHelpers.CreateReadOnlySpan(in _0, Length); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array11 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array112.cs b/src/LibHac/Common/FixedArrays/Array112.cs deleted file mode 100644 index 33efc0d8..00000000 --- a/src/LibHac/Common/FixedArrays/Array112.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array112 -{ - public const int Length = 112; - - private Array80 _0; - private Array32 _80; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array112 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array12.cs b/src/LibHac/Common/FixedArrays/Array12.cs deleted file mode 100644 index abcb9a1f..00000000 --- a/src/LibHac/Common/FixedArrays/Array12.cs +++ /dev/null @@ -1,32 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array12 -{ - public const int Length = 12; - - private T _0; - private T _1; - private T _2; - private T _3; - private T _4; - private T _5; - private T _6; - private T _7; - private T _8; - private T _9; - private T _10; - private T _11; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] public Span Items => SpanHelpers.CreateSpan(ref _0, Length); - [UnscopedRef] public readonly ReadOnlySpan ItemsRo => SpanHelpers.CreateReadOnlySpan(in _0, Length); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array12 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array128.cs b/src/LibHac/Common/FixedArrays/Array128.cs deleted file mode 100644 index 83846199..00000000 --- a/src/LibHac/Common/FixedArrays/Array128.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array128 -{ - public const int Length = 128; - - private Array64 _0; - private Array64 _64; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array128 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array14.cs b/src/LibHac/Common/FixedArrays/Array14.cs deleted file mode 100644 index 3891a881..00000000 --- a/src/LibHac/Common/FixedArrays/Array14.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array14 -{ - public const int Length = 14; - - private Array8 _0; - private Array6 _8; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array14 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array144.cs b/src/LibHac/Common/FixedArrays/Array144.cs deleted file mode 100644 index f9866c7e..00000000 --- a/src/LibHac/Common/FixedArrays/Array144.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array144 -{ - public const int Length = 144; - - private Array128 _0; - private Array16 _128; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array144 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array15.cs b/src/LibHac/Common/FixedArrays/Array15.cs deleted file mode 100644 index 0c4f525b..00000000 --- a/src/LibHac/Common/FixedArrays/Array15.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array15 -{ - public const int Length = 15; - - private Array8 _0; - private Array7 _8; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array15 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array16.cs b/src/LibHac/Common/FixedArrays/Array16.cs deleted file mode 100644 index 03d99869..00000000 --- a/src/LibHac/Common/FixedArrays/Array16.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array16 -{ - public const int Length = 16; - - private Array8 _0; - private Array8 _8; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array16 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array16384.cs b/src/LibHac/Common/FixedArrays/Array16384.cs deleted file mode 100644 index a1438ef2..00000000 --- a/src/LibHac/Common/FixedArrays/Array16384.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array16384 -{ - public const int Length = 16384; - - private Array8192 _0; - private Array8192 _8192; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array16384 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array18.cs b/src/LibHac/Common/FixedArrays/Array18.cs deleted file mode 100644 index fc790594..00000000 --- a/src/LibHac/Common/FixedArrays/Array18.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array18 -{ - public const int Length = 18; - - private Array16 _0; - private Array2 _16; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array18 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array192.cs b/src/LibHac/Common/FixedArrays/Array192.cs deleted file mode 100644 index 633ed43e..00000000 --- a/src/LibHac/Common/FixedArrays/Array192.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array192 -{ - public const int Length = 192; - - private Array128 _0; - private Array64 _128; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array192 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array2.cs b/src/LibHac/Common/FixedArrays/Array2.cs deleted file mode 100644 index d2f27166..00000000 --- a/src/LibHac/Common/FixedArrays/Array2.cs +++ /dev/null @@ -1,22 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array2 -{ - public const int Length = 2; - - private T _0; - private T _1; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] public Span Items => SpanHelpers.CreateSpan(ref _0, Length); - [UnscopedRef] public readonly ReadOnlySpan ItemsRo => SpanHelpers.CreateReadOnlySpan(in _0, Length); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array2 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array20.cs b/src/LibHac/Common/FixedArrays/Array20.cs deleted file mode 100644 index 3b58eb24..00000000 --- a/src/LibHac/Common/FixedArrays/Array20.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array20 -{ - public const int Length = 20; - - private Array16 _0; - private Array4 _16; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array20 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array2048.cs b/src/LibHac/Common/FixedArrays/Array2048.cs deleted file mode 100644 index 77f762cc..00000000 --- a/src/LibHac/Common/FixedArrays/Array2048.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array2048 -{ - public const int Length = 2048; - - private Array1024 _0; - private Array1024 _1024; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array2048 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array24.cs b/src/LibHac/Common/FixedArrays/Array24.cs deleted file mode 100644 index 22eee51e..00000000 --- a/src/LibHac/Common/FixedArrays/Array24.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array24 -{ - public const int Length = 24; - - private Array16 _0; - private Array8 _16; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array24 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array256.cs b/src/LibHac/Common/FixedArrays/Array256.cs deleted file mode 100644 index 14a60957..00000000 --- a/src/LibHac/Common/FixedArrays/Array256.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array256 -{ - public const int Length = 256; - - private Array128 _0; - private Array128 _128; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array256 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array26.cs b/src/LibHac/Common/FixedArrays/Array26.cs deleted file mode 100644 index f91d3982..00000000 --- a/src/LibHac/Common/FixedArrays/Array26.cs +++ /dev/null @@ -1,35 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array26 -{ - public const int Length = 26; - - private Array16 _0; - private Array8 _16; - private Array2 _24; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array26 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array27.cs b/src/LibHac/Common/FixedArrays/Array27.cs deleted file mode 100644 index 88d72eee..00000000 --- a/src/LibHac/Common/FixedArrays/Array27.cs +++ /dev/null @@ -1,36 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array27 -{ - public const int Length = 27; - - private Array16 _0; - private Array8 _16; - private Array2 _24; - private T _26; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array27 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array28.cs b/src/LibHac/Common/FixedArrays/Array28.cs deleted file mode 100644 index 76d44460..00000000 --- a/src/LibHac/Common/FixedArrays/Array28.cs +++ /dev/null @@ -1,35 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array28 -{ - public const int Length = 28; - - private Array16 _0; - private Array8 _16; - private Array4 _24; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array28 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array3.cs b/src/LibHac/Common/FixedArrays/Array3.cs deleted file mode 100644 index efab5fdf..00000000 --- a/src/LibHac/Common/FixedArrays/Array3.cs +++ /dev/null @@ -1,23 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array3 -{ - public const int Length = 3; - - private T _0; - private T _1; - private T _2; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] public Span Items => SpanHelpers.CreateSpan(ref _0, Length); - [UnscopedRef] public readonly ReadOnlySpan ItemsRo => SpanHelpers.CreateReadOnlySpan(in _0, Length); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array3 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array3000.cs b/src/LibHac/Common/FixedArrays/Array3000.cs deleted file mode 100644 index 3f7dbc7f..00000000 --- a/src/LibHac/Common/FixedArrays/Array3000.cs +++ /dev/null @@ -1,37 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array3000 -{ - public const int Length = 3000; - - private Array2048 _0; - private Array512 _2048; - private Array256 _2560; - private Array128 _2816; - private Array56 _2944; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array3000 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array32.cs b/src/LibHac/Common/FixedArrays/Array32.cs deleted file mode 100644 index a59569b2..00000000 --- a/src/LibHac/Common/FixedArrays/Array32.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array32 -{ - public const int Length = 32; - - private Array16 _0; - private Array16 _16; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array32 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array356.cs b/src/LibHac/Common/FixedArrays/Array356.cs deleted file mode 100644 index 513107f0..00000000 --- a/src/LibHac/Common/FixedArrays/Array356.cs +++ /dev/null @@ -1,36 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array356 -{ - public const int Length = 356; - - private Array256 _0; - private Array64 _256; - private Array32 _320; - private Array4 _352; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array356 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array36.cs b/src/LibHac/Common/FixedArrays/Array36.cs deleted file mode 100644 index 3bcc8b72..00000000 --- a/src/LibHac/Common/FixedArrays/Array36.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array36 -{ - public const int Length = 36; - - private Array32 _0; - private Array4 _32; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array36 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array37.cs b/src/LibHac/Common/FixedArrays/Array37.cs deleted file mode 100644 index db7c5270..00000000 --- a/src/LibHac/Common/FixedArrays/Array37.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array37 -{ - public const int Length = 37; - - private Array32 _0; - private Array5 _32; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array37 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array38.cs b/src/LibHac/Common/FixedArrays/Array38.cs deleted file mode 100644 index 358ec291..00000000 --- a/src/LibHac/Common/FixedArrays/Array38.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array38 -{ - public const int Length = 38; - - private Array32 _0; - private Array6 _32; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array38 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array4.cs b/src/LibHac/Common/FixedArrays/Array4.cs deleted file mode 100644 index 9060b902..00000000 --- a/src/LibHac/Common/FixedArrays/Array4.cs +++ /dev/null @@ -1,24 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array4 -{ - public const int Length = 4; - - private T _0; - private T _1; - private T _2; - private T _3; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] public Span Items => SpanHelpers.CreateSpan(ref _0, Length); - [UnscopedRef] public readonly ReadOnlySpan ItemsRo => SpanHelpers.CreateReadOnlySpan(in _0, Length); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array4 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array400.cs b/src/LibHac/Common/FixedArrays/Array400.cs deleted file mode 100644 index 29831cf3..00000000 --- a/src/LibHac/Common/FixedArrays/Array400.cs +++ /dev/null @@ -1,35 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array400 -{ - public const int Length = 400; - - private Array256 _0; - private Array128 _256; - private Array16 _384; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array400 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array4096.cs b/src/LibHac/Common/FixedArrays/Array4096.cs deleted file mode 100644 index 6743b875..00000000 --- a/src/LibHac/Common/FixedArrays/Array4096.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array4096 -{ - public const int Length = 4096; - - private Array2048 _0; - private Array2048 _2048; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array4096 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array436.cs b/src/LibHac/Common/FixedArrays/Array436.cs deleted file mode 100644 index a552b403..00000000 --- a/src/LibHac/Common/FixedArrays/Array436.cs +++ /dev/null @@ -1,36 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array436 -{ - public const int Length = 436; - - private Array256 _0; - private Array128 _256; - private Array32 _384; - private Array20 _416; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array436 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array452.cs b/src/LibHac/Common/FixedArrays/Array452.cs deleted file mode 100644 index f43571fe..00000000 --- a/src/LibHac/Common/FixedArrays/Array452.cs +++ /dev/null @@ -1,36 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array452 -{ - public const int Length = 452; - - private Array256 _0; - private Array128 _256; - private Array64 _384; - private Array4 _448; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array452 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array464.cs b/src/LibHac/Common/FixedArrays/Array464.cs deleted file mode 100644 index ae31b74c..00000000 --- a/src/LibHac/Common/FixedArrays/Array464.cs +++ /dev/null @@ -1,36 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array464 -{ - public const int Length = 464; - - private Array256 _0; - private Array128 _256; - private Array64 _384; - private Array16 _448; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array464 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array48.cs b/src/LibHac/Common/FixedArrays/Array48.cs deleted file mode 100644 index 2a72dc84..00000000 --- a/src/LibHac/Common/FixedArrays/Array48.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array48 -{ - public const int Length = 48; - - private Array32 _0; - private Array16 _32; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array48 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array5.cs b/src/LibHac/Common/FixedArrays/Array5.cs deleted file mode 100644 index 49aa4378..00000000 --- a/src/LibHac/Common/FixedArrays/Array5.cs +++ /dev/null @@ -1,25 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array5 -{ - public const int Length = 5; - - private T _0; - private T _1; - private T _2; - private T _3; - private T _4; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] public Span Items => SpanHelpers.CreateSpan(ref _0, Length); - [UnscopedRef] public readonly ReadOnlySpan ItemsRo => SpanHelpers.CreateReadOnlySpan(in _0, Length); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array5 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array512.cs b/src/LibHac/Common/FixedArrays/Array512.cs deleted file mode 100644 index 04fdd0ff..00000000 --- a/src/LibHac/Common/FixedArrays/Array512.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array512 -{ - public const int Length = 512; - - private Array256 _0; - private Array256 _256; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array512 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array56.cs b/src/LibHac/Common/FixedArrays/Array56.cs deleted file mode 100644 index 3b730c2d..00000000 --- a/src/LibHac/Common/FixedArrays/Array56.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array56 -{ - public const int Length = 56; - - private Array32 _0; - private Array24 _32; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array56 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array6.cs b/src/LibHac/Common/FixedArrays/Array6.cs deleted file mode 100644 index 8772c9df..00000000 --- a/src/LibHac/Common/FixedArrays/Array6.cs +++ /dev/null @@ -1,26 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array6 -{ - public const int Length = 6; - - private T _0; - private T _1; - private T _2; - private T _3; - private T _4; - private T _5; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] public Span Items => SpanHelpers.CreateSpan(ref _0, Length); - [UnscopedRef] public readonly ReadOnlySpan ItemsRo => SpanHelpers.CreateReadOnlySpan(in _0, Length); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array6 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array60.cs b/src/LibHac/Common/FixedArrays/Array60.cs deleted file mode 100644 index 56051820..00000000 --- a/src/LibHac/Common/FixedArrays/Array60.cs +++ /dev/null @@ -1,35 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array60 -{ - public const int Length = 60; - - private Array32 _0; - private Array16 _32; - private Array12 _48; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array60 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array64.cs b/src/LibHac/Common/FixedArrays/Array64.cs deleted file mode 100644 index 439bca02..00000000 --- a/src/LibHac/Common/FixedArrays/Array64.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array64 -{ - public const int Length = 64; - - private Array32 _0; - private Array32 _32; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array64 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array65.cs b/src/LibHac/Common/FixedArrays/Array65.cs deleted file mode 100644 index 069c60f5..00000000 --- a/src/LibHac/Common/FixedArrays/Array65.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array65 -{ - public const int Length = 65; - - private Array64 _0; - private T _64; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array65 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array68.cs b/src/LibHac/Common/FixedArrays/Array68.cs deleted file mode 100644 index e389f095..00000000 --- a/src/LibHac/Common/FixedArrays/Array68.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array68 -{ - public const int Length = 68; - - private Array64 _0; - private Array4 _64; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array68 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array7.cs b/src/LibHac/Common/FixedArrays/Array7.cs deleted file mode 100644 index 90f8871e..00000000 --- a/src/LibHac/Common/FixedArrays/Array7.cs +++ /dev/null @@ -1,27 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array7 -{ - public const int Length = 7; - - private T _0; - private T _1; - private T _2; - private T _3; - private T _4; - private T _5; - private T _6; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] public Span Items => SpanHelpers.CreateSpan(ref _0, Length); - [UnscopedRef] public readonly ReadOnlySpan ItemsRo => SpanHelpers.CreateReadOnlySpan(in _0, Length); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array7 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array768.cs b/src/LibHac/Common/FixedArrays/Array768.cs deleted file mode 100644 index 8f17fe3c..00000000 --- a/src/LibHac/Common/FixedArrays/Array768.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array768 -{ - public const int Length = 768; - - private Array512 _0; - private Array256 _512; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array768 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array769.cs b/src/LibHac/Common/FixedArrays/Array769.cs deleted file mode 100644 index 052db573..00000000 --- a/src/LibHac/Common/FixedArrays/Array769.cs +++ /dev/null @@ -1,35 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array769 -{ - public const int Length = 769; - - private Array512 _0; - private Array256 _512; - private Array1 _768; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array769 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array8.cs b/src/LibHac/Common/FixedArrays/Array8.cs deleted file mode 100644 index 6b7b64b4..00000000 --- a/src/LibHac/Common/FixedArrays/Array8.cs +++ /dev/null @@ -1,28 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array8 -{ - public const int Length = 8; - - private T _0; - private T _1; - private T _2; - private T _3; - private T _4; - private T _5; - private T _6; - private T _7; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] public Span Items => SpanHelpers.CreateSpan(ref _0, Length); - [UnscopedRef] public readonly ReadOnlySpan ItemsRo => SpanHelpers.CreateReadOnlySpan(in _0, Length); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array8 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array80.cs b/src/LibHac/Common/FixedArrays/Array80.cs deleted file mode 100644 index 2aacc932..00000000 --- a/src/LibHac/Common/FixedArrays/Array80.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array80 -{ - public const int Length = 80; - - private Array64 _0; - private Array16 _64; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array80 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array8192.cs b/src/LibHac/Common/FixedArrays/Array8192.cs deleted file mode 100644 index 2669e3d9..00000000 --- a/src/LibHac/Common/FixedArrays/Array8192.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array8192 -{ - public const int Length = 8192; - - private Array4096 _0; - private Array4096 _4096; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array8192 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Array96.cs b/src/LibHac/Common/FixedArrays/Array96.cs deleted file mode 100644 index c388d00a..00000000 --- a/src/LibHac/Common/FixedArrays/Array96.cs +++ /dev/null @@ -1,34 +0,0 @@ -#pragma warning disable CS0169, CS0649, IDE0051 // Field is never used, Field is never assigned to, Remove unused private members -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace LibHac.Common.FixedArrays; - -public struct Array96 -{ - public const int Length = 96; - - private Array80 _0; - private Array16 _80; - - [UnscopedRef] public ref T this[int i] => ref Items[i]; - - [UnscopedRef] - public Span Items - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.Items), Length); - } - - [UnscopedRef] - public readonly ReadOnlySpan ItemsRo - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => SpanHelpers.CreateSpan(ref MemoryMarshal.GetReference(_0.ItemsRo), Length); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator ReadOnlySpan(in Array96 value) => value.ItemsRo; -} \ No newline at end of file diff --git a/src/LibHac/Common/FixedArrays/Arrays.cs b/src/LibHac/Common/FixedArrays/Arrays.cs new file mode 100644 index 00000000..c2b32ef6 --- /dev/null +++ b/src/LibHac/Common/FixedArrays/Arrays.cs @@ -0,0 +1,50 @@ +using System.Runtime.CompilerServices; + +namespace LibHac.Common.FixedArrays; + +[InlineArray(1)] public struct Array1 { public readonly int Length => 1; private T _0; } +[InlineArray(2)] public struct Array2 { public readonly int Length => 2; private T _0; } +[InlineArray(3)] public struct Array3 { public readonly int Length => 3; private T _0; } +[InlineArray(4)] public struct Array4 { public readonly int Length => 4; private T _0; } +[InlineArray(5)] public struct Array5 { public readonly int Length => 5; private T _0; } +[InlineArray(6)] public struct Array6 { public readonly int Length => 6; private T _0; } +[InlineArray(7)] public struct Array7 { public readonly int Length => 7; private T _0; } +[InlineArray(8)] public struct Array8 { public readonly int Length => 8; private T _0; } +[InlineArray(11)] public struct Array11 { public readonly int Length => 11; private T _0; } +[InlineArray(12)] public struct Array12 { public readonly int Length => 12; private T _0; } +[InlineArray(14)] public struct Array14 { public readonly int Length => 14; private T _0; } +[InlineArray(15)] public struct Array15 { public readonly int Length => 15; private T _0; } +[InlineArray(16)] public struct Array16 { public readonly int Length => 16; private T _0; } +[InlineArray(18)] public struct Array18 { public readonly int Length => 18; private T _0; } +[InlineArray(20)] public struct Array20 { public readonly int Length => 20; private T _0; } +[InlineArray(24)] public struct Array24 { public readonly int Length => 24; private T _0; } +[InlineArray(26)] public struct Array26 { public readonly int Length => 26; private T _0; } +[InlineArray(27)] public struct Array27 { public readonly int Length => 27; private T _0; } +[InlineArray(28)] public struct Array28 { public readonly int Length => 28; private T _0; } +[InlineArray(32)] public struct Array32 { public readonly int Length => 32; private T _0; } +[InlineArray(36)] public struct Array36 { public readonly int Length => 36; private T _0; } +[InlineArray(37)] public struct Array37 { public readonly int Length => 37; private T _0; } +[InlineArray(38)] public struct Array38 { public readonly int Length => 38; private T _0; } +[InlineArray(48)] public struct Array48 { public readonly int Length => 48; private T _0; } +[InlineArray(56)] public struct Array56 { public readonly int Length => 56; private T _0; } +[InlineArray(60)] public struct Array60 { public readonly int Length => 60; private T _0; } +[InlineArray(64)] public struct Array64 { public readonly int Length => 64; private T _0; } +[InlineArray(65)] public struct Array65 { public readonly int Length => 65; private T _0; } +[InlineArray(68)] public struct Array68 { public readonly int Length => 68; private T _0; } +[InlineArray(100)] public struct Array100 { public readonly int Length => 100; private T _0; } +[InlineArray(112)] public struct Array112 { public readonly int Length => 112; private T _0; } +[InlineArray(128)] public struct Array128 { public readonly int Length => 128; private T _0; } +[InlineArray(144)] public struct Array144 { public readonly int Length => 144; private T _0; } +[InlineArray(192)] public struct Array192 { public readonly int Length => 192; private T _0; } +[InlineArray(256)] public struct Array256 { public readonly int Length => 256; private T _0; } +[InlineArray(356)] public struct Array356 { public readonly int Length => 356; private T _0; } +[InlineArray(400)] public struct Array400 { public readonly int Length => 400; private T _0; } +[InlineArray(436)] public struct Array436 { public readonly int Length => 436; private T _0; } +[InlineArray(452)] public struct Array452 { public readonly int Length => 452; private T _0; } +[InlineArray(464)] public struct Array464 { public readonly int Length => 464; private T _0; } +[InlineArray(512)] public struct Array512 { public readonly int Length => 512; private T _0; } +[InlineArray(768)] public struct Array768 { public readonly int Length => 768; private T _0; } +[InlineArray(769)] public struct Array769 { public readonly int Length => 769; private T _0; } +[InlineArray(3000)] public struct Array3000 { public readonly int Length => 3000; private T _0; } +[InlineArray(8192)] public struct Array8192 { public readonly int Length => 8192; private T _0; } +[InlineArray(16384)] public struct Array16384 { public readonly int Length => 16384; private T _0; } \ No newline at end of file diff --git a/src/LibHac/Common/Keys/KeySet.cs b/src/LibHac/Common/Keys/KeySet.cs index dbe4a686..e995c1f8 100644 --- a/src/LibHac/Common/Keys/KeySet.cs +++ b/src/LibHac/Common/Keys/KeySet.cs @@ -54,37 +54,37 @@ public class KeySet public ExternalKeySet ExternalKeySet { get; } = new ExternalKeySet(); - public Span MarikoAesClassKeys => RootKeys.MarikoAesClassKeys.Items; + public Span MarikoAesClassKeys => RootKeys.MarikoAesClassKeys; public ref AesKey MarikoKek => ref RootKeys.MarikoKek; public ref AesKey MarikoBek => ref RootKeys.MarikoBek; - public Span KeyBlobs => RootKeys.KeyBlobs.Items; - public Span KeyBlobKeySources => _keys.KeySeeds.KeyBlobKeySources.Items; + public Span KeyBlobs => RootKeys.KeyBlobs; + public Span KeyBlobKeySources => _keys.KeySeeds.KeyBlobKeySources; public ref AesKey KeyBlobMacKeySource => ref _keys.KeySeeds.KeyBlobMacKeySource; - public Span TsecSecrets => Secrets.Secrets.Items; - public Span TsecRootKeks => RootKeys.TsecRootKeks.Items; - public Span Package1MacKeks => RootKeys.Package1MacKeks.Items; - public Span Package1Keks => RootKeys.Package1Keks.Items; - public Span TsecAuthSignatures => _keys.KeySeeds.TsecAuthSignatures.Items; - public Span TsecRootKeys => RootKeys.TsecRootKeys.Items; - public Span MasterKekSources => _keys.KeySeeds.MasterKekSources.Items; - public Span GcTitleKeyKeks => RootKeys.GcTitleKeyKeks.Items; + public Span TsecSecrets => Secrets.Secrets; + public Span TsecRootKeks => RootKeys.TsecRootKeks; + public Span Package1MacKeks => RootKeys.Package1MacKeks; + public Span Package1Keks => RootKeys.Package1Keks; + public Span TsecAuthSignatures => _keys.KeySeeds.TsecAuthSignatures; + public Span TsecRootKeys => RootKeys.TsecRootKeys; + public Span MasterKekSources => _keys.KeySeeds.MasterKekSources; + public Span GcTitleKeyKeks => RootKeys.GcTitleKeyKeks; public Span MarikoMasterKekSources => _mode == Mode.Dev - ? _keys.KeySeeds.MarikoMasterKekSourcesDev.Items - : _keys.KeySeeds.MarikoMasterKekSources.Items; + ? _keys.KeySeeds.MarikoMasterKekSourcesDev[..] + : _keys.KeySeeds.MarikoMasterKekSources[..]; - public Span MasterKeks => DerivedKeys.MasterKeks.Items; + public Span MasterKeks => DerivedKeys.MasterKeks; public ref AesKey MasterKeySource => ref _keys.KeySeeds.MasterKeySource; - public Span MasterKeys => DerivedKeys.MasterKeys.Items; - public Span Package1MacKeys => DerivedKeys.Package1MacKeys.Items; - public Span Package1Keys => DerivedKeys.Package1Keys.Items; - public Span Package2Keys => DerivedKeys.Package2Keys.Items; + public Span MasterKeys => DerivedKeys.MasterKeys; + public Span Package1MacKeys => DerivedKeys.Package1MacKeys; + public Span Package1Keys => DerivedKeys.Package1Keys; + public Span Package2Keys => DerivedKeys.Package2Keys; public ref AesKey Package2KeySource => ref _keys.KeySeeds.Package2KeySource; public ref AesKey PerConsoleKeySource => ref _keys.KeySeeds.PerConsoleKeySource; public ref AesKey RetailSpecificAesKeySource => ref _keys.KeySeeds.RetailSpecificAesKeySource; public ref AesKey BisKekSource => ref _keys.KeySeeds.BisKekSource; - public Span BisKeySources => _keys.KeySeeds.BisKeySources.Items; + public Span BisKeySources => _keys.KeySeeds.BisKeySources; public ref AesKey AesKekGenerationSource => ref _keys.KeySeeds.AesKekGenerationSource; public ref AesKey AesKeyGenerationSource => ref _keys.KeySeeds.AesKeyGenerationSource; public ref AesKey KeyAreaKeyApplicationSource => ref _keys.KeySeeds.KeyAreaKeyApplicationSource; @@ -93,15 +93,15 @@ public class KeySet public ref AesKey TitleKekSource => ref _keys.KeySeeds.TitleKekSource; public ref AesKey HeaderKekSource => ref _keys.KeySeeds.HeaderKekSource; public ref AesKey SdCardKekSource => ref _keys.KeySeeds.SdCardKekSource; - public Span SdCardKeySources => _keys.KeySeeds.SdCardKeySources.Items; + public Span SdCardKeySources => _keys.KeySeeds.SdCardKeySources; public ref AesKey DeviceUniqueSaveMacKekSource => ref _keys.KeySeeds.DeviceUniqueSaveMacKekSource; - public Span DeviceUniqueSaveMacKeySources => _keys.KeySeeds.DeviceUniqueSaveMacKeySources.Items; + public Span DeviceUniqueSaveMacKeySources => _keys.KeySeeds.DeviceUniqueSaveMacKeySources; public ref AesKey SeedUniqueSaveMacKekSource => ref _keys.KeySeeds.SeedUniqueSaveMacKekSource; public ref AesKey SeedUniqueSaveMacKeySource => ref _keys.KeySeeds.SeedUniqueSaveMacKeySource; public ref AesXtsKey HeaderKeySource => ref _keys.KeySeeds.HeaderKeySource; public ref AesXtsKey HeaderKey => ref DerivedKeys.HeaderKey; - public Span TitleKeks => DerivedKeys.TitleKeks.Items; - public Span> KeyAreaKeys => DerivedKeys.KeyAreaKeys.Items; + public Span TitleKeks => DerivedKeys.TitleKeks; + public Span> KeyAreaKeys => DerivedKeys.KeyAreaKeys; public ref AesKey XciHeaderKey => ref StoredKeys.XciHeaderKey; public ref AesKey ETicketRsaKek => ref DerivedKeys.ETicketRsaKek; public ref AesKey SslRsaKek => ref DerivedKeys.SslRsaKek; @@ -109,20 +109,20 @@ public class KeySet public ref AesKey SecureBootKey => ref _keys.DeviceKeys.SecureBootKey; public ref AesKey TsecKey => ref _keys.DeviceKeys.TsecKey; public ref AesKey SdCardEncryptionSeed => ref _keys.DeviceKeys.SdCardEncryptionSeed; - public Span EncryptedKeyBlobs => _keys.DeviceKeys.EncryptedKeyBlobs.Items; + public Span EncryptedKeyBlobs => _keys.DeviceKeys.EncryptedKeyBlobs; - public Span KeyBlobKeys => DerivedDeviceKeys.KeyBlobKeys.Items; - public Span KeyBlobMacKeys => DerivedDeviceKeys.KeyBlobMacKeys.Items; + public Span KeyBlobKeys => DerivedDeviceKeys.KeyBlobKeys; + public Span KeyBlobMacKeys => DerivedDeviceKeys.KeyBlobMacKeys; public ref AesKey DeviceKey => ref DerivedDeviceKeys.DeviceKey; - public Span BisKeys => DerivedDeviceKeys.BisKeys.Items; - public Span DeviceUniqueSaveMacKeys => DerivedDeviceKeys.DeviceUniqueSaveMacKeys.Items; + public Span BisKeys => DerivedDeviceKeys.BisKeys; + public Span DeviceUniqueSaveMacKeys => DerivedDeviceKeys.DeviceUniqueSaveMacKeys; public ref AesKey SeedUniqueSaveMacKey => ref DerivedDeviceKeys.SeedUniqueSaveMacKey; // Todo: Make a separate type? Not actually an AES-XTS key, but it's still the same shape. - public Span SdCardEncryptionKeys => DerivedDeviceKeys.SdCardEncryptionKeys.Items; + public Span SdCardEncryptionKeys => DerivedDeviceKeys.SdCardEncryptionKeys; - public Span NcaHeaderSigningKeys => RsaSigningKeys.NcaHeaderSigningKeys.Items; - public Span AcidSigningKeys => RsaSigningKeys.AcidSigningKeys.Items; + public Span NcaHeaderSigningKeys => RsaSigningKeys.NcaHeaderSigningKeys; + public Span AcidSigningKeys => RsaSigningKeys.AcidSigningKeys; public ref RsaKey Package2SigningKey => ref RsaSigningKeys.Package2SigningKey; public ref RsaFullKey BetaNca0KeyAreaKey => ref RsaKeys.BetaNca0KeyAreaKey; public ref RsaKeyPair ETicketRsaKey => ref DeviceRsaKeys.ETicketRsaKey; @@ -147,7 +147,7 @@ public class KeySet // Todo: Remove local variable after Roslyn issue #67697 is fixed ref Array2 array = ref keys.Value; - return array.Items; + return array; } } @@ -166,7 +166,7 @@ public class KeySet // Todo: Remove local variable after Roslyn issue #67697 is fixed ref Array2 array = ref keys.Value; - return array.Items; + return array; } } @@ -207,7 +207,7 @@ public class KeySet { ref Optional keys = ref _rsaKeyParams.ETicketRsaKey; - if (!keys.HasValue && !ETicketRsaKey.PublicExponent.ItemsRo.IsZeros()) + if (!keys.HasValue && !ETicketRsaKey.PublicExponent[..].IsZeros()) { RSAParameters rsaParams = Rsa.RecoverParameters(ETicketRsaKey.Modulus, ETicketRsaKey.PublicExponent, ETicketRsaKey.PrivateExponent); keys.Set(rsaParams); @@ -261,8 +261,8 @@ public class KeySet { return new RSAParameters { - Exponent = key.PublicExponent.ItemsRo.ToArray(), - Modulus = key.Modulus.ItemsRo.ToArray() + Exponent = key.PublicExponent[..].ToArray(), + Modulus = key.Modulus[..].ToArray() }; } @@ -270,14 +270,14 @@ public class KeySet { return new RSAParameters { - D = key.PrivateExponent.ItemsRo.ToArray(), - DP = key.Dp.ItemsRo.ToArray(), - DQ = key.Dq.ItemsRo.ToArray(), - Exponent = key.PublicExponent.ItemsRo.ToArray(), - InverseQ = key.InverseQ.ItemsRo.ToArray(), - Modulus = key.Modulus.ItemsRo.ToArray(), - P = key.P.ItemsRo.ToArray(), - Q = key.Q.ItemsRo.ToArray() + D = key.PrivateExponent[..].ToArray(), + DP = key.Dp[..].ToArray(), + DQ = key.Dq[..].ToArray(), + Exponent = key.PublicExponent[..].ToArray(), + InverseQ = key.InverseQ[..].ToArray(), + Modulus = key.Modulus[..].ToArray(), + P = key.P[..].ToArray(), + Q = key.Q[..].ToArray() }; } diff --git a/src/LibHac/Fs/Common/SaveDataTypes.cs b/src/LibHac/Fs/Common/SaveDataTypes.cs index 22b82032..f0f8ee0c 100644 --- a/src/LibHac/Fs/Common/SaveDataTypes.cs +++ b/src/LibHac/Fs/Common/SaveDataTypes.cs @@ -123,8 +123,8 @@ public struct HashSalt { private Array32 _value; - [UnscopedRef] public Span Hash => _value.Items; - [UnscopedRef] public readonly ReadOnlySpan HashRo => _value.ItemsRo; + [UnscopedRef] public Span Hash => _value; + [UnscopedRef] public readonly ReadOnlySpan HashRo => _value; } public struct SaveDataAttribute : IEquatable, IComparable @@ -385,19 +385,19 @@ internal static class SaveDataTypesValidity public static bool IsValid(in SaveDataCreationInfo2 creationInfo) { - foreach (byte b in creationInfo.Reserved1.ItemsRo) + foreach (byte b in creationInfo.Reserved1) if (b != 0) return false; - foreach (byte b in creationInfo.Reserved2.ItemsRo) + foreach (byte b in creationInfo.Reserved2) if (b != 0) return false; - foreach (byte b in creationInfo.Reserved3.ItemsRo) + foreach (byte b in creationInfo.Reserved3) if (b != 0) return false; - foreach (byte b in creationInfo.Reserved4.ItemsRo) + foreach (byte b in creationInfo.Reserved4) if (b != 0) return false; - foreach (byte b in creationInfo.Attribute.Reserved.ItemsRo) + foreach (byte b in creationInfo.Attribute.Reserved) if (b != 0) return false; return IsValid(in creationInfo.Attribute) diff --git a/src/LibHac/Fs/EncryptionSeed.cs b/src/LibHac/Fs/EncryptionSeed.cs index 8d5601e1..26af6ebd 100644 --- a/src/LibHac/Fs/EncryptionSeed.cs +++ b/src/LibHac/Fs/EncryptionSeed.cs @@ -7,5 +7,5 @@ public struct EncryptionSeed { public Array16 Value; - public readonly override string ToString() => Value.ItemsRo.ToHexString(); + public readonly override string ToString() => Value[..].ToHexString(); } \ No newline at end of file diff --git a/src/LibHac/Fs/MountName.cs b/src/LibHac/Fs/MountName.cs index cfd37d93..7009505b 100644 --- a/src/LibHac/Fs/MountName.cs +++ b/src/LibHac/Fs/MountName.cs @@ -8,7 +8,7 @@ namespace LibHac.Fs; internal struct MountName { private Array16 _nameArray; - [UnscopedRef] public Span Name => _nameArray.Items; + [UnscopedRef] public Span Name => _nameArray; public override string ToString() => new U8Span(Name).ToString(); } \ No newline at end of file diff --git a/src/LibHac/Fs/RightsId.cs b/src/LibHac/Fs/RightsId.cs index a81b5cf5..688555ef 100644 --- a/src/LibHac/Fs/RightsId.cs +++ b/src/LibHac/Fs/RightsId.cs @@ -20,19 +20,19 @@ public struct RightsId : IEquatable Unsafe.SkipInit(out Value); - Span longsThis = MemoryMarshal.Cast(Value.Items); + Span longsThis = MemoryMarshal.Cast(Value); ReadOnlySpan longsValue = MemoryMarshal.Cast(value); longsThis[1] = longsValue[1]; longsThis[0] = longsValue[0]; } - public readonly override string ToString() => Value.ItemsRo.ToHexString(); + public readonly override string ToString() => Value[..].ToHexString(); public readonly string DebugDisplay() { - ReadOnlySpan highBytes = Value.ItemsRo.Slice(0, 8); - ReadOnlySpan lowBytes = Value.ItemsRo.Slice(8, 8); + ReadOnlySpan highBytes = Value[..].Slice(0, 8); + ReadOnlySpan lowBytes = Value[..].Slice(8, 8); return $"{highBytes.ToHexString()} {lowBytes.ToHexString()}"; } @@ -47,7 +47,7 @@ public struct RightsId : IEquatable public readonly override int GetHashCode() { - ReadOnlySpan longSpan = MemoryMarshal.Cast(Value.ItemsRo); + ReadOnlySpan longSpan = MemoryMarshal.Cast(Value[..]); return HashCode.Combine(longSpan[0], longSpan[1]); } diff --git a/src/LibHac/Fs/Shim/Host.cs b/src/LibHac/Fs/Shim/Host.cs index 81d19ccf..b6c7241a 100644 --- a/src/LibHac/Fs/Shim/Host.cs +++ b/src/LibHac/Fs/Shim/Host.cs @@ -69,7 +69,7 @@ public static class Host public HostCommonMountNameGenerator(U8Span path) { - StringUtils.Strlcpy(_path.Items, path, PathTool.EntryNameLengthMax + 1); + StringUtils.Strlcpy(_path, path, PathTool.EntryNameLengthMax + 1); } public void Dispose() { } diff --git a/src/LibHac/FsSrv/DebugConfigurationService.cs b/src/LibHac/FsSrv/DebugConfigurationService.cs index e86442fd..7e255cc5 100644 --- a/src/LibHac/FsSrv/DebugConfigurationService.cs +++ b/src/LibHac/FsSrv/DebugConfigurationService.cs @@ -98,7 +98,7 @@ public class DebugConfigurationServiceImpl : IDisposable using ScopedLock scopedLock = ScopedLock.Lock(ref _mutex); - for (int i = 0; i < _entries.ItemsRo.Length; i++) + for (int i = 0; i < _entries.Length; i++) { // Update the existing value if the key is already registered if (_entries[i].Key == key) @@ -108,7 +108,7 @@ public class DebugConfigurationServiceImpl : IDisposable } } - for (int i = 0; i < _entries.ItemsRo.Length; i++) + for (int i = 0; i < _entries.Length; i++) { if (_entries[i].Key == 0) { @@ -130,7 +130,7 @@ public class DebugConfigurationServiceImpl : IDisposable using ScopedLock scopedLock = ScopedLock.Lock(ref _mutex); - for (int i = 0; i < _entries.ItemsRo.Length; i++) + for (int i = 0; i < _entries.Length; i++) { if (_entries[i].Key == key) { @@ -150,7 +150,7 @@ public class DebugConfigurationServiceImpl : IDisposable using ScopedLock scopedLock = ScopedLock.Lock(ref _mutex); - for (int i = 0; i < _entries.ItemsRo.Length; i++) + for (int i = 0; i < _entries.Length; i++) { if (_entries[i].Key == (uint)key) { diff --git a/src/LibHac/FsSrv/FileSystemProxyCoreImpl.cs b/src/LibHac/FsSrv/FileSystemProxyCoreImpl.cs index 3e40a483..bf6187bd 100644 --- a/src/LibHac/FsSrv/FileSystemProxyCoreImpl.cs +++ b/src/LibHac/FsSrv/FileSystemProxyCoreImpl.cs @@ -41,7 +41,7 @@ public class FileSystemProxyCoreImpl if (res.IsFailure()) return res.Miss(); using scoped var path = new Path(); - res = PathFunctions.SetUpFixedPathSingleEntry(ref path.Ref(), pathBuffer.Items, + res = PathFunctions.SetUpFixedPathSingleEntry(ref path.Ref(), pathBuffer, CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.System)); if (res.IsFailure()) return res.Miss(); @@ -55,7 +55,7 @@ public class FileSystemProxyCoreImpl if (res.IsFailure()) return res.Miss(); using scoped var path = new Path(); - res = PathFunctions.SetUpFixedPathDoubleEntry(ref path.Ref(), pathBuffer.Items, + res = PathFunctions.SetUpFixedPathDoubleEntry(ref path.Ref(), pathBuffer, CommonDirNames.SdCardNintendoRootDirectoryName, CustomStorage.GetCustomStorageDirectoryName(CustomStorageId.System)); if (res.IsFailure()) return res.Miss(); diff --git a/src/LibHac/FsSrv/FsCreator/SaveDataFileSystemCreator.cs b/src/LibHac/FsSrv/FsCreator/SaveDataFileSystemCreator.cs index 8e14729d..8701f49c 100644 --- a/src/LibHac/FsSrv/FsCreator/SaveDataFileSystemCreator.cs +++ b/src/LibHac/FsSrv/FsCreator/SaveDataFileSystemCreator.cs @@ -47,7 +47,7 @@ public class SaveDataFileSystemCreator : ISaveDataFileSystemCreator Unsafe.SkipInit(out Array18 saveImageNameBuffer); using scoped var saveImageName = new Path(); - Result res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId); + Result res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer, saveDataId); if (res.IsFailure()) return res.Miss(); res = baseFileSystem.Get.GetEntryType(out DirectoryEntryType type, in saveImageName); diff --git a/src/LibHac/FsSrv/Impl/LocationResolverSet.cs b/src/LibHac/FsSrv/Impl/LocationResolverSet.cs index 52408dca..f837a064 100644 --- a/src/LibHac/FsSrv/Impl/LocationResolverSet.cs +++ b/src/LibHac/FsSrv/Impl/LocationResolverSet.cs @@ -58,7 +58,7 @@ internal class LocationResolverSet : IDisposable public void Dispose() { - for (int i = 0; i < Array5>.Length; i++) + for (int i = 0; i < _resolvers.Length; i++) { if (_resolvers[i].HasValue) { diff --git a/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs b/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs index d239daac..b90cee60 100644 --- a/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs +++ b/src/LibHac/FsSrv/NcaFileSystemServiceImpl.cs @@ -2,7 +2,6 @@ using System.Buffers.Text; using System.Runtime.CompilerServices; using LibHac.Common; -using LibHac.Common.FixedArrays; using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.FsSrv.FsCreator; @@ -241,22 +240,23 @@ public class NcaFileSystemServiceImpl return ResultFs.InvalidArgument.Log(); } - Unsafe.SkipInit(out Array64 contentStoragePathBuffer); + Span contentStoragePathBuffer = stackalloc byte[64]; + //Unsafe.SkipInit(out Array64 contentStoragePathBuffer); // Build the appropriate path for the content storage ID if (contentStorageId == ContentStorageId.SdCard) { - var sb = new U8StringBuilder(contentStoragePathBuffer.Items); + var sb = new U8StringBuilder(contentStoragePathBuffer); sb.Append(StringTraits.DirectorySeparator).Append(CommonDirNames.SdCardNintendoRootDirectoryName); sb.Append(StringTraits.DirectorySeparator).Append(CommonDirNames.ContentStorageDirectoryName); } else { - var sb = new U8StringBuilder(contentStoragePathBuffer.Items); + var sb = new U8StringBuilder(contentStoragePathBuffer); sb.Append(StringTraits.DirectorySeparator).Append(CommonDirNames.ContentStorageDirectoryName); } - using var contentStoragePath = new Path(); + using scoped var contentStoragePath = new Path(); res = PathFunctions.SetUpFixedPath(ref contentStoragePath.Ref(), contentStoragePathBuffer); if (res.IsFailure()) return res.Miss(); diff --git a/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs b/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs index 522c80a5..8938823b 100644 --- a/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs +++ b/src/LibHac/FsSrv/SaveDataFileSystemServiceImpl.cs @@ -128,7 +128,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable Unsafe.SkipInit(out Array18 saveImageNameBuffer); using scoped var saveImageName = new Path(); - res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId); + res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer, saveDataId); if (res.IsFailure()) return res.Miss(); res = fileSystem.Get.GetEntryType(out _, in saveImageName); @@ -170,7 +170,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable // Create the save data directory on the host if needed. Unsafe.SkipInit(out Array18 saveDirectoryNameBuffer); using scoped var saveDirectoryName = new Path(); - res = PathFunctions.SetUpFixedPathSaveId(ref saveDirectoryName.Ref(), saveDirectoryNameBuffer.Items, saveDataId); + res = PathFunctions.SetUpFixedPathSaveId(ref saveDirectoryName.Ref(), saveDirectoryNameBuffer, saveDataId); if (res.IsFailure()) return res.Miss(); res = FsSystem.Utility.EnsureDirectory(fileSystem.Get, in saveDirectoryName); @@ -234,7 +234,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable using scoped var saveDataMetaIdDirectoryName = new Path(); Result res = PathFunctions.SetUpFixedPathSaveMetaDir(ref saveDataMetaIdDirectoryName.Ref(), - saveDataMetaIdDirectoryNameBuffer.Items, saveDataId); + saveDataMetaIdDirectoryNameBuffer, saveDataId); if (res.IsFailure()) return res.Miss(); return OpenSaveDataDirectoryFileSystemImpl(ref outFileSystem, spaceId, in saveDataMetaIdDirectoryName).Ret(); @@ -314,7 +314,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable Unsafe.SkipInit(out Array15 saveDataMetaNameBuffer); using scoped var saveDataMetaName = new Path(); - res = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items, + res = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer, (uint)metaType); if (res.IsFailure()) return res.Miss(); @@ -334,7 +334,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable Unsafe.SkipInit(out Array15 saveDataMetaNameBuffer); using scoped var saveDataMetaName = new Path(); - res = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items, + res = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer, (uint)metaType); if (res.IsFailure()) return res.Miss(); @@ -361,7 +361,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable if (res.IsFailure()) return res.Miss(); using scoped var saveDataIdDirectoryName = new Path(); - PathFunctions.SetUpFixedPathSaveId(ref saveDataIdDirectoryName.Ref(), saveDataIdDirectoryNameBuffer.Items, + PathFunctions.SetUpFixedPathSaveId(ref saveDataIdDirectoryName.Ref(), saveDataIdDirectoryNameBuffer, saveDataId); if (res.IsFailure()) return res.Miss(); @@ -390,7 +390,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable Unsafe.SkipInit(out Array15 saveDataMetaNameBuffer); using scoped var saveDataMetaName = new Path(); - res = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer.Items, + res = PathFunctions.SetUpFixedPathSaveMetaName(ref saveDataMetaName.Ref(), saveDataMetaNameBuffer, (uint)metaType); if (res.IsFailure()) return res.Miss(); @@ -418,7 +418,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable if (res.IsFailure()) return res.Miss(); using scoped var saveImageName = new Path(); - res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId); + res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer, saveDataId); if (res.IsFailure()) return res.Miss(); bool isPseudoSaveFs = _config.IsPseudoSaveData(); @@ -490,7 +490,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable if (res.IsFailure()) return res.Miss(); using scoped var saveImageName = new Path(); - res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId); + res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer, saveDataId); if (res.IsFailure()) return res.Miss(); // Check if the save data is a file or a directory @@ -758,7 +758,7 @@ public class SaveDataFileSystemServiceImpl : IDisposable Unsafe.SkipInit(out Array64 pathParentBuffer); using scoped var pathParent = new Path(); - res = PathFunctions.SetUpFixedPathSingleEntry(ref pathParent.Ref(), pathParentBuffer.Items, + res = PathFunctions.SetUpFixedPathSingleEntry(ref pathParent.Ref(), pathParentBuffer, CommonDirNames.SdCardNintendoRootDirectoryName); if (res.IsFailure()) return res.Miss(); diff --git a/src/LibHac/FsSrv/SaveDataIndexer.cs b/src/LibHac/FsSrv/SaveDataIndexer.cs index 4229d086..2d35ee32 100644 --- a/src/LibHac/FsSrv/SaveDataIndexer.cs +++ b/src/LibHac/FsSrv/SaveDataIndexer.cs @@ -77,8 +77,8 @@ public class SaveDataIndexer : ISaveDataIndexer { Assert.SdkRequires(!_isMounted); - int mountNameLength = StringUtils.Strlcpy(_mountName.Items, mountName, Array16.Length); - Assert.SdkLess(mountNameLength, Array16.Length); + int mountNameLength = StringUtils.Strlcpy(_mountName, mountName, _mountName.Length); + Assert.SdkLess(mountNameLength, _mountName.Length); _fsClient.DisableAutoSaveDataCreation(); @@ -227,7 +227,7 @@ public class SaveDataIndexer : ISaveDataIndexer _handle = 1; _openReaders = new LinkedList(); _isDelayedReaderUnregistrationRequired = false; - StringUtils.Copy(_mountName.Items, mountName); + StringUtils.Copy(_mountName, mountName); _fsClient = fsClient; } diff --git a/src/LibHac/FsSrv/SaveDataSharedFileStorage.cs b/src/LibHac/FsSrv/SaveDataSharedFileStorage.cs index 97dbfcc3..0b0b0381 100644 --- a/src/LibHac/FsSrv/SaveDataSharedFileStorage.cs +++ b/src/LibHac/FsSrv/SaveDataSharedFileStorage.cs @@ -337,7 +337,7 @@ public class SaveDataFileStorageHolder Unsafe.SkipInit(out Array18 saveImageNameBuffer); using scoped var saveImageName = new Path(); - Result res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer.Items, saveDataId); + Result res = PathFunctions.SetUpFixedPathSaveId(ref saveImageName.Ref(), saveImageNameBuffer, saveDataId); if (res.IsFailure()) return res.Miss(); // If an open type isn't specified, open the save without the shared file storage layer diff --git a/src/LibHac/FsSrv/SaveDataTransferCryptoConfiguration.cs b/src/LibHac/FsSrv/SaveDataTransferCryptoConfiguration.cs index 21fdc3ef..17b44f1c 100644 --- a/src/LibHac/FsSrv/SaveDataTransferCryptoConfiguration.cs +++ b/src/LibHac/FsSrv/SaveDataTransferCryptoConfiguration.cs @@ -11,10 +11,10 @@ public class SaveDataTransferCryptoConfiguration private Array256 _kekEncryptionKeyModulus; private Array256 _keyPackageSigningModulus; - public Span TokenSigningKeyModulus => _tokenSigningKeyModulus.Items; - public Span KeySeedPackageSigningKeyModulus => _keySeedPackageSigningKeyModulus.Items; - public Span KekEncryptionKeyModulus => _kekEncryptionKeyModulus.Items; - public Span KeyPackageSigningModulus => _keyPackageSigningModulus.Items; + public Span TokenSigningKeyModulus => _tokenSigningKeyModulus; + public Span KeySeedPackageSigningKeyModulus => _keySeedPackageSigningKeyModulus; + public Span KekEncryptionKeyModulus => _kekEncryptionKeyModulus; + public Span KeyPackageSigningModulus => _keyPackageSigningModulus; public SaveTransferAesKeyGenerator GenerateAesKey { get; set; } public RandomDataGenerator GenerateRandomData { get; set; } diff --git a/src/LibHac/FsSystem/AesCtrCounterExtendedStorage.cs b/src/LibHac/FsSystem/AesCtrCounterExtendedStorage.cs index 06cf980e..9fb925c8 100644 --- a/src/LibHac/FsSystem/AesCtrCounterExtendedStorage.cs +++ b/src/LibHac/FsSystem/AesCtrCounterExtendedStorage.cs @@ -44,12 +44,12 @@ public class AesCtrCounterExtendedStorage : IStorage public void SetOffset(long value) { - BinaryPrimitives.WriteInt64LittleEndian(Offset.Items, value); + BinaryPrimitives.WriteInt64LittleEndian(Offset, value); } public readonly long GetOffset() { - return BinaryPrimitives.ReadInt64LittleEndian(Offset.ItemsRo); + return BinaryPrimitives.ReadInt64LittleEndian(Offset); } } @@ -189,7 +189,7 @@ public class AesCtrCounterExtendedStorage : IStorage return ResultFs.InvalidAesCtrCounterExtendedDataStorageSize.Log(); _dataStorage.Set(in dataStorage); - key.CopyTo(_key.Items); + key.CopyTo(_key); _secureValue = secureValue; _counterOffset = counterOffset; _decryptor.Set(ref decryptor); @@ -306,7 +306,7 @@ public class AesCtrCounterExtendedStorage : IStorage }; Unsafe.SkipInit(out Array16 counter); - AesCtrStorage.MakeIv(counter.Items, upperIv.Value, counterOffset); + AesCtrStorage.MakeIv(counter, upperIv.Value, counterOffset); // Decrypt the data from the current entry. res = _decryptor.Get.Decrypt(currentData.Slice(0, (int)dataSize), _key, counter); @@ -440,7 +440,7 @@ public class AesCtrCounterExtendedStorage : IStorage Assert.SdkRequiresEqual(iv.Length, IvSize); Unsafe.SkipInit(out Array16 counter); - iv.CopyTo(counter.Items); + iv.CopyTo(counter); int remainingSize = destination.Length; int currentOffset = 0; @@ -466,7 +466,7 @@ public class AesCtrCounterExtendedStorage : IStorage if (remainingSize > 0) { - Utility.AddCounter(counter.Items, (uint)currentSize / (uint)BlockSize); + Utility.AddCounter(counter, (uint)currentSize / (uint)BlockSize); } } diff --git a/src/LibHac/FsSystem/AesCtrStorage.cs b/src/LibHac/FsSystem/AesCtrStorage.cs index 2c8afd56..dc742eb3 100644 --- a/src/LibHac/FsSystem/AesCtrStorage.cs +++ b/src/LibHac/FsSystem/AesCtrStorage.cs @@ -46,8 +46,8 @@ public class AesCtrStorage : IStorage _baseStorage = baseStorage; - key.CopyTo(_key.Items); - iv.CopyTo(_iv.Items); + key.CopyTo(_key); + iv.CopyTo(_iv); } public AesCtrStorage(in SharedRef baseStorage, ReadOnlySpan key, ReadOnlySpan iv) @@ -59,8 +59,8 @@ public class AesCtrStorage : IStorage _baseStorage = baseStorage.Get; _baseStorageShared = SharedRef.CreateCopy(in baseStorage); - key.CopyTo(_key.Items); - iv.CopyTo(_iv.Items); + key.CopyTo(_key); + iv.CopyTo(_iv); } public override void Dispose() @@ -88,7 +88,7 @@ public class AesCtrStorage : IStorage using var changePriority = new ScopedThreadPriorityChanger(1, ScopedThreadPriorityChanger.Mode.Relative); Array16 counter = _iv; - Utility.AddCounter(counter.Items, (ulong)offset / (uint)BlockSize); + Utility.AddCounter(counter, (ulong)offset / (uint)BlockSize); int decSize = Aes.DecryptCtr128(destination, destination, _key, counter); if (decSize != destination.Length) @@ -121,7 +121,7 @@ public class AesCtrStorage : IStorage // Setup the counter. var counter = new Array16(); - Utility.AddCounter(counter.Items, (ulong)offset / (uint)BlockSize); + Utility.AddCounter(counter, (ulong)offset / (uint)BlockSize); // Loop until all data is written. int remaining = source.Length; @@ -152,7 +152,7 @@ public class AesCtrStorage : IStorage remaining -= writeSize; if (remaining > 0) { - Utility.AddCounter(counter.Items, (uint)writeSize / (uint)BlockSize); + Utility.AddCounter(counter, (uint)writeSize / (uint)BlockSize); } } diff --git a/src/LibHac/FsSystem/AesXtsStorage.cs b/src/LibHac/FsSystem/AesXtsStorage.cs index ebcedb7f..29eec445 100644 --- a/src/LibHac/FsSystem/AesXtsStorage.cs +++ b/src/LibHac/FsSystem/AesXtsStorage.cs @@ -52,9 +52,9 @@ public class AesXtsStorage : IStorage Assert.SdkRequiresEqual(IvSize, iv.Length); Assert.SdkRequiresAligned(blockSize, AesBlockSize); - key1.CopyTo(_key1.Items); - key2.CopyTo(_key2.Items); - iv.CopyTo(_iv.Items); + key1.CopyTo(_key1); + key2.CopyTo(_key2); + iv.CopyTo(_iv); } public AesXtsStorage(ref SharedRef baseStorage, ReadOnlySpan key1, ReadOnlySpan key2, @@ -70,9 +70,9 @@ public class AesXtsStorage : IStorage Assert.SdkRequiresEqual(IvSize, iv.Length); Assert.SdkRequiresAligned(blockSize, AesBlockSize); - key1.CopyTo(_key1.Items); - key2.CopyTo(_key2.Items); - iv.CopyTo(_iv.Items); + key1.CopyTo(_key1); + key2.CopyTo(_key2); + iv.CopyTo(_iv); } public override void Dispose() diff --git a/src/LibHac/FsSystem/AesXtsStorageExternal.cs b/src/LibHac/FsSystem/AesXtsStorageExternal.cs index e6b43108..8595ca77 100644 --- a/src/LibHac/FsSystem/AesXtsStorageExternal.cs +++ b/src/LibHac/FsSystem/AesXtsStorageExternal.cs @@ -45,12 +45,12 @@ public class AesXtsStorageExternal : IStorage Assert.SdkRequiresAligned(blockSize, AesBlockSize); if (key1.Length != 0) - key1.CopyTo(_key[0].Items); + key1.CopyTo(_key[0]); if (key2.Length != 0) - key2.CopyTo(_key[1].Items); + key2.CopyTo(_key[1]); - iv.CopyTo(_iv.Items); + iv.CopyTo(_iv); } public AesXtsStorageExternal(in SharedRef baseStorage, ReadOnlySpan key1, ReadOnlySpan key2, @@ -93,7 +93,7 @@ public class AesXtsStorageExternal : IStorage // Setup the counter. Span counter = stackalloc byte[IvSize]; - _iv.ItemsRo.CopyTo(counter); + _iv[..].CopyTo(counter); Utility.AddCounter(counter, (ulong)offset / _blockSize); // Handle any unaligned data before the start. @@ -175,7 +175,7 @@ public class AesXtsStorageExternal : IStorage // Setup the counter. Span counter = stackalloc byte[IvSize]; - _iv.ItemsRo.CopyTo(counter); + _iv[..].CopyTo(counter); Utility.AddCounter(counter, (ulong)offset / _blockSize); // Handle any unaligned data before the start. diff --git a/src/LibHac/FsSystem/ConcatenationFileSystem.cs b/src/LibHac/FsSystem/ConcatenationFileSystem.cs index a0c384bb..931eccb8 100644 --- a/src/LibHac/FsSystem/ConcatenationFileSystem.cs +++ b/src/LibHac/FsSystem/ConcatenationFileSystem.cs @@ -535,9 +535,9 @@ public class ConcatenationFileSystem : IFileSystem private static Result AppendInternalFilePath(ref Path path, int index) { var buffer = new Array3(); - Utf8Formatter.TryFormat(index, buffer.Items, out _, new StandardFormat('d', 2)); + Utf8Formatter.TryFormat(index, buffer, out _, new StandardFormat('d', 2)); - return path.AppendChild(buffer.ItemsRo).Ret(); + return path.AppendChild(buffer).Ret(); } private static Result GenerateInternalFilePath(ref Path outPath, int index, in Path basePath) diff --git a/src/LibHac/FsSystem/Impl/PartitionFileSystemFormats.cs b/src/LibHac/FsSystem/Impl/PartitionFileSystemFormats.cs index 3ba816e2..e7e6d710 100644 --- a/src/LibHac/FsSystem/Impl/PartitionFileSystemFormats.cs +++ b/src/LibHac/FsSystem/Impl/PartitionFileSystemFormats.cs @@ -37,7 +37,7 @@ public struct PartitionFileSystemFormat : IPartitionFileSystemFormat { get { - ReadOnlySpan span = _signature.ItemsRo; + ReadOnlySpan span = _signature; return MemoryMarshal.CreateReadOnlySpan(ref MemoryMarshal.GetReference(span), span.Length); } } diff --git a/src/LibHac/FsSystem/IndirectStorage.cs b/src/LibHac/FsSystem/IndirectStorage.cs index e4aae334..bfe6d952 100644 --- a/src/LibHac/FsSystem/IndirectStorage.cs +++ b/src/LibHac/FsSystem/IndirectStorage.cs @@ -73,7 +73,7 @@ public class IndirectStorage : IStorage { FinalizeObject(); - Span items = _dataStorage.Items; + Span items = _dataStorage; for (int i = 0; i < items.Length; i++) items[i].Dispose(); @@ -160,7 +160,7 @@ public class IndirectStorage : IStorage { _table.FinalizeObject(); - Span storages = _dataStorage.Items; + Span storages = _dataStorage; for (int i = 0; i < storages.Length; i++) { using var emptySubStorage = new ValueSubStorage(); @@ -303,9 +303,9 @@ public class IndirectStorage : IStorage Result res = _table.InvalidateCache(); if (res.IsFailure()) return res.Miss(); - for (int i = 0; i < _dataStorage.Items.Length; i++) + for (int i = 0; i < _dataStorage.Length; i++) { - res = _dataStorage.Items[i].OperateRange(OperationId.InvalidateCache, 0, long.MaxValue); + res = _dataStorage[i].OperateRange(OperationId.InvalidateCache, 0, long.MaxValue); if (res.IsFailure()) return res.Miss(); } } diff --git a/src/LibHac/FsSystem/IntegrityVerificationStorage.cs b/src/LibHac/FsSystem/IntegrityVerificationStorage.cs index 39895d8d..6efe3d75 100644 --- a/src/LibHac/FsSystem/IntegrityVerificationStorage.cs +++ b/src/LibHac/FsSystem/IntegrityVerificationStorage.cs @@ -70,7 +70,7 @@ public class IntegrityVerificationStorage : IStorage [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void SetValidationBit(ref BlockHash hash) { - hash.Hash.Items[HashSize - 1] |= 0x80; + hash.Hash[HashSize - 1] |= 0x80; } /// @@ -82,7 +82,7 @@ public class IntegrityVerificationStorage : IStorage [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool IsValidationBit(in BlockHash hash) { - return (hash.Hash.ItemsRo[HashSize - 1] & 0x80) != 0; + return (hash.Hash[HashSize - 1] & 0x80) != 0; } public int GetBlockSize() @@ -611,9 +611,9 @@ public class IntegrityVerificationStorage : IStorage if (IsValidationBit(in hash)) return Result.Success; - for (int i = 0; i < hash.Hash.ItemsRo.Length; i++) + for (int i = 0; i < hash.Hash.Length; i++) { - if (hash.Hash.ItemsRo[i] != 0) + if (hash.Hash[i] != 0) return ResultFs.InvalidZeroHash.Log(); } diff --git a/src/LibHac/FsSystem/LocalDirectory.cs b/src/LibHac/FsSystem/LocalDirectory.cs index 67c5e2ef..2b6c1a06 100644 --- a/src/LibHac/FsSystem/LocalDirectory.cs +++ b/src/LibHac/FsSystem/LocalDirectory.cs @@ -40,7 +40,7 @@ public class LocalDirectory : IDirectory DirectoryEntryType type = isDir ? DirectoryEntryType.Directory : DirectoryEntryType.File; long length = isDir ? 0 : ((FileInfo)localEntry).Length; - StringUtils.Copy(entryBuffer[i].Name.Items, name); + StringUtils.Copy(entryBuffer[i].Name, name); entryBuffer[i].Name[PathTool.EntryNameLengthMax] = 0; entryBuffer[i].Attributes = localEntry.Attributes.ToNxAttributes(); diff --git a/src/LibHac/FsSystem/NcaReader.cs b/src/LibHac/FsSystem/NcaReader.cs index 9feba9d9..81838ffe 100644 --- a/src/LibHac/FsSystem/NcaReader.cs +++ b/src/LibHac/FsSystem/NcaReader.cs @@ -64,7 +64,7 @@ public class NcaReader : IDisposable Unsafe.SkipInit(out Array2> commonDecryptionKeys); for (int i = 0; i < NcaCryptoConfiguration.HeaderEncryptionKeyCount; i++) { - cryptoConfig.GenerateKey(commonDecryptionKeys[i].Items, cryptoConfig.HeaderEncryptedEncryptionKeys[i], + cryptoConfig.GenerateKey(commonDecryptionKeys[i], cryptoConfig.HeaderEncryptedEncryptionKeys[i], headerKeyTypes[i]); } @@ -158,18 +158,18 @@ public class NcaReader : IDisposable if (cryptoConfig.IsAvailableSwKey) { int keyTypeValue = NcaKeyFunctions.GetKeyTypeValue(_header.KeyAreaEncryptionKeyIndex, _header.GetProperKeyGeneration()); - ReadOnlySpan encryptedKeyCtr = _header.EncryptedKeys.ItemsRo.Slice((int)NcaHeader.DecryptionKey.AesCtr * Aes.KeySize128, Aes.KeySize128); + ReadOnlySpan encryptedKeyCtr = _header.EncryptedKeys[..].Slice((int)NcaHeader.DecryptionKey.AesCtr * Aes.KeySize128, Aes.KeySize128); - cryptoConfig.GenerateKey(_decryptionKeys[(int)NcaHeader.DecryptionKey.AesCtr].Items, encryptedKeyCtr, keyTypeValue); + cryptoConfig.GenerateKey(_decryptionKeys[(int)NcaHeader.DecryptionKey.AesCtr], encryptedKeyCtr, keyTypeValue); } // Copy the plaintext hardware key. - ReadOnlySpan keyCtrHw = _header.EncryptedKeys.ItemsRo.Slice((int)NcaHeader.DecryptionKey.AesCtrHw * Aes.KeySize128, Aes.KeySize128); - keyCtrHw.CopyTo(_decryptionKeys[(int)NcaHeader.DecryptionKey.AesCtrHw].Items); + ReadOnlySpan keyCtrHw = _header.EncryptedKeys[..].Slice((int)NcaHeader.DecryptionKey.AesCtrHw * Aes.KeySize128, Aes.KeySize128); + keyCtrHw.CopyTo(_decryptionKeys[(int)NcaHeader.DecryptionKey.AesCtrHw]); } // Clear the external decryption key. - _externalDataDecryptionKey.Items.Clear(); + _externalDataDecryptionKey[..].Clear(); // Copy the configuration to the NcaReader. _isAvailableSwKey = cryptoConfig.IsAvailableSwKey; @@ -212,7 +212,7 @@ public class NcaReader : IDisposable { Assert.SdkRequiresEqual(NcaHeader.HeaderSignSize, outBuffer.Length); - _header.Signature2.ItemsRo.CopyTo(outBuffer); + _header.Signature2[..].CopyTo(outBuffer); } public void GetHeaderSign2TargetHash(Span outBuffer) @@ -294,7 +294,7 @@ public class NcaReader : IDisposable { Assert.SdkRequiresGreaterEqual(outBuffer.Length, NcaHeader.RightsIdSize); - _header.RightsId.ItemsRo.CopyTo(outBuffer); + _header.RightsId[..].CopyTo(outBuffer); } public bool HasFsInfo(int index) @@ -377,7 +377,7 @@ public class NcaReader : IDisposable Assert.SdkRequiresNotNull(_bodyStorage); Assert.SdkRequiresGreaterEqual(outBuffer.Length, NcaHeader.EncryptedKeyAreaSize); - _header.EncryptedKeys.ItemsRo.CopyTo(outBuffer); + _header.EncryptedKeys[..].CopyTo(outBuffer); } public ReadOnlySpan GetDecryptionKey(int index) @@ -395,7 +395,7 @@ public class NcaReader : IDisposable for (int i = 0; i < (int)NcaHeader.DecryptionKey.Count; i++) { if (!CryptoUtil.IsSameBytes(zeroKey, - _header.EncryptedKeys.ItemsRo.Slice(i * Aes.KeySize128, Aes.KeySize128), Aes.KeySize128)) + _header.EncryptedKeys[..].Slice(i * Aes.KeySize128, Aes.KeySize128), Aes.KeySize128)) { return true; } @@ -408,7 +408,7 @@ public class NcaReader : IDisposable { Array16 zeroKey = default; return !CryptoUtil.IsSameBytes(zeroKey, GetDecryptionKey((int)NcaHeader.DecryptionKey.AesCtrHw), - Array16.Length); + zeroKey.Length); } public bool IsSwAesPrioritized() @@ -428,20 +428,20 @@ public class NcaReader : IDisposable public void SetExternalDecryptionKey(ReadOnlySpan key) { - Assert.SdkRequiresEqual(_externalDataDecryptionKey.ItemsRo.Length, key.Length); + Assert.SdkRequiresEqual(_externalDataDecryptionKey[..].Length, key.Length); - key.CopyTo(_externalDataDecryptionKey.Items); + key.CopyTo(_externalDataDecryptionKey); } public ReadOnlySpan GetExternalDecryptionKey() { - return _externalDataDecryptionKey.ItemsRo; + return _externalDataDecryptionKey; } public bool HasExternalDecryptionKey() { Array16 zeroKey = default; - return !CryptoUtil.IsSameBytes(zeroKey, GetExternalDecryptionKey(), Array16.Length); + return !CryptoUtil.IsSameBytes(zeroKey, GetExternalDecryptionKey(), zeroKey.Length); } public void GetRawData(Span outBuffer) @@ -505,7 +505,7 @@ public class NcaFsHeaderReader Unsafe.SkipInit(out Hash hash); IHash256GeneratorFactory generator = reader.GetHashGeneratorFactorySelector().GetFactory(HashAlgorithmType.Sha2); - generator.GenerateHash(hash.Value.Items, SpanHelpers.AsReadOnlyByteSpan(in _header)); + generator.GenerateHash(hash.Value, SpanHelpers.AsReadOnlyByteSpan(in _header)); if (!CryptoUtil.IsSameBytes(reader.GetFsHeaderHash(index).Value, hash.Value, Unsafe.SizeOf())) { diff --git a/src/LibHac/FsSystem/PartitionFileSystem.cs b/src/LibHac/FsSystem/PartitionFileSystem.cs index d5575363..e60c39ae 100644 --- a/src/LibHac/FsSystem/PartitionFileSystem.cs +++ b/src/LibHac/FsSystem/PartitionFileSystem.cs @@ -370,7 +370,7 @@ public class PartitionFileSystemCore : IFil dirEntry.Type = DirectoryEntryType.File; dirEntry.Size = entry.Size; U8Span entryName = _parent._metaData.GetEntryName(_currentIndex); - StringUtils.Strlcpy(dirEntry.Name.Items, entryName, dirEntry.Name.ItemsRo.Length - 1); + StringUtils.Strlcpy(dirEntry.Name, entryName, dirEntry.Name[..].Length - 1); _currentIndex++; } diff --git a/src/LibHac/Gc/GameCardEmulated.cs b/src/LibHac/Gc/GameCardEmulated.cs index c9572c7a..fb51e651 100644 --- a/src/LibHac/Gc/GameCardEmulated.cs +++ b/src/LibHac/Gc/GameCardEmulated.cs @@ -81,7 +81,7 @@ public sealed class GameCardEmulated : IGcApi Abort.DoAbortUnlessSuccess(ReadBaseStorage(0x100, SpanHelpers.AsByteSpan(ref _cardHeader))); Abort.DoAbortUnlessSuccess(ReadBaseStorage(GcCertAreaPageAddress * GcPageSize, SpanHelpers.AsByteSpan(ref _certificate))); - Sha256.GenerateSha256Hash(SpanHelpers.AsReadOnlyByteSpan(in _cardHeader), _imageHash.Items); + Sha256.GenerateSha256Hash(SpanHelpers.AsReadOnlyByteSpan(in _cardHeader), _imageHash); DecryptCardHeader(ref _cardHeader); @@ -361,7 +361,7 @@ public sealed class GameCardEmulated : IGcApi Result res = CheckCardReady(); if (res.IsFailure()) return res.Miss(); - _certificate.T1CardDeviceId.ItemsRo.CopyTo(destBuffer); + _certificate.T1CardDeviceId[..].CopyTo(destBuffer); return Result.Success; } @@ -393,7 +393,7 @@ public sealed class GameCardEmulated : IGcApi Result res = CheckCardReady(); if (res.IsFailure()) return res.Miss(); - _imageHash.ItemsRo.CopyTo(destBuffer); + _imageHash[..].CopyTo(destBuffer); return Result.Success; } diff --git a/src/LibHac/GcSrv/GameCardStorageDevice.cs b/src/LibHac/GcSrv/GameCardStorageDevice.cs index a1d55e33..d872c47d 100644 --- a/src/LibHac/GcSrv/GameCardStorageDevice.cs +++ b/src/LibHac/GcSrv/GameCardStorageDevice.cs @@ -48,8 +48,8 @@ internal class GameCardStorageDevice : GameCardStorageInterfaceAdapter, IStorage _handle = handle; _isSecure = isSecure; - cardDeviceId.CopyTo(_cardDeviceId.Items); - cardImageHash.CopyTo(_cardImageHash.Items); + cardDeviceId.CopyTo(_cardDeviceId); + cardImageHash.CopyTo(_cardImageHash); _gc = gc; } diff --git a/src/LibHac/Loader/NsoReader.cs b/src/LibHac/Loader/NsoReader.cs index 11beb28e..0cba7907 100644 --- a/src/LibHac/Loader/NsoReader.cs +++ b/src/LibHac/Loader/NsoReader.cs @@ -92,9 +92,9 @@ public class NsoReader if (checkHash) { var hash = new Array32(); - Crypto.Sha256.GenerateSha256Hash(buffer.Slice(0, (int)segment.Size), hash.Items); + Crypto.Sha256.GenerateSha256Hash(buffer.Slice(0, (int)segment.Size), hash); - if (hash.ItemsRo.SequenceCompareTo(fileHash) != 0) + if (hash[..].SequenceCompareTo(fileHash) != 0) return ResultLoader.InvalidNso.Log(); } diff --git a/src/LibHac/Ns/ApplicationControlProperty.cs b/src/LibHac/Ns/ApplicationControlProperty.cs index 075e4f14..89a96c96 100644 --- a/src/LibHac/Ns/ApplicationControlProperty.cs +++ b/src/LibHac/Ns/ApplicationControlProperty.cs @@ -71,18 +71,18 @@ public struct ApplicationControlProperty public AccessibleLaunchRequiredVersionValue AccessibleLaunchRequiredVersion; public Array3000 Reserved3448; - [UnscopedRef] public readonly U8Span IsbnString => new U8Span(Isbn.ItemsRo); - [UnscopedRef] public readonly U8Span DisplayVersionString => new U8Span(DisplayVersion.ItemsRo); - [UnscopedRef] public readonly U8Span ApplicationErrorCodeCategoryString => new U8Span(ApplicationErrorCodeCategory.ItemsRo); - [UnscopedRef] public readonly U8Span BcatPassphraseString => new U8Span(BcatPassphrase.ItemsRo); + [UnscopedRef] public readonly U8Span IsbnString => new U8Span(Isbn); + [UnscopedRef] public readonly U8Span DisplayVersionString => new U8Span(DisplayVersion); + [UnscopedRef] public readonly U8Span ApplicationErrorCodeCategoryString => new U8Span(ApplicationErrorCodeCategory); + [UnscopedRef] public readonly U8Span BcatPassphraseString => new U8Span(BcatPassphrase); public struct ApplicationTitle { public Array512 Name; public Array256 Publisher; - [UnscopedRef] public readonly U8Span NameString => new U8Span(Name.ItemsRo); - [UnscopedRef] public readonly U8Span PublisherString => new U8Span(Publisher.ItemsRo); + [UnscopedRef] public readonly U8Span NameString => new U8Span(Name); + [UnscopedRef] public readonly U8Span PublisherString => new U8Span(Publisher); } public struct ApplicationNeighborDetectionClientConfiguration diff --git a/src/LibHac/Tools/Es/Ticket.cs b/src/LibHac/Tools/Es/Ticket.cs index 0dfe13fd..e3410744 100644 --- a/src/LibHac/Tools/Es/Ticket.cs +++ b/src/LibHac/Tools/Es/Ticket.cs @@ -158,7 +158,7 @@ public class Ticket return commonKey; } - if (keySet.ETicketRsaKey.PublicExponent.ItemsRo.IsZeros()) + if (keySet.ETicketRsaKey.PublicExponent[..].IsZeros()) return null; try diff --git a/src/LibHac/Tools/Fs/InMemoryFileSystem.cs b/src/LibHac/Tools/Fs/InMemoryFileSystem.cs index 55e94be3..f1a9b36c 100644 --- a/src/LibHac/Tools/Fs/InMemoryFileSystem.cs +++ b/src/LibHac/Tools/Fs/InMemoryFileSystem.cs @@ -252,7 +252,7 @@ public class InMemoryFileSystem : IAttributeFileSystem { ref DirectoryEntry entry = ref entryBuffer[i]; - StringUtils.Copy(entry.Name.Items, CurrentDir.Name); + StringUtils.Copy(entry.Name, CurrentDir.Name); entry.Name[PathTool.EntryNameLengthMax] = 0; entry.Type = DirectoryEntryType.Directory; @@ -270,7 +270,7 @@ public class InMemoryFileSystem : IAttributeFileSystem { ref DirectoryEntry entry = ref entryBuffer[i]; - StringUtils.Copy(entry.Name.Items, CurrentFile.Name); + StringUtils.Copy(entry.Name, CurrentFile.Name); entry.Name[PathTool.EntryNameLengthMax] = 0; entry.Type = DirectoryEntryType.File; diff --git a/src/LibHac/Tools/Fs/SwitchFs.cs b/src/LibHac/Tools/Fs/SwitchFs.cs index ff23e74f..5dfe3c94 100644 --- a/src/LibHac/Tools/Fs/SwitchFs.cs +++ b/src/LibHac/Tools/Fs/SwitchFs.cs @@ -232,7 +232,7 @@ public class SwitchFs : IDisposable control.Get.Read(out _, 0, title.Control.ByteSpan).ThrowIfFailure(); } - foreach (ref readonly ApplicationControlProperty.ApplicationTitle desc in title.Control.Value.Title.ItemsRo) + foreach (ref readonly ApplicationControlProperty.ApplicationTitle desc in title.Control.Value.Title) { if (!desc.NameString.IsEmpty()) { diff --git a/src/LibHac/Tools/Fs/XciHeader.cs b/src/LibHac/Tools/Fs/XciHeader.cs index ef93befd..ae3f7164 100644 --- a/src/LibHac/Tools/Fs/XciHeader.cs +++ b/src/LibHac/Tools/Fs/XciHeader.cs @@ -220,14 +220,14 @@ public class XciHeader ref readonly CardInitialData data = ref SpanHelpers.AsReadOnlyStruct(initialData); - if (dest.Length != data.Payload.AuthData.ItemsRo.Length) + if (dest.Length != data.Payload.AuthData[..].Length) return ResultFs.GameCardPreconditionViolation.Log(); // Verify padding is all-zero. bool anyNonZero = false; - for (int i = 0; i < data.Padding.ItemsRo.Length; i++) + for (int i = 0; i < data.Padding.Length; i++) { - anyNonZero |= data.Padding.ItemsRo[i] != 0; + anyNonZero |= data.Padding[i] != 0; } if (anyNonZero) diff --git a/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs b/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs index 28e672de..f46dd96e 100644 --- a/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs +++ b/src/LibHac/Tools/FsSystem/NcaUtils/Nca.cs @@ -173,7 +173,7 @@ public class Nca ref NcaSparseInfo sparseInfo = ref fsHeader.GetSparseInfo(); Unsafe.SkipInit(out BucketTree.Header header); - sparseInfo.MetaHeader.ItemsRo.CopyTo(SpanHelpers.AsByteSpan(ref header)); + sparseInfo.MetaHeader[..].CopyTo(SpanHelpers.AsByteSpan(ref header)); header.Verify().ThrowIfFailure(); var sparseStorage = new SparseStorage(); @@ -429,7 +429,7 @@ public class Nca ref NcaCompressionInfo compressionInfo = ref header.GetCompressionInfo(); Unsafe.SkipInit(out BucketTree.Header bucketTreeHeader); - compressionInfo.TableHeader.ItemsRo.CopyTo(SpanHelpers.AsByteSpan(ref bucketTreeHeader)); + compressionInfo.TableHeader[..].CopyTo(SpanHelpers.AsByteSpan(ref bucketTreeHeader)); bucketTreeHeader.Verify().ThrowIfFailure(); long nodeStorageSize = CompressedStorage.QueryNodeStorageSize(bucketTreeHeader.EntryCount); diff --git a/src/LibHac/Tools/FsSystem/RomFs/RomFsDirectory.cs b/src/LibHac/Tools/FsSystem/RomFs/RomFsDirectory.cs index d7b25092..ed2e593c 100644 --- a/src/LibHac/Tools/FsSystem/RomFs/RomFsDirectory.cs +++ b/src/LibHac/Tools/FsSystem/RomFs/RomFsDirectory.cs @@ -50,7 +50,7 @@ public class RomFsDirectory : IDirectory ref DirectoryEntry entry = ref entryBuffer[i]; Span nameUtf8 = Encoding.UTF8.GetBytes(name); - StringUtils.Copy(entry.Name.Items, nameUtf8); + StringUtils.Copy(entry.Name, nameUtf8); entry.Name[PathTool.EntryNameLengthMax] = 0; entry.Type = DirectoryEntryType.Directory; @@ -70,7 +70,7 @@ public class RomFsDirectory : IDirectory ref DirectoryEntry entry = ref entryBuffer[i]; Span nameUtf8 = Encoding.UTF8.GetBytes(name); - StringUtils.Copy(entry.Name.Items, nameUtf8); + StringUtils.Copy(entry.Name, nameUtf8); entry.Name[PathTool.EntryNameLengthMax] = 0; entry.Type = DirectoryEntryType.File; diff --git a/src/LibHac/Tools/FsSystem/Save/SaveDataDirectory.cs b/src/LibHac/Tools/FsSystem/Save/SaveDataDirectory.cs index d1133b8a..adf8f9dd 100644 --- a/src/LibHac/Tools/FsSystem/Save/SaveDataDirectory.cs +++ b/src/LibHac/Tools/FsSystem/Save/SaveDataDirectory.cs @@ -50,7 +50,7 @@ public class SaveDataDirectory : IDirectory ref DirectoryEntry entry = ref entryBuffer[i]; Span nameUtf8 = Encoding.UTF8.GetBytes(name); - StringUtils.Copy(entry.Name.Items, nameUtf8); + StringUtils.Copy(entry.Name, nameUtf8); entry.Name[64] = 0; entry.Type = DirectoryEntryType.Directory; @@ -70,7 +70,7 @@ public class SaveDataDirectory : IDirectory ref DirectoryEntry entry = ref entryBuffer[i]; Span nameUtf8 = Encoding.UTF8.GetBytes(name); - StringUtils.Copy(entry.Name.Items, nameUtf8); + StringUtils.Copy(entry.Name, nameUtf8); entry.Name[64] = 0; entry.Type = DirectoryEntryType.File; diff --git a/src/hactoolnet/ProcessNca.cs b/src/hactoolnet/ProcessNca.cs index 99ed6b38..35701bd5 100644 --- a/src/hactoolnet/ProcessNca.cs +++ b/src/hactoolnet/ProcessNca.cs @@ -13,7 +13,6 @@ using LibHac.Tools.Fs; using LibHac.Tools.FsSystem; using LibHac.Tools.FsSystem.NcaUtils; using LibHac.Tools.Npdm; -using LibHac.Util; using static hactoolnet.Print; using NcaFsHeader = LibHac.Tools.FsSystem.NcaUtils.NcaFsHeader; diff --git a/src/hactoolnet/ProcessPackage.cs b/src/hactoolnet/ProcessPackage.cs index b39c70a3..9c6e2be7 100644 --- a/src/hactoolnet/ProcessPackage.cs +++ b/src/hactoolnet/ProcessPackage.cs @@ -65,9 +65,9 @@ internal static class ProcessPackage if (package1.IsMariko) { sb.AppendLine("Mariko OEM Header:"); - PrintItem(sb, colLen, " Signature:", package1.MarikoOemHeader.RsaSig.ItemsRo.ToArray()); - PrintItem(sb, colLen, " Random Salt:", package1.MarikoOemHeader.Salt.ItemsRo.ToArray()); - PrintItem(sb, colLen, " OEM Bootloader Hash:", package1.MarikoOemHeader.Hash.ItemsRo.ToArray()); + PrintItem(sb, colLen, " Signature:", package1.MarikoOemHeader.RsaSig[..].ToArray()); + PrintItem(sb, colLen, " Random Salt:", package1.MarikoOemHeader.Salt[..].ToArray()); + PrintItem(sb, colLen, " OEM Bootloader Hash:", package1.MarikoOemHeader.Hash[..].ToArray()); PrintItem(sb, colLen, " OEM Bootloader Version:", $"{package1.MarikoOemHeader.Version:x2}"); PrintItem(sb, colLen, " OEM Bootloader Size:", $"{package1.MarikoOemHeader.Size:x8}"); PrintItem(sb, colLen, " OEM Bootloader Load Address:", $"{package1.MarikoOemHeader.LoadAddress:x8}"); @@ -98,7 +98,7 @@ internal static class ProcessPackage validity = mac.SequenceEqual(package1.Pk11Mac) ? " (Valid)" : " (Invalid)"; } - PrintItem(sb, colLen, $" PK11 MAC:{validity}", package1.Pk11Mac.ItemsRo.ToArray()); + PrintItem(sb, colLen, $" PK11 MAC:{validity}", package1.Pk11Mac[..].ToArray()); } if (package1.IsDecrypted) @@ -178,7 +178,7 @@ internal static class ProcessPackage sb.AppendLine(); sb.AppendLine("PK21:"); - PrintItem(sb, colLen, $"Signature{signatureValidity.GetValidityString()}:", package2.Header.Signature.ItemsRo.ToArray()); + PrintItem(sb, colLen, $"Signature{signatureValidity.GetValidityString()}:", package2.Header.Signature[..].ToArray()); PrintItem(sb, colLen, "Header Version:", $"{package2.Header.Meta.GetKeyGeneration():x2}"); for (int i = 0; i < 3; i++) @@ -186,8 +186,8 @@ internal static class ProcessPackage string name = package2.Header.Meta.PayloadSizes[i] != 0 ? Package2SectionNames[i] : "Empty"; sb.AppendLine($"Section {i} ({name}):"); - PrintItem(sb, colLen, " Hash:", package2.Header.Meta.PayloadHashes[i].ItemsRo.ToArray()); - PrintItem(sb, colLen, " CTR:", package2.Header.Meta.PayloadIvs[i].ItemsRo.ToArray()); + PrintItem(sb, colLen, " Hash:", package2.Header.Meta.PayloadHashes[i][..].ToArray()); + PrintItem(sb, colLen, " CTR:", package2.Header.Meta.PayloadIvs[i][..].ToArray()); PrintItem(sb, colLen, " Load Address:", $"{package2.Header.Meta.PayloadOffsets[i] + 0x80000000:x8}"); PrintItem(sb, colLen, " Size:", $"{package2.Header.Meta.PayloadSizes[i]:x8}"); } diff --git a/tests/LibHac.Tests/Common/FixedArraySizeTests.cs b/tests/LibHac.Tests/Common/FixedArraySizeTests.cs index 84bcf30f..deeebf9d 100644 --- a/tests/LibHac.Tests/Common/FixedArraySizeTests.cs +++ b/tests/LibHac.Tests/Common/FixedArraySizeTests.cs @@ -6,35 +6,35 @@ namespace LibHac.Tests.Common; public class FixedArraySizeTests { - [Fact] public static void Array1SpanSizeIsCorrect() => Assert.Equal(1, new Array1().Items.Length); + [Fact] public static void Array1SpanSizeIsCorrect() => Assert.Equal(1, new Array1().Length); [Fact] public static void Array1ByteSizeIsCorrect() => Assert.Equal(sizeof(byte) * 1, Unsafe.SizeOf>()); [Fact] public static void Array1LongSizeIsCorrect() => Assert.Equal(sizeof(long) * 1, Unsafe.SizeOf>()); - [Fact] public static void Array3SpanSizeIsCorrect() => Assert.Equal(3, new Array3().Items.Length); + [Fact] public static void Array3SpanSizeIsCorrect() => Assert.Equal(3, new Array3().Length); [Fact] public static void Array3ByteSizeIsCorrect() => Assert.Equal(sizeof(byte) * 3, Unsafe.SizeOf>()); [Fact] public static void Array3LongSizeIsCorrect() => Assert.Equal(sizeof(long) * 3, Unsafe.SizeOf>()); - [Fact] public static void Array8SpanSizeIsCorrect() => Assert.Equal(8, new Array8().Items.Length); + [Fact] public static void Array8SpanSizeIsCorrect() => Assert.Equal(8, new Array8().Length); [Fact] public static void Array8ByteSizeIsCorrect() => Assert.Equal(sizeof(byte) * 8, Unsafe.SizeOf>()); [Fact] public static void Array8LongSizeIsCorrect() => Assert.Equal(sizeof(long) * 8, Unsafe.SizeOf>()); - [Fact] public static void Array12SpanSizeIsCorrect() => Assert.Equal(12, new Array12().Items.Length); + [Fact] public static void Array12SpanSizeIsCorrect() => Assert.Equal(12, new Array12().Length); [Fact] public static void Array12ByteSizeIsCorrect() => Assert.Equal(sizeof(byte) * 12, Unsafe.SizeOf>()); [Fact] public static void Array12LongSizeIsCorrect() => Assert.Equal(sizeof(long) * 12, Unsafe.SizeOf>()); - [Fact] public static void Array32SpanSizeIsCorrect() => Assert.Equal(32, new Array32().Items.Length); + [Fact] public static void Array32SpanSizeIsCorrect() => Assert.Equal(32, new Array32().Length); [Fact] public static void Array32ByteSizeIsCorrect() => Assert.Equal(sizeof(byte) * 32, Unsafe.SizeOf>()); [Fact] public static void Array32LongSizeIsCorrect() => Assert.Equal(sizeof(long) * 32, Unsafe.SizeOf>()); - [Fact] public static void Array64SpanSizeIsCorrect() => Assert.Equal(64, new Array64().Items.Length); + [Fact] public static void Array64SpanSizeIsCorrect() => Assert.Equal(64, new Array64().Length); [Fact] public static void Array64ByteSizeIsCorrect() => Assert.Equal(sizeof(byte) * 64, Unsafe.SizeOf>()); [Fact] public static void Array64LongSizeIsCorrect() => Assert.Equal(sizeof(long) * 64, Unsafe.SizeOf>()); - [Fact] public static void Array128SpanSizeIsCorrect() => Assert.Equal(128, new Array128().Items.Length); + [Fact] public static void Array128SpanSizeIsCorrect() => Assert.Equal(128, new Array128().Length); [Fact] public static void Array128ByteSizeIsCorrect() => Assert.Equal(sizeof(byte) * 128, Unsafe.SizeOf>()); [Fact] public static void Array128LongSizeIsCorrect() => Assert.Equal(sizeof(long) * 128, Unsafe.SizeOf>()); - [Fact] public static void Array256SpanSizeIsCorrect() => Assert.Equal(256, new Array256().Items.Length); + [Fact] public static void Array256SpanSizeIsCorrect() => Assert.Equal(256, new Array256().Length); [Fact] public static void Array256ByteSizeIsCorrect() => Assert.Equal(sizeof(byte) * 256, Unsafe.SizeOf>()); [Fact] public static void Array256LongSizeIsCorrect() => Assert.Equal(sizeof(long) * 256, Unsafe.SizeOf>()); } \ No newline at end of file diff --git a/tests/LibHac.Tests/FsSystem/TypeLayoutTests.cs b/tests/LibHac.Tests/FsSystem/TypeLayoutTests.cs index e085b8f3..252adb38 100644 --- a/tests/LibHac.Tests/FsSystem/TypeLayoutTests.cs +++ b/tests/LibHac.Tests/FsSystem/TypeLayoutTests.cs @@ -232,12 +232,12 @@ public class TypeLayoutTests Assert.Equal(NcaHeader.Size, Unsafe.SizeOf()); Assert.Equal(NcaHeader.SectorSize, 1 << NcaHeader.SectorShift); - Assert.Equal(NcaHeader.HeaderSignSize, s.Signature1.ItemsRo.Length); - Assert.Equal(NcaHeader.HeaderSignSize, s.Signature2.ItemsRo.Length); - Assert.Equal(NcaHeader.RightsIdSize, s.RightsId.ItemsRo.Length); - Assert.Equal(NcaHeader.FsCountMax, s.FsInfos.ItemsRo.Length); - Assert.Equal(NcaHeader.FsCountMax, s.FsHeaderHashes.ItemsRo.Length); - Assert.Equal(NcaHeader.EncryptedKeyAreaSize, s.EncryptedKeys.ItemsRo.Length); + Assert.Equal(NcaHeader.HeaderSignSize, s.Signature1.Length); + Assert.Equal(NcaHeader.HeaderSignSize, s.Signature2.Length); + Assert.Equal(NcaHeader.RightsIdSize, s.RightsId.Length); + Assert.Equal(NcaHeader.FsCountMax, s.FsInfos.Length); + Assert.Equal(NcaHeader.FsCountMax, s.FsHeaderHashes.Length); + Assert.Equal(NcaHeader.EncryptedKeyAreaSize, s.EncryptedKeys.Length); } [Fact] @@ -258,14 +258,14 @@ public class TypeLayoutTests { NcaCryptoConfiguration s = default; - Assert.Equal(NcaCryptoConfiguration.Header1SignatureKeyGenerationMax + 1, s.Header1SignKeyModuli.ItemsRo.Length); - Assert.Equal(NcaCryptoConfiguration.Rsa2048KeyModulusSize, s.Header1SignKeyModuli.ItemsRo[0].ItemsRo.Length); - Assert.Equal(NcaCryptoConfiguration.Rsa2048KeyPublicExponentSize, s.Header1SignKeyPublicExponent.ItemsRo.Length); - Assert.Equal(NcaCryptoConfiguration.KeyAreaEncryptionKeyIndexCount, s.KeyAreaEncryptionKeySources.ItemsRo.Length); - Assert.Equal(NcaCryptoConfiguration.Aes128KeySize, s.KeyAreaEncryptionKeySources.ItemsRo[0].ItemsRo.Length); - Assert.Equal(NcaCryptoConfiguration.Aes128KeySize, s.HeaderEncryptionKeySource.ItemsRo.Length); - Assert.Equal(NcaCryptoConfiguration.HeaderEncryptionKeyCount, s.HeaderEncryptedEncryptionKeys.ItemsRo.Length); - Assert.Equal(NcaCryptoConfiguration.Aes128KeySize, s.HeaderEncryptedEncryptionKeys.ItemsRo[0].ItemsRo.Length); + Assert.Equal(NcaCryptoConfiguration.Header1SignatureKeyGenerationMax + 1, s.Header1SignKeyModuli.Length); + Assert.Equal(NcaCryptoConfiguration.Rsa2048KeyModulusSize, s.Header1SignKeyModuli[0].Length); + Assert.Equal(NcaCryptoConfiguration.Rsa2048KeyPublicExponentSize, s.Header1SignKeyPublicExponent.Length); + Assert.Equal(NcaCryptoConfiguration.KeyAreaEncryptionKeyIndexCount, s.KeyAreaEncryptionKeySources.Length); + Assert.Equal(NcaCryptoConfiguration.Aes128KeySize, s.KeyAreaEncryptionKeySources[0].Length); + Assert.Equal(NcaCryptoConfiguration.Aes128KeySize, s.HeaderEncryptionKeySource.Length); + Assert.Equal(NcaCryptoConfiguration.HeaderEncryptionKeyCount, s.HeaderEncryptedEncryptionKeys.Length); + Assert.Equal(NcaCryptoConfiguration.Aes128KeySize, s.HeaderEncryptedEncryptionKeys[0].Length); } [Fact] @@ -306,7 +306,7 @@ public class TypeLayoutTests Assert.Equal(0x04, GetOffset(in s, in s.Layers)); Assert.Equal(0x94, GetOffset(in s, in s.HashSalt)); - Assert.Equal(Constants.IntegrityMaxLayerCount - 1, s.Layers.ItemsRo.Length); + Assert.Equal(Constants.IntegrityMaxLayerCount - 1, s.Layers.Length); } [Fact] @@ -327,7 +327,7 @@ public class TypeLayoutTests { HierarchicalIntegrityVerificationSizeSet s = default; - Assert.Equal(Constants.IntegrityMaxLayerCount - 2, s.LayeredHashSizes.ItemsRo.Length); + Assert.Equal(Constants.IntegrityMaxLayerCount - 2, s.LayeredHashSizes.Length); } [Fact] @@ -335,7 +335,7 @@ public class TypeLayoutTests { HierarchicalIntegrityVerificationStorageControlArea.InputParam s = default; - Assert.Equal(Constants.IntegrityMaxLayerCount - 1, s.LevelBlockSizes.ItemsRo.Length); + Assert.Equal(Constants.IntegrityMaxLayerCount - 1, s.LevelBlockSizes[..].Length); } [Fact]