nhabuiduc / TypescriptSyntaxPaste

Visual Studio Extension which convert C# SYNTAX to Typescript SYNTAX
70 stars 24 forks source link

TypescriptSyntaxPaste

HOW TO DEBUG/RUN.

Need Visual Studio 2015 + install VS 2015 SDK to compile and run this extension.
Then you need to configure project to allow you debug with VS 2015: go to project Property, Debug tab ->

BRIEF CODE INFORMATION

Almost all converting classes are in folder Translation, which for each file containing the convert method to convert one kind of syntax (C#) to Typescript. For example ClassDeclarationSyntax in Roslyn will be ClassDeclarationTranslation in this project.

Let say you want convert :
in C#: class A {}
typescript: class myA{}

you just need to navigate to class ClassDeclarationTranslation in project, then change this line:

 return $@"{GetAttributeList()}export class {Syntax.Identifier}{TypeParameterList?.Translate()} {baseTranslation}
           {{
           {Members.Translate()} 
           }}";

to:

 return $@"{GetAttributeList()}export class my{Syntax.Identifier}{TypeParameterList?.Translate()} {baseTranslation}
           {{
           {Members.Translate()} 
           }}";

For more information about Syntax Tree in Roslyn, you can use Syntax Visualizer which is included in VS 2015 (View -> Other Windows-> Syntax Visualizer) or online version: http://bdnprojects.net/CSharpSyntaxParser/