@@ -61,18 +61,17 @@ public class MemoryPool : IDisposable
61
61
/// </summary>
62
62
private bool _disposedValue = false ; // To detect redundant calls
63
63
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>
64
68
#if DEBUG
65
69
public MemoryPoolBlock Lease ( [ CallerMemberName ] string memberName = "" ,
66
70
[ CallerFilePath ] string sourceFilePath = "" ,
67
71
[ CallerLineNumber ] int sourceLineNumber = 0 )
68
72
{
69
73
Debug . Assert ( ! _disposedValue , "Block being leased from disposed pool!" ) ;
70
74
#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>
76
75
public MemoryPoolBlock Lease ( )
77
76
{
78
77
#endif
@@ -83,9 +82,7 @@ public MemoryPoolBlock Lease()
83
82
#if DEBUG
84
83
block . Leaser = memberName + ", " + sourceFilePath + ", " + sourceLineNumber ;
85
84
block . IsLeased = true ;
86
- #if ! NETSTANDARD1_3
87
- block . StackTrace = new StackTrace ( true ) . ToString ( ) ;
88
- #endif
85
+ block . StackTrace = Environment . StackTrace ;
89
86
#endif
90
87
return block ;
91
88
}
@@ -94,9 +91,7 @@ public MemoryPoolBlock Lease()
94
91
#if DEBUG
95
92
block . Leaser = memberName + ", " + sourceFilePath + ", " + sourceLineNumber ;
96
93
block . IsLeased = true ;
97
- #if ! NETSTANDARD1_3
98
- block . StackTrace = new StackTrace ( true ) . ToString ( ) ;
99
- #endif
94
+ block . StackTrace = Environment . StackTrace ;
100
95
#endif
101
96
return block ;
102
97
}
@@ -153,7 +148,7 @@ public void Return(MemoryPoolBlock block)
153
148
{
154
149
#if DEBUG
155
150
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 ) ;
157
152
block . IsLeased = false ;
158
153
#endif
159
154
0 commit comments