So, if one were to use this or something like it, how would you handle DOM interaction? Write JavaScript by hand for that, and have it call out to JSIL-generated code?
Functions can also have their body entirely replaced by a JavaScript expression, and it's done using an attribute so that it doesn't affect how your code runs in native .NET. This is used in parts of the runtime library and in some of the examples, like so:
[JSReplacement("document.getElementById('speed').innerHTML = $text")]
static void WriteSpeedText (string text) {
Debug.WriteLine(text);
}
You can also directly embed raw JavaScript into function bodies, like this: var a = 2;
var b = 5;
Verbatim.Expression("print($0 + $1)", a, b);
That allows you to embed particular JavaScript constructs that the compiler won't normally generate, call out to things like jQuery directly, etc. The downside to this is that you've now written something that won't run in any other .NET environment, but you can always wrap it in a JavaScript-only conditional.