Coder Social home page Coder Social logo

nfmalde / typewriter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adaskothebeast/typewriter

0.0 0.0 0.0 6.26 MB

Automatic TypeScript template generation from C# source files

Home Page: http://frhagn.github.io/Typewriter

License: Apache License 2.0

C# 98.71% PowerShell 0.46% Scilab 0.83% Batchfile 0.01%

typewriter's Introduction

Typewriter (Unofficial fork)

Typewriter is a Visual Studio extensions that generates TypeScript files from c# code files using TypeScript Templates. This allows you to create fully typed TypeScript representations of server side API, models, controllers, SignalR hubs etc. that automatically updates when you make changes to your c# code.

Original Documentation
Download from Visual Studio Gallery old version 1.22.0

Why new fork?

It seems that Fredrik Hagnelius author of Typewriter is very busy and do not have enough time for supporting that extensions. From the other side that extensions really helps fullstack developers and work on it should be continued.

Main differences between original and this fork

Version 2.9.2

  • Compatible with Visual Studio 17.3.3

Version 2.9.1

  • Compatible with Visual Studio 17.3.2

Version 2.9.0

  • version compatible with Visual Studio 17.3.x
  • added special fork of Buildalyzer to be able to run tests - existing version of Buildalyzer compatible with net 4.7.2 too old and causing problems with tests

Version 2.8.1

  • fixed tool manifest dependency to require VS 17.2.x

Version 2.8.0

  • version compatible with Visual Studio 17.2.x

Version 2.7.0

  • latest updates for Visual Studio 17.1.x

Version 2.6.1

  • fix relative paths in output directory - now relative to template location

Version 2.6.0

  • ability to setup different output directory in settings.OutputDirectory
  • ability to skip adding generated files in project in template by using settings.SkipAddingGeneratedFilesToProject

Version 2.5.0

  • file scoped namespaces C# 10 compatibility

Version 2.3.1

  • exposing solution path in settings

Version 2.2.6

Version 1.32.0

  • added DefaultValue

Version 1.31.0

Version 1.30.0

  • Added support for C# 9.0 records
  • Fixed error for 'string?' type - invalid marked as IsEnumerable

Issues

The issue tracker is the preferred channel for bug reports, features requests and submitting pull requests.
For personal support requests Stack Overflow is a better place to get help. Please use the typewriter tag when posting your questions.

Getting started

Step 1: Add a TypeScript Template file (.tst)
Step 2: Add the following code in the template

$Classes(*Model)[ // Find all classes with a name ending with Model
    class $Name {
        constructor($Properties[public $name: $Type][, ]) {
        }
    }
]

Step 3: Save the template
Step 4: Add a c# class named TestModel
Step 5: Add the following code to the class

using System;

namespace TestApplication
{
    public class TestModel
    {
        public int Id { get; set; }
        public int Name { get; set; }
    }
}

Step 6: Save the class.

Each time a class matching the filter in the template is saved a TypeScript class matching the template is updated or added to the project.

Advanced usage of templates

Repository https://github.com/AdaskoTheBeAsT/NetCoreTypewriterRecipes shows advanced generation of classes, interfaces, enums, records, etc. using Typewriter. It uses polymorphic capabilities of Newtonsoft.Json to properly generate TypeScript classes with polymorphiysm enabled - by using $type property. It also contains brand new generation of classes using System.Text.Json with polymorphic capabilities upcoming in .NET 7.

.NET 6 Newtonsoft.Json

  1. Angular sample .NET 6
  1. React sample .NET 6
  • use same ideas as in Angular sample - it is only limited to models due to multitude of possible creation api connecting functions ReactWebApiSample2

.NET 7 System.Text.Json

To show new functionality with polymorphism https://devblogs.microsoft.com/dotnet/system-text-json-in-dotnet-7/#using-type-discriminators Please see in samples:

  1. Angular sample .NET 7
  1. React sample .NET 7
  • use same ideas as in Angular sample - it is only limited to models due to multitude of possible creation api connecting functions ReactWebApiSample2

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.