Take your C# code and skills
to the web
with DuoCode

C#-to-JavaScript compiler
powered by Microsoft® Roslyn





We have beta invitations!
Leave your email to get one soon

Features

The power of
the C# language

Enjoy the power and convenience of C# 6.0 language, complete with strong-typing, class-based inheritance, reflection, generics, lambda expressions and Linq.
See complete list

The power of
Visual Studio

Enjoy the convenience of Visual Studio - the best IDE in the world, with state-of-the-art development and debugging experience.
More information

The power of
.NET Framework

Utilize the familiar classes in the standard libraries of the .NET Framework, including string manipulations, collections, and more.

The power of
DuoCode

Cross-compile C# code into readable and maintainable JavaScript.
Share code between Windows and JavaScript applications.

Compile C# code to JavaScript in Visual Studio


DuoCode is an alternative compiler, powered by Microsoft® Roslyn, and integrated in Visual Studio.

It magically cross-compiles your C# 6.0 code into high-quality readable JavaScript code, enabling rapid development of web applications utilizing the extensive features of the C# language, the Visual Studio IDE, and the .NET Framework base class libraries.

Development in C# with Visual Studio brings great productivity wins, thanks to strong-typing, code completion, compile-time error checking, static analysis, code navigation and refactoring.

Develop HTML5 applications using strongly-typed and documented class-definitions of the entire DOM class library (including HTML, CSS, SVG and WebGL definitions).

See code samples

C# features supported in DuoCode


C# Classes
Method overloading
Properties
Interfaces
Generics
Integral types
Events and delegates
Lambda expressions
Arrays
Structs*
ForEach, Enumerators, Yield
Enums
Loops
Reflection
Dynamic binding
Nullable types
Ref and Out
Params
Optional arguments
Extension methods
Attributes
Operator overloading
Casting
Async and Await*
Exception handling
Collections
Linq
Integer arithmetic
Resource embedding
C# 6.0: nameof
C# 6.0: Expression-methods
C# 6.0: Expression-properties
C# 6.0: using static

Amazing C# debugging right inside the browser!


DuoCode automatically generates source mappings, which allow you to view and debug the original C# source files directly inside the browser or in Visual Studio 2015.

This groundbreaking feature enables full C# debugging using the browser's built-in developing tools, including source stepping, breakpoints, watches and complete C# call-stack.

image1

C#

// Original C# code
private static int GetBestMove(Board board, Player player, out Player winner)
{
  winner = Board.Other(player);
  int result = -1;

  if (board.Count == 0)
    return new Random().Next(9);

  for (int i = 0; i < 9; i++) {
    if (board[i] != Player.None)
      continue;

    Board newBoard = board.Move(player, i);
    Player newWinner = newBoard.GetWinner();

    if (newWinner == Player.None && !newBoard.Full) {
      int tempMove = GetBestMove(newBoard, Board.Other(player), out newWinner);
    }

    if (winner == Board.Other(player) || newWinner == player) {
      winner = newWinner;
      result = i;

      if (winner == player)
        break;
    }
  }

  return result;
}

JavaScript

// JavaScript code generated by DuoCode
GetBestMove = function(board, player, winner)
{
  winner.value = TicTacDuo.Board.Other(player);
  var result = -1;

  if (board.Count == 0)
    return new System.Random.ctor().Next$1(9);

  for (var i = 0; i < 9; i++) {
    if (board.get_Item(i) != 0 /* Player.None */)
      continue;

    var newBoard = board.Move(player, i);
    var newWinner = { value: newBoard.GetWinner() };

    if (newWinner.value == 0 /* Player.None */ && !newBoard.get_Full()) {
      var tempMove = TicTacDuo.AI.GetBestMove$1(newBoard, TicTacDuo.Board.Other(player), newWinner);
    }

    if (winner.value == TicTacDuo.Board.Other(player) || newWinner.value == player) {
      winner.value = newWinner.value;
      result = i;

      if (winner.value == player)
        break;
    }
  }

  return result;
};

Live Sample

Contact Us

We’d love to hear from you