File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -694,6 +694,11 @@ public async Task DisposeAsync()
694
694
finally
695
695
{
696
696
m_isDisposed = true ;
697
+
698
+ // Component implements the Dispose pattern, with some core logic implemented in Dispose(bool disposing). DbConnection
699
+ // adds DisposeAsync but doesn't implement the full DisposeAsyncCore pattern. Thus, although DisposeAsync is supposed
700
+ // to call Dispose(false), we call Dispose(true) here to execute that base class logic in both the sync and async paths.
701
+ base . Dispose ( true ) ;
697
702
}
698
703
}
699
704
Original file line number Diff line number Diff line change @@ -524,6 +524,17 @@ public async Task UnixDomainSocket()
524
524
Assert . Equal ( ConnectionState . Open , connection . State ) ;
525
525
}
526
526
527
+ [ Fact ]
528
+ public async Task DisposeAsyncRaisesDisposed ( )
529
+ {
530
+ var disposedCount = 0 ;
531
+ var connection = new MySqlConnection ( AppConfig . ConnectionString ) ;
532
+ connection . Disposed += ( sender , args ) => disposedCount ++ ;
533
+ await connection . OpenAsync ( ) . ConfigureAwait ( false ) ;
534
+ await connection . DisposeAsync ( ) . ConfigureAwait ( false ) ;
535
+ Assert . Equal ( 1 , disposedCount ) ;
536
+ }
537
+
527
538
readonly DatabaseFixture m_database ;
528
539
}
529
540
Original file line number Diff line number Diff line change @@ -589,5 +589,16 @@ public void UnixDomainSocket()
589
589
Assert . Equal ( ConnectionState . Open , connection . State ) ;
590
590
}
591
591
592
+ [ Fact ]
593
+ public void DisposeRaisesDisposed ( )
594
+ {
595
+ var disposedCount = 0 ;
596
+ var connection = new MySqlConnection ( AppConfig . ConnectionString ) ;
597
+ connection . Disposed += ( sender , args ) => disposedCount ++ ;
598
+ connection . Open ( ) ;
599
+ connection . Dispose ( ) ;
600
+ Assert . Equal ( 1 , disposedCount ) ;
601
+ }
602
+
592
603
readonly DatabaseFixture m_database ;
593
604
}
You can’t perform that action at this time.
0 commit comments