CSharpEssentials.Enums
3.0.2
See the version list below for details.
dotnet add package CSharpEssentials.Enums --version 3.0.2
NuGet\Install-Package CSharpEssentials.Enums -Version 3.0.2
<PackageReference Include="CSharpEssentials.Enums" Version="3.0.2" />
<PackageVersion Include="CSharpEssentials.Enums" Version="3.0.2" />
<PackageReference Include="CSharpEssentials.Enums" />
paket add CSharpEssentials.Enums --version 3.0.2
#r "nuget: CSharpEssentials.Enums, 3.0.2"
#:package CSharpEssentials.Enums@3.0.2
#addin nuget:?package=CSharpEssentials.Enums&version=3.0.2
#tool nuget:?package=CSharpEssentials.Enums&version=3.0.2
CSharpEssentials.Enums
CSharpEssentials.Enums provides enum metadata attributes and a built-in source generator for fast, compile-time enum operations. It is designed to work with CSharpEssentials.Json and CSharpEssentials.EntityFrameworkCore for serialization and storage scenarios.
🚀 Features
- StringEnumAttribute: A marker attribute to explicitly indicate that an
Enumshould be serialized as a string rather than an integer. - Built-in Source Generator: Apply
[StringEnum]to enums and the generator produces compile-time optimized extension methods and constants.
📦 Installation
dotnet add package CSharpEssentials.Enums
🛠 Usage
Apply the [StringEnum] attribute to your enum definitions.
using CSharpEssentials.Enums;
[StringEnum]
public enum UserStatus
{
Active,
Inactive,
Suspended
}
The source generator automatically creates {Enum}Extensions with:
| Member | Description |
|---|---|
ToOptimizedString() |
Fast switch-based string conversion |
ToSnakeCase() |
Compile-time snake_case string |
ToKebabCase() |
Compile-time kebab-case string |
ToLowerCase() |
Compile-time lower-case string |
ToUpperCase() |
Compile-time upper-case string |
{Member}SnakeCase |
Public constant for snake_case |
{Member}KebabCase |
Public constant for kebab-case |
IsDefined(string) |
Fast name lookup |
TryParse(string, out Enum) |
Fast parsing with numeric fallback |
Parse(string) |
Fast parsing (throws on failure) |
GetNames() |
Array of enum member names |
GetValues() |
Array of enum values |
AsUnderlyingType() |
Cast to backing numeric type |
Example
UserStatus s = UserStatus.Active;
s.ToOptimizedString(); // "Active"
s.ToSnakeCase(); // "active"
s.ToKebabCase(); // "active"
UserStatusExtensions.ActiveSnakeCase; // "active"
UserStatusExtensions.InactiveKebabCase; // "inactive"
UserStatusExtensions.IsDefined("Active"); // true
UserStatusExtensions.TryParse("Inactive", out var v); // true, v = Inactive
Integration
This package is intended to be used with serialization libraries (like CSharpEssentials.Json) and ORMs (like CSharpEssentials.EntityFrameworkCore) that look for this marker to automatically apply string conversion logic.
| Product | Versions 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 is compatible. 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 is compatible. 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. net11.0 is compatible. |
| .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 is compatible. |
| .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. |
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net10.0
- No dependencies.
-
net11.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on CSharpEssentials.Enums:
| Package | Downloads |
|---|---|
|
CSharpEssentials
A comprehensive C# library enhancing functional programming capabilities with type-safe monads (Maybe, Result), discriminated unions (Any), and robust error handling. Features include: domain-driven design support, enhanced Entity Framework integration, testable time management, JSON utilities, and LINQ extensions. Built for modern C# development with focus on maintainability, testability, and functional programming principles. |
|
|
CSharpEssentials.EntityFrameworkCore
Enhances Entity Framework Core with functional programming patterns and DDD-friendly features. Includes base entity classes, soft delete support, audit trails, query filters, optimistic concurrency, PostgreSQL integration, query performance monitoring, and domain event handling. Perfect for building maintainable and scalable data access layers in modern .NET applications. |
|
|
CSharpEssentials.Json
JSON utilities and custom converters for System.Text.Json in C#. Includes MultiFormatDateTimeConverter, ConditionalStringEnumConverter, PolymorphicJsonConverterFactory, and JsonOptions. Essential for advanced JSON serialization scenarios. |
|
|
CSharpEssentials.Errors
Comprehensive error handling system for functional programming in C#. Provides Error types, ErrorMetadata, ErrorType enums, and extensions for robust error management. Foundation for Result pattern and functional error handling. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.5 | 458 | 5/7/2026 |
| 3.0.4 | 431 | 5/6/2026 |
| 3.0.3 | 440 | 5/5/2026 |
| 3.0.2 | 430 | 5/5/2026 |
| 3.0.1 | 429 | 5/3/2026 |
| 3.0.0 | 413 | 5/3/2026 |
| 2.1.0 | 431 | 11/26/2025 |
| 2.0.9 | 348 | 9/30/2025 |
| 2.0.8 | 344 | 9/29/2025 |
| 2.0.7 | 342 | 9/29/2025 |
| 2.0.6 | 344 | 9/29/2025 |
| 2.0.5 | 328 | 9/29/2025 |
| 2.0.4 | 348 | 9/28/2025 |
| 2.0.3 | 343 | 9/28/2025 |
| 2.0.2 | 361 | 9/28/2025 |
| 2.0.1 | 346 | 9/28/2025 |
| 2.0.0 | 348 | 9/28/2025 |