Strinum 2.1.1
dotnet add package Strinum --version 2.1.1
NuGet\Install-Package Strinum -Version 2.1.1
<PackageReference Include="Strinum" Version="2.1.1" />
paket add Strinum --version 2.1.1
#r "nuget: Strinum, 2.1.1"
// Install Strinum as a Cake Addin #addin nuget:?package=Strinum&version=2.1.1 // Install Strinum as a Cake Tool #tool nuget:?package=Strinum&version=2.1.1
Strinum
Versatile source code tool designed to automate the generation of stringification extension methods for enum types. By intelligently scanning your source code, this generator identifies enum types and creates streamlined methods for converting enum members to human-readable string representations. Improve code readability, simplify debugging, and boost productivity with EnumStringifyGenerator – the essential companion for enum handling in your projects.
Usage
The Stringify()
extension method is generated for each enum type in your source code. If you call it on an enum member, it will return the member represented as a string.
public enum Number
{
One,
Two,
Three
}
Console.WriteLine(Number.One.Stringify());
Console.WriteLine(Number.Two.Stringify());
Console.WriteLine(Number.Three.Stringify());
// Output:
// One
// Two
// Three
Customizing outputs
Sometimes you want to change the output of a stringified enum value. To do that, you can use StringifyAttribute
to override the default enum string value.
using Strinum;
public enum Number
{
[Stringify("NumberOne")] One,
[Stringify("number_two")] Two,
[Stringify("number-three")] Three,
[Stringify("numberFour")] Four,
[Stringify("Number 5")] Five
}
Console.WriteLine(Number.One.Stringify());
Console.WriteLine(Number.Two.Stringify());
Console.WriteLine(Number.Three.Stringify());
Console.WriteLine(Number.Four.Stringify());
Console.WriteLine(Number.Five.Stringify());
// Output:
// NumberOne
// number_two
// number-three
// numberFour
// Number 5
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 4.6.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.