FastEnum.Extensions.Generator 1.0.0-preview.1

This is a prerelease version of FastEnum.Extensions.Generator.
There is a newer version of this package available.
See the version list below for details.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package FastEnum.Extensions.Generator --version 1.0.0-preview.1                
NuGet\Install-Package FastEnum.Extensions.Generator -Version 1.0.0-preview.1                
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="FastEnum.Extensions.Generator" Version="1.0.0-preview.1">
  <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 FastEnum.Extensions.Generator --version 1.0.0-preview.1                
#r "nuget: FastEnum.Extensions.Generator, 1.0.0-preview.1"                
#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 FastEnum.Extensions.Generator as a Cake Addin
#addin nuget:?package=FastEnum.Extensions.Generator&version=1.0.0-preview.1&prerelease

// Install FastEnum.Extensions.Generator as a Cake Tool
#tool nuget:?package=FastEnum.Extensions.Generator&version=1.0.0-preview.1&prerelease                

FastEnumToString

Source Generator generating ToString extension methods for any enums.

Usage

Use the [Extensions] on your enums, so the source generator will genrate the extensions for those enums:

Example

using FastEnum;

namespace ToStringExample;

public class NestingClass<T, K>
    where T : struct
    where K : class, new()
{
    [Extensions]
    public enum NestedInClassEnum // Warning: 'ETS1003' Extension generation for enum's nested in generic types are restricted.
    {
        None
    }
}

[Extensions]
public enum Color : System.Byte
{
    Red,
    Green,
    Blue,
}

[Extensions, Flags]
public enum Options
{
    None = 0,
    ToString = 1,
    Parse = 2,
    HasFlag = 4,
}

Something similar will be generated:

// <auto-generated/>

#nullable enable annotations
#nullable disable warnings

namespace ToStringExample
{
    [global::System.CodeDom.Compiler.GeneratedCode("FastEnum.Extensions.Generator.EnumToStringGenerator", "1.0.0")]
    public static class ColorExtensions
    {
        private static readonly byte[] _underlyingValues = { ... }

        private static readonly Color[] _values = { ... }

        private static readonly string[] _names = { ... }

        public const int MembersCount = 3;

        public static ToStringExample.Color[] GetValues() => _values;

        public static byte[] GetUnderlyingValues() => _underlyingValues;

        public static string[] GetNames() => _names;

        public static string FastToString(this Color value) { ... }

        public static string FastToString(this Color value, string? format) { ... }

        public static bool IsDefined(this Color value) { ... }
}
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.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
1.3.0 120 10/20/2024

First working preview version