A simple wrapper around mono utilities that allows you to compile and run your C# app from source.
npm install node-csharp
mono and mcs in your path. To install package run:var nodeCSharp = require('../lib/nodeCSharp');
var sourceProgram = public class Hello1;
{
public static void Main()
{
System.Console.WriteLine("Hello, World!");
}
}
nodeCSharp.fromSource(sourceProgram, {}, (err, res) => {
console.log(res);
});
You can also pass input stream:
var nodeCSharp = require('../lib/nodeCSharp');
var s2str = require('string-to-stream');
var sourceProgram = public class Hello1;
{
public static void Main()
{
var readLine = System.Console.ReadLine();
System.Console.WriteLine(readLine.ToUpper());
}
}
var stdin = s2str("Hello node-csharp!");
nodeCSharp.fromSource(sourceProgram, {stdin}, (err, res) => {
console.log(res);
});
node-csharp is just a wrapper on top of mono so it expects standard Main method.