NocturnalGroup.ValuableEnums 1.0.0-preview.1

This is a prerelease version of NocturnalGroup.ValuableEnums.
dotnet add package NocturnalGroup.ValuableEnums --version 1.0.0-preview.1                
NuGet\Install-Package NocturnalGroup.ValuableEnums -Version 1.0.0-preview.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="NocturnalGroup.ValuableEnums" Version="1.0.0-preview.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NocturnalGroup.ValuableEnums --version 1.0.0-preview.1                
#r "nuget: NocturnalGroup.ValuableEnums, 1.0.0-preview.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.
// Install NocturnalGroup.ValuableEnums as a Cake Addin
#addin nuget:?package=NocturnalGroup.ValuableEnums&version=1.0.0-preview.1&prerelease

// Install NocturnalGroup.ValuableEnums as a Cake Tool
#tool nuget:?package=NocturnalGroup.ValuableEnums&version=1.0.0-preview.1&prerelease                

<img align="right" width="256" height="256" src="Assets/Logo.png">

<div id="user-content-toc"> <ul align="center" style="list-style: none;"> <summary> <h1>ValuableEnums</h1> </summary> </ul> </div>

Making enums more valuable


ValuableEnums is a source generator that emulates fields on enums. This lets you add compile time values to an enum member, similar to Java's enums.

Installing

You can install the package from NuGet:

dotnet add package NocturnalGroup.ValuableEnums

Usage

A complete, but short, walkthrough of ValuableEnums can be found here.

Quickstart

// 👇 Here you can set a default value for the field.
[EnumField<string>("description", "No description provided.")]
public enum Command
{
  // 👇 Members that don't provide an override will use the default value.
	CreateEntry = 1,

  // 👇 Members that provide an override will use it instead of the default.
  [EnumField<string>("description", "Creates a new entry.")]
	ListEntries = 2,

  // 👇 If you don't set a default value, the default value will be `null`.
  [EnumField<string>("usage", "delete {id}")]
  DeleteEntry = 3,
}

// 👇 Use the generated getters to retrieve the field values
Console.WriteLine(Command.CreateEntry.GetDescription()); // "No description provided."
Console.WriteLine(Command.ListEntries.GetDescription()); // "Creates a new entry."
Console.WriteLine(Command.DeleteEntry.GetDescription()); // "No description provided."

Console.WriteLine(Command.CreateEntry.GetUsage()); // null
Console.WriteLine(Command.ListEntries.GetUsage()); // null
Console.WriteLine(Command.DeleteEntry.GetUsage()); // "delete {id}"

Versioning

ValuableEnums follows the SemVer versioning scheme.

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.0.0-preview.1 40 2/3/2025