Do some code formatting in LibHac

This commit is contained in:
Alex Barney 2022-11-09 22:14:07 -07:00
parent ef71eedc05
commit 80d52dd499
267 changed files with 310 additions and 342 deletions

View File

@ -58,5 +58,6 @@ public struct KeyBlob
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ReadOnlySpan<byte>(in KeyBlob value) => SpanHelpers.AsReadOnlyByteSpan(in value); public static implicit operator ReadOnlySpan<byte>(in KeyBlob value) => SpanHelpers.AsReadOnlyByteSpan(in value);
public readonly override string ToString() => BytesRo.ToHexString(); public readonly override string ToString() => BytesRo.ToHexString();
} }

View File

@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Type = LibHac.Common.Keys.KeyInfo.KeyType; using Type = LibHac.Common.Keys.KeyInfo.KeyType;
namespace LibHac.Common.Keys; namespace LibHac.Common.Keys;

View File

@ -146,8 +146,7 @@ public static class ExternalKeyReader
/// <param name="keyList">A list of all the keys that will be loaded into the key set. /// <param name="keyList">A list of all the keys that will be loaded into the key set.
/// <see cref="DefaultKeySet.CreateKeyList"/> will create a list containing all loadable keys.</param> /// <see cref="DefaultKeySet.CreateKeyList"/> will create a list containing all loadable keys.</param>
/// <param name="logger">An optional logger that key-parsing errors will be written to.</param> /// <param name="logger">An optional logger that key-parsing errors will be written to.</param>
public static void ReadMainKeys(KeySet keySet, Stream reader, List<KeyInfo> keyList, public static void ReadMainKeys(KeySet keySet, Stream reader, List<KeyInfo> keyList, IProgressReport logger = null)
IProgressReport logger = null)
{ {
if (reader == null) return; if (reader == null) return;

View File

@ -5,7 +5,6 @@ using System.Text;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Spl; using LibHac.Spl;
using LibHac.Util; using LibHac.Util;
using Type = LibHac.Common.Keys.KeyInfo.KeyType; using Type = LibHac.Common.Keys.KeyInfo.KeyType;
using RangeType = LibHac.Common.Keys.KeyInfo.KeyRangeType; using RangeType = LibHac.Common.Keys.KeyInfo.KeyRangeType;
@ -150,6 +149,7 @@ public static class ExternalKeyWriter
PrintKeys(keySet, sb, DefaultKeySet.CreateKeyList(), Type.Common | Type.Seed | Type.DifferentDev, true); PrintKeys(keySet, sb, DefaultKeySet.CreateKeyList(), Type.Common | Type.Seed | Type.DifferentDev, true);
keySet.SetMode(KeySet.Mode.Prod); keySet.SetMode(KeySet.Mode.Prod);
} }
return sb.ToString(); return sb.ToString();
} }

View File

@ -34,18 +34,14 @@ public class MissingKeyException : LibHacException
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MissingKeyException"/> class. /// Initializes a new instance of the <see cref="MissingKeyException"/> class.
/// </summary> /// </summary>
public MissingKeyException() public MissingKeyException() { }
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MissingKeyException"/> class with a specified error message. /// Initializes a new instance of the <see cref="MissingKeyException"/> class with a specified error message.
/// </summary> /// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="message">The error message that explains the reason for the exception.</param>
public MissingKeyException(string message) public MissingKeyException(string message)
: base(message) : base(message) { }
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MissingKeyException"/> class with a specified error message /// Initializes a new instance of the <see cref="MissingKeyException"/> class with a specified error message
@ -54,9 +50,7 @@ public class MissingKeyException : LibHacException
/// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param> /// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
public MissingKeyException(string message, Exception innerException) public MissingKeyException(string message, Exception innerException)
: base(message, innerException) : base(message, innerException) { }
{
}
public override string Message public override string Message
{ {

View File

@ -10,18 +10,14 @@ public class LibHacException : Exception
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="LibHacException"/> class. /// Initializes a new instance of the <see cref="LibHacException"/> class.
/// </summary> /// </summary>
public LibHacException() public LibHacException() { }
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="LibHacException"/> class with a specified error message. /// Initializes a new instance of the <see cref="LibHacException"/> class with a specified error message.
/// </summary> /// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="message">The error message that explains the reason for the exception.</param>
public LibHacException(string message) public LibHacException(string message)
: base(message) : base(message) { }
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="LibHacException"/> class with a specified error message /// Initializes a new instance of the <see cref="LibHacException"/> class with a specified error message
@ -30,7 +26,5 @@ public class LibHacException : Exception
/// <param name="message">The error message that explains the reason for the exception.</param> /// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param> /// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
public LibHacException(string message, Exception innerException) public LibHacException(string message, Exception innerException)
: base(message, innerException) : base(message, innerException) { }
{
}
} }

View File

