Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

joao-neves95/CSharpToTypescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

55 Commits

Repository files navigation

CSharpToTypescript


Original Repository: https://github.com/nhabuiduc/TypescriptSyntaxPaste

Modified and adapted to migrate to .NET Standard 2.0 and compile with Visual Studio 2019 (originally only compilable with Visual Studio 2015).

An issue with .NET 5 runtime assembly resolution and mscorlib has been (more or less) addressed, but only tested on Windows.
Linux will be the next step.

It does not work as a Visual Studio Extension anymore.
Its intent now, is to be used as a library.

Download (NuGet)

dotnet add package LibCSharpToTypescript

How to use CSharpToTypescript:


string typescriptInput = @"class Foo{}";
ICSharpToTypescriptConverter cSharpToTypescriptConverter = new CSharpToTypescriptConverter();
string typescriptCode = cSharpToTypescriptConverter.ConvertToTypescript( typescriptInput, new MySettingStore() );

  • Visual Studio Extension which converts C# SYNTAX to Typescript SYNTAX.

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: http://bdnprojects.net/CSharpSyntaxParser/

About

Library that converts C# SYNTAX into Typescript SYNTAX

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%

AltStyle によって変換されたページ (->オリジナル) /