ardalis/SmartEnum
51.6
Adequate · 21 September 2026
5.2k
lines of production code
C#
primary language
4
measurements over time
What this system is
This system is a .NET library that provides a strongly-typed, object-oriented alternative to standard C\# enums, supporting both single and flag-based enumeration patterns. It offers deep integration with common .NET data access and serialization frameworks, including Entity Framework Core, Dapper, ASP.NET Core model binding, and multiple JSON/MessagePack/Protobuf serializers. The library also includes utilities for testing, guard clauses, and specific exception handling to ensure robust usage across different application layers.
How it got here
2017–2018 — Serialization and integration expansion
7 changes.
This period focused on expanding the SmartEnum library's ecosystem by adding integration packages for AutoFixture, GuardClauses, and various serialization formats including JSON, Protobuf, and MessagePack. The work also introduced specific exception types for better error handling and reorganized the repository structure to support multi-targeting and consistent code formatting.
2020 — System.Text.Json integration and test expansion
8 changes.
This period focused on adding System.Text.Json serialization support for SmartEnums and SmartFlagEnums, introducing new converters for name and value-based serialization. Concurrently, the test suite was expanded to cover these new features and to validate serialization across multiple libraries including JsonNet, Utf8Json, MessagePack, and ProtoBuf.
2021–2024 — ORM and framework integrations
8 changes.
This period focused on expanding SmartEnum's compatibility with major .NET data access and web frameworks, specifically adding support for Entity Framework Core, Dapper, and ASP.NET Core model binding. The work included implementing automatic type conversion, model binding, and type handlers, while simultaneously establishing comprehensive unit and integration test suites to verify these new integrations.
Features
Add ASP.NET Core model binding for SmartEnum types
The SmartEnum.ModelBinding package now includes a custom model binder and provider that automatically bind HTTP request data to SmartEnum types. This allows controllers to accept SmartEnum parameters directly, enabling seamless model binding for SmartEnum properties in ASP.NET Core applications.
src/SmartEnum.ModelBinding · high confidence
Add Dapper integration for SmartEnum
Introduces new classes in the \Ardalis.SmartEnum.Dapper\ namespace to integrate SmartEnum with the Dapper micro-ORM. This includes \DapperRegistration\ for automatic type handler registration, base classes \DapperSmartEnum\, \DapperSmartEnumByName\, and \DapperSmartEnumByValue\ that automatically register their respective type handlers (\SmartEnumByNameTypeHandler\, \SmartEnumByValueTypeHandler\) with Dapper's \SqlMapper\. The implementation also adds attributes (\DbTypeAttribute\, \DoNotSetDbTypeAttribute\, \IgnoreCaseAttribute\) to configure how SmartEnums are mapped to database columns, allowing users to map SmartEnums by name or value in database queries.
src/SmartEnum.Dapper · high confidence
Add JSON and Protobuf serialization support for SmartEnum and SmartFlagEnum
New converters and surrogates are introduced for the JsonNet and ProtoBufNet libraries, enabling seamless serialization and deserialization of SmartEnum and SmartFlagEnum types. For JsonNet, the new SmartEnumNameConverter, SmartEnumValueConverter, SmartFlagEnumNameConverter, and SmartFlagEnumValueConverter allow these enums to be serialized as their string names or underlying values. For ProtoBufNet, the new SmartEnumNameSurrogate, SmartEnumValueSurrogate, SmartFlagEnumNameSurrogate, and SmartFlagEnumValueSurrogate provide equivalent serialization capabilities for Protobuf.
src/SmartEnum.JsonNet · high confidence
Add MessagePack serialization support for SmartEnum and SmartFlagEnum
The SmartEnum.MessagePack library now includes formatters and resolvers for serializing SmartEnum and SmartFlagEnum types to and from MessagePack. This adds support for both name-based and value-based serialization strategies, allowing users to serialize these enums as either their string names or their underlying numeric values in MessagePack payloads.
src/SmartEnum.MessagePack · high confidence
Add System.Text.Json serialization support for SmartEnums
Users can now serialize and deserialize SmartEnums using the System.Text.Json library. This change introduces four new converters—SmartEnumNameConverter, SmartEnumValueConverter, SmartFlagEnumNameConverter, and SmartFlagEnumValueConverter—which enable JSON serialization of SmartEnums by name or value, and also support using SmartEnums as dictionary keys.
src/SmartEnum.SystemTextJson · high confidence
Add automatic SmartEnum conversion for Entity Framework Core
The SmartEnum.EFCore package now provides automatic value conversion for SmartEnum properties in Entity Framework Core. By calling the new \ConfigureSmartEnum\ extension on \ModelBuilder\ or \ModelConfigurationBuilder\, all properties of types derived from \SmartEnum\<TEnum, TValue\>\ are automatically mapped to their underlying value types, with support for owned types and respect for the \\[NotMapped\]\ attribute.
src/SmartEnum.EFCore · high confidence
Added specific exception types for SmartEnum validation errors
The library now introduces five new, specific exception classes to handle distinct error conditions during SmartEnum and SmartFlagEnum usage. These include \InvalidFlagEnumValueParseException\, \NegativeValueArgumentException\, \SmartEnumNotFoundException\, \SmartFlagEnumContainsNegativeValueException\, and \SmartFlagEnumDoesNotContainPowerOfTwoValuesException\. This allows users to catch and handle these specific scenarios more precisely than with generic exceptions.
src/SmartEnum/Exceptions · high confidence
New integration packages for AutoFixture, GuardClauses, and Utf8Json serialization
The SmartEnum library now includes three new integration packages. The AutoFixture package provides a \SmartEnumCustomization\ and \SmartEnumSpecimenBuilder\ to automatically generate SmartEnum instances during testing. The GuardClauses package adds a \SmartEnumOutOfRange\ guard clause that validates input values against a SmartEnum, throwing a \SmartEnumNotFoundException\ if invalid. The Utf8Json package introduces formatters and resolvers (\SmartEnumNameFormatter\, \SmartEnumValueFormatter\, etc.) that enable JSON serialization of SmartEnums by either their name or their underlying value, supporting both standard and flag-style enums.
src/SmartEnum · high confidence
Behavioural changes
Repository structure and build configuration updates
The repository has been reorganized with a new solution file (SmartEnum.sln) that groups projects into src, test, and benchmarks folders, and a Directory.Build.props file that sets the package version to 8.2.0 and targets .NET 6.0, 7.0, 8.0, and .NET Standard 2.0. A .editorconfig file was added to enforce consistent code formatting (UTF-8, 4-space indentation, trailing whitespace trimming). The CONTRIBUTING.md file was added to guide external contributors, and the .gitignore was updated to exclude VS Code, macOS, and coverage files. The Azure Pipelines configuration was archived.
(repo-wide) · high confidence
Updated benchmark reports for equality, name lookup, and serialization tests
The benchmark reports in the benchmarks directory have been regenerated, reflecting updated performance metrics for the EqualsBenchmarks, FromNameBenchmarks, and SerializationBenchmarks. The new reports include detailed timing and memory allocation data for various library implementations (Enum, Constant, Ardalis, SmartEnum) across different serialization libraries (JsonNet, Utf8Json, MessagePack, ProtoBufNet).
benchmarks · high confidence
Test coverage
Add integration tests for SmartEnum with Entity Framework Core; Add unit tests for SmartFlagEnum; Added integration tests for SmartEnum with Dapper; Added test project configuration files; Added unit tests for Dapper integration; Added unit tests for MessagePack serialization of SmartEnum and SmartFlagEnum types; Added unit tests for SmartEnum JSON serialization; Added unit tests for SmartEnum comparison, equality, conversion, and conditional execution; Added unit tests for SmartEnum guard clauses; Added unit tests for SmartEnum serialization and flag enum support; Added unit tests for System.Text.Json serialization of SmartEnums and SmartFlagEnums; Updated test project to target .NET 7 and .NET 8.
Dependencies
Centralize package version management with Directory.Packages.props
The project now uses a central Directory.Packages.props file to manage all package versions, including major updates to Microsoft.EntityFrameworkCore (7.0.13), xunit (2.9.2), and SonarAnalyzer.CSharp (9.32.0.97167). This change ensures consistent dependency versions across all projects and test suites.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 48 → 52 (+3.8)
- Rubric changed (rubric-2026.08.18 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 71 → 58 (-12.4)
- Architecture 100 → 100 (+0.0)
- Maturity 50 → 51 (+1.0)
- Readiness 41 → 42 (+1.1)
- Security 41 → 66 (+24.9)
- Performance 82 → 82 (+0.0)
Resolved (61)
- Bounded contexts not declared
- Duplicated block (11 lines × 2) (src/SmartEnum.JsonNet/SmartEnumValueConverter.cs)
- Duplicated block (12 lines × 2) (src/SmartEnum.MessagePack/SmartEnumValueFormatter.cs)
- Duplicated block (6 lines × 2) (src/SmartEnum.MessagePack/SmartEnumValueFormatter.cs)
- Duplicated block (6 lines × 2) (src/SmartEnum.SystemTextJson/SmartEnumValueConverter.cs)
- Duplicated block (6 lines × 2) (src/SmartEnum.Utf8Json/SmartEnumValueFormatter.cs)
- Duplicated block (7 lines × 2) (src/SmartEnum.SystemTextJson/SmartEnumValueConverter.cs)
- Duplicated block (7 lines × 2) (src/SmartEnum.Utf8Json/SmartEnumValueFormatter.cs)
- High CVE: MessagePack 2.5.192
- High CVE: MessagePack 2.5.192
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- …and 41 more
New (82)
- Documentation: no architecture or design documentation (README.md)
- Duplicated block (10 lines × 2) (src/SmartEnum.SystemTextJson/SmartEnumValueConverter.cs)
- Duplicated block (10 lines × 2) (src/SmartEnum.SystemTextJson/SmartEnumValueConverter.cs)
- Duplicated block (14 lines × 2) (src/SmartEnum.JsonNet/SmartEnumValueConverter.cs)
- Duplicated block (18 lines × 2) (src/SmartEnum.EFCore/TypeUtil.cs)
- Duplicated block (22 lines × 2) (src/SmartEnum.Utf8Json/SmartEnumValueFormatter.cs)
- Duplicated block (23 lines × 2) (src/SmartEnum.Utf8Json/SmartEnumValueFormatter.cs)
- Duplicated block (25 lines × 2) (src/SmartEnum.MessagePack/SmartEnumValueFormatter.cs)
- Duplicated block (25 lines × 2) (src/SmartEnum.SystemTextJson/SmartEnumValueConverter.cs)
- Duplicated block (50 lines × 2) (src/SmartEnum.MessagePack/SmartEnumValueFormatter.cs)
- High CVE: MessagePack 2.5.192
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- …and 62 more
Architecture
- Unchanged — 1 containers · 0 contexts · 0 edges
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
ardalis/SmartEnum was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 21 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 9bc3f7a430552649e598cce7d2d2f481fb54a1b9 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-28e75b8e3254.