Skip to content

Commit

Permalink
.Net: Fix postgres memory store dispose (#3177)
Browse files Browse the repository at this point in the history
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->
Fix #3121

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Convert to `IDisposable` to execute `Dispose`.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

---------

Co-authored-by: Roger Barreto <[email protected]>
  • Loading branch information
JadynWong and RogerBarreto authored Nov 7, 2023
1 parent 49e057f commit cc6dd60
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
this._dataSource?.Dispose();
// Avoid error when running in .Net 7 where it throws
// Could not load type 'System.Data.Common.DbDataSource' from assembly 'Npgsql, Version=7.*
(this._dataSource as IDisposable)?.Dispose();
}
}

Expand Down

0 comments on commit cc6dd60

Please sign in to comment.