FractalDataWorks.EnhancedEnums 0.1.2-alpha-g50778d9a34

This is a prerelease version of FractalDataWorks.EnhancedEnums.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package FractalDataWorks.EnhancedEnums --version 0.1.2-alpha-g50778d9a34
                    
NuGet\Install-Package FractalDataWorks.EnhancedEnums -Version 0.1.2-alpha-g50778d9a34
                    
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="FractalDataWorks.EnhancedEnums" Version="0.1.2-alpha-g50778d9a34">
  <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="FractalDataWorks.EnhancedEnums" Version="0.1.2-alpha-g50778d9a34" />
                    
Directory.Packages.props
<PackageReference Include="FractalDataWorks.EnhancedEnums">
  <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 FractalDataWorks.EnhancedEnums --version 0.1.2-alpha-g50778d9a34
                    
#r "nuget: FractalDataWorks.EnhancedEnums, 0.1.2-alpha-g50778d9a34"
                    
#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 FractalDataWorks.EnhancedEnums@0.1.2-alpha-g50778d9a34
                    
#: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=FractalDataWorks.EnhancedEnums&version=0.1.2-alpha-g50778d9a34&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=FractalDataWorks.EnhancedEnums&version=0.1.2-alpha-g50778d9a34&prerelease
                    
Install as a Cake Tool

FractalDataWorks Enhanced Enums

Part of the FractalDataWorks toolkit.

Build Status

Master Build Develop Build

Release Status

GitHub release (latest by date) GitHub release (latest by date including pre-releases)

Package Status

Nuget GitHub Packages

License

License

Advanced enumeration system with source generation for .NET applications.

Overview

FractalDataWorks Enhanced Enums provides a powerful alternative to standard C# enums, offering:

  • Type-safe enumeration patterns with compile-time validation
  • Source generation for boilerplate code reduction
  • Cross-assembly support for shared enum definitions
  • Lookup capabilities for efficient value retrieval
  • Rich metadata support through attributes

Installation

# Core interfaces (required dependency)
dotnet add package FractalDataWorks

# Source generators and analyzers
dotnet add package FractalDataWorks.EnhancedEnumOptions

Quick Start

Define an Enhanced Enum

using FractalDataWorks;
using FractalDataWorks.EnhancedEnumOptions.Attributes;

[EnhancedEnumOption]
public partial class OrderStatus : IEnhancedEnumOption<OrderStatus>
{
    [EnumOption(1, "Pending")]
    public static readonly OrderStatus Pending = new();
    
    [EnumOption(2, "Processing")]
    public static readonly OrderStatus Processing = new();
    
    [EnumOption(3, "Shipped")]
    public static readonly OrderStatus Shipped = new();
    
    [EnumOption(4, "Delivered")]
    public static readonly OrderStatus Delivered = new();
}

Use the Enhanced Enum

// Get by ID
var status = OrderStatus.GetById(2); // Returns Processing

// Get by name
var pending = OrderStatus.GetByName("Pending");

// Iterate all values
foreach (var s in OrderStatus.GetAll())
{
    Console.WriteLine($"{s.Id}: {s.Name}");
}

// Empty/default value
var empty = OrderStatus.Empty();

Lookup Properties

[EnhancedEnumOption]
public partial class Country : IEnhancedEnumOption<Country>
{
    [EnumOption(1, "United States")]
    [EnumLookup("Code", "US")]
    [EnumLookup("Currency", "USD")]
    public static readonly Country UnitedStates = new();
    
    [EnumOption(2, "Canada")]
    [EnumLookup("Code", "CA")]
    [EnumLookup("Currency", "CAD")]
    public static readonly Country Canada = new();
}

// Lookup by property
var country = Country.GetByCode("US");
var currency = country.Currency; // "USD"

Features

Cross-Assembly Support

Enhanced enums can be discovered and used across assembly boundaries:

// In Assembly A
[EnhancedEnumOption]
public partial class SharedStatus : IEnhancedEnumOption<SharedStatus>
{
    // ...
}

// In Assembly B - automatically discovered
var status = SharedStatus.GetById(1);

Validation

The source generator provides compile-time validation for:

  • Duplicate IDs
  • Duplicate names
  • Missing attributes
  • Invalid configurations

Performance

  • O(1) lookup by ID using dictionary
  • Cached reflection for property lookups
  • Minimal runtime overhead

Documentation

Requirements

  • .NET Standard 2.0 or higher
  • C# 9.0 or higher for source generators
  • Visual Studio 2022 or VS Code with C# extension

Contributing

See our Contributing Guide for details on how to contribute to this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 (8)

Showing the top 5 NuGet packages that depend on FractalDataWorks.EnhancedEnums:

Package Downloads
FractalDataWorks.Connections

Package Description

FractalDataWorks.Services

Package Description

FractalDataWorks.Tools

Package Description

FractalDataWorks.Services.ExternalConnections.Abstractions

Package Description

FractalDataWorks.Services.SecretManagement.Abstractions

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.