feat(dispose): add debug checks for double disposal
Added debug-only checks in Dispose methods of HashMapHelper, UnTypedArray, and UnsafeArray to log a message (with optional stack trace) if Dispose is called on an uninitialized or already disposed instance, unless the buffer is null. Incremented assembly version to 1.6.6.
This commit is contained in:
@@ -418,6 +418,12 @@ public unsafe struct UnsafeArray<T> : IUnsafeCollection<T>
|
||||
{
|
||||
if (!IsCreated)
|
||||
{
|
||||
#if DEBUG
|
||||
if (_buffer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var message = "The UnsafeArray is not created or already disposed.";
|
||||
#if MHP_ENABLE_STACKTRACE
|
||||
var stackTrace = new StackTrace(1, true);
|
||||
@@ -435,6 +441,7 @@ public unsafe struct UnsafeArray<T> : IUnsafeCollection<T>
|
||||
message += Environment.NewLine + sb.ToString();
|
||||
#endif
|
||||
Debug.WriteLine(message);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user