I'm trying to get started with JSIL. I've followed the directions as far as I understand. I have a very basic C# dummy project with the code:
namespace TestLib
{
public class MagicType
{
public int Multiply(int x, int y)
{ // test instance method
return x * y;
}
public static int Add(int x, int y)
{// test static int method
return x + y;
}
}
}
I've compiled this with jsilc
, and created a website that hosts this along with the jsil scripts. My html initializes this:
<script type="text/javascript">
var jsilConfig = {
libraryRoot: '/js/jsil/',
scriptRoot: '/js/testlib/',
manifestRoot: '/js/testlib/',
manifests: ['TestLib.dll'] // gets as far as Loading '/js/testlib/TestLib.dll.manifest.js'...
// which is 200 / OK
};
var asm = null;
var runMain = function () { // doesn't get invoked
console.log('> main');
asm = JSIL.GetAssembly("TestLib", true); // (executed outside method) returns a stub with no content
console.log('< main');
};
</script>
<script src="/js/jsil/jsil.js"></script>
but... I can't access the library. The console output indicates that it is loading:
Loading '/js/testlib/TestLib.dll.manifest.js'...
which is a 200 OK. However, I can't access it. If I run:
var asm = JSIL.GetAssembly("TestLib", true);
then I get back a stub to the library, but it doesn't have anything in it. There's a asm.$typesByName
, but that is an empty object. What I want to do (to see it work) is to call the Multiply
and Add
methods.
So: what am I missing? my intent is to host a transpiled library that I can access through js, which is as I understand it: possible. I just can't make it work. I have uploaded my entire test project here: https://github.com/mgravell/jsilfun