Changing Trace.Assert to Debug.Assert

* Also Debug.Assert for unreturned memory blocks
This commit is contained in:
Louis DeJardin 2015-09-25 13:01:54 -07:00
parent f740616573
commit 318f3b7145
3 changed files with 8 additions and 5 deletions

View File

@ -196,8 +196,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
} }
// Now that the while loop has completed the following invariants should hold true: // Now that the while loop has completed the following invariants should hold true:
Trace.Assert(_numBytesPreCompleted >= 0); Debug.Assert(_numBytesPreCompleted >= 0);
Trace.Assert(_numBytesPreCompleted <= _maxBytesPreCompleted); Debug.Assert(_numBytesPreCompleted <= _maxBytesPreCompleted);
} }
} }

View File

@ -77,6 +77,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Infrastructure
~MemoryPoolBlock2() ~MemoryPoolBlock2()
{ {
Debug.Assert(!_pinHandle.IsAllocated, "Ad-hoc memory block wasn't unpinned");
Debug.Assert(Slab == null || !Slab.IsActive, "Block being garbage collected instead of returned to pool");
if (_pinHandle.IsAllocated) if (_pinHandle.IsAllocated)
{ {
// if this is a one-time-use block, ensure that the GCHandle does not leak // if this is a one-time-use block, ensure that the GCHandle does not leak

View File

@ -77,9 +77,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
public void Validate(bool closed = false) public void Validate(bool closed = false)
{ {
Trace.Assert(closed || !IsClosed, "Handle is closed"); Debug.Assert(closed || !IsClosed, "Handle is closed");
Trace.Assert(!IsInvalid, "Handle is invalid"); Debug.Assert(!IsInvalid, "Handle is invalid");
Trace.Assert(_threadId == Thread.CurrentThread.ManagedThreadId, "ThreadId is incorrect"); Debug.Assert(_threadId == Thread.CurrentThread.ManagedThreadId, "ThreadId is incorrect");
} }
unsafe public static THandle FromIntPtr<THandle>(IntPtr handle) unsafe public static THandle FromIntPtr<THandle>(IntPtr handle)