Skip to content
CAI
Software that uses CAICheck a score

ardalis/SmartEnum

51.2

Adequate · 8 November 2026

5.2k

lines of production code

C#

primary language

7

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Features

Add ASP.NET Core model binding support for SmartEnum types

The SmartEnum.ModelBinding package now provides automatic model binding for SmartEnum instances in ASP.NET Core applications. By registering the new SmartEnumBinderProvider, controllers can accept SmartEnum parameters directly; the framework will automatically resolve the incoming string value to the corresponding SmartEnum instance using the FromName method, eliminating the need for manual conversion logic in action methods.

src/SmartEnum.ModelBinding · high confidence

Add Dapper integration for SmartEnum types

This change introduces a new \Ardalis.SmartEnum.Dapper\ library that enables seamless mapping of SmartEnum types to database columns when using the Dapper micro-ORM. It provides base classes (\DapperSmartEnum\, \DapperSmartEnumByName\, \DapperSmartEnumByValue\) that automatically register Dapper type handlers upon first use, eliminating the need for manual configuration. The integration supports mapping by enum name or value, allows case-insensitive name parsing via the \IgnoreCaseAttribute\, and lets users control parameter \DbType\ assignment using \DbTypeAttribute\ and \DoNotSetDbTypeAttribute\.

src/SmartEnum.Dapper · high confidence

Add EF Core support for SmartEnum properties

The \src/SmartEnum.EFCore\ library now includes a \SmartEnumConverter\ and extension methods (\ConfigureSmartEnum\) that allow Entity Framework Core to automatically map properties of type \SmartEnum\. This enables seamless persistence of SmartEnum values in database models, with support for owned types and respect for the \NotMappedAttribute\.

src/SmartEnum.EFCore · high confidence

Add System.Text.Json converters for SmartEnums and SmartFlagEnums

This change introduces four new JSON converters for the System.Text.Json library, enabling native serialization and deserialization of SmartEnum and SmartFlagEnum types. The new SmartEnumNameConverter and SmartEnumValueConverter handle standard SmartEnums by serializing them as either their name (string) or their underlying value (numeric/boolean), while SmartFlagEnumNameConverter and SmartFlagEnumValueConverter provide equivalent support for flag-based enums. These converters also support using SmartEnums as dictionary keys by implementing ReadAsPropertyName and WriteAsPropertyName, allowing them to be used directly in JSON objects without custom handling.

src/SmartEnum.SystemTextJson · high confidence

SmartEnum gains flag enum support, guard clauses, and switch-style methods

SmartEnum now supports flag-style enums via the new SmartFlagEnum base class, which handles bitwise combinations and validates that values are powers of two. A new Ardalis.SmartEnum.GuardClauses package provides a SmartEnumOutOfRange guard clause to validate inputs against valid enum values. Switch-style control flow is enabled through SmartEnumWhen and SmartEnumThen methods, allowing fluent when/then/default logic. Serialization support for flag enums is added for Utf8Json, and validation is improved with SmartEnumNameAttribute (supporting case-insensitive matching) and SmartEnumComparerAttribute for custom string comparisons.

src/SmartEnum · high confidence

SmartEnum v8.2.0: Multi-targeting, SmartFlagEnum, and new integrations

The library has been updated to version 8.2.0, expanding target frameworks to include .NET 6, .NET 7, .NET 8, and .NET Standard 2.0. A new SmartFlagEnum type is introduced, providing flag-based enumeration functionality with power-of-two value enforcement. The ecosystem of integration packages has grown to include dedicated support for System.Text.Json, Entity Framework Core, ASP.NET Core Model Binding, and Dapper, alongside existing AutoFixture, JsonNet, MessagePack, ProtoBufNet, and Utf8Json support. The public API also gains a fluent switch-style interface for cleaner conditional logic, and the project structure has been reorganized with a centralized Directory.Build.props for consistent build configuration.

(repo-wide) · high confidence

Support for MessagePack serialization of SmartFlagEnum and migration to modern MessagePack API

