FastEnum.Extensions.Generator 1.6.0

dotnet add package FastEnum.Extensions.Generator --version 1.6.0
                    
NuGet\Install-Package FastEnum.Extensions.Generator -Version 1.6.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="FastEnum.Extensions.Generator" Version="1.6.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FastEnum.Extensions.Generator" Version="1.6.0" />
                    
Directory.Packages.props
<PackageReference Include="FastEnum.Extensions.Generator">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 FastEnum.Extensions.Generator --version 1.6.0
                    
#r "nuget: FastEnum.Extensions.Generator, 1.6.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.
#addin nuget:?package=FastEnum.Extensions.Generator&version=1.6.0
                    
Install FastEnum.Extensions.Generator as a Cake Addin
#tool nuget:?package=FastEnum.Extensions.Generator&version=1.6.0
                    
Install FastEnum.Extensions.Generator as a Cake Tool

Build & Test

FastEnum.Extensions.Generator

Source Generator for enums to create extension methods with basic functionality.

Usage

Use the [Extensions] on your enums, so it will generate the extensions for those enums:

Feature

  • MembersCount (field)
  • GetValues
  • GetUnderlyingValues
  • GetNames
  • HasFlag
  • IsDefined
  • FastToString
  • FastToString with format option
  • GetDescription
  • TryParse (string/System.ReadOnlySpan<char>)
  • TryParseIgnoreCase (string/System.ReadOnlySpan<char>)

Note: I'm trying to make the generated code behave the same as the .NET implementation. If you find any differences, please let me know.

Limitations

  • Only currently supported .NET versions are supported. See: supported version list
  • .NET Framework is not supported
  • Generation extensions for enums nested in classes with generic type parameters are not supported.
  • Generation extensions for enums nested in multiple classes is not supported.

Example

using FastEnum;

namespace ToStringExample;

public class NestingClass
{
    [Extensions]
    public enum NestedInClassEnum
    {
        None
    }
}

[Extensions, Flags]
public enum Color
{
    [Description("Crimson Red")]
    Red = 0x990000,
    [Display(Name = "Pine", Description = "Pine")]
    Green = 0x166138,
    [EnumMember(Value = "Sky")]
    Blue = 0x87CEEB
}

[Extensions, Flags]
public enum GenerationOptions : byte
{
    None = 0,
    ToString = 1,
    Parse = 2,
    HasFlag = 4
}
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

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
1.6.0 133 3/30/2025
1.5.0 112 2/8/2025
1.4.0 121 1/1/2025
1.3.2 100 12/25/2024
1.3.1 96 12/24/2024
1.3.0 174 10/20/2024

- BREAKING: Attributes namespace modified from `FastEnum` to `FastEnum.Attributes`.
- New attribute to support generating extensions for external enums.
- Added support for generating extensions for external enums.
- Attributes marked with a `[Conditional("DEBUG")]` attribute; therfore, they will be removed from the release build but the extension generation will not be affected.