Harden disposal paths and test project metadata
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<OutputType>Library</OutputType>
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -964,6 +964,9 @@ namespace DynamORM.Builders.Implementation
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
IsDisposed = true;
|
||||
|
||||
if (Database != null)
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace DynamORM
|
||||
|
||||
private List<Data> _data = new List<Data>();
|
||||
private int _currentDataPosition = 0;
|
||||
private bool _isDisposed;
|
||||
|
||||
private DynamicCachedReader()
|
||||
{
|
||||
@@ -445,11 +446,27 @@ namespace DynamORM
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed)
|
||||
return;
|
||||
|
||||
_isDisposed = true;
|
||||
IsClosed = true;
|
||||
|
||||
if (_data == null)
|
||||
return;
|
||||
|
||||
foreach (var data in _data)
|
||||
{
|
||||
if (data == null)
|
||||
continue;
|
||||
|
||||
if (data._names != null)
|
||||
data._names.Clear();
|
||||
if (data._types != null)
|
||||
data._types.Clear();
|
||||
if (data._cache != null)
|
||||
data._cache.Clear();
|
||||
if (data._schema != null)
|
||||
data._schema.Dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -264,18 +264,31 @@ namespace DynamORM
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
lock (_db.SyncLock)
|
||||
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);
|
||||
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();
|
||||
@@ -283,6 +296,9 @@ namespace DynamORM
|
||||
_command.Dispose();
|
||||
_command = null;
|
||||
}
|
||||
|
||||
_con = null;
|
||||
_db = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,15 @@ namespace DynamORM
|
||||
/// releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
_db.Close(Connection);
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
var db = _db;
|
||||
if (db != null && Connection != null)
|
||||
db.Close(Connection);
|
||||
|
||||
Connection = null;
|
||||
_db = null;
|
||||
IsDisposed = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2010,6 +2010,9 @@ namespace DynamORM
|
||||
/// releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
#if !DYNAMORM_OMMIT_OLDSYNTAX
|
||||
List<DynamicTable> tables = TablesCache.Values.ToList();
|
||||
TablesCache.Clear();
|
||||
@@ -2067,6 +2070,8 @@ namespace DynamORM
|
||||
if (_proc != null)
|
||||
_proc.Dispose();
|
||||
|
||||
_proc = null;
|
||||
_tempConn = null;
|
||||
IsDisposed = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace DynamORM
|
||||
{
|
||||
private DynamicDatabase _db;
|
||||
private List<string> _prefixes;
|
||||
private bool _isDisposed;
|
||||
|
||||
internal DynamicProcedureInvoker(DynamicDatabase db, List<string> prefixes = null)
|
||||
{
|
||||
@@ -450,6 +451,12 @@ namespace DynamORM
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed)
|
||||
return;
|
||||
|
||||
_isDisposed = true;
|
||||
_db = null;
|
||||
_prefixes = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -954,6 +954,9 @@ namespace DynamORM
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
// Lose reference but don't kill it.
|
||||
if (Database != null)
|
||||
{
|
||||
|
||||
@@ -174,11 +174,18 @@ namespace DynamORM
|
||||
/// freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed)
|
||||
return;
|
||||
|
||||
_isDisposed = true;
|
||||
Rollback();
|
||||
|
||||
if (_disposed != null)
|
||||
_disposed();
|
||||
|
||||
_disposed = null;
|
||||
_con = null;
|
||||
_db = null;
|
||||
}
|
||||
|
||||
/// <summary>Gets a value indicating whether this instance is disposed.</summary>
|
||||
|
||||
@@ -1449,6 +1449,9 @@ namespace DynamORM.Helpers.Dynamics
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsDisposed)
|
||||
return;
|
||||
|
||||
IsDisposed = true;
|
||||
|
||||
if (_uncertainResult != null)
|
||||
|
||||
Reference in New Issue
Block a user