Harden disposal paths and test project metadata

This commit is contained in:
root
2026-02-23 21:31:07 +01:00
parent a2fd695738
commit 03b7d06a14
10 changed files with 192 additions and 122 deletions

View File

@@ -260,35 +260,51 @@ namespace DynamORM
#region IExtendedDisposable Members
/// <summary>Performs application-defined tasks associated with
/// freeing, releasing, or resetting unmanaged resources.</summary>
public void Dispose()
{
lock (_db.SyncLock)
{
if (_con != null)
{
List<IDbCommand> pool = _db.CommandsPool.TryGetValue(_con.Connection);
if (pool != null && pool.Contains(this))
pool.Remove(this);
}
IsDisposed = true;
if (_command != null)
{
_command.Parameters.Clear();
_command.Dispose();
_command = null;
}
}
}
/// <summary>Performs application-defined tasks associated with
/// freeing, releasing, or resetting unmanaged resources.</summary>
public void Dispose()
{
if (IsDisposed)
return;
var db = _db;
if (db == null)
{
IsDisposed = true;
return;
}
lock (db.SyncLock)
{
if (IsDisposed)
return;
IsDisposed = true;
if (_con != null)
{
List<IDbCommand> pool = db.CommandsPool.TryGetValue(_con.Connection);
if (pool != null && pool.Contains(this))
pool.Remove(this);
}
if (_command != null)
{
_command.Parameters.Clear();
_command.Dispose();
_command = null;
}
_con = null;
_db = null;
}
}
/// <summary>Gets a value indicating whether this instance is disposed.</summary>
public bool IsDisposed { get; private set; }
#endregion IExtendedDisposable Members
}
}
}