@ -110,6 +110,7 @@ public class ProgressBar : IDisposable, IProgressReport
int progressBlockCount = (int)Math.Min(progress * BlockCount, BlockCount); int progressBlockCount = (int)Math.Min(progress * BlockCount, BlockCount);
text = $"[{new string('#', progressBlockCount)}{new string('-', BlockCount - progressBlockCount)}] {_progress}/{_total} {progress:P1} {Animation[_animationIndex++ % Animation.Length]}{speed}"; text = $"[{new string('#', progressBlockCount)}{new string('-', BlockCount - progressBlockCount)}] {_progress}/{_total} {progress:P1} {Animation[_animationIndex++ % Animation.Length]}{speed}";
} }
UpdateText(text); UpdateText(text);
ResetTimer(); ResetTimer();

View File

@ -35,9 +35,7 @@ public readonly ref struct Ref<T>
/// <param name="pointer">The pointer to the target value.</param> /// <param name="pointer">The pointer to the target value.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe Ref(void* pointer) public unsafe Ref(void* pointer)
: this(ref Unsafe.AsRef<T>(pointer)) : this(ref Unsafe.AsRef<T>(pointer)) { }
{
}
/// <summary> /// <summary>
/// Gets the <typeparamref name="T"/> reference represented by the current <see cref="Ref{T}"/> instance. /// Gets the <typeparamref name="T"/> reference represented by the current <see cref="Ref{T}"/> instance.
@ -97,9 +95,7 @@ public readonly ref struct ReadOnlyRef<T>
/// <param name="pointer">The pointer to the target value.</param> /// <param name="pointer">The pointer to the target value.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe ReadOnlyRef(void* pointer) public unsafe ReadOnlyRef(void* pointer)
: this(in Unsafe.AsRef<T>(pointer)) : this(in Unsafe.AsRef<T>(pointer)) { }
{
}
/// <summary> /// <summary>
/// Gets the <typeparamref name="T"/> reference represented by the current <see cref="Ref{T}"/> instance. /// Gets the <typeparamref name="T"/> reference represented by the current <see cref="Ref{T}"/> instance.

View File

@ -230,6 +230,7 @@ public static class Utilities
{ {
return bytes.ToString("0 B"); // Byte return bytes.ToString("0 B"); // Byte
} }
// Divide by 1024 to get fractional value // Divide by 1024 to get fractional value
readable = readable / 1024; readable = readable / 1024;
// Return formatted number with suffix // Return formatted number with suffix

View File

@ -142,8 +142,7 @@ public static class Rsa
{ {
rng.NextBytes(rndBuf); rng.NextBytes(rndBuf);
g = GetBigInteger(rndBuf); g = GetBigInteger(rndBuf);
} } while (g >= n);
while (g >= n);
y = BigInteger.ModPow(g, r, n); y = BigInteger.ModPow(g, r, n);

View File

@ -492,7 +492,6 @@ namespace LibHac.Fs.Impl
.Append(LogLineEnd); .Append(LogLineEnd);
OutputAccessLogImpl(fs, new U8Span(sb.Buffer)); OutputAccessLogImpl(fs, new U8Span(sb.Buffer));
} }
finally finally
{ {

View File

@ -1,5 +1,4 @@
using System; using System;
using Buffer = LibHac.Mem.Buffer; using Buffer = LibHac.Mem.Buffer;
using CacheHandle = System.UInt64; using CacheHandle = System.UInt64;

View File

@ -27,6 +27,6 @@ internal static class CommonPaths
public static ReadOnlySpan<byte> SdCardNintendoRootDirectoryName => // Nintendo public static ReadOnlySpan<byte> SdCardNintendoRootDirectoryName => // Nintendo
new[] new[]
{ {
(byte) 'N', (byte) 'i', (byte) 'n', (byte) 't', (byte) 'e', (byte) 'n', (byte) 'd', (byte) 'o' (byte)'N', (byte)'i', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'d', (byte)'o'
}; };
} }

View File

@ -2,6 +2,7 @@
using LibHac.Common.FixedArrays; using LibHac.Common.FixedArrays;
namespace LibHac.Fs; namespace LibHac.Fs;
public struct DirectoryEntry public struct DirectoryEntry
{ {
public Array769<byte> Name; public Array769<byte> Name;

View File

@ -74,7 +74,6 @@ public enum FileSystemProxyType
RegisteredUpdate = 8 RegisteredUpdate = 8
} }
public enum ImageDirectoryId public enum ImageDirectoryId
{ {
Nand = 0, Nand = 0,

View File

@ -311,6 +311,7 @@ internal class FileSystemAccessor : IDisposable
res = _fileSystem.Get.RenameDirectory(in currentPathNormalized, in newPathNormalized); res = _fileSystem.Get.RenameDirectory(in currentPathNormalized, in newPathNormalized);
if (res.IsFailure()) return res.Miss(); if (res.IsFailure()) return res.Miss();
} }
return Result.Success; return Result.Success;
} }

View File

@ -1,5 +1,4 @@
global using GameCardHandle = System.UInt32; global using GameCardHandle = System.UInt32;
using System; using System;
using LibHac.Common.FixedArrays; using LibHac.Common.FixedArrays;

View File

@ -2,7 +2,6 @@
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.Fs.Impl; using LibHac.Fs.Impl;
using LibHac.FsSrv.Sf; using LibHac.FsSrv.Sf;
using IFileSystem = LibHac.Fs.Fsa.IFileSystem; using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem; using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;

View File

@ -5,7 +5,6 @@ using LibHac.Fs.Fsa;
using LibHac.Fs.Impl; using LibHac.Fs.Impl;
using LibHac.FsSrv.Sf; using LibHac.FsSrv.Sf;
using LibHac.Os; using LibHac.Os;
using static LibHac.Fs.Impl.AccessLogStrings; using static LibHac.Fs.Impl.AccessLogStrings;
using static LibHac.Fs.SaveData; using static LibHac.Fs.SaveData;
using IFileSystem = LibHac.Fs.Fsa.IFileSystem; using IFileSystem = LibHac.Fs.Fsa.IFileSystem;

View File

@ -8,7 +8,6 @@ using LibHac.Ncm;
using LibHac.Os; using LibHac.Os;
using IFileSystem = LibHac.Fs.Fsa.IFileSystem; using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem; using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
using static LibHac.Fs.Impl.AccessLogStrings; using static LibHac.Fs.Impl.AccessLogStrings;
using static LibHac.Fs.SaveData; using static LibHac.Fs.SaveData;

View File

@ -5,7 +5,6 @@ using LibHac.Common;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.Sf; using LibHac.Sf;
using LibHac.Util; using LibHac.Util;
using IFile = LibHac.Fs.Fsa.IFile; using IFile = LibHac.Fs.Fsa.IFile;
using IFileSf = LibHac.FsSrv.Sf.IFile; using IFileSf = LibHac.FsSrv.Sf.IFile;
using IDirectory = LibHac.Fs.Fsa.IDirectory; using IDirectory = LibHac.Fs.Fsa.IDirectory;

View File

@ -9,10 +9,8 @@ using LibHac.Gc;
using LibHac.Os; using LibHac.Os;
using LibHac.Sf; using LibHac.Sf;
using LibHac.Util; using LibHac.Util;
using static LibHac.Fs.Impl.AccessLogStrings; using static LibHac.Fs.Impl.AccessLogStrings;
using static LibHac.Gc.Values; using static LibHac.Gc.Values;
using IFileSystem = LibHac.Fs.Fsa.IFileSystem; using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem; using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
using IStorageSf = LibHac.FsSrv.Sf.IStorage; using IStorageSf = LibHac.FsSrv.Sf.IStorage;

View File

@ -6,7 +6,6 @@ using LibHac.FsSrv.Sf;
using LibHac.Os; using LibHac.Os;
using IFileSystem = LibHac.Fs.Fsa.IFileSystem; using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem; using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
using static LibHac.Fs.Impl.AccessLogStrings; using static LibHac.Fs.Impl.AccessLogStrings;
namespace LibHac.Fs.Shim; namespace LibHac.Fs.Shim;

View File

@ -7,7 +7,6 @@ using LibHac.Ncm;
using LibHac.Os; using LibHac.Os;
using IFileSystem = LibHac.Fs.Fsa.IFileSystem; using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem; using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
using static LibHac.Fs.Impl.AccessLogStrings; using static LibHac.Fs.Impl.AccessLogStrings;
namespace LibHac.Fs.Shim; namespace LibHac.Fs.Shim;

View File

@ -5,7 +5,6 @@ using LibHac.Diag;
using LibHac.Fs.Impl; using LibHac.Fs.Impl;
using LibHac.FsSrv.Sf; using LibHac.FsSrv.Sf;
using LibHac.Os; using LibHac.Os;
using static LibHac.Fs.Impl.AccessLogStrings; using static LibHac.Fs.Impl.AccessLogStrings;
using static LibHac.Fs.SaveData; using static LibHac.Fs.SaveData;

View File

@ -12,7 +12,6 @@ using LibHac.Ncm;
using LibHac.Os; using LibHac.Os;
using LibHac.Sf; using LibHac.Sf;
using LibHac.Time; using LibHac.Time;
using static LibHac.Fs.Impl.AccessLogStrings; using static LibHac.Fs.Impl.AccessLogStrings;
using static LibHac.Fs.SaveData; using static LibHac.Fs.SaveData;

View File

@ -8,7 +8,6 @@ using LibHac.Fs.Shim;
using LibHac.FsSrv.Sf; using LibHac.FsSrv.Sf;
using LibHac.Sf; using LibHac.Sf;
using LibHac.Util; using LibHac.Util;
using static LibHac.Fs.SaveData; using static LibHac.Fs.SaveData;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace

View File

