Tip to avoid bug joining strings in Javascript for Metro Apps

Hi,

If anyone’s having trouble compiling a Javascript app for Metro here’s my tips:

  1. If it doesn’t compile at all with some error about “boo.lang” versions 2.0.9.5 (which it might do if you’ve upgraded your project form 3.x to 4.x):

In Visual Studio delete:
boo.lang.dll
unityScript.lang.dll
from the references.

  1. All the places where you have joined strings with a “+” change it to use String.Concat:
var a:String="Hello ";
var b:String="World!";
var c:String=a+b; //Will fail when building for Metro!!!!
var c:String=String.Concat(a,b);// Will work!!!

This is a strange bug. I would be interested just what caused this bug!!! It took me over 3 hours to work out why my app was failing!!! And it’s not easy to go over all your code to check if any of your “+”'s are actually string concats so it would be nice for a fix!

  1. Or on the other hand just use C#.

I have raised this to Unity as a bug. But hope this helps other people. If you have any other tips write them below.

Also another tip is that use:

myarray.Length

not

myarray.length

If you do all these things right then managedAssemblies.txt should not contain boo.lang.dll or unityScript.lang.dll and it should pass windows certification.

But it’s a bit of a hassle so its must better to use C sharp if you can.

Another tip is to use

function foo(s:String){
}

instead of just
function foo(s){
}

I think basically anywhere that the compiler could get confused with the syntax of adding strings etc. and it has to revert back to it’s javascript/boo methodology will cause problems. Hopefully, this will all be sorted out in a future version.