fix(serialization): Remove legacy BinaryFormatter support
SonarQube Analysis / sonarqube (pull_request) Successful in 4m42s
SonarQube Analysis / sonarqube (pull_request) Successful in 4m42s
The `[Serializable]` attribute and corresponding `[OnDeserialized]` methods have been removed from various breakdown classes. This eliminates reliance on `BinaryFormatter`, which is a deprecated and insecure serialization mechanism in modern .NET. This change also resolves SonarQube rule S5766 warnings by removing the context in which they apply, leading to cleaner and more secure code.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using Strata.SqlTools.SqlBreakdown.Interfaces;
|
||||
using Strata.SqlTools.SqlBreakdown.Interfaces.QueryEngine;
|
||||
@@ -13,7 +12,6 @@ namespace Strata.SqlTools.SqlBreakdown.Classes;
|
||||
/// allowing efficient management and retrieval of multiple SQL breakdowns as a unified collection.
|
||||
/// Implements ICollection<ISqlBreakdown> to provide standard collection semantics and LINQ support.
|
||||
/// </remarks>
|
||||
[Serializable]
|
||||
public class SqlBreakdownCollection : ICollection<ISqlBreakdown>
|
||||
{
|
||||
private readonly List<ISqlBreakdown> _breakdowns;
|
||||
@@ -36,20 +34,6 @@ public class SqlBreakdownCollection : ICollection<ISqlBreakdown>
|
||||
_breakdowns = new List<ISqlBreakdown>(breakdowns ?? Enumerable.Empty<ISqlBreakdown>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates that the backing list survived deserialization, since deserialization bypasses
|
||||
/// the constructors that normally initialize it (SonarQube rule S5766).
|
||||
/// </summary>
|
||||
/// <param name="context">The streaming context for the deserialization operation.</param>
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
if (_breakdowns is null)
|
||||
{
|
||||
throw new SerializationException("Deserialized SqlBreakdownCollection is missing its backing list.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of SQL breakdowns.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user