@ -5,7 +5,6 @@ using LibHac.Fs.Fsa;
using LibHac.Fs.Impl; using LibHac.Fs.Impl;
using LibHac.FsSrv.Sf; using LibHac.FsSrv.Sf;
using LibHac.Os; using LibHac.Os;
using static LibHac.Fs.Impl.AccessLogStrings; using static LibHac.Fs.Impl.AccessLogStrings;
using static LibHac.Fs.SaveData; using static LibHac.Fs.SaveData;
using IFileSystem = LibHac.Fs.Fsa.IFileSystem; using IFileSystem = LibHac.Fs.Fsa.IFileSystem;

View File

@ -67,10 +67,10 @@ internal readonly struct AccessLogService
private static ReadOnlySpan<byte> MultiProgramTag => // FS_ACCESS: { multi_program_tag: true }\n private static ReadOnlySpan<byte> MultiProgramTag => // FS_ACCESS: { multi_program_tag: true }\n
new[] new[]
{ {
(byte) 'F', (byte) 'S', (byte) '_', (byte) 'A', (byte) 'C', (byte) 'C', (byte) 'E', (byte) 'S', (byte)'F', (byte)'S', (byte)'_', (byte)'A', (byte)'C', (byte)'C', (byte)'E', (byte)'S',
(byte) 'S', (byte) ':', (byte) ' ', (byte) '{', (byte) ' ', (byte) 'm', (byte) 'u', (byte) 'l', (byte)'S', (byte)':', (byte)' ', (byte)'{', (byte)' ', (byte)'m', (byte)'u', (byte)'l',
(byte) 't', (byte) 'i', (byte) '_', (byte) 'p', (byte) 'r', (byte) 'o', (byte) 'g', (byte) 'r', (byte)'t', (byte)'i', (byte)'_', (byte)'p', (byte)'r', (byte)'o', (byte)'g', (byte)'r',
(byte) 'a', (byte) 'm', (byte) '_', (byte) 't', (byte) 'a', (byte) 'g', (byte) ':', (byte) ' ', (byte)'a', (byte)'m', (byte)'_', (byte)'t', (byte)'a', (byte)'g', (byte)':', (byte)' ',
(byte) 't', (byte) 'r', (byte) 'u', (byte) 'e', (byte) ' ', (byte) '}', (byte) '\n' (byte)'t', (byte)'r', (byte)'u', (byte)'e', (byte)' ', (byte)'}', (byte)'\n'
}; };
} }

View File

@ -20,6 +20,7 @@ public class EmulatedGameCard
{ {
KeySet = keySet; KeySet = keySet;
} }
public GameCardHandle GetGameCardHandle() public GameCardHandle GetGameCardHandle()
{ {
return Handle; return Handle;

View File

@ -2,7 +2,6 @@
using LibHac.Common; using LibHac.Common;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using Utility = LibHac.FsSrv.Impl.Utility; using Utility = LibHac.FsSrv.Impl.Utility;
namespace LibHac.FsSrv.FsCreator; namespace LibHac.FsSrv.FsCreator;

View File

@ -3,7 +3,6 @@ using LibHac.Common;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.Util; using LibHac.Util;
using Utility = LibHac.FsSrv.Impl.Utility; using Utility = LibHac.FsSrv.Impl.Utility;
namespace LibHac.FsSrv.FsCreator; namespace LibHac.FsSrv.FsCreator;

View File

@ -7,7 +7,6 @@ using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.Util; using LibHac.Util;
using OpenType = LibHac.FsSrv.SaveDataOpenTypeSetFileStorage.OpenType; using OpenType = LibHac.FsSrv.SaveDataOpenTypeSetFileStorage.OpenType;
namespace LibHac.FsSrv.FsCreator; namespace LibHac.FsSrv.FsCreator;

View File

@ -6,7 +6,6 @@ using LibHac.Fs;
using LibHac.Fs.Fsa; using LibHac.Fs.Fsa;
using LibHac.FsSystem; using LibHac.FsSystem;
using LibHac.Sf; using LibHac.Sf;
using IFile = LibHac.Fs.Fsa.IFile; using IFile = LibHac.Fs.Fsa.IFile;
using IFileSf = LibHac.FsSrv.Sf.IFile; using IFileSf = LibHac.FsSrv.Sf.IFile;
using IDirectory = LibHac.Fs.Fsa.IDirectory; using IDirectory = LibHac.Fs.Fsa.IDirectory;

View File

@ -53,7 +53,6 @@ public class ProgramIndexMapInfoManager : IDisposable
// We skip running ClearImpl() if the allocation failed because we don't need to worry about that in C# // We skip running ClearImpl() if the allocation failed because we don't need to worry about that in C#
return Result.Success; return Result.Success;
} }
/// <summary> /// <summary>

View File

