Skip to content

TiLied/CSharpToJavaScript

Repository files navigation

CSharpToJavaScript

Nuget package | CLI | Website | Try it online!

This library is a "core" where all the "magic" happens for translating/converting cs into js, using Roslyn. You should use the CLI/dotnet tool, it behaves more or less like dotnet cli, tsc cli, meson. Look for the implementation in CLI, BWA app or simple "Hello world" below.

Status

test262-parser(master): Only JS part (code is not public, yet. ES3 implemented) Total tests: 5363 | Passed: 2786 (51 %) | Failed: 2577

test262(es5 branch): Total tests: 11725 | Passed: 7950 (67 %)** | Failed: 3775

**Note: Tests run with "UseVarOverLet" and "DisableCompilationErrors" options, using Jint as an engine. The goal is to generate valid C# code and get rid of "DisableCompilationErrors" option.

Hello world

FileData file = new()
{
	SourceStr = @"Console.WriteLine(""Hello world."");"
};
file = CSTOJS.Translate(file);

Console.WriteLine(file.TranslatedStr);
  • Run a program
  • Console output should be:
console.log("Hello world.");
  • For options look at the code or on a website.
  • To specify options (options applying per file):
FileData file = new()
{
	OptionsForFile = new(){ Debug = true },
	...
};
...

Related Repository