@@ -309,31 +309,27 @@ public void DisposePendingDisposablesOnException()
309
309
Exception ? exception = null ;
310
310
311
311
Debug . Assert ( Current . AsyncDisposable is null ) ;
312
- DisposeFrame ( Current . CollectionEnumerator , Current . Disposable , ref exception ) ;
312
+ DisposeFrame ( Current . CollectionEnumerator , ref exception ) ;
313
313
314
314
int stackSize = Math . Max ( _count , _continuationCount ) ;
315
315
for ( int i = 0 ; i < stackSize - 1 ; i ++ )
316
316
{
317
317
Debug . Assert ( _stack [ i ] . AsyncDisposable is null ) ;
318
- DisposeFrame ( _stack [ i ] . CollectionEnumerator , _stack [ i ] . Disposable , ref exception ) ;
318
+ DisposeFrame ( _stack [ i ] . CollectionEnumerator , ref exception ) ;
319
319
}
320
320
321
321
if ( exception is not null )
322
322
{
323
323
ExceptionDispatchInfo . Capture ( exception ) . Throw ( ) ;
324
324
}
325
325
326
- static void DisposeFrame ( IEnumerator ? collectionEnumerator , IDisposable ? disposable , ref Exception ? exception )
326
+ static void DisposeFrame ( IEnumerator ? collectionEnumerator , ref Exception ? exception )
327
327
{
328
328
try
329
329
{
330
- if ( collectionEnumerator is IDisposable disposableEnumerator )
330
+ if ( collectionEnumerator is IDisposable disposable )
331
331
{
332
- disposableEnumerator . Dispose ( ) ;
333
- }
334
- else
335
- {
336
- disposable ? . Dispose ( ) ;
332
+ disposable . Dispose ( ) ;
337
333
}
338
334
}
339
335
catch ( Exception e )
@@ -351,37 +347,33 @@ public async ValueTask DisposePendingDisposablesOnExceptionAsync()
351
347
{
352
348
Exception ? exception = null ;
353
349
354
- exception = await DisposeFrame ( Current . CollectionEnumerator , Current . AsyncDisposable , Current . Disposable , exception ) . ConfigureAwait ( false ) ;
350
+ exception = await DisposeFrame ( Current . CollectionEnumerator , Current . AsyncDisposable , exception ) . ConfigureAwait ( false ) ;
355
351
356
352
int stackSize = Math . Max ( _count , _continuationCount ) ;
357
353
for ( int i = 0 ; i < stackSize - 1 ; i ++ )
358
354
{
359
- exception = await DisposeFrame ( _stack [ i ] . CollectionEnumerator , _stack [ i ] . AsyncDisposable , _stack [ i ] . Disposable , exception ) . ConfigureAwait ( false ) ;
355
+ exception = await DisposeFrame ( _stack [ i ] . CollectionEnumerator , _stack [ i ] . AsyncDisposable , exception ) . ConfigureAwait ( false ) ;
360
356
}
361
357
362
358
if ( exception is not null )
363
359
{
364
360
ExceptionDispatchInfo . Capture ( exception ) . Throw ( ) ;
365
361
}
366
362
367
- static async ValueTask < Exception ? > DisposeFrame ( IEnumerator ? collectionEnumerator , IAsyncDisposable ? asyncDisposable , IDisposable ? disposable , Exception ? exception )
363
+ static async ValueTask < Exception ? > DisposeFrame ( IEnumerator ? collectionEnumerator , IAsyncDisposable ? asyncDisposable , Exception ? exception )
368
364
{
369
365
Debug . Assert ( ! ( collectionEnumerator is not null && asyncDisposable is not null ) ) ;
370
366
371
367
try
372
368
{
373
- if ( collectionEnumerator is IDisposable disposableEnumerator )
369
+ if ( collectionEnumerator is IDisposable disposable )
374
370
{
375
- disposableEnumerator . Dispose ( ) ;
371
+ disposable . Dispose ( ) ;
376
372
}
377
373
else if ( asyncDisposable is not null )
378
374
{
379
375
await asyncDisposable . DisposeAsync ( ) . ConfigureAwait ( false ) ;
380
376
}
381
- else
382
- {
383
- disposable ? . Dispose ( ) ;
384
- }
385
377
}
386
378
catch ( Exception e )
387
379
{
0 commit comments