@ -908,13 +908,13 @@ public class NcaFileSystemServiceImpl
private static ReadOnlySpan<byte> SdCardNintendoRootDirectoryName => // Nintendo private static ReadOnlySpan<byte> SdCardNintendoRootDirectoryName => // Nintendo
new[] new[]
{ {
(byte) 'N', (byte) 'i', (byte) 'n', (byte) 't', (byte) 'e', (byte) 'n', (byte) 'd', (byte) 'o' (byte)'N', (byte)'i', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'d', (byte)'o'
}; };
private static ReadOnlySpan<byte> ContentStorageDirectoryName => // Contents private static ReadOnlySpan<byte> ContentStorageDirectoryName => // Contents
new[] new[]
{ {
(byte) 'C', (byte) 'o', (byte) 'n', (byte) 't', (byte) 'e', (byte) 'n', (byte) 't', (byte) 's' (byte)'C', (byte)'o', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'t', (byte)'s'
}; };
} }

View File

@ -14,10 +14,8 @@ using LibHac.Ncm;
using LibHac.Os; using LibHac.Os;
using LibHac.Sf; using LibHac.Sf;
using LibHac.Util; using LibHac.Util;
using static LibHac.Fs.SaveData; using static LibHac.Fs.SaveData;
using static LibHac.Fs.StringTraits; using static LibHac.Fs.StringTraits;
using IFileSystem = LibHac.Fs.Fsa.IFileSystem; using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem; using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
using IFile = LibHac.Fs.Fsa.IFile; using IFile = LibHac.Fs.Fsa.IFile;

View File

@ -12,7 +12,6 @@ using LibHac.Kvdb;
using LibHac.Os; using LibHac.Os;
using LibHac.Sf; using LibHac.Sf;
using LibHac.Util; using LibHac.Util;
using static LibHac.Fs.SaveData; using static LibHac.Fs.SaveData;
namespace LibHac.FsSrv; namespace LibHac.FsSrv;
@ -41,8 +40,8 @@ public class SaveDataIndexer : ISaveDataIndexer
private static ReadOnlySpan<byte> LastPublishedIdFileName => // lastPublishedId private static ReadOnlySpan<byte> LastPublishedIdFileName => // lastPublishedId
new[] new[]
{ {
(byte) 'l', (byte) 'a', (byte) 's', (byte) 't', (byte) 'P', (byte) 'u', (byte) 'b', (byte) 'l', (byte)'l', (byte)'a', (byte)'s', (byte)'t', (byte)'P', (byte)'u', (byte)'b', (byte)'l',
(byte) 'i', (byte) 's', (byte) 'h', (byte) 'e', (byte) 'd', (byte) 'I', (byte) 'd' (byte)'i', (byte)'s', (byte)'h', (byte)'e', (byte)'d', (byte)'I', (byte)'d'
}; };
private static ReadOnlySpan<byte> MountDelimiter => // :/ private static ReadOnlySpan<byte> MountDelimiter => // :/

View File

@ -234,32 +234,32 @@ internal class SaveDataIndexerManager : ISaveDataIndexerManager, IDisposable
private static ReadOnlySpan<byte> BisIndexerMountName => private static ReadOnlySpan<byte> BisIndexerMountName =>
new[] new[]
{ {
(byte) 's', (byte) 'a', (byte) 'v', (byte) 'e', (byte) 'D', (byte) 'a', (byte) 't', (byte) 'a', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a',
(byte) 'I', (byte) 'x', (byte) 'r', (byte) 'D', (byte) 'b' (byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b'
}; };
/// <summary>"<c>saveDataIxrDbSd</c>"</summary> /// <summary>"<c>saveDataIxrDbSd</c>"</summary>
private static ReadOnlySpan<byte> SdCardIndexerMountName => private static ReadOnlySpan<byte> SdCardIndexerMountName =>
new[] new[]
{ {
(byte) 's', (byte) 'a', (byte) 'v', (byte) 'e', (byte) 'D', (byte) 'a', (byte) 't', (byte) 'a', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a',
(byte) 'I', (byte) 'x', (byte) 'r', (byte) 'D', (byte) 'b', (byte) 'S', (byte) 'd' (byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b', (byte)'S', (byte)'d'
}; };
/// <summary>"<c>saveDataIxrDbPr</c>"</summary> /// <summary>"<c>saveDataIxrDbPr</c>"</summary>
private static ReadOnlySpan<byte> ProperBisIndexerMountName => private static ReadOnlySpan<byte> ProperBisIndexerMountName =>
new[] new[]
{ {
(byte) 's', (byte) 'a', (byte) 'v', (byte) 'e', (byte) 'D', (byte) 'a', (byte) 't', (byte) 'a', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a',
(byte) 'I', (byte) 'x', (byte) 'r', (byte) 'D', (byte) 'b', (byte) 'P', (byte) 'r' (byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b', (byte)'P', (byte)'r'
}; };
/// <summary>"<c>saveDataIxrDbSf</c>"</summary> /// <summary>"<c>saveDataIxrDbSf</c>"</summary>
private static ReadOnlySpan<byte> SafeModeIndexerMountName => private static ReadOnlySpan<byte> SafeModeIndexerMountName =>
new[] new[]
{ {
(byte) 's', (byte) 'a', (byte) 'v', (byte) 'e', (byte) 'D', (byte) 'a', (byte) 't', (byte) 'a', (byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a',
(byte) 'I', (byte) 'x', (byte) 'r', (byte) 'D', (byte) 'b', (byte) 'S', (byte) 'f' (byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b', (byte)'S', (byte)'f'
}; };
} }

View File

@ -420,7 +420,6 @@ public class SaveDataFileStorageHolder
ref Entry entry = ref currentEntry.ValueRef; ref Entry entry = ref currentEntry.ValueRef;
_entryList.Remove(currentEntry); _entryList.Remove(currentEntry);
entry.Dispose(); entry.Dispose();
} }
currentEntry = currentEntry.Next; currentEntry = currentEntry.Next;

View File

@ -7,7 +7,6 @@ using LibHac.Fs;
using LibHac.FsSystem.Buffers; using LibHac.FsSystem.Buffers;
using LibHac.Os; using LibHac.Os;
using LibHac.Util; using LibHac.Util;
using Buffer = LibHac.Mem.Buffer; using Buffer = LibHac.Mem.Buffer;
using CacheHandle = System.UInt64; using CacheHandle = System.UInt64;
@ -882,7 +881,6 @@ public class BufferedStorage : IStorage
using var lk = new ScopedLock<SdkMutexType>(ref _bufferedStorage._mutex); using var lk = new ScopedLock<SdkMutexType>(ref _bufferedStorage._mutex);
_cache.Value.UnprepareFetch(); _cache.Value.UnprepareFetch();
} }
} }
@ -1693,6 +1691,7 @@ public class BufferedStorage : IStorage
} }
} }
} }
cache.Write(currentOffset, currentSource.Slice(0, currentSize)); cache.Write(currentOffset, currentSource.Slice(0, currentSize));
BufferManagerUtility.EnableBlockingBufferManagerAllocation(); BufferManagerUtility.EnableBlockingBufferManagerAllocation();

