Giter Site home page Giter Site logo

grebro / typegen Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jburzynski/typegen

0.0 0.0 0.0 16.06 MB

Single-class-per-file C# to TypeScript generator

License: MIT License

C# 92.98% Smarty 0.26% PowerShell 0.93% TypeScript 3.24% CSS 0.14% JavaScript 0.01% HTML 2.45%

typegen's Introduction

TypeGen

Single-class-per-file C# to TypeScript generator

Build status

! Due to lack of time and the need to do other things, I had to leave this project. Please find more information here.

Project's website: http://jburzynski.net/TypeGen

Complete documentation: http://typegen.readthedocs.io

How to get

Quick start

  1. Add TypeGen NuGet package to your project. If you wish to use TypeGen as a .NET Core CLI tool, you'll need to install it from this package

  2. Mark your C# classes/enums as exportable to TypeScript:

// with attributes

[ExportTsClass]
public class ProductDto
{
    public decimal Price { get; set; }
    public string[] Tags { get; set; }
}

// or with a generation spec (created anywhere in your project)

public class MyGenerationSpec : GenerationSpec
{
    public MyGenerationSpec()
    {
        AddClass<ProductDto>();
    }
}
  1. If you're using a generation spec, create a file named tgconfig.json directly in your project folder and place the following content there:
{
  "generationSpecs": ["MyGenerationSpec"]
}
  1. Build your project and type TypeGen generate or TypeGen -p "MyProjectName" generate (depending on the current working directory of the PM Console) into the Package Manager Console (you might need to restart Visual Studio), or dotnet typegen generate in the system console if you're using TypeGen .NET Core CLI tool.

After completing the steps described above, a single TypeScript file (named product-dto.ts) will be generated in your project directory. The file will look like this:

export class ProductDto {
    price: number;
    tags: string[];
}

Features

Some of TypeGen's features include:

  • generating TypeScript classes, interfaces and enums - single class per file
  • generating barrel (index) files
  • support for collection (or nested collection) types
  • generic classes/types generation
  • support for inheritance
  • customizable convertion between C#/TypeScript names (naming conventions)

For a complete list of features with examples, please refer to the project's documentation: http://typegen.readthedocs.io

typegen's People

Contributors

jburzynski avatar stephtr avatar sdamian avatar bcrosnier avatar bergi9 avatar allov avatar grebro avatar vsvirydau-cl avatar newdark90 avatar onliner10 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.