Smart Enums Performance - PawelGerr/Thinktecture.Runtime.Extensions GitHub Wiki
When running on .NET 8 or higher, Smart Enums automatically use FrozenDictionary for internal lookups, providing better performance compared to regular dictionaries.
String-based Smart Enums in .NET 9+ support ReadOnlySpan<char> operations for improved performance:
[SmartEnum<string>]
public partial class ProductType
{
public static readonly ProductType Electronics = new("Electronics");
// In .NET 9+, you can use ReadOnlySpan<char> for lookups - no string allocation needed
public static bool TryGet(ReadOnlySpan<char> key, out ProductType? item)
{
...
}
}ReadOnlySpan<char> support also enables zero-allocation JSON deserialization with System.Text.Json on .NET 9+. See Zero-Allocation JSON Deserialization for details on how this works and configuration options.