View File

@ -7,7 +7,6 @@ using LibHac.Diag;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Os; using LibHac.Os;
using LibHac.Util; using LibHac.Util;
using Buffer = LibHac.Mem.Buffer; using Buffer = LibHac.Mem.Buffer;
using CacheHandle = System.UInt64; using CacheHandle = System.UInt64;

View File

@ -5,7 +5,6 @@ using LibHac.Diag;
using LibHac.Fs; using LibHac.Fs;
using LibHac.FsSystem.Impl; using LibHac.FsSystem.Impl;
using LibHac.Os; using LibHac.Os;
using Buffer = LibHac.Mem.Buffer; using Buffer = LibHac.Mem.Buffer;
using CacheHandle = System.UInt64; using CacheHandle = System.UInt64;
@ -310,7 +309,6 @@ public class CompressedStorage : IStorage, IAsynchronousAccessSplitter
if (res.IsFailure()) return res.Miss(); if (res.IsFailure()) return res.Miss();
return Result.Success; return Result.Success;
} }
public void FinalizeObject() public void FinalizeObject()

View File

@ -5,7 +5,6 @@ using LibHac.Diag;
using LibHac.Fs; using LibHac.Fs;
using LibHac.Os; using LibHac.Os;
using LibHac.Util; using LibHac.Util;
using BlockCache = LibHac.FsSystem.LruListCache<long, System.Memory<byte>>; using BlockCache = LibHac.FsSystem.LruListCache<long, System.Memory<byte>>;
namespace LibHac.FsSystem; namespace LibHac.FsSystem;

View File

@ -67,6 +67,7 @@ internal ref struct ValueStringBuilder
EnsureCapacity(Length + 1); EnsureCapacity(Length + 1);
_chars[Length] = '\0'; _chars[Length] = '\0';
} }
return ref MemoryMarshal.GetReference(_chars); return ref MemoryMarshal.GetReference(_chars);
} }
@ -100,6 +101,7 @@ internal ref struct ValueStringBuilder
EnsureCapacity(Length + 1); EnsureCapacity(Length + 1);
_chars[Length] = '\0'; _chars[Length] = '\0';
} }
return _chars.Slice(0, _pos); return _chars.Slice(0, _pos);
} }
@ -205,6 +207,7 @@ internal ref struct ValueStringBuilder
{ {
dst[i] = c; dst[i] = c;
} }
_pos += count; _pos += count;
} }

View File

@ -289,6 +289,7 @@ public class KipReader : IDisposable
// Copy directly. // Copy directly.
data[--outOffset] = data[--inOffset]; data[--outOffset] = data[--inOffset];
} }
control <<= 1; control <<= 1;
if (outOffset == 0) if (outOffset == 0)

View File

