Skip to content

Please can you make Dispose in TestContextBase virtual #338

Answered by egil
robalexclark asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @robalexclark

It is virtual, or rather, the Dispose(bool disposing) method is. This follows the recommended disposing pattern described here: https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose#implement-the-dispose-pattern-for-a-derived-class.

Please make sure you call base.Dispose(disposing) from your overwrite of this method when you are done with the disposing steps you need.

An alternative you can consider is to simply add the SQLite connection to the Services collection/provider. This will take care of disposing it for you, if you allow the service provider to create the SQLite instance.

Hope this helps.

ps. will convert this to a QA discussion.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@robalexclark
Comment options

Answer selected by egil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #337 on March 08, 2021 20:46.