EnumExtensions.Generator 0.3.1

dotnet add package EnumExtensions.Generator --version 0.3.1
                    
NuGet\Install-Package EnumExtensions.Generator -Version 0.3.1
                    
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="EnumExtensions.Generator" Version="0.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EnumExtensions.Generator" Version="0.3.1" />
                    
Directory.Packages.props
<PackageReference Include="EnumExtensions.Generator" />
                    
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 EnumExtensions.Generator --version 0.3.1
                    
#r "nuget: EnumExtensions.Generator, 0.3.1"
                    
#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 EnumExtensions.Generator@0.3.1
                    
#: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=EnumExtensions.Generator&version=0.3.1
                    
Install as a Cake Addin
#tool nuget:?package=EnumExtensions.Generator&version=0.3.1
                    
Install as a Cake Tool

EnumExtensions

Source generator that generates useful extension and utility methods for enums

Usage

  • Annotate your enum with [GenerateExtensions] Attribute

    You can optionally provide a ClassName for the generated class like so: [GenerateExtensions(ClassName = "NameOfGeneratedClass")]. By default, the name of the enum followed by the "Extensions" suffix is used as the class name. Similarly, You can also provide an optional Namespace for the generated class. Default namespace is the same as the enum.

  • Done!
using EnumExtensions;

[GenerateExtensions]
enum Direction
{
    Up,
    Down,
    Left,
    Right
}

Installation

NuGet

TODO

Unity

TODO

Generated Methods

  • Is*()
  • GetValues()
  • GetNames()
  • GetValuesEnumerable()
  • GetNamesEnumerable()
  • ToStringFast()
  • Next()
  • Previous()
  • GetRandomValue()
  • GetRandomValueExcluding()
  • TryParse()
  • Parse()
  • ParseOrDefault()
  • ParseOrThrow()
  • ParseOrElse()
  • TryParseIgnoreCase()
  • ParseIgnoreCase()
  • ParseOrDefaultIgnoreCase()
  • ParseOrThrowIgnoreCase()
  • ParseOrElseIgnoreCase()
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
0.3.1 150 5/19/2025