Rename Assert.AssertTrue to Assert.True

This commit is contained in:
Alex Barney 2020-11-19 22:30:42 -07:00
parent acce155341
commit 454f38f1bb
22 changed files with 76 additions and 76 deletions

View file

@ -335,7 +335,7 @@ namespace LibHac.Boot
private bool VerifyPk11Sizes()
{
Assert.AssertTrue(IsDecrypted);
Assert.True(IsDecrypted);
int pk11Size = Unsafe.SizeOf<Package1Pk11Header>() + GetSectionSize(Package1Section.WarmBoot) +
GetSectionSize(Package1Section.Bootloader) + GetSectionSize(Package1Section.SecureMonitor);

View file

@ -493,8 +493,8 @@ namespace LibHac.Common.Keys
// of the file which will be treated as the end of a line.
if (state == ReaderState.Value || state == ReaderState.WhiteSpace2)
{
Assert.AssertTrue(i == buffer.Length);
Assert.AssertTrue(reader.HasReadEndOfFile);
Assert.True(i == buffer.Length);
Assert.True(reader.HasReadEndOfFile);
// WhiteSpace2 will have already set this value
if (state == ReaderState.Value)
@ -506,8 +506,8 @@ namespace LibHac.Common.Keys
// Same situation as the two above states
if (state == ReaderState.Comment)
{
Assert.AssertTrue(i == buffer.Length);
Assert.AssertTrue(reader.HasReadEndOfFile);
Assert.True(i == buffer.Length);
Assert.True(reader.HasReadEndOfFile);
keyLength = i - keyOffset;
state = ReaderState.CommentSuccess;
@ -516,8 +516,8 @@ namespace LibHac.Common.Keys
// Same as the above states except the final line was empty or whitespace.
if (state == ReaderState.Initial)
{
Assert.AssertTrue(i == buffer.Length);
Assert.AssertTrue(reader.HasReadEndOfFile);
Assert.True(i == buffer.Length);
Assert.True(reader.HasReadEndOfFile);
reader.BufferPos = i;
return ReaderStatus.NoKeyRead;

View file

@ -48,7 +48,7 @@ namespace LibHac.Common.Keys
public KeyInfo(int group, KeyType type, string name, KeyGetter retrieveFunc)
{
Assert.AssertTrue(IsKeyTypeValid(type));
Assert.True(IsKeyTypeValid(type));
Name = name;
RangeType = KeyRangeType.Single;
@ -61,7 +61,7 @@ namespace LibHac.Common.Keys
public KeyInfo(int group, KeyType type, string name, byte rangeStart, byte rangeEnd, KeyGetter retrieveFunc)
{
Assert.AssertTrue(IsKeyTypeValid(type));
Assert.True(IsKeyTypeValid(type));
Name = name;
RangeType = KeyRangeType.Range;

View file

@ -296,7 +296,7 @@ namespace LibHac.Crypto
private static void LeftShiftBytes(ReadOnlySpan<byte> input, Span<byte> output)
{
Assert.AssertTrue(output.Length >= input.Length);
Assert.True(output.Length >= input.Length);
byte carry = 0;

View file

@ -7,7 +7,7 @@ namespace LibHac.Diag
public static class Assert
{
[Conditional("DEBUG")]
public static void AssertTrue([DoesNotReturnIf(false)] bool condition, string message = null)
public static void True([DoesNotReturnIf(false)] bool condition, string message = null)
{
if (condition)
return;

View file

@ -188,7 +188,7 @@ namespace LibHac.Fs.Fsa
if (!openMode.HasFlag(OpenMode.Write))
return ResultFs.InvalidOpenModeForWrite.Log();
Assert.AssertTrue(size >= 0);
Assert.True(size >= 0);
return Result.Success;
}

View file

@ -81,9 +81,9 @@ namespace LibHac.Fs
Size = size;
IsResizable = false;
Assert.AssertTrue(IsValid());
Assert.AssertTrue(Offset >= 0);
Assert.AssertTrue(Size >= 0);
Assert.True(IsValid());
Assert.True(Offset >= 0);
Assert.True(Size >= 0);
}
/// <summary>
@ -101,9 +101,9 @@ namespace LibHac.Fs
Size = size;
IsResizable = false;
Assert.AssertTrue(IsValid());
Assert.AssertTrue(Offset >= 0);
Assert.AssertTrue(Size >= 0);
Assert.True(IsValid());
Assert.True(Offset >= 0);
Assert.True(Size >= 0);
}
/// <summary>
@ -125,10 +125,10 @@ namespace LibHac.Fs
Size = size;
IsResizable = false;
Assert.AssertTrue(IsValid());
Assert.AssertTrue(Offset >= 0);
Assert.AssertTrue(Size >= 0);
Assert.AssertTrue(other.Size >= offset + size);
Assert.True(IsValid());
Assert.True(Offset >= 0);
Assert.True(Size >= 0);
Assert.True(other.Size >= offset + size);
}
private bool IsValid() => BaseStorage != null;

View file

@ -196,7 +196,7 @@ namespace LibHac.FsSrv.Impl
private static int GetResolverIndexFromStorageId(StorageId id)
{
Assert.AssertTrue(IsValidStorageId(id));
Assert.True(IsValidStorageId(id));
return id switch
{

View file

@ -36,7 +36,7 @@ namespace LibHac.FsSrv.Impl
private static Result EnsureDirectoryImpl(IFileSystem fileSystem, Span<byte> path)
{
// Double check the trailing separators have been trimmed
Assert.AssertTrue(path.Length <= 1 || path[path.Length - 1] != StringTraits.DirectorySeparator);
Assert.True(path.Length <= 1 || path[path.Length - 1] != StringTraits.DirectorySeparator);
// Use the root path if the input path is empty
var pathToCheck = new U8Span(path.IsEmpty ? FileSystemRootPath : path);
@ -91,7 +91,7 @@ namespace LibHac.FsSrv.Impl
private static Result EnsureParentDirectoryImpl(IFileSystem fileSystem, Span<byte> path)
{
// The path should not be empty or have a trailing directory separator
Assert.AssertTrue(path.Length > 0);
Assert.True(path.Length > 0);
Assert.NotEqual(StringTraits.DirectorySeparator, path[path.Length - 1]);
// Make sure the path's not too long

View file

@ -121,7 +121,7 @@ namespace LibHac.FsSrv
if (originalResult.IsFailure())
return originalResult;
Assert.AssertTrue(originalPathNormalizerHasValue);
Assert.True(originalPathNormalizerHasValue);
// There is an original version and no patch version. Open the original directly
rc = ServiceImpl.OpenFileSystem(out tempFileSystem, originalPathNormalizer.Path, fsType, programId.Value);

View file

@ -532,7 +532,7 @@ namespace LibHac.FsSrv
private FlatMapKeyValueStore<SaveDataAttribute>.Iterator GetBeginIterator()
{
Assert.AssertTrue(IsKvdbLoaded);
Assert.True(IsKvdbLoaded);
return KvDatabase.GetBeginIterator();
}

View file

@ -168,7 +168,7 @@ namespace LibHac.FsSrv
// ReSharper disable once RedundantAssignment
Result rc = _tempIndexer.Indexer.Reset();
Assert.AssertTrue(rc.IsSuccess());
Assert.True(rc.IsSuccess());
}
public void InvalidateIndexer(SaveDataSpaceId spaceId)

View file

@ -35,11 +35,11 @@ namespace LibHac.FsSystem
public Result Initialize(SubStorage nodeStorage, SubStorage entryStorage, int nodeSize, int entrySize,
int entryCount)
{
Assert.AssertTrue(entrySize >= sizeof(long));
Assert.AssertTrue(nodeSize >= entrySize + Unsafe.SizeOf<NodeHeader>());
Assert.AssertTrue(NodeSizeMin <= nodeSize && nodeSize <= NodeSizeMax);
Assert.AssertTrue(BitUtil.IsPowerOfTwo(nodeSize));
Assert.AssertTrue(!IsInitialized());
Assert.True(entrySize >= sizeof(long));
Assert.True(nodeSize >= entrySize + Unsafe.SizeOf<NodeHeader>());
Assert.True(NodeSizeMin <= nodeSize && nodeSize <= NodeSizeMax);
Assert.True(BitUtil.IsPowerOfTwo(nodeSize));
Assert.True(!IsInitialized());
// Ensure valid entry count.
if (entryCount <= 0)
@ -119,7 +119,7 @@ namespace LibHac.FsSystem
public Result Find(ref Visitor visitor, long virtualAddress)
{
Assert.AssertTrue(IsInitialized());
Assert.True(IsInitialized());
if (virtualAddress < 0)
return ResultFs.InvalidOffset.Log();
@ -137,11 +137,11 @@ namespace LibHac.FsSystem
public static long QueryNodeStorageSize(long nodeSize, long entrySize, int entryCount)
{
Assert.AssertTrue(entrySize >= sizeof(long));
Assert.AssertTrue(nodeSize >= entrySize + Unsafe.SizeOf<NodeHeader>());
Assert.AssertTrue(NodeSizeMin <= nodeSize && nodeSize <= NodeSizeMax);
Assert.AssertTrue(BitUtil.IsPowerOfTwo(nodeSize));
Assert.AssertTrue(entryCount >= 0);
Assert.True(entrySize >= sizeof(long));
Assert.True(nodeSize >= entrySize + Unsafe.SizeOf<NodeHeader>());
Assert.True(NodeSizeMin <= nodeSize && nodeSize <= NodeSizeMax);
Assert.True(BitUtil.IsPowerOfTwo(nodeSize));
Assert.True(entryCount >= 0);
if (entryCount <= 0)
return 0;
@ -151,11 +151,11 @@ namespace LibHac.FsSystem
public static long QueryEntryStorageSize(long nodeSize, long entrySize, int entryCount)
{
Assert.AssertTrue(entrySize >= sizeof(long));
Assert.AssertTrue(nodeSize >= entrySize + Unsafe.SizeOf<NodeHeader>());
Assert.AssertTrue(NodeSizeMin <= nodeSize && nodeSize <= NodeSizeMax);
Assert.AssertTrue(BitUtil.IsPowerOfTwo(nodeSize));
Assert.AssertTrue(entryCount >= 0);
Assert.True(entrySize >= sizeof(long));
Assert.True(nodeSize >= entrySize + Unsafe.SizeOf<NodeHeader>());
Assert.True(NodeSizeMin <= nodeSize && nodeSize <= NodeSizeMax);
Assert.True(BitUtil.IsPowerOfTwo(nodeSize));
Assert.True(entryCount >= 0);
if (entryCount <= 0)
return 0;
@ -276,7 +276,7 @@ namespace LibHac.FsSystem
public bool Allocate(int nodeSize)
{
Assert.AssertTrue(_header == null);
Assert.True(_header == null);
_header = new long[nodeSize / sizeof(long)];
@ -298,7 +298,7 @@ namespace LibHac.FsSystem
public ref NodeHeader GetHeader()
{
Assert.AssertTrue(_header.Length / sizeof(long) >= Unsafe.SizeOf<NodeHeader>());
Assert.True(_header.Length / sizeof(long) >= Unsafe.SizeOf<NodeHeader>());
return ref Unsafe.As<long, NodeHeader>(ref _header[0]);
}
@ -322,8 +322,8 @@ namespace LibHac.FsSystem
{
_buffer = buffer;
Assert.AssertTrue(_buffer.Length >= Unsafe.SizeOf<NodeHeader>());
Assert.AssertTrue(_buffer.Length >= Unsafe.SizeOf<NodeHeader>() + GetHeader().Count * Unsafe.SizeOf<TEntry>());
Assert.True(_buffer.Length >= Unsafe.SizeOf<NodeHeader>());
Assert.True(_buffer.Length >= Unsafe.SizeOf<NodeHeader>() + GetHeader().Count * Unsafe.SizeOf<TEntry>());
}
public int GetCount() => GetHeader().Count;
@ -381,8 +381,8 @@ namespace LibHac.FsSystem
public Result Initialize(BucketTree tree)
{
Assert.AssertTrue(tree != null);
Assert.AssertTrue(Tree == null || tree == Tree);
Assert.True(tree != null);
Assert.True(Tree == null || tree == Tree);
if (Entry == null)
{

View file

@ -42,10 +42,10 @@ namespace LibHac.FsSystem
public Result Initialize(SubStorage headerStorage, SubStorage nodeStorage, SubStorage entryStorage,
int nodeSize, int entrySize, int entryCount)
{
Assert.AssertTrue(entrySize >= sizeof(long));
Assert.AssertTrue(nodeSize >= entrySize + Unsafe.SizeOf<NodeHeader>());
Assert.AssertTrue(NodeSizeMin <= nodeSize && nodeSize <= NodeSizeMax);
Assert.AssertTrue(BitUtil.IsPowerOfTwo(nodeSize));
Assert.True(entrySize >= sizeof(long));
Assert.True(nodeSize >= entrySize + Unsafe.SizeOf<NodeHeader>());
Assert.True(NodeSizeMin <= nodeSize && nodeSize <= NodeSizeMax);
Assert.True(BitUtil.IsPowerOfTwo(nodeSize));
if (headerStorage is null || nodeStorage is null || entryStorage is null)
return ResultFs.NullptrArgument.Log();
@ -99,7 +99,7 @@ namespace LibHac.FsSystem
/// <returns>The <see cref="Result"/> of the operation.</returns>
public Result Add<T>(ref T entry) where T : unmanaged
{
Assert.AssertTrue(Unsafe.SizeOf<T>() == EntrySize);
Assert.True(Unsafe.SizeOf<T>() == EntrySize);
if (CurrentEntryIndex >= EntryCount)
return ResultFs.OutOfRange.Log();

View file

@ -84,9 +84,9 @@ namespace LibHac.FsSystem
public Result GetEntryList(Span<Entry> entryBuffer, out int outputEntryCount, long offset, long size)
{
// Validate pre-conditions
Assert.AssertTrue(offset >= 0);
Assert.AssertTrue(size >= 0);
Assert.AssertTrue(IsInitialized());
Assert.True(offset >= 0);
Assert.True(size >= 0);
Assert.True(IsInitialized());
// Clear the out count
outputEntryCount = 0;
@ -153,8 +153,8 @@ namespace LibHac.FsSystem
protected override unsafe Result DoRead(long offset, Span<byte> destination)
{
// Validate pre-conditions
Assert.AssertTrue(offset >= 0);
Assert.AssertTrue(IsInitialized());
Assert.True(offset >= 0);
Assert.True(IsInitialized());
// Succeed if there's nothing to read
if (destination.Length == 0)
@ -206,9 +206,9 @@ namespace LibHac.FsSystem
private Result OperatePerEntry(long offset, long size, OperateFunc func)
{
// Validate preconditions
Assert.AssertTrue(offset >= 0);
Assert.AssertTrue(size >= 0);
Assert.AssertTrue(IsInitialized());
Assert.True(offset >= 0);
Assert.True(size >= 0);
Assert.True(IsInitialized());
// Succeed if there's nothing to operate on
if (size == 0)
@ -272,12 +272,12 @@ namespace LibHac.FsSystem
// Get the offset of the entry in the data we read
long dataOffset = currentOffset - currentEntryOffset;
long dataSize = nextEntryOffset - currentEntryOffset - dataOffset;
Assert.AssertTrue(dataSize > 0);
Assert.True(dataSize > 0);
// Determine how much is left
long remainingSize = endOffset - currentOffset;
long currentSize = Math.Min(remainingSize, dataSize);
Assert.AssertTrue(currentSize <= size);
Assert.True(currentSize <= size);
{
SubStorage currentStorage = DataStorage[currentEntry.StorageIndex];

View file

@ -254,7 +254,7 @@ namespace LibHac.FsSystem.NcaUtils
private static bool CheckIfDecrypted(ReadOnlySpan<byte> header)
{
Assert.AssertTrue(header.Length >= 0x400);
Assert.True(header.Length >= 0x400);
// Check the magic value
if (header[0x200] != 'N' || header[0x201] != 'C' || header[0x202] != 'A')

View file

@ -80,7 +80,7 @@ namespace LibHac.FsSystem
Shared.Move(out _semaphore, ref semaphore);
Shared.Move(out _pinnedObject, ref pinnedObject);
Assert.AssertTrue(_semaphore.IsLocked);
Assert.True(_semaphore.IsLocked);
}
public void Dispose()

View file

@ -64,7 +64,7 @@ namespace LibHac.Kernel
private static Result GetKipOffsets(out (int offset, int size)[] kipOffsets, IStorage iniStorage,
int processCount)
{
Assert.AssertTrue(processCount <= MaxProcessCount);
Assert.True(processCount <= MaxProcessCount);
kipOffsets = default;

View file

@ -486,7 +486,7 @@ namespace LibHac.Kvdb
if (_count > 0)
{
// The key being added must be greater than the last key in the list.
Assert.AssertTrue(key.CompareTo(_entries[_count - 1].Key) > 0);
Assert.True(key.CompareTo(_entries[_count - 1].Key) > 0);
}
_entries[_count] = new KeyValue(in key, value);

View file

@ -75,7 +75,7 @@ namespace LibHac.Kvdb
Unsafe.SkipInit(out count);
// This should only be called at the start of reading stream.
Assert.AssertTrue(_offset == 0);
Assert.True(_offset == 0);
// Read and validate header.
var header = new KeyValueArchiveHeader();
@ -177,7 +177,7 @@ namespace LibHac.Kvdb
private void Write(ReadOnlySpan<byte> source)
{
// Bounds check.
Assert.AssertTrue(_offset + source.Length <= _buffer.Length &&
Assert.True(_offset + source.Length <= _buffer.Length &&
_offset + source.Length > _offset);
source.CopyTo(_buffer.Slice(_offset));

View file

@ -11,7 +11,7 @@ namespace LibHac.Util
public static ulong AlignUpPow2(ulong value, uint alignment)
{
Assert.AssertTrue(BitUtil.IsPowerOfTwo(alignment));
Assert.True(BitUtil.IsPowerOfTwo(alignment));
ulong invMask = alignment - 1;
return ((value + invMask) & ~invMask);
@ -19,7 +19,7 @@ namespace LibHac.Util
public static ulong AlignDownPow2(ulong value, uint alignment)
{
Assert.AssertTrue(BitUtil.IsPowerOfTwo(alignment));
Assert.True(BitUtil.IsPowerOfTwo(alignment));
ulong invMask = alignment - 1;
return (value & ~invMask);
@ -28,7 +28,7 @@ namespace LibHac.Util
[MethodImpl(MethodImplOptions.NoInlining)]
public static bool IsAlignedPow2(ulong value, uint alignment)
{
Assert.AssertTrue(BitUtil.IsPowerOfTwo(alignment));
Assert.True(BitUtil.IsPowerOfTwo(alignment));
ulong invMask = alignment - 1;
return (value & invMask) == 0;

View file

@ -14,7 +14,7 @@ namespace LibHac.Util
{
get
{
Assert.AssertTrue(_hasValue);
Assert.True(_hasValue);
// It's beautiful
return ref MemoryMarshal.CreateSpan(ref _value, 1)[0];
}
@ -23,7 +23,7 @@ namespace LibHac.Util
{
get
{
Assert.AssertTrue(_hasValue);
Assert.True(_hasValue);
return ref SpanHelpers.CreateReadOnlySpan(in _value, 1)[0];
}
}