The SmartEnum.MessagePack library now supports serializing and deserializing SmartFlagEnum types in addition to standard SmartEnum, introducing new formatters (SmartFlagEnumNameFormatter, SmartFlagEnumValueFormatter) and resolvers (SmartFlagEnumNameResolver, SmartFlagEnumValueResolver) that handle flag-based enums by name or underlying value. Existing SmartEnum formatters and resolvers have been updated to use the modern MessagePack API (MessagePackWriter/Reader) instead of the legacy byte-array-based methods, ensuring compatibility with newer MessagePack versions and improving serialization performance.

src/SmartEnum.MessagePack · high confidence

Support for serializing SmartFlagEnum types in Json.NET and ProtoBuf

This change introduces new serialization support for SmartFlagEnum types. In the Json.NET integration, new \SmartFlagEnumNameConverter\ and \SmartFlagEnumValueConverter\ classes are added to handle converting flag enums to and from JSON strings and values. Similarly, the ProtoBuf integration adds \SmartFlagEnumNameSurrogate\ and \SmartFlagEnumValueSurrogate\ classes to enable serialization of flag enums via name or value surrogates. Additionally, the existing \SmartEnumNameConverter\ and \SmartEnumValueConverter\ in Json.NET, along with their ProtoBuf surrogates, have been updated to remove the \struct\ constraint on the \TValue\ type parameter, allowing them to work with non-struct value types.

src/SmartEnum.JsonNet · high confidence

Behavioural changes

Benchmarks restructured and updated for .NET Standard 2.0 compatibility

The benchmarking project has been moved from src/SmartEnum.Benchmarks to benchmarks/SmartEnum.Benchmarks. To support .NET Standard 2.0, the FromNameBenchmarks now use a conditional compilation approach for Enum.Parse, and the MessagePack serialization benchmarks have been updated to use the new resolver API. Additionally, the BenchmarkDotNet configuration has been refactored to use the new AddJob/AddDiagnoser/AddColumn methods, and various code style fixes and suppressions have been applied across the benchmark files.

benchmarks · high confidence

New exceptions for SmartFlagEnum validation and cleanup of SmartEnumNotFoundException

This release introduces four new exception types to improve error handling for SmartFlagEnum scenarios: InvalidFlagEnumValueParseException is thrown when a flag enum value cannot be parsed, NegativeValueArgumentException for negative argument values, SmartFlagEnumContainsNegativeValueException when a flag enum definition includes negative values, and SmartFlagEnumDoesNotContainPowerOfTwoValuesException when the enum lacks consecutive power-of-two values. Additionally, the existing SmartEnumNotFoundException has been updated to remove the obsolete ISerializable constructor and suppress a code smell warning, aligning it with modern serialization practices.

src/SmartEnum/Exceptions · high confidence

Test coverage

2 commits adding/updating tests in src; Added integration tests for Dapper SmartEnum type handlers; Added integration tests for SmartEnum EF Core mapping; Added tests for SmartFlagEnum serialization and moved existing tests to test directory; Added tests for SmartFlagEnum serialization in MessagePack; Added unit tests for Dapper SmartEnum type handlers; Added unit tests for SmartEnum and SmartFlagEnum JSON serialization; Added unit tests for SmartEnum guard clauses; Added unit tests for SmartFlagEnum core behaviors; Added unit tests for System.Text.Json SmartEnum converters; Expanded test coverage for SmartEnum validation, string handling, and derived types; Updated test project target frameworks to .NET 6, 7, and 8.

Dependencies

Centralized dependency management and major version upgrades

The project has adopted Central Package Versions (Directory.Packages.props) to manage dependencies, removing explicit version numbers from individual .csproj files. This change includes significant upgrades to key libraries: System.Text.Json and System.Text.Encodings.Web are updated to version 9.0.0, BenchmarkDotNet to 0.14.0, xunit to 2.9.2, and SonarAnalyzer.CSharp to 9.32.0. Additionally, the project structure has been reorganized with test projects moved to a dedicated test/ directory and benchmarks moved to benchmarks/, while several source projects (AutoFixture, JsonNet, MessagePack, ProtoBufNet, Utf8Json) have been cleaned up to remove obsolete metadata and rely on the central versioning.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 50 → 51 (+0.9)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.

