Skip to content

Commit 31d5ac0

Browse files
committed
Address additional Copilot AI feedback
1. Fix potential NullReferenceException in GetHashCode() - Changed from CSharpType.GetHashCode() to HashCode.Combine(CSharpType) - HashCode.Combine handles null values properly 2. Update CHANGELOG for accuracy - Clarify that string/byte[] compare _maxWidthForStrings (backing field) - Not the Width property which includes Size.ToStringLength() - Add note about avoiding Size interference - Mention null-safety improvement in GetHashCode() - Update test count to 19 (added 2 edge case tests) All 396 tests pass.
1 parent 718c3ee commit 31d5ac0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
- **DatabaseTypeRequest.Equals()**: Now uses type-specific equality semantics (Issue #19)
1414
- **decimal**: Compares only `CSharpType` and `Size` (precision/scale) - ignores `Width` and `Unicode`
15-
- **string**: Compares `CSharpType`, `Width`, and `Unicode` - ignores `Size`
16-
- **byte[]**: Compares `CSharpType` and `Width` - ignores `Size` and `Unicode`
15+
- **string**: Compares `CSharpType`, explicit width (`_maxWidthForStrings`), and `Unicode` - ignores `Size`
16+
- **byte[]**: Compares `CSharpType` and explicit width (`_maxWidthForStrings`) - ignores `Size` and `Unicode`
1717
- **Other types** (bool, int, long, DateTime, TimeSpan, Guid, etc.): Compares only `CSharpType`
1818
- Fixes round-trip equality when comparing guesser-created and SQL reverse-engineered types
19-
- `GetHashCode()` updated to match new equality semantics for consistency
20-
- Added 17 comprehensive tests covering all type-specific equality cases
19+
- Compares backing field `_maxWidthForStrings` instead of computed `Width` property to avoid Size interference
20+
- `GetHashCode()` updated to match new equality semantics for consistency and null-safety
21+
- Added 19 comprehensive tests covering all type-specific equality cases and edge cases
2122

2223
## [2.0.1] - 2025-11-15
2324

TypeGuesser/DatabaseTypeRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public override int GetHashCode()
182182
}
183183

184184
// For all other types, only hash the type
185-
return CSharpType.GetHashCode();
185+
return HashCode.Combine(CSharpType);
186186
}
187187

188188
/// <summary>

0 commit comments

Comments
 (0)