EpicEnums 1.2023.7.291832

There is a newer version of this package available.
See the version list below for details.
dotnet add package EpicEnums --version 1.2023.7.291832                
NuGet\Install-Package EpicEnums -Version 1.2023.7.291832                
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="EpicEnums" Version="1.2023.7.291832" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EpicEnums --version 1.2023.7.291832                
#r "nuget: EpicEnums, 1.2023.7.291832"                
#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.
// Install EpicEnums as a Cake Addin
#addin nuget:?package=EpicEnums&version=1.2023.7.291832

// Install EpicEnums as a Cake Tool
#tool nuget:?package=EpicEnums&version=1.2023.7.291832                

Epic Enums

Think the standard C# enums are boring? Yeah, same! Lets improve that.

What does it solve/improve on?

Common c# enums are a powerfull tool for constant data. They are fast and simple. However they sometimes lack the flexibility that you want in a complex application.

Here is a standard C# enum like we all know:

public enum FruitsEnum
{
    Apple,
    Banana,
    Orange,
    DragonFruit
} 

All pretty standard nothing special, however if we want to tie some extra properties to our fruit then things get a little tricky. We could of course add an attribute and make it work:

public enum FruitsEnum
{
    [Display(Name = "Apple")]
    Apple,
    [Display(Name = "Banana")]
    Banana,
    [Display(Name = "Orange")]
    Orange,
    [Display(Name = "Dragon Fruit")]
    DragonFruit
} 

First of all, this is not very readable and can get messy quickly. Most importantly: To access these values you have to write code using reflection to access these properties: (as per stackoverflow)

public static class Extensions
{
    /// <summary>
    ///     A generic extension method that aids in reflecting 
    ///     and retrieving any attribute that is applied to an `Enum`.
    /// </summary>
    public static TAttribute GetAttribute<TAttribute>(this Enum enumValue) 
            where TAttribute : Attribute
    {
        return enumValue.GetType()
                        .GetMember(enumValue.ToString())
                        .First()
                        .GetCustomAttribute<TAttribute>();
    }
}

public class Foo 
{
    public FruitsEnum Fruit = FruitsEnum.Apple;

    public void DisplayName()
    {
        var fruitDisplayName = Fruit.GetAttribute<DisplayAttribute>();
        Console.WriteLine("Which friot is it?");
        Console.WriteLine (fruitDisplayName.Name);
    } 
}

Reflection can be slow and give issues in AOT compiling. Plus it can be kind of tedious.

A Better enum

(The name epic enums was chosen because it alliterats ever so lovely)

Installing the package

The epic enums package can be found on nuget.

dotnet add package EpicEnums

Creating an Epic Enum

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in 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
1.2023.10.231942 319 10/23/2023
1.2023.10.231827 142 10/23/2023
1.2023.10.182059 128 10/18/2023
1.2023.8.31931 164 8/3/2023
1.2023.7.310908 163 7/31/2023
1.2023.7.301221 210 7/30/2023
1.2023.7.301215 163 7/30/2023
1.2023.7.301213 157 7/30/2023
1.2023.7.301040 153 7/30/2023
1.2023.7.291844 171 7/29/2023
1.2023.7.291842 158 7/29/2023
1.2023.7.291832 143 7/29/2023
1.2023.7.291628 163 7/29/2023
1.2023.7.291624 159 7/29/2023
1.2023.7.291615 171 7/29/2023
1.2023.7.291611 183 7/29/2023
1.2023.7.291608 185 7/29/2023
1.2023.7.291606 170 7/29/2023
1.2023.7.291553 149 7/29/2023
1.2023.7.291551 256 7/29/2023
1.0.0 165 7/29/2023