Skip to content

Comments

fix: Protection against StrongTypedEnum representing the value as a number internally#176

Merged
steffenskov merged 2 commits intomainfrom
enum-primitive-protection
Jan 29, 2026
Merged

fix: Protection against StrongTypedEnum representing the value as a number internally#176
steffenskov merged 2 commits intomainfrom
enum-primitive-protection

Conversation

@steffenskov
Copy link
Owner

@steffenskov steffenskov commented Jan 29, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Corrected StrongTypedEnum constructor handling to ensure numeric string values are stored as enum names internally, resolving serialization inconsistencies.
  • Chores

    • Bumped version to 2.5.2.
    • Restructured project configuration for centralized maintenance.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

Version bumped to 2.5.2 with a bug fix for StrongTypedEnum numeric string handling. Build properties centralized to Directory.Build.props; individual .csproj files cleaned up to remove duplication. StrongTypedEnumValue parsing refactored into dedicated helper. MongoDbBuilder API updated.

Changes

Cohort / File(s) Summary
Release & Configuration
CHANGELOG.md, Directory.Build.props
Version bumped to 2.5.2. Global build properties (TargetFramework, ImplicitUsings, Nullable, TreatWarningsAsErrors) and package metadata (Authors, Company, Copyright, PackageLicenseExpression) added to Directory.Build.props.
Solution & Project Cleanup
StrongTypedId.sln, src/StrongTypedId*/StrongTypedId*.csproj, src/StrongTypedId/StrongTypedId.csproj, tests/StrongTypedId.*/StrongTypedId.UnitTests.csproj
Removed redundant build properties and metadata from individual .csproj files (8–9 properties each) now centralized in Directory.Build.props. CHANGELOG.md added to solution items.
Source Code Refactoring
src/StrongTypedId/StrongTypedEnumValue.cs
String-based constructor refactored to delegate to new private Parse(string) helper method; centralized Enum.TryParse logic and exception handling.
Test Updates
tests/StrongTypedId.IntegrationTests/Fixtures/ContainerFixture.cs, tests/StrongTypedId.UnitTests/StrongTypedEnumValueTests.cs
MongoDbBuilder constructor updated to accept image parameter directly. New unit test added to verify numeric string maps to enum name in StrongTypedEnumValue.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A version hops forward with care,
Properties shared everywhere,
Parsing made clean with a helper so bright,
StrongTyped enums now get strings right! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main fix: preventing StrongTypedEnum from storing numeric string values internally, ensuring the enum name is used instead.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@steffenskov steffenskov merged commit ef5b806 into main Jan 29, 2026
3 checks passed
@steffenskov steffenskov deleted the enum-primitive-protection branch January 29, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant