Meziantou.Framework.FastEnumToStringGenerator 1.0.8

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Meziantou.Framework.FastEnumToStringGenerator --version 1.0.8                
NuGet\Install-Package Meziantou.Framework.FastEnumToStringGenerator -Version 1.0.8                
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="Meziantou.Framework.FastEnumToStringGenerator" Version="1.0.8">
  <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.
paket add Meziantou.Framework.FastEnumToStringGenerator --version 1.0.8                
#r "nuget: Meziantou.Framework.FastEnumToStringGenerator, 1.0.8"                
#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 Meziantou.Framework.FastEnumToStringGenerator as a Cake Addin
#addin nuget:?package=Meziantou.Framework.FastEnumToStringGenerator&version=1.0.8

// Install Meziantou.Framework.FastEnumToStringGenerator as a Cake Tool
#tool nuget:?package=Meziantou.Framework.FastEnumToStringGenerator&version=1.0.8                

Meziantou.Framework.FastEnumToStringGenerator

The source generator generates a ToStringFast method for some enumerations

[assembly: FastEnumToStringAttribute(typeof(Sample.Color), IsPublic = true, ExtensionMethodNamespace = "Sample.Extensions")]

namespace Sample
{
    public enum Color
    {
        Blue,
        Red,
        Green,
    }
}

The source generator adds the following code:

internal static partial class FastEnumToStringExtensions
{
    internal static string ToStringFast(this Sample.Color value)
    {
        return value switch
        {
            case Blue => "Blue",
            case Red => "Red",
            case Green => "Green",
            _ => value.ToString(),
        };
    }
}

You can now replace the ToString method with the new ToStringFast method:

Color value = Color.Green;
Console.WriteLine(value.ToStringFast());

Additional resources

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.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
2.0.2 916 11/17/2024
2.0.1 26,292 11/29/2023
2.0.0 5,824 11/19/2023
1.0.8 399 11/15/2023
1.0.7 4,890 9/6/2023
1.0.6 9,082 12/24/2022
1.0.5 3,594 11/10/2021
1.0.4 1,003 7/14/2021
1.0.3 528 6/30/2021
1.0.2 852 6/21/2021
1.0.1 556 6/16/2021
1.0.0 565 6/16/2021