Generate typescript enums matching your C# enums
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitattributes
.gitignore
LICENSE.md
README.md

README.md

EnumGenie

Build status Master

Build status CI

Generate enums matching your C# enums.

Comes with generators for TypeScript.

Installation

EnumGenie is a nuget! Crazy, I know.

    dotnet add package EnumGenie.TypeScript

Documentation

See the wiki

Usage

See EnumGenie.Sample project for a ...umm... sample. Crazy.

using EnumGenie.Filters;
using EnumGenie.Sample.Enums;
using EnumGenie.Sources;
using EnumGenie.Transforms;
using EnumGenie.TypeScript;
using EnumGenie.Writers;

namespace EnumGenie.Sample
{
    public static class Program
    {
        public static void Main()
        {
            var genie = new EnumGenie()
                .SourceFrom.Assembly(typeof(Program).Assembly)
                .FilterBy.Predicate(t => t != typeof(Ignored))
                .TransformBy.RenamingEnum(def => def.Name.Replace("StripThisOut", ""))
                .WriteTo.Console(cfg => cfg.TypeScript(ts => ts.Declaration().Description().Descriptor()))
                .WriteTo.File("./TypeScript/enums.ts", cfg => cfg.TypeScript(ts => ts.Declaration().Description().Descriptor()));

            genie.Write();
        }
    }
}

Common Mistakes

Nothing is being output!

Ensure you are calling .Write() at the end. This is where the work is done, the rest is just configuration.