Supernova.Enum.Generators 1.0.12

.NET Standard 2.0
dotnet add package Supernova.Enum.Generators --version 1.0.12
NuGet\Install-Package Supernova.Enum.Generators -Version 1.0.12
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="Supernova.Enum.Generators" Version="1.0.12" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Supernova.Enum.Generators --version 1.0.12
#r "nuget: Supernova.Enum.Generators, 1.0.12"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Supernova.Enum.Generators as a Cake Addin
#addin nuget:?package=Supernova.Enum.Generators&version=1.0.12

// Install Supernova.Enum.Generators as a Cake Tool
#tool nuget:?package=Supernova.Enum.Generators&version=1.0.12

GitHub license Nuget Nuget


The best Source Generator for working with enums in C#

A C# source generator to create an enumeration class from an enum type. With this package, you can work on enums very, very fast without using reflection.

Package - Supernova.Enum.Generators

Add the package to your application using

dotnet add package Supernova.Enum.Generators

Adding the package will automatically add a marker attribute, [EnumGenerator], to your project.

To use the generator, add the [EnumGenerator] attribute to an enum. For example:

public enum UserTypeTest
    [Display(Name = "مرد")]

    [Display(Name = "زن")]

    //[Display(Name = "نامشخص")]

This will generate a class called EnumNameEnumExtensions (UserTypeTest + EnumExtensions), which contains a number of helper methods. For example:

    public static class UserTypeTestEnumExtensions
        public static string ToStringFast(this UnitTests.UserTypeTest states)
            return states switch
                UnitTests.UserTypeTest.Men => nameof(UnitTests.UserTypeTest.Men),
                UnitTests.UserTypeTest.Women => nameof(UnitTests.UserTypeTest.Women),
                UnitTests.UserTypeTest.None => nameof(UnitTests.UserTypeTest.None),
                _ => throw new ArgumentOutOfRangeException(nameof(states), states, null)
        public static bool IsDefinedFast(UnitTests.UserTypeTest states)
            return states switch
                UnitTests.UserTypeTest.Men => true,
                UnitTests.UserTypeTest.Women => true,
                UnitTests.UserTypeTest.None => true,
                _ => throw new ArgumentOutOfRangeException(nameof(states), states, null)
        public static bool IsDefinedFast(string states)
            return states switch
                nameof(UnitTests.UserTypeTest.Men) => true,
                nameof(UnitTests.UserTypeTest.Women) => true,
                nameof(UnitTests.UserTypeTest.None) => true,
                _ => throw new ArgumentOutOfRangeException(nameof(states), states, null)
        public static string ToDisplayFast(this UnitTests.UserTypeTest states)
            return states switch
                UnitTests.UserTypeTest.Men => "مرد",
                UnitTests.UserTypeTest.Women => "زن",
                UnitTests.UserTypeTest.None => "None",
                _ => throw new ArgumentOutOfRangeException(nameof(states), states, null)
        public static UnitTests.UserTypeTest[] GetValuesFast()
            return new[]
        public static string[] GetNamesFast()
            return new[]
        public static int GetLengthFast()
            return 3;


You do not see this file inside the project. But you can use it.


var stringEnum = UserTypeTest.Men.ToStringFast(); //Men;

var isDefined = UserTypeTestEnumExtensions.IsDefinedFast(UserType.Men); //true;

var displayEnum = UserTypeTest.Men.ToDisplayFast(); //مرد

var names = UserTypeTestEnumExtensions.GetNamesFast(); //string[]

var values = UserTypeTestEnumExtensions.GetValuesFast(); //UserType[]

var length = UserTypeTestEnumExtensions.GetLengthFast(); //3

If you had trouble using UserTypeTestEnumExtensions and the IDE did not recognize it. This is an IDE problem and you need to restart the IDE once.




Create an issue if you find a BUG or have a Suggestion or Question. If you want to develop this project :

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Give a Star! ⭐️

If you find this repository useful, please give it a star. Thanks!


Supernova.Enum.Generators is Copyright © 2022 Mohsen Rajabi under the MIT License.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
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.0.12 715 5/31/2022
1.0.11 175 5/28/2022
1.0.10 168 5/27/2022
1.0.9 151 5/26/2022
1.0.8 151 5/26/2022
1.0.7 152 5/26/2022
1.0.5 154 5/26/2022
1.0.4 156 5/26/2022
1.0.0 157 5/26/2022

         Breaking changes
         - rename StringToFast to ToStringFast