@ -27,8 +27,8 @@ public class FlatMapKeyValueStore<TKey> : IDisposable where TKey : unmanaged, IE
private static ReadOnlySpan<byte> ArchiveFileName => // /imkvdb.arc private static ReadOnlySpan<byte> ArchiveFileName => // /imkvdb.arc
new[] new[]
{ {
(byte) '/', (byte) 'i', (byte) 'm', (byte) 'k', (byte) 'v', (byte) 'd', (byte) 'b', (byte) '.', (byte)'/', (byte)'i', (byte)'m', (byte)'k', (byte)'v', (byte)'d', (byte)'b', (byte)'.',
(byte) 'a', (byte) 'r', (byte) 'c' (byte)'a', (byte)'r', (byte)'c'
}; };
public int Count => _index.Count; public int Count => _index.Count;

View File

@ -2,6 +2,7 @@
using LibHac.Common; using LibHac.Common;
using LibHac.Common.FixedArrays; using LibHac.Common.FixedArrays;
using LibHac.Ncm; using LibHac.Ncm;
#pragma warning disable 169 // Unused private fields #pragma warning disable 169 // Unused private fields
namespace LibHac.Loader; namespace LibHac.Loader;

View File

@ -241,6 +241,7 @@ public class MultiWaitImpl : IDisposable
outHolder = null; outHolder = null;
return waitResult; return waitResult;
} }
break; break;
case WaitCancelled: case WaitCancelled:
{ {

View File

@ -80,7 +80,6 @@ public static class ReaderWriterLockApi
{ {
Assert.SdkRequires(rwLock.LockState == ReaderWriterLockType.State.Initialized); Assert.SdkRequires(rwLock.LockState == ReaderWriterLockType.State.Initialized);
return ReaderWriterLockImpl.GetReadLockCount(in ReaderWriterLockImpl.GetLockCountRo(in rwLock)) != 0; return ReaderWriterLockImpl.GetReadLockCount(in ReaderWriterLockImpl.GetLockCountRo(in rwLock)) != 0;
} }
// Todo: Use Horizon thread APIs // Todo: Use Horizon thread APIs

View File

@ -434,12 +434,12 @@ public class InMemoryFileSystem : IAttributeFileSystem
private class FileTable private class FileTable
{ {
private DirectoryNode Root; private DirectoryNode _root;
public FileTable() public FileTable()
{ {
Root = new DirectoryNode(); _root = new DirectoryNode();
Root.Name = new U8String(""); _root.Name = new U8String("");
} }
public Result AddFile(U8Span path) public Result AddFile(U8Span path)
@ -645,7 +645,7 @@ public class InMemoryFileSystem : IAttributeFileSystem
private Result FindDirectory(U8Span path, out DirectoryNode directory) private Result FindDirectory(U8Span path, out DirectoryNode directory)
{ {
var parser = new PathParser(path); var parser = new PathParser(path);
DirectoryNode current = Root; DirectoryNode current = _root;
while (parser.MoveNext()) while (parser.MoveNext())
{ {

View File

@ -122,7 +122,9 @@ public class SwitchFs : IDisposable
catch (MissingKeyException ex) catch (MissingKeyException ex)
{ {
if (ex.Name == null) if (ex.Name == null)
{ Console.WriteLine($"{ex.Message} File:\n{fileEntry}"); } {
Console.WriteLine($"{ex.Message} File:\n{fileEntry}");
}
else else
{ {
string name = ex.Type == KeyType.Title ? $"Title key for rights ID {ex.Name}" : ex.Name; string name = ex.Type == KeyType.Title ? $"Title key for rights ID {ex.Name}" : ex.Name;

View File

@ -493,8 +493,7 @@ public static class PathTools
public static bool MatchesPattern(string searchPattern, string name, bool ignoreCase) public static bool MatchesPattern(string searchPattern, string name, bool ignoreCase)
{ {
return FileSystemName.MatchesSimpleExpression(searchPattern.AsSpan(), return FileSystemName.MatchesSimpleExpression(searchPattern.AsSpan(), name.AsSpan(), ignoreCase);
name.AsSpan(), ignoreCase);
} }
private static bool IsValidMountNameChar(char c) private static bool IsValidMountNameChar(char c)

View File

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

View File

@ -6,7 +6,7 @@ namespace LibHac.Tools.FsSystem.Save;
public class JournalMap public class JournalMap
{ {
private int MapEntryLength = 8; private const int MapEntryLength = 8;
public JournalMapHeader Header { get; } public JournalMapHeader Header { get; }
private JournalMapEntry[] Entries { get; } private JournalMapEntry[] Entries { get; }

View File

@ -1,5 +1,8 @@
# LibHac.Tools # LibHac.Tools
The `LibHac.Tools` namespace contains classes that aren't necessarily part of Horizon. Some examples might include: The `LibHac.Tools` namespace contains classes that aren't necessarily part of Horizon. Some examples might include:
- Classes that provide additional functionality to that found in nnsdk. - Classes that provide additional functionality to that found in nnsdk.
- Classes that have a more user-friendly or C#-like API than those in nnsdk. e.g. A standalone NCA reader that streamlines opening and reading an NCA file. - Classes that have a more user-friendly or C#-like API than those in nnsdk. e.g. A standalone NCA reader that
streamlines opening and reading an NCA file.
- File parsers that read a file's structure into standard C# objects/fields instead of operating on a raw byte array. - File parsers that read a file's structure into standard C# objects/fields instead of operating on a raw byte array.

View File

@ -53,7 +53,6 @@ public class Nro
return AssetStorage.Slice(header.FileOffset, header.Size, leaveOpen); return AssetStorage.Slice(header.FileOffset, header.Size, leaveOpen);
} }
} }
public class NroStart public class NroStart

View File

@ -121,6 +121,7 @@ public class Calibration
stream.Position = 0x88 + i * 4; stream.Position = 0x88 + i * 4;
WlanCountryCodes[i] = reader.ReadUtf8Z(); WlanCountryCodes[i] = reader.ReadUtf8Z();
} }
stream.Position = 0x210; stream.Position = 0x210;
WlanMacAddr = reader.ReadBytes(0x6); WlanMacAddr = reader.ReadBytes(0x6);

View File

@ -855,7 +855,6 @@ public static class CharacterEncoding
bufferSrc[1] = source[1]; bufferSrc[1] = source[1];
bufferSrc[2] = source[2]; bufferSrc[2] = source[2];
} }
else if (source[0] >= 0xF0 && source[0] < 0xF8) else if (source[0] >= 0xF0 && source[0] < 0xF8)
{ {
@ -1001,7 +1000,6 @@ public static class CharacterEncoding
destination[0] = (byte)(0xE0 | (source >> 12) & 0xF); destination[0] = (byte)(0xE0 | (source >> 12) & 0xF);
destination[1] = (byte)(0x80 | (source >> 6) & 0x3F); destination[1] = (byte)(0x80 | (source >> 6) & 0x3F);
destination[2] = (byte)(0x80 | (source >> 0) & 0x3F); destination[2] = (byte)(0x80 | (source >> 0) & 0x3F);
} }
else if (source < 0x110000) else if (source < 0x110000)
{ {

View File

@ -224,10 +224,10 @@ internal static class HexConverter
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 15 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 15
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 31 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 31
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 47 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 47
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 63 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 63
0xFF, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 79 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 79
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 95 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 95
0xFF, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 111 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 111
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 127 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 127
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 143 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 143
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 159 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 159

View File

@ -22,8 +22,7 @@ public static class Lz4
do do
{ {
length += sum = cmp[cmpPos++]; length += sum = cmp[cmpPos++];
} } while (sum == 0xff);
while (sum == 0xff);
} }
return length; return length;
@ -70,8 +69,7 @@ public static class Lz4
dec[decPos++] = dec[encPos++]; dec[decPos++] = dec[encPos++];
} }
} }
} } while (cmpPos < cmp.Length &&
while (cmpPos < cmp.Length &&
decPos < dec.Length); decPos < dec.Length);
return dec; return dec;
@ -92,8 +90,7 @@ public static class Lz4
do do
{ {
length += sum = cmp[cmpPos++]; length += sum = cmp[cmpPos++];
} } while (sum == 0xff);
while (sum == 0xff);
} }
return length; return length;
@ -140,8 +137,7 @@ public static class Lz4
dec[decPos++] = dec[encPos++]; dec[decPos++] = dec[encPos++];
} }
} }
} } while (cmpPos < cmp.Length &&
while (cmpPos < cmp.Length &&
decPos < dec.Length); decPos < dec.Length);
} }
} }