Lenses

  • Code Health 69 → 69 (+0.0)
  • Architecture 100 → 74 (-25.9)
  • Maturity 44 → 47 (+3.3)
  • Readiness 42 → 45 (+3.1)
  • Security 59 → 53 (-6.6)
  • Performance 82 → 97 (+15.2)

Resolved (23)

  • Dormant codebase
  • Low XML-doc coverage: SmartEnum.Benchmarks(net6.0) (benchmarks/SmartEnum.Benchmarks/SmartEnum.Benchmarks.csproj)
  • Low XML-doc coverage: SmartEnum.ModelBinding(net6.0) (src/SmartEnum.ModelBinding/SmartEnum.ModelBinding.csproj)
  • Low coverage: src/SmartEnum/Exceptions/InvalidFlagEnumValueParseException.cs (src/SmartEnum/Exceptions/InvalidFlagEnumValueParseException.cs)
  • Low coverage: src/SmartEnum/Exceptions/NegativeValueArgumentException.cs (src/SmartEnum/Exceptions/NegativeValueArgumentException.cs)
  • Low coverage: src/SmartEnum/Exceptions/SmartEnumNotFoundException.cs (src/SmartEnum/Exceptions/SmartEnumNotFoundException.cs)
  • Low coverage: src/SmartEnum/Exceptions/SmartFlagEnumContainsNegativeValueException.cs (src/SmartEnum/Exceptions/SmartFlagEnumContainsNegativeValueException.cs)
  • Low coverage: src/SmartEnum/Exceptions/SmartFlagEnumDoesNotContainPowerOfTwoValuesException.cs (src/SmartEnum/Exceptions/SmartFlagEnumDoesNotContainPowerOfTwoValuesException.cs)
  • Most significant orphaned file (src/SmartEnum/SmartEnum.cs)
  • Most significant orphaned file (src/SmartEnum/SmartFlagEnum.cs)
  • Orphaned file (src/SmartEnum.MessagePack/SmartEnumValueFormatter.cs)
  • Orphaned file (src/SmartEnum.MessagePack/SmartFlagEnumValueFormatter.cs)
  • Vulnerable: MessagePack
  • XML-doc coverage: SmartEnum(net6.0) (src/SmartEnum/SmartEnum.csproj)
  • XML-doc coverage: SmartEnum.AutoFixture(net6.0) (src/SmartEnum.AutoFixture/SmartEnum.AutoFixture.csproj)
  • XML-doc coverage: SmartEnum.Dapper(net6.0) (src/SmartEnum.Dapper/SmartEnum.Dapper.csproj)
  • XML-doc coverage: SmartEnum.EFCore(net6) (src/SmartEnum.EFCore/SmartEnum.EFCore.csproj)
  • XML-doc coverage: SmartEnum.GuardClauses(net6.0) (src/SmartEnum.GuardClauses/SmartEnum.GuardClauses.csproj)
  • XML-doc coverage: SmartEnum.JsonNet(net6.0) (src/SmartEnum.JsonNet/SmartEnum.JsonNet.csproj)
  • XML-doc coverage: SmartEnum.MessagePack(net6.0) (src/SmartEnum.MessagePack/SmartEnum.MessagePack.csproj)
  • …and 3 more

New (3)

  • Further orphaned files (smaller)
  • Orphaned knowledge (src/SmartEnum/SmartEnum.cs)
  • Orphaned knowledge (src/SmartEnum/SmartFlagEnum.cs)

Changes since last survey

  • 1 commits — 1 feature/other, 0 fixes

By area

  • (root) — 1 commit

Notable commits

  • change: docs: add announcement for commercial license transition

Architecture

  • Unchanged — 1 containers · 0 contexts · 0 edges

Written by cca.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 8 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit e06da550950b347f0ee47b1ec370a7416e79b030 — the exact code this score is about.
  • Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.3+preprod-45ab2cab63de.