File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,16 @@ namespace SQLitePCL.pretty.tests
2626 [ TestFixture ]
2727 public class SQLiteDatabaseConnectionTests
2828 {
29+ [ Test ]
30+ public void TestFinalize ( )
31+ {
32+ // There is no way to assert, so this test is primarily for code coverage.
33+ var db = SQLite3 . Open ( ":memory:" ) ;
34+ var stmt = db . PrepareStatement ( "SELECT 1;" ) ;
35+
36+ GC . Collect ( ) ;
37+ }
38+
2939 [ Test ]
3040 public void TestDispose ( )
3141 {
Original file line number Diff line number Diff line change @@ -1126,6 +1126,14 @@ public void RemoveCommitHook()
11261126 /// <inheritdoc/>
11271127 public void Dispose ( )
11281128 {
1129+ Dispose ( true ) ;
1130+ GC . SuppressFinalize ( this ) ;
1131+ }
1132+
1133+ private void Dispose ( bool disposing )
1134+ {
1135+ if ( disposed ) { return ; }
1136+
11291137 this . Disposing ( this , null ) ;
11301138
11311139 disposed = true ;
@@ -1134,6 +1142,12 @@ public void Dispose()
11341142 raw . sqlite3_close ( db ) ;
11351143 }
11361144
1145+ /// <inheritdoc/>
1146+ ~ SQLiteDatabaseConnection ( )
1147+ {
1148+ Dispose ( false ) ;
1149+ }
1150+
11371151 private sealed class CtxState < T >
11381152 {
11391153 private readonly T value ;
You can’t perform that action at this time.
0 commit comments