View File

@ -11,6 +11,7 @@ public struct Optional<T>
private T _value; private T _value;
public readonly bool HasValue => _hasValue; public readonly bool HasValue => _hasValue;
public ref T Value public ref T Value
{ {
get get
@ -20,6 +21,7 @@ public struct Optional<T>
return ref MemoryMarshal.GetReference(SpanHelpers.CreateSpan(ref _value, 1)); return ref MemoryMarshal.GetReference(SpanHelpers.CreateSpan(ref _value, 1));
} }
} }
public readonly ref readonly T ValueRo public readonly ref readonly T ValueRo
{ {
get get

View File

@ -163,6 +163,7 @@ public static class StringUtils
{ {
c = (byte)(c | 0x20); c = (byte)(c | 0x20);
} }
return c; return c;
} }

View File

@ -5,17 +5,17 @@ namespace hactoolnet;
public struct ScopedIndentation : IDisposable public struct ScopedIndentation : IDisposable
{ {
private IndentingStringBuilder Builder; private IndentingStringBuilder _builder;
public ScopedIndentation(IndentingStringBuilder builder) public ScopedIndentation(IndentingStringBuilder builder)
{ {
builder.IncreaseLevel(); builder.IncreaseLevel();
Builder = builder; _builder = builder;
} }
public void Dispose() public void Dispose()
{ {
Builder.DecreaseLevel(); _builder.DecreaseLevel();
} }
} }