Skip to content
This repository has been archived by the owner on Apr 18, 2018. It is now read-only.

A Gulp plugin to convert C# POCO classes into Typescript type definitions.

License

Notifications You must be signed in to change notification settings

ffMathy/gulp-typescript-cs-poco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED!

This library has been deprecated in favor of the new, much more stable and flexible: https://github.com/ffMathy/FluffySpoon.JavaScript.CSharpToTypeScriptGenerator.Gulp/

Overview

See https://github.com/ffMathy/typescript-cs-poco for actual implementation. This is just a wrapper.

Gulp-typescript-cs-poco is a Gulp plugin that translates basic C# POCO classes like this:

public class MyPoco
{
	public string Name { get; set; }
	public int Id { get; set; }
	public long Value { get; set; }
	public bool IsValid { get; set; }
	public SomeOtherPoco RelatedObject { get; set; }
}

Into this Typescript file:

interface MyPoco {
	Name: string;
	Id: number;
	Value: number;
	IsValid: boolean;
	RelatedObject: SomeOtherPoco;
}

Installation

Install with NPM:

npm install --save-dev gulp-typescript-cs-poco

Use

var pocoGen = require('gulp-typescript-cs-poco');

gulp.task('poco', function () {
  return gulp.src('Models/*.cs')
              .pipe(pocoGen())
              .pipe(gulp.dest('Scripts/myPocoTsFolder'));
})

This will create a single .ts file for every .cs file it finds. You can combine this with tools like gulp-concat to turn this into one file if desired.

Options

For a full list of options available, see: https://github.com/ffMathy/typescript-cs-poco

Options can be passed into the function to alter behavior. You can pass in only the options you need, or none at all for default behavior.

var pocoGen = require('gulp-typescript-cs-poco');

gulp.task('poco', function () {
  return gulp.src('Models/*.cs')
              .pipe(pocoGen({
                //options go here
	      }))
              .pipe(gulp.dest('Scripts/myPocoTsFolder'));
})

Or:

var pocoGen = require('gulp-typescript-cs-poco');

gulp.task('poco', function () {
  var pocoGenOptions = {
     //options go here
  };

  return gulp.src('Models/*.cs')
              .pipe(pocoGen(pocoGenOptions))
              .pipe(gulp.dest('Scripts/myPocoTsFolder'));
})

About

A Gulp plugin to convert C# POCO classes into Typescript type definitions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages