Compile C# to JavaScript with DuoCode
"DuoCode understands' C# using the Roslyn compiler," said Stav Harel, of DuoCode, in an email. "Roslyn performs the code-parsing, syntactic tree (AST) generation, and contextual analysis. Then DuoCode takes over to perform the code translation and generates JavaScript code -- along with source maps -- while completing language features that exist in C# and are missing in JavaScript." Roslyn features open source C# and Visual Basic compilers offering code analysis APIs.
DuoCode is another tool for compiling to JavaScript without actually writing JavaScript. Google's Dart language also offers this capability, as does Microsoft's own TypeScript. Harel sees DuoCode, which is a commercial technology and not open source, as a solution for organizations with vast C# assets, including projects, code, and knowledge, to reuse these assets in JavaScript. In addition, DuoCode can be used for server-side development with Node.js, mobile applications via Cordova, and games development using WebGL.
Harel says DuoCode offers an improved approach to linking C# to JavaScript.
"Even though there have been other attempts to develop C#-to-JavaScript compilers, they are very different in their approach -- not using Roslyn, not supplying source maps," Harel said. "This makes it hard for them to keep up-to-date with latest technologies like C# 6.0 and Visual Studio 2015."
Currently in public beta, DuoCode can be downloaded by registering on the company website and used until June 30. A pricing model is expected at some point, Harel said.