CSharpToJavaScript 0.0.10

There is a newer version of this package available.
See the version list below for details.
dotnet add package CSharpToJavaScript --version 0.0.10
                    
NuGet\Install-Package CSharpToJavaScript -Version 0.0.10
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSharpToJavaScript" Version="0.0.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSharpToJavaScript" Version="0.0.10" />
                    
Directory.Packages.props
<PackageReference Include="CSharpToJavaScript" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CSharpToJavaScript --version 0.0.10
                    
#r "nuget: CSharpToJavaScript, 0.0.10"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CSharpToJavaScript@0.0.10
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CSharpToJavaScript&version=0.0.10
                    
Install as a Cake Addin
#tool nuget:?package=CSharpToJavaScript&version=0.0.10
                    
Install as a Cake Tool

CSharpToJavaScript

Nuget package | Website | Try it online! | CLI | VS Code Extension | VS Extension

C# conversion to JavaScript as is.

This is a personal project. Updates will be irregular.

C# input

namespace ConsoleAppTest.CSharp;

public class Test							
{
	public Test()
	{
		Console.WriteLine("Hello World!");
	}
}

Javascript output

class Test
{
	constructor()
	{
		console.log("Hello World!");
	}
}

How to use

CSTOJS cstojs = new();
await cstojs.GenerateOneAsync("Path(full path) to c# file(folder with c# files)");

Other methods "GenerateOne" can be found on the website.

  • 5 Run program and file will be generated in output path(default is "Directory.GetCurrentDirectory()") with name "|C# file name|.js"(default)
  • 6 See below for an example "Model" and "HelloWorld".

Example "Model"

Program.cs

using CSharpToJavaScript;
namespace ConsoleAppTest;

public class Program
{
	public static async Task Main()
	{
		CSTOJS cstojs = new(new CSTOJSOptions() 
			{ 
				KeepBraceOnTheSameLine = true,
				NormalizeWhitespace = true
			});
		await cstojs.GenerateOneAsync("C:\\GitReps\\ConsoleAppTest\\CSharp\\Person.cs");

		Console.ReadKey();
	}
}

List of options can be found on the website or in the code directly.

CSharp/Person.cs

using static CSharpToJavaScript.APIs.JS.GlobalObject;
namespace ConsoleAppTest.CSharp;

public partial class Person
{
    private int _Id;
    public string FullName { get; set; }
    public int Age { get; set; }
}

Above code will generate "Person.js" file that contains:

