Cenum 1.0.0

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

// Install Cenum as a Cake Tool
#tool nuget:?package=Cenum&version=1.0.0

Cenum

An implementation of a type safe & object oriented alternative to C# enum.

Background

Instead of being limited to a fixed set of integral values, imagine if enums were a fixed set of objects. They could have fields, properties and methods - just as other types do. The only difference would be that there would only ever be one instance for each value.

Usage

The source generator will scan the source code for classes marked with [Enumeration] attribute and then generate Enumerate() method for them.

The method will enumerate all public static readonly fields with the same type as the class itself.

Example

[Enumeration]
public partial class Number
{
    public static readonly Number One = new(1);
    public static readonly Number Two = new(2);
    public static readonly Number Three = new(3);
    
    private readonly int _value;
    
    private Number(int value) => _value = value;
    
    public override string ToString() => _value.ToString();
}


foreach (var number in Number.Enumerate())
{
    Console.WriteLine(number.ToString());
}

// Output:
// 1
// 2
// 3
There are no supported framework assets in this 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.0.4 77 5/3/2024
1.0.3 259 11/8/2023
1.0.2 165 11/2/2023
1.0.0 160 11/2/2023

Basic functionality