FinalEnumGenerator 2.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FinalEnumGenerator --version 2.5.0
                    
NuGet\Install-Package FinalEnumGenerator -Version 2.5.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FinalEnumGenerator" Version="2.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FinalEnumGenerator" Version="2.5.0" />
                    
Directory.Packages.props
<PackageReference Include="FinalEnumGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FinalEnumGenerator --version 2.5.0
                    
#r "nuget: FinalEnumGenerator, 2.5.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FinalEnumGenerator@2.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FinalEnumGenerator&version=2.5.0
                    
Install as a Cake Addin
#tool nuget:?package=FinalEnumGenerator&version=2.5.0
                    
Install as a Cake Tool

<div align="center">

FinalEnumGenerator

Generates High-Performance string and UTF-8 Extensions for Enums

nuget DeepWiki

</div>

 

  • Generates high-performance ToStringFast(), ToStringUtf8(), and TryParse() methods.
  • Adds helpers GetNames(), GetValues(), GetNamesUtf8(), and IsDefined(long/ulong) on the enum type.
  • Supports display names from InspectorNameAttribute (Unity compatibility) or CategoryAttribute.
  • Emits diagnostics for non-public containing types and ambiguous/invalid display names.

 

🚀 Getting Started

The sample code talks enough.

using FinalEnumGenerator;

[FinalEnum]
[Flags]
public enum MyEnum
{
    None = 0,

    // Customize name by Category attribute from System.ComponentModel
    // to avoid unnecessary dependency to FinalEnum
    [Category("日本語")]
    Flag1 = 1,
    Flag2 = 2,

    // Non-alphanumerics are supported ofcourse!
    [Category("ひらがな \"français\" カタカナ")]
    Flag3 = 4,
    Flag4 = 8,

    // ERROR: Display name cannot have ',' to avoid ambiguity of Flags enums
    [InspectorName("子,丑,寅,卯,辰,巳,午,未,申,酉,戌,亥")]  // InspectorName can be used (Unity)
    InspectorNameAttribute_from_Unity = 16,
}

Here shows how to use the generated extensions.

using FinalEnums;
using FinalEnums.EnumNamespace;  // Methods are generated in FinalEnums namespace

if (MyEnum.TryParse("日本語", out var value))
{
    var text = value.ToStringFast();
    var utf8 = value.ToStringUtf8();
}

// GetNames/Values always allocates array
var allNames = MyEnum.GetNames();
var allValues = MyEnum.GetValues();

// Utf8 byte arrays are cached internally but array of ReadOnlyMemory allocates
var allUtf8Arrays = MyEnum.GetNamesUtf8();

// Check by underlying primitive
if (MyEnum.IsDefined(100))
{
    // accepts `long` or `ulong` depending on the Enum shape
}

 

🕹️ Technical Specs

  • TryParse checks string/byte length first and uses delimiter-aware token matching (including [Flags]).
  • [Flags] fast-path uses a switch for single flags and falls back to a builder for combined values; combined string/UTF-8 outputs allocate only in that fallback path.
  • TryParse supports both string and ReadOnlySpan<byte>.
    • string path accepts a StringComparison and always trims input.
    • UTF-8 path can optionally ignore whitespace separators.
  • The generated members live in FinalEnums.<Namespace>.<ContainingTypes>.<EnumName> and reuse shared helpers in FinalEnums.FinalEnumUtility (throw helper, boundary-aware ContainsToken).
  • [Flags] parsing:
    • Delimiter-aware token matching succeeds when at least one known token is present; unknown tokens are ignored rather than rejected.
    • Commas are rejected for [Flags] display names to keep parsing unambiguous.
  • Display name diagnostics include empty/whitespace-only, leading/trailing whitespace, commas, and overlapping tokens; matching is case-insensitive after trimming.

TryParse always allows fuzzy match (can contain undefined name). ToStringFast/Utf8 does not allow converting undefined value.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.1 353 3/3/2026
3.0.0 240 3/2/2026
3.0.0-rc.1 173 3/1/2026
2.5.1 732 2/16/2026
2.5.0 171 2/11/2026
2.4.1 239 2/10/2026
2.4.0 153 2/9/2026
2.3.1 235 2/3/2026
2.3.0 100 2/3/2026
2.2.3 278 2/1/2026
2.2.2 102 2/1/2026