Skip to content

Commit ee43888

Browse files
committed
Fix final 2 CodeQL alerts
HicServices#28 WARNING: Fixed Equals pattern to handle subclasses correctly - Changed from 'is' pattern to GetType() comparison in DecimalSize.Equals(object) - This ensures proper equality behavior for potential subclasses #1 NOTE: Extracted Where filter to separate variable in DateTimeTypeDecider - Moved Where clause to explicit variable before foreach - Satisfies CodeQL recommendation while avoiding ref struct limitation Build: 0 warnings, 0 errors. Tests: 377/377 passing.
1 parent 6c52392 commit ee43888

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

TypeGuesser/Deciders/DateTimeTypeDecider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ public void GuessDateFormat(IEnumerable<string> samples)
205205
if (!AllowCultureGuessing)
206206
return;
207207

208-
foreach (var sSample in samples.Where(static sSample => !string.IsNullOrWhiteSpace(sSample)))
208+
var nonEmptySamples = samples.Where(static s => !string.IsNullOrWhiteSpace(s));
209+
210+
foreach (var sSample in nonEmptySamples)
209211
{
210212
var sample = sSample.AsSpan();
211213
total++;

TypeGuesser/DecimalSize.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ public bool Equals(DecimalSize? other)
144144
/// <inheritdoc/>
145145
public override bool Equals(object? obj)
146146
{
147-
return obj is DecimalSize other && Equals(other);
147+
if (obj is null) return false;
148+
if (ReferenceEquals(this, obj)) return true;
149+
// Use GetType() comparison to handle subclasses correctly
150+
return obj.GetType() == GetType() && Equals((DecimalSize)obj);
148151
}
149152

150153
/// <inheritdoc/>

0 commit comments

Comments
 (0)