Fixed SCA warnings
This commit is contained in:
parent
72d49d421c
commit
56eca71853
13 changed files with 299 additions and 236 deletions
|
|
@ -14,6 +14,7 @@ namespace TShockAPI.DB
|
|||
/// <param name="query">Query string with parameters as @0, @1, etc.</param>
|
||||
/// <param name="args">Parameters to be put in the query</param>
|
||||
/// <returns>Rows affected by query</returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities")]
|
||||
public static int Query(this IDbConnection olddb, string query, params object[] args)
|
||||
{
|
||||
using (var db = olddb.CloneEx())
|
||||
|
|
@ -36,6 +37,7 @@ namespace TShockAPI.DB
|
|||
/// <param name="query">Query string with parameters as @0, @1, etc.</param>
|
||||
/// <param name="args">Parameters to be put in the query</param>
|
||||
/// <returns>Query result as IDataReader</returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities")]
|
||||
public static QueryResult QueryReader(this IDbConnection olddb, string query, params object[] args)
|
||||
{
|
||||
var db = olddb.CloneEx();
|
||||
|
|
@ -125,10 +127,32 @@ namespace TShockAPI.DB
|
|||
Reader = reader;
|
||||
}
|
||||
|
||||
~QueryResult()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Reader.Dispose();
|
||||
Connection.Dispose();
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (Reader != null)
|
||||
{
|
||||
Reader.Dispose();
|
||||
Reader = null;
|
||||
}
|
||||
if (Connection != null)
|
||||
{
|
||||
Connection.Dispose();
|
||||
Connection = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Read()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue