npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mono.csharp

v0.0.1-fg

Published

Talk C# to .NET using Node. (still under development)

Downloads

8

Readme

CSharpScriptEngine 0.0.1

JOI Javascript Oriented Interoperability.

This module requires .NET 4.0 or higher. It works by starting my C# Evaluator based on Mono.CSharp from the Mono Runtime. Node will start a child REPL process. You send C# code by writing to the child's stdin and subscribe to its stdout.

Minimal

Minimal use. Define a string in C# environment.

const CSharpScriptEngine = require('mono.csharp')

let CSE = new CSharpScriptEngine()
CSE.on('data', data => {
	console.log(data)
})
CSE.write('string MyName = "Jochem Stoel";')

Less Minimal

Load assemblies programatically and inhabit their namespace.

/* IPC using CSE */
let CSE = new CSharpScriptEngine()

/* handle however you feel */
function handle(data) {
	console.log(data)
}

/* sends "using $namespace" to process stdin */
CSE.using('System')
CSE.using('System.IO')
CSE.loadAssembly('MyFile.dll')
CSE.using('MyNamespace')

CSE.write('int x = 4;')

/* data is a console line */
CSE.on('data', data => {
	handle(data)
})

/* initiate dialog with user/client */
CSE.REPL()

Methods

Using(namespace)

using will simply prepend "using " before line and append ";" after line before sending to stdin. Basically CSE.using('System.IO') is the same as CSE.write('using System.IO;')

/* can be written as chain */
CSE.using('System').using('System.IO').using('System.Reflection') ...

/* suggested way */
CSE.using('System.IO')
	.using('System.Windows.Forms')
	.loadAssembly('MyLibrary.dll')
	.using('MyNameSpace')
	.using('MyNameSpace.SubSpace')
	.write('var MyObj = new MyObject();')
.done()

on(what, that)

wrap child_process.stdout.on to on()

write(line)

write line to CSE process stdin

REPL(void)

initiate REPL dialog with user/client

done nothing more to do

kill the child

Random technical details that could be useful

When CSE.exe evaluates an expression, it will stdout print "true" if it parsed correctly or "false" when you forget a semi colon or whatever. You can use this in your on.data event handler to determine what is happening.

If you want, you could prototype a method "getVar" that sends Console.WriteLine(varName.toString()) to the child process and then catch it with your handler function.

This package/module is experimental in general implementation as well as for myself. I strongly advise not to implement this in real world applications. However, if you do find a useful purpose for it or want to contribute, don't be shy and email me jochemstoel(@)gmail.com. That is after all why I publish these things in the first place.

Jochem Stoel

Involuntary public figure.