Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit d3c1876

Browse files
committed
Use Environment.NewLine and Environment.StackTrace
1 parent 304c7ee commit d3c1876

File tree

1 file changed

+7
-12
lines changed
  • src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure

1 file changed

+7
-12
lines changed

src/Microsoft.AspNetCore.Server.Kestrel/Internal/Infrastructure/MemoryPool.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,17 @@ public class MemoryPool : IDisposable
6161
/// </summary>
6262
private bool _disposedValue = false; // To detect redundant calls
6363

64+
/// <summary>
65+
/// Called to take a block from the pool.
66+
/// </summary>
67+
/// <returns>The block that is reserved for the called. It must be passed to Return when it is no longer being used.</returns>
6468
#if DEBUG
6569
public MemoryPoolBlock Lease([CallerMemberName] string memberName = "",
6670
[CallerFilePath] string sourceFilePath = "",
6771
[CallerLineNumber] int sourceLineNumber = 0)
6872
{
6973
Debug.Assert(!_disposedValue, "Block being leased from disposed pool!");
7074
#else
71-
72-
/// <summary>
73-
/// Called to take a block from the pool.
74-
/// </summary>
75-
/// <returns>The block that is reserved for the called. It must be passed to Return when it is no longer being used.</returns>
7675
public MemoryPoolBlock Lease()
7776
{
7877
#endif
@@ -83,9 +82,7 @@ public MemoryPoolBlock Lease()
8382
#if DEBUG
8483
block.Leaser = memberName + ", " + sourceFilePath + ", " + sourceLineNumber;
8584
block.IsLeased = true;
86-
#if !NETSTANDARD1_3
87-
block.StackTrace = new StackTrace(true).ToString();
88-
#endif
85+
block.StackTrace = Environment.StackTrace;
8986
#endif
9087
return block;
9188
}
@@ -94,9 +91,7 @@ public MemoryPoolBlock Lease()
9491
#if DEBUG
9592
block.Leaser = memberName + ", " + sourceFilePath + ", " + sourceLineNumber;
9693
block.IsLeased = true;
97-
#if !NETSTANDARD1_3
98-
block.StackTrace = new StackTrace(true).ToString();
99-
#endif
94+
block.StackTrace = Environment.StackTrace;
10095
#endif
10196
return block;
10297
}
@@ -153,7 +148,7 @@ public void Return(MemoryPoolBlock block)
153148
{
154149
#if DEBUG
155150
Debug.Assert(block.Pool == this, "Returned block was not leased from this pool");
156-
Debug.Assert(block.IsLeased, "Block being returned to pool twice: " + block.Leaser + "\n" + block.StackTrace);
151+
Debug.Assert(block.IsLeased, $"Block being returned to pool twice: {block.Leaser}" + Environment.NewLine + block.StackTrace);
157152
block.IsLeased = false;
158153
#endif
159154

0 commit comments

Comments
 (0)