class Person {
    _Id;
    #_FullName_;
    get FullName() { return this.#_FullName_; } 
    set FullName(value) { this.#_FullName_ = value; }
    #_Age_;
    get Age() { return this.#_Age_; } 
    set Age(value) { this.#_Age_ = value; }
}

Example "HelloWorld"

Program.cs

using CSharpToJavaScript;
namespace ConsoleAppTest;

public class Program
{
	public static async Task Main()
	{
		CSTOJS cstojs = new();
		await cstojs.GenerateOneAsync("C:\\GitReps\\ConsoleAppTest\\CSharp\\Test.cs");

		Console.ReadKey();
	}
}

CSharp/Test.cs

using static CSharpToJavaScript.APIs.JS.GlobalObject;
namespace ConsoleAppTest.CSharp;

public class Test
{
	public Test()
	{
		GlobalThis.Console.Log("HelloWorld!");
	}
}

Above code will generate "Test.js" file that contains:

class Test
{
	constructor()
 	{
   		globalThis.console.log("HelloWorld!");
 	}
}

CLI for library: https://github.com/TiLied/CSTOJS_CLI

VS Code Extension using CLI: https://github.com/TiLied/CSTOJS_VSCode_Ext

VS Extension using CLI: https://github.com/TiLied/CSTOJS_VS_Ext

Website/documentation: https://github.com/TiLied/CSTOJS_Pages

Project includes

Microsoft CodeAnalysis CSharp Core nuget package.

MDN-content for JS api.

<VersionPrefix>0.0.09</VersionPrefix>

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.3 50 12/15/2025
0.1.2 421 12/8/2025
0.1.1 191 11/24/2025
0.1.0 127 9/27/2025
0.0.10 266 9/15/2025

- dotnet 10
- [Clamping large numbers and printing a warning.](https://github.com/TiLied/CSharpToJavaScript/commit/0e84644f55ff62b578b626328f374f68fcb5da84)
- [Added workaround for "string.Empty"](https://github.com/TiLied/CSharpToJavaScript/commit/06f85256d6bb4b7b44120ffeb3dbfbedc07e4694)
- [c# object -> js Object](https://github.com/TiLied/CSharpToJavaScript/commit/1005996745075610becb6c08f8558b90a1f9eb89)
- [Added very specific workaround for "Method(new())"](https://github.com/TiLied/CSharpToJavaScript/commit/2807b0929916f588aa9115b44ea481b7aa95e2b5)
- [Added many missing assignments.](https://github.com/TiLied/CSharpToJavaScript/commit/2b43e0c217ec2826e012ea2b643ae9caf40aa2f3)
- [Added "Debug.Assert" to log error.](https://github.com/TiLied/CSharpToJavaScript/commit/849e787b7c326fb0e2b34973a6e2555ca5ba9899)
- [Added ecma boolean, function, symbol.](https://github.com/TiLied/CSharpToJavaScript/commit/cb95360a49298d05ffb240b3cc6c4723a9a37926)
- [c# TrimEnd -> js trimEnd](https://github.com/TiLied/CSharpToJavaScript/commit/c64d3e901cd278db956d5c7d614a7d38410e58be)
- - c# TrimStart -> js trimStart
- - c# ToUpper-> js toUpperCase
- - c# ToLower-> js toLowerCase
- [Added support for top-level statements.](https://github.com/TiLied/CSharpToJavaScript/commit/53e34b1e289723a00fcafaf19d76278f2ab2a406)
- [Added ecma String and updated other.](https://github.com/TiLied/CSharpToJavaScript/commit/a2282407bd22c5a876806905cf7e08ae98e9287d)
- [More debug logs.](https://github.com/TiLied/CSharpToJavaScript/commit/97262f3d7f381bbf039bfc8971cfd8093061ac96)
- [Added Array.](https://github.com/TiLied/CSharpToJavaScript/commit/938efbcbf0a2e2939cf9ef09b7b61f10c763a36f)
- - More pragma ignore.
- [Added TypedArray.](https://github.com/TiLied/CSharpToJavaScript/commit/9fbcccb1d62da9191021f3edd7a0628c11501ce8)
- [Further improvement to the debug output.](https://github.com/TiLied/CSharpToJavaScript/commit/55d6ba331165dd8d3822f37b643a1deb5d19aa02)
- [Added ArrayBuffer, Atomics, DataView, JSON, Map, Set, SharedArrayBuff…](https://github.com/TiLied/CSharpToJavaScript/commit/880e3b6a528c3cc0834a772f7e9619ebcbf2ed7f)
- - …er, WeakMap, WeakSet.
- [Added the rest of ecma objects.](https://github.com/TiLied/CSharpToJavaScript/commit/e1129b7e9104241b4c3ec5329363b50adb88b9a9)
- [Added an indexer to an ObjectPrototype.](https://github.com/TiLied/CSharpToJavaScript/commit/6bf2d7c2bf0447b71b9d2f1ab6f4ad34fa48c9ce)
- - For emulation "Bracket notation" in js.
- [Print an error to the console if there is a compilation error.](https://github.com/TiLied/CSharpToJavaScript/commit/0988383ae1fbf9d9d4b8f36b0c3ed5057fc5f3f7)
- [Always run the stopwatch.](https://github.com/TiLied/CSharpToJavaScript/commit/0145f9606cb0bac0f2c332b6601a0da77f801497)
- [Display certain debug output only with Debug build.](https://github.com/TiLied/CSharpToJavaScript/commit/85fb0691f7daa7310e29e9b8ce7506153cf80fb4)
- [Changed "CustomCSNamesToJS" to Dictionary.](https://github.com/TiLied/CSharpToJavaScript/commit/64229335bfb6c7fba4c991cbd7c58fe18c9959a4)
- [Methods now include "options" parameter.](https://github.com/TiLied/CSharpToJavaScript/commit/1a61aaf886031cc3e101f4cbfa19f215f73b417d)
- [Renamed "OutPutPath" to "OutputPath".](https://github.com/TiLied/CSharpToJavaScript/commit/36535417a5f8d483ba9a71f0f91002c482d5c5a2)
- - Added option "OutputFileName".
- [Support for a local function.](https://github.com/TiLied/CSharpToJavaScript/commit/31809a5d7fcc500fe9d2eda83ca90f849be661f3)
- - More debug info with "ErrorLine".
- [Fixed default values for properties.](https://github.com/TiLied/CSharpToJavaScript/commit/563bdaf947ad880378155b88d7bf0a5daf227122)
- [Fixed "CA1859: Use concrete types when possible for improved performa…](https://github.com/TiLied/CSharpToJavaScript/commit/4a1ace02b2276008929e1297522aae2e24a3cf32)
- - …nce" with Logging.
- - Added the rest of overrides.
- [A few fixes with methods.](https://github.com/TiLied/CSharpToJavaScript/commit/4b27ab39288c22c040b60fcb6e0e414d44862055)
- [Fixed many warnings.](https://github.com/TiLied/CSharpToJavaScript/commit/69d8e39839d6f1c9e52343be4145669ac3905684)
- [Explicitly call "VisitBinaryExpression".](https://github.com/TiLied/CSharpToJavaScript/commit/4089c2a21198bbc981474c45bdb136aba6c8378c)
- [Fixed a crash where "foregroundcolor" is not supported.](https://github.com/TiLied/CSharpToJavaScript/commit/b49494166df52758f67795e49640da736143b49d)
- [Changed a little debug output to the file.](https://github.com/TiLied/CSharpToJavaScript/commit/417dd9f71c8c43dff578c984a7ab14ccdba35983)
- Updated generated documentation.
- Updated generated csharp.
**Full Changelog**: https://github.com/TiLied/CSharpToJavaScript/compare/0.0.09...0.0.10