Giter VIP home page Giter VIP logo

csts's Introduction

CSTS

A simple library that can convert .NET types to TypeScript types. The output can be both a .ts file with classes as well as a .d.ts file with only the interface definitions.

Installation

A nuget package is available:

Install-Package CSTS 

Basic usage:

var generator = new Generator(typeof(MyType).Assembly.GetExportedTypes());

 // generate classes and interfaces for a .ts file
string types = generator.GenerateTypes();

// only generate interfaces for a .d.ts file
string interfaceDefinitions = generator.GenerateInterfaceDefinitions(); 

By default, it will only generate TypeScript code for types that are in the same assembly as the assemblies of the types that you passed in. To change this behavior, pass in a Func<Type, bool> for the processType parameter of the Generator constructor that returns whether or not to process the type that it encountered. The same holds true for the processBaseType parameter; this should return whether or not the base type of a type should also be turned into TypeScript code. By default it only does this if the base type is part of the same assembly as the types you passed into the constructor. Additionally, the moduleNameGenerator function returns the name of the module that a given type should be part of. It defaults to a type's Namespace property.

csts's People

Contributors

julianrooze avatar julianr avatar omeaart avatar

Stargazers

Kevin Visscher avatar

Watchers

James Cloos avatar

Forkers

omeaart kvisscher

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.