Ban runtime asserts without a message
This commit is contained in:
parent
8e12e44411
commit
67f87b15c4
|
@ -9,4 +9,6 @@ M:System.Convert.ToSingle(System.String);use float.{Try,}Parse
|
|||
M:System.Convert.ToUInt16(System.String);use ushort.{Try,}Parse
|
||||
M:System.Convert.ToUInt32(System.String);use uint.{Try,}Parse
|
||||
M:System.Convert.ToUInt64(System.String);use ulong.{Try,}Parse
|
||||
M:System.Diagnostics.Debug.Assert(System.Boolean);include a unique message
|
||||
M:System.Diagnostics.Trace.Assert(System.Boolean);include a unique message
|
||||
M:System.Windows.Forms.Control.Focus;use Activate for Forms, or Select otherwise
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace BizHawk.Bizware.Graphics
|
|||
|
||||
public void UnlockBits(BitmapData bmpd)
|
||||
{
|
||||
Debug.Assert(CurrLock == bmpd);
|
||||
Debug.Assert(CurrLock == bmpd, "must pass in the same object obtained from " + nameof(LockBits));
|
||||
|
||||
if (WrappedBitmap != null)
|
||||
{
|
||||
|
|
|
@ -285,7 +285,7 @@ namespace BizHawk.Client.Common.FilterManager
|
|||
if (ps.Type == ProgramStepType.NewTarget)
|
||||
{
|
||||
var size = (Size)ps.Args;
|
||||
Debug.Assert(size == outsize);
|
||||
Debug.Assert(size == outsize, "size of last " + nameof(ProgramStepType.NewTarget) + " was set wrong");
|
||||
Program[i] = new(ProgramStepType.FinalTarget, size, ps.Comment);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#nullable enable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -27,7 +26,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
var @base = File.ReadAllBytes(baseFilename);
|
||||
var (patched, actualHash) = PerformPatchInMemory(@base, in patchOption);
|
||||
Trace.Assert(actualHash == patchOption.TargetHash);
|
||||
if (actualHash != patchOption.TargetHash) throw new InvalidOperationException("patch produced incorrect output");
|
||||
var patchedParentDir = Path.Combine(pathEntries[PathEntryCollection.GLOBAL, "Temp Files"].Path, "AutopatchedFirmware");
|
||||
Directory.CreateDirectory(patchedParentDir);
|
||||
var ff = FirmwareDatabase.FirmwareFilesByHash[patchOption.TargetHash];
|
||||
|
|
|
@ -821,13 +821,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private bool IsVisible(int index)
|
||||
{
|
||||
Debug.Assert(FirstVisibleRow < LastFullyVisibleRow);
|
||||
Debug.Assert(FirstVisibleRow < LastFullyVisibleRow, "rows out of order?");
|
||||
return FirstVisibleRow <= index && index <= LastFullyVisibleRow;
|
||||
}
|
||||
|
||||
public bool IsPartiallyVisible(int index)
|
||||
{
|
||||
Debug.Assert(FirstVisibleRow < LastVisibleRow);
|
||||
Debug.Assert(FirstVisibleRow < LastVisibleRow, "rows out of order?");
|
||||
return FirstVisibleRow <= index && index <= LastVisibleRow;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
Debug.Assert(inFinalTarget);
|
||||
Debug.Assert(inFinalTarget, "not in final target?");
|
||||
|
||||
// present and conclude drawing
|
||||
_graphicsControl.SwapBuffers();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Windows.Forms;
|
||||
|
@ -459,7 +460,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
dims.Height = dims.Width = Math.Max(dims.Width, dims.Height);
|
||||
allocate(dims.Width, dims.Height);
|
||||
numPixels = dims.Width * dims.Height;
|
||||
System.Diagnostics.Debug.Assert(stride / 4 == dims.Width);
|
||||
Debug.Assert(dims.Width * 4 == stride, "line is not `width` pixels at 32bpp?");
|
||||
|
||||
map = gd.FetchTilemap(bg.ScreenAddr, bg.ScreenSize);
|
||||
int paletteStart = 0;
|
||||
|
|
|
@ -148,7 +148,7 @@ namespace BizHawk.Common
|
|||
if (size is 0)
|
||||
{
|
||||
var rleSize = (data[i++] * 0x100) | data[i++];
|
||||
Debug.Assert(rleSize is not 0);
|
||||
Debug.Assert(rleSize is not 0, "may not run-length-encode nothing");
|
||||
records.Add((i, targetOffset, rleSize, true));
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -14,19 +14,19 @@ namespace BizHawk.Common
|
|||
|
||||
public static implicit operator Bit(int rhs)
|
||||
{
|
||||
Debug.Assert((rhs & ~1) == 0);
|
||||
Debug.Assert((rhs & ~1) is 0, "higher bits can't be used");
|
||||
return new Bit((uint)rhs);
|
||||
}
|
||||
|
||||
public static implicit operator Bit(uint rhs)
|
||||
{
|
||||
Debug.Assert((rhs & ~1) == 0);
|
||||
Debug.Assert((rhs & ~1) is 0, "higher bits can't be used");
|
||||
return new Bit(rhs);
|
||||
}
|
||||
|
||||
public static implicit operator Bit(byte rhs)
|
||||
{
|
||||
Debug.Assert((rhs & ~1) == 0);
|
||||
Debug.Assert((rhs & ~1) is 0, "higher bits can't be used");
|
||||
return new Bit(rhs);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace BizHawk.Common
|
|||
{
|
||||
#if true //TODO benchmark (both methods work correctly); also there is another method involving shifting the (output copy of the) array over by 1 byte then manually writing every second byte
|
||||
var l = a.Length;
|
||||
Debug.Assert(l % 2 == 0);
|
||||
Debug.Assert(l % 2 is 0, "octets must be in pairs");
|
||||
fixed (byte* p = &a[0]) for (var i = 0; i < l; i += 2)
|
||||
{
|
||||
var b = p[i];
|
||||
|
@ -17,7 +17,7 @@ namespace BizHawk.Common
|
|||
p[i + 1] = b;
|
||||
}
|
||||
#else
|
||||
Debug.Assert(a.Length % 2 == 0);
|
||||
Debug.Assert(a.Length % 2 is 0, "octets must be in pairs");
|
||||
var shorts = MemoryMarshal.Cast<byte, ushort>(a);
|
||||
for (var i = 0; i < shorts.Length; i++) shorts[i] = BinaryPrimitives.ReverseEndianness(shorts[i]);
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@ namespace BizHawk.Common
|
|||
{
|
||||
#if true //TODO benchmark (both methods work correctly)
|
||||
var l = a.Length;
|
||||
Debug.Assert(l % 4 == 0);
|
||||
Debug.Assert(l % 4 is 0, "octets must be in groups of 4");
|
||||
fixed (byte* p = &a[0]) for (var i = 0; i < l; i += 4)
|
||||
{
|
||||
var b = p[i];
|
||||
|
@ -39,7 +39,7 @@ namespace BizHawk.Common
|
|||
p[i + 2] = b;
|
||||
}
|
||||
#else
|
||||
Debug.Assert(a.Length % 4 == 0);
|
||||
Debug.Assert(a.Length % 4 is 0, "octets must be in groups of 4");
|
||||
var ints = MemoryMarshal.Cast<byte, uint>(a);
|
||||
for (var i = 0; i < ints.Length; i++) ints[i] = BinaryPrimitives.ReverseEndianness(ints[i]);
|
||||
#endif
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace BizHawk.Common.CollectionExtensions
|
|||
if (a.Length is 0) return b;
|
||||
var combined = new T[a.Length + b.Length];
|
||||
var returned = ((ReadOnlySpan<T>) a).ConcatArray(b, combined);
|
||||
Debug.Assert(returned == combined);
|
||||
Debug.Assert(returned == combined, "expecting return value to cover all of combined since the whole thing was written to");
|
||||
return combined;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace BizHawk.Common
|
|||
if (tmp[0] != 0x1F || tmp[1] != 0x8B) throw new InvalidOperationException("GZIP header not present");
|
||||
src.Seek(-4, SeekOrigin.End);
|
||||
var bytesRead = src.Read(tmp, offset: 0, count: tmp.Length);
|
||||
Debug.Assert(bytesRead == tmp.Length);
|
||||
Debug.Assert(bytesRead == tmp.Length, "failed to read tail");
|
||||
src.Seek(0, SeekOrigin.Begin);
|
||||
using var gs = new GZipStream(src, CompressionMode.Decompress, true);
|
||||
var data = new byte[BitConverter.ToInt32(tmp, 0)];
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace BizHawk.Common
|
|||
if (_md5Impl == null)
|
||||
{
|
||||
_md5Impl = MD5.Create();
|
||||
Debug.Assert(_md5Impl.CanReuseTransform && _md5Impl.HashSize is EXPECTED_LENGTH);
|
||||
Debug.Assert(_md5Impl.CanReuseTransform && _md5Impl.HashSize is EXPECTED_LENGTH, "nonstandard implementation?");
|
||||
}
|
||||
return _md5Impl;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace BizHawk.Common
|
|||
if (_sha1Impl == null)
|
||||
{
|
||||
_sha1Impl = SHA1.Create();
|
||||
Debug.Assert(_sha1Impl.CanReuseTransform && _sha1Impl.HashSize is EXPECTED_LENGTH);
|
||||
Debug.Assert(_sha1Impl.CanReuseTransform && _sha1Impl.HashSize is EXPECTED_LENGTH, "nonstandard implementation?");
|
||||
}
|
||||
return _sha1Impl;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace BizHawk.Common
|
|||
if (_sha256Impl == null)
|
||||
{
|
||||
_sha256Impl = SHA256.Create();
|
||||
Debug.Assert(_sha256Impl.CanReuseTransform && _sha256Impl.HashSize is EXPECTED_LENGTH);
|
||||
Debug.Assert(_sha256Impl.CanReuseTransform && _sha256Impl.HashSize is EXPECTED_LENGTH, "nonstandard implementation?");
|
||||
}
|
||||
return _sha256Impl;
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
private void RemoveAtInternal(int index)
|
||||
{
|
||||
Debug.Assert(_modifyInProgress);
|
||||
Debug.Assert(_modifyInProgress, "unexpected collection mutation state");
|
||||
CopyIfRequired();
|
||||
|
||||
var removedItem = _items[index];
|
||||
|
@ -357,7 +357,7 @@ namespace BizHawk.Emulation.Common
|
|||
private void EndCopyOnWrite()
|
||||
{
|
||||
_copyOnWriteRequired--;
|
||||
Debug.Assert(_copyOnWriteRequired >= 0);
|
||||
Debug.Assert(_copyOnWriteRequired >= 0, "unexpected CoW state");
|
||||
}
|
||||
|
||||
public Enumerator GetEnumerator()
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
{
|
||||
// target number of samples to emit: length of 1 frame minus whatever overflow
|
||||
samplesEmitted = TICKSINFRAME - frameOverflow;
|
||||
Debug.Assert(samplesEmitted * 2 <= _soundbuff.Length);
|
||||
Debug.Assert(samplesEmitted * 2 <= _soundbuff.Length, "buffer capacity exceeded");
|
||||
if (LibGambatte.gambatte_runfor(GambatteState, FrameBuffer, 160, _soundbuff, ref samplesEmitted) > 0)
|
||||
{
|
||||
Array.Copy(FrameBuffer, VideoBuffer, FrameBuffer.Length);
|
||||
|
@ -90,7 +90,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
inputFrameLengthInt = TICKSINFRAME;
|
||||
}
|
||||
samplesEmitted = inputFrameLengthInt - frameOverflow;
|
||||
Debug.Assert(samplesEmitted * 2 <= _soundbuff.Length);
|
||||
Debug.Assert(samplesEmitted * 2 <= _soundbuff.Length, "buffer capacity exceeded");
|
||||
if (LibGambatte.gambatte_runfor(GambatteState, FrameBuffer, 160, _soundbuff, ref samplesEmitted) > 0)
|
||||
{
|
||||
Array.Copy(FrameBuffer, VideoBuffer, FrameBuffer.Length);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
using BizHawk.Common.CollectionExtensions;
|
||||
using BizHawk.Common.NumberExtensions;
|
||||
|
@ -171,7 +172,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
|
||||
//Console.WriteLine("binary searched"); //use this to check for mistaken LastReadIndex logic resulting in binary searches during sequential access
|
||||
var listIndex = Index.LowerBoundBinarySearch(idx => idx.LogicalOffset, offset);
|
||||
System.Diagnostics.Debug.Assert(listIndex < Index.Count);
|
||||
Debug.Assert(listIndex < Index.Count, "insertion point may not be after end");
|
||||
//Console.WriteLine("byte_pos {0:X8} using index #{1} at offset {2:X8}", offset, listIndex, Index[listIndex].LogicalOffset);
|
||||
|
||||
return listIndex;
|
||||
|
|
|
@ -81,10 +81,9 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
// plaindisc.ReadLBA_2352_Flat(item.Item1, chunkbuf_corlet, 0, item.Item2); // API has changed
|
||||
// ecmdisc.ReadLBA_2352_Flat(item.Item1, chunkbuf_mine, 0, item.Item2); // API has changed
|
||||
for (int i = 0; i < item.Item2; i++)
|
||||
if (chunkbuf_corlet[i] != chunkbuf_mine[i])
|
||||
{
|
||||
Debug.Assert(false);
|
||||
}
|
||||
{
|
||||
Debug.Assert(chunkbuf_corlet[i] == chunkbuf_mine[i], $"buffers differ at [{t}; {i}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue