diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs index 5c890807b6..0eed51d7d3 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs @@ -196,8 +196,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } // Now that the while loop has completed the following invariants should hold true: - Trace.Assert(_numBytesPreCompleted >= 0); - Trace.Assert(_numBytesPreCompleted <= _maxBytesPreCompleted); + Debug.Assert(_numBytesPreCompleted >= 0); + Debug.Assert(_numBytesPreCompleted <= _maxBytesPreCompleted); } } diff --git a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolBlock2.cs b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolBlock2.cs index bb7eb5758c..c0c9fae183 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolBlock2.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolBlock2.cs @@ -77,6 +77,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Infrastructure ~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 this is a one-time-use block, ensure that the GCHandle does not leak diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvMemory.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvMemory.cs index 051218ffef..a8389c39a2 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvMemory.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvMemory.cs @@ -77,9 +77,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking public void Validate(bool closed = false) { - Trace.Assert(closed || !IsClosed, "Handle is closed"); - Trace.Assert(!IsInvalid, "Handle is invalid"); - Trace.Assert(_threadId == Thread.CurrentThread.ManagedThreadId, "ThreadId is incorrect"); + Debug.Assert(closed || !IsClosed, "Handle is closed"); + Debug.Assert(!IsInvalid, "Handle is invalid"); + Debug.Assert(_threadId == Thread.CurrentThread.ManagedThreadId, "ThreadId is incorrect"); } unsafe public static THandle FromIntPtr(IntPtr handle)