sq / JSIL

CIL to Javascript Compiler
http://jsil.org/
Other
1.73k stars 240 forks source link

Could not find the name 'Microsoft' in the namespace '<Microsoft.CSharp, ... #1002

Open wklingler opened 8 years ago

wklingler commented 8 years ago

I'm sure I am just missing something but my project builds and all the js code is written but when I run it in a browser I get the error that is the title of this issue. Do you know why this might be happening?

iskiselev commented 8 years ago

Could you check what lines in original source ends with this exception or at least which JS lines are responsible for it?

iskiselev commented 8 years ago

It would also helps if you would provide full error text.

wklingler commented 8 years ago

The stack trace is: makeError in JSIL.Core.js:1063 JSIL.ResolveName in JSIL.Core.js:1071 JSIL.MakeTypeAlias in JSIL.Core.js:5316 (anonymous function) in Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PulicKeyToken=b03f5f7f11d50a3a.js:6

And the full error text is: Could not find the name 'Microsoft' in the namespace '<Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PulicKeyToken=b03f5f7f11d50a3a Public Interface>'

I hope that is what you are looking for

wklingler commented 8 years ago

It looks like I can't use the characters '<' and '>' in this comment block so the full error text without those two characters is Uncaught Error: Could not find the name 'Microsoft' in the namespace 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Public Interface'.

iskiselev commented 8 years ago

Unfortunately I'm unable to guess what have happened. Could you give me you translated source with html startup page?

wklingler commented 8 years ago

Sadly I can't do that (company policy). I can tell you that this is the start of the Microsoft.CSharp file that was translated

/* Generated by JSIL v0.8.2 build 26644. See http://jsil.org/ for more information. / 'use strict'; / Generating type stubs only */ var $asm00 = JSIL.DeclareAssembly("Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");

JSIL.MakeTypeAlias($jsilcore, "Microsoft.CSharp.RuntimeBinder.Binder");

JSIL.DeclareNamespace("Microsoft"); JSIL.DeclareNamespace("Microsoft.CSharp"); JSIL.DeclareNamespace("Microsoft.CSharp.RuntimeBinder"); /* class Microsoft.CSharp.RuntimeBinder.BinderHelper */

As you can see the namespace 'Microsoft' is clearly declared so I'm stumped. I realize that you might not be able to help me any further because I can't give you the translated code so just let me know if you can or can't. Thanks

kg commented 8 years ago

Are there any preceding errors in the console? If something else failed it's possible it stopped the assembly from loading, so the namespace can't be resolved.

wklingler commented 8 years ago

No, that is the first error in the console

wklingler commented 8 years ago

Another odd thing is that one of my coworkers got this working last year in January so I just updated our JSIL code (and that's when this error started) and now the line "Builtins.Global["window"].alert(errorMsg) and "Builtins.Global["window"].confirm(notificationMsg)" errors out when it didn't used to before. The error is that there is no function 'alert' or 'confirm' on the object. Have you ever seen that?

iskiselev commented 8 years ago

Have you updated both JSIL and it's Libraries?

wklingler commented 8 years ago

Yeah, I actually just created a new local repository and pulled down the code from this repo then pulled down the submodules. I followed the steps in the wiki. Now I have two JSIL repos but only the new one actually builds and only the old one actually works (the old has all the needed files in it so I don't have to build it)

iskiselev commented 8 years ago

Your HTML page loads some js files, that was located in JSIL/Libraries folder. New version comes with new files. Please check, that you have updated path to Libraries (or copied them) and that you don't use them from old JSIL location.

wklingler commented 8 years ago

The only thing we have ever loaded in our HTML file is JSIL.js and the way we have our build working is that when we build our c# code a bat file is run that deletes everything in the web directory and rewrites everything it needs back into that directory through environment variables set on our computers so I know those always get updated every time we build our code as long as I have remembered to update the environment variable (which I have)

wklingler commented 8 years ago

It looks like the line JSIL.MakeTypeAlias($jsilcore, "Microsoft.CSharp.RuntimeBinder.Binder"); is not placed in the right location because it comes before the namespaces are declared.

/* Generated by JSIL v0.8.2 build 26644. See http://jsil.org/ for more information. / 'use strict'; / Generating type stubs only */ var $asm00 = JSIL.DeclareAssembly("Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");

JSIL.MakeTypeAlias($jsilcore, "Microsoft.CSharp.RuntimeBinder.Binder");

JSIL.DeclareNamespace("Microsoft"); JSIL.DeclareNamespace("Microsoft.CSharp"); JSIL.DeclareNamespace("Microsoft.CSharp.RuntimeBinder"); /* class Microsoft.CSharp.RuntimeBinder.BinderHelper */

so that makes sense that it is failing but why is the file being generated like that now when it wasn't before. With the old repo (that doesn't error) I have this is what the start of that file looks like:

/* Generated by JSIL v0.8.2 build 25664. See http://jsil.org/ for more information. / 'use strict'; / Generating type stubs only */ var $asm00 = JSIL.DeclareAssembly("Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");

JSIL.DeclareNamespace("Microsoft"); JSIL.DeclareNamespace("Microsoft.CSharp"); JSIL.DeclareNamespace("Microsoft.CSharp.RuntimeBinder"); /* class Microsoft.CSharp.RuntimeBinder.Binder */

(function Binder$Members () { var $, $thisType;

JSIL.MakeStaticClass("Microsoft.CSharp.RuntimeBinder.Binder", true, [], function ($ib) {

wklingler commented 8 years ago

If I move that line below the namespace declarations then I don't get that error anymore, btw.

iskiselev commented 8 years ago

Thank you for your investigation. I'll look on it and will try fix in next days.

wklingler commented 8 years ago

Okay, now that I got past that I'm getting a TypeError that says JSIL.MethodPointerInfo is not a constructor. Any ideas for fixing that? It errors when new JSIL.MethodPointerInfo is called in this static constructor:

`function AppDocument__cctor () {

  $T00().FramerImpl = $T01().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewFramer", $S00(), true, false));

  $T00().ASV2InteriorLineFinderImpl = $T02().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewASV2InteriorLineFinder", $S01(), true, false));

  $T00().CopyGroupsAndSectorsImpl = $T03().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewCopyGroupsAndSectors", $S02(), true, false));

  $T00().CopyPrimImpl = $T04().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewCopyPrim", $S03(), true, false));

  $T00().CoverFloorDisplayImpl = $T05().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewCoverFloorDisplay", $S04(), true, false));

  $T00().CoverFloorImpl = $T06().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewCoverFloor", $S05(), true, false));

  $T00().CreateRoofsImpl = $T07().New(null, null, new JSIL.MethodPointerInfo($thisType, "CreateRoofs", $S06(), true, false));

  $T00().DrawWallOpeningImpl = $T08().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewDrawWallOpening", $S07(), true, false));

  $T00().MoveFreeWallPrimImpl = $T09().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewMoveFreeWallPrim", $S08(), true, false));

  $T00().ProcessRoofResultsImpl = $T0A().New(null, null, new JSIL.MethodPointerInfo($thisType, "ProcessRoofResults", $S09(), true, false));

  $T00().ConvertRWF = $T0B().New(null, null, new JSIL.MethodPointerInfo($thisType, "ConvertRWF", $S0A(), true, false));

  $T00().RITestResultImpl = $T0C().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewRITestResult", $S0B(), true, false));

  $T00().ScopeImpl = $T0D().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewScopePrim", $S0C(), true, false));

  $T00().SectorContainedAlgorithmImpl = $T0E().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewSectorContainedAlgorithm", $S0D(), true, false));

  $T00().SectorUpdateImpl = $T0F().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewSectorUpdate", $S0E(), true, false));

  $T00().SvgDrawImpl = $T10().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewSvgDraw", $S0F(), true, false));

  $T00().ValidateDistanceImpl = $T11().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewValidateDistance", $S10(), true, false));

  $T00().ValidateRefPointImpl = $T12().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewValidateRefPoint", $S11(), true, false));

  $T00().ValidateSectorOnWallImpl = $T13().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewValidateSectorOnWall", $S12(), true, false));

  $T00().ValidateTempSectorInRoomImpl = $T14().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewValidateTempSectorInRoom", $S13(), true, false));

  $T00().ValidateWallIntersectionImpl = $T15().New(null, null, new JSIL.MethodPointerInfo($thisType, "NewValidateWallIntersection", $S14(), true, false));

  $T00().WallGrowImpl = $T16().New(null, null, new JSIL.MethodPointerInfo($thisType, "WallGrow", $S15(), true, false));

};`

`$.Method({Static:true , Public:false}, ".cctor", 
  JSIL.MethodSignature.Void, 
  AppDocument__cctor
);`
wklingler commented 8 years ago

Never mind, it looks like you may have been right about the correct libraries being moved over to the web directory. I need to look into it even further so hold off looking at this until I get back with you.

wklingler commented 8 years ago

In my bat file I do 'jsilc path\to\exe.exe -o path\to\web\dir. Does that not grab all the needed files from the same base directory that jsilc is found in?

iskiselev commented 8 years ago

No, today JSIL doesn't copy libraries. Your command line only execute translation of your program, you still need to copy Libraries to correct place. It may be not path\to\web\dir, but some other path - you should check it in your config.

wklingler commented 8 years ago

Okay, I misunderstood that whole process. Now that I have the correct files the MethodPointerInfo error is gone but the Microsoft.CSharp file still gets generated the same way as before which still throws that exception.

wklingler commented 8 years ago

Now I'm getting this error: Method not found: void System.Collections.Generic.List`1[Sketch.Sys.PointD].I415$CopyTo(Sketch.Sys.PointD[], System.Int32) at Object.JSIL.Host.warning (http://localhost/js/JSIL.Host.js:158:22) at makeSingleMethodGroup (http://localhost/js/JSIL.Core.js:3954:17) at Object.JSIL.$MakeMethodGroup (http://localhost/js/JSIL.Core.js:4188:14) at Object.GetMethodGroup (http://localhost/js/JSIL.Core.js:3353:18) at Object.LazyValueProperty_Get as I415$CopyTo at hasNonPlaceholder (http://localhost/js/JSIL.Core.js:3127:22) at Object.JSIL.FixupInterfaces (http://localhost/js/JSIL.Core.js:3157:9) at http://localhost/js/JSIL.Core.js:4626:16 at Object.JSIL.RunStaticConstructors (http://localhost/js/JSIL.Core.js:4733:7

I don't see any of my files in that stack trace so is this something on JSIL that is failing? From what I can tell, this is a new function call. The old repo that I have fro JSIL never even calls the I415$CopyTo function. What are your thoughts?

BTW, I'm not getting the error that this whole issue was originally about anymore. I don't know why thought.

iskiselev commented 8 years ago

@wklingler, I suppose that last issue may be connected with my last changes. Please update to: https://github.com/sq/JSIL/commit/5c92bdb68373116bb5ca0aff229d00949b59414d It should be before this changes, so probably it will solve your issue.

I'm now working on more changes that should also resolve your last issue. I've not yet looked on original issue.

wklingler commented 8 years ago

That did fix the latest issue by going back to that commit but now I'm getting a Binary Operation is not supported error. Have you come across that yet?

iskiselev commented 8 years ago

Would you be able to extract small example to reproduce it?

wklingler commented 8 years ago

I'll see what I can do. It happens when I try to get the position of a mouse click on a canvas. I'll try to come up with an example for you.

wklingler commented 8 years ago

Before I create an example, here is sample code of the old translation (using the older JSIL version I have) and the new translation.

The c# code:

private dynamic GetCanvasPosition(dynamic e)
        {
            var element = e.currentTarget;
            var xPosition = 0;
            var yPosition = 0;

            while (element != null)
            {
                xPosition += (element.offsetLeft - element.scrollLeft + element.clientLeft);
                yPosition += (element.offsetTop - element.scrollTop + element.clientTop);
                element = element.offsetParent;
            }
            dynamic ret = new System.Dynamic.ExpandoObject();
            ret.X = e.clientX - xPosition;       // Maybe pageX instead of clientX?
            ret.Y = e.clientY - yPosition;
            return ret;
        }

Old translation:

  function Workspace_GetCanvasPosition (e) {
    var element = e.currentTarget;
    var xPosition = 0;
    var yPosition = 0;

  $loop0: 
    while (true) {
      if (element === null) {
        break $loop0;
      }
      var arg_285_2 = xPosition;
      var arg_22B_2 = element.offsetLeft;
      var arg_280_2 = arg_22B_2 - element.scrollLeft;
      xPosition = $T13().$Cast(arg_285_2 += arg_280_2 + element.clientLeft);
      var arg_4BB_2 = yPosition;
      var arg_461_2 = element.offsetTop;
      var arg_4B6_2 = arg_461_2 - element.scrollTop;
      yPosition = $T13().$Cast(arg_4BB_2 += arg_4B6_2 + element.clientTop);
      element = element.offsetParent;
    }
    var ret = new ($T20())();
    ret.X = e.clientX - xPosition;
    ret.Y = e.clientY - yPosition;
    return ret;
  }; 

New translation:

  function Workspace_GetCanvasPosition (e) {
    if ($T67().$l$gp__Site130 === null) {
      $T67().$l$gp__Site130 = $T2C().Create($T07().GetMember($T08().None, "currentTarget", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null)])));
    }
    var element = $T67().$l$gp__Site130.Target($T67().$l$gp__Site130, e);
    var xPosition = 0;
    var yPosition = 0;

  $loop0: 
    while (true) {
      if ($T67().$l$gp__Site140 === null) {
        $T67().$l$gp__Site140 = $T28().Create($T07().UnaryOperation($T08().None, $T29().IsTrue, $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null)])));
      }
      var arg_5B7_0 = $T67().$l$gp__Site140.Target;
      var arg_5B7_1 = $T67().$l$gp__Site140;
      if ($T67().$l$gp__Site141 === null) {
        $T67().$l$gp__Site141 = $T45().Create($T07().BinaryOperation($T08().None, $T29().NotEqual, $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null), $T09().Create($T0A().Constant, null)])));
      }
      if (!arg_5B7_0(arg_5B7_1, $T67().$l$gp__Site141.Target($T67().$l$gp__Site141, element, null))) {
        break $loop0;
      }
      if ($T67().$l$gp__Site131 === null) {
        $T67().$l$gp__Site131 = $T68().Create($T07().Convert($T08().ConvertExplicit, $T02().__Type__, $thisType.__Type__));
      }
      var arg_28A_1 = $T67().$l$gp__Site131;
      if ($T67().$l$gp__Site132 === null) {
        $T67().$l$gp__Site132 = $T4B().Create($T07().BinaryOperation($T08().None, $T29().AddAssign, $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().UseCompileTimeType, null), $T09().Create($T0A().None, null)])));
      }
      var arg_285_1 = $T67().$l$gp__Site132;
      var arg_285_2 = xPosition;
      if ($T67().$l$gp__Site133 === null) {
        $T67().$l$gp__Site133 = $T45().Create($T07().BinaryOperation($T08().None, $T29().Add, $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null), $T09().Create($T0A().None, null)])));
      }
      var arg_280_1 = $T67().$l$gp__Site133;
      if ($T67().$l$gp__Site134 === null) {
        $T67().$l$gp__Site134 = $T45().Create($T07().BinaryOperation($T08().None, $T29().Subtract, $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null), $T09().Create($T0A().None, null)])));
      }
      var arg_22B_0 = $T67().$l$gp__Site134.Target;
      var arg_22B_1 = $T67().$l$gp__Site134;
      if ($T67().$l$gp__Site135 === null) {
        $T67().$l$gp__Site135 = $T2C().Create($T07().GetMember($T08().None, "offsetLeft", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null)])));
      }
      var arg_22B_2 = $T67().$l$gp__Site135.Target($T67().$l$gp__Site135, element);
      if ($T67().$l$gp__Site136 === null) {
        $T67().$l$gp__Site136 = $T2C().Create($T07().GetMember($T08().None, "scrollLeft", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null)])));
      }
      var arg_280_2 = arg_22B_0(arg_22B_1, arg_22B_2, $T67().$l$gp__Site136.Target($T67().$l$gp__Site136, element));
      if ($T67().$l$gp__Site137 === null) {
        $T67().$l$gp__Site137 = $T2C().Create($T07().GetMember($T08().None, "clientLeft", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null)])));
      }
      xPosition = ($T67().$l$gp__Site131.Target(arg_28A_1, $T67().$l$gp__Site132.Target(arg_285_1, arg_285_2, $T67().$l$gp__Site133.Target(arg_280_1, arg_280_2, $T67().$l$gp__Site137.Target($T67().$l$gp__Site137, element)))) | 0);
      if ($T67().$l$gp__Site138 === null) {
        $T67().$l$gp__Site138 = $T68().Create($T07().Convert($T08().ConvertExplicit, $T02().__Type__, $thisType.__Type__));
      }
      var arg_4C0_1 = $T67().$l$gp__Site138;
      if ($T67().$l$gp__Site139 === null) {
        $T67().$l$gp__Site139 = $T4B().Create($T07().BinaryOperation($T08().None, $T29().AddAssign, $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().UseCompileTimeType, null), $T09().Create($T0A().None, null)])));
      }
      var arg_4BB_1 = $T67().$l$gp__Site139;
      var arg_4BB_2 = yPosition;
      if ($T67().$l$gp__Site13a === null) {
        $T67().$l$gp__Site13a = $T45().Create($T07().BinaryOperation($T08().None, $T29().Add, $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null), $T09().Create($T0A().None, null)])));
      }
      var arg_4B6_1 = $T67().$l$gp__Site13a;
      if ($T67().$l$gp__Site13b === null) {
        $T67().$l$gp__Site13b = $T45().Create($T07().BinaryOperation($T08().None, $T29().Subtract, $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null), $T09().Create($T0A().None, null)])));
      }
      var arg_461_0 = $T67().$l$gp__Site13b.Target;
      var arg_461_1 = $T67().$l$gp__Site13b;
      if ($T67().$l$gp__Site13c === null) {
        $T67().$l$gp__Site13c = $T2C().Create($T07().GetMember($T08().None, "offsetTop", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null)])));
      }
      var arg_461_2 = $T67().$l$gp__Site13c.Target($T67().$l$gp__Site13c, element);
      if ($T67().$l$gp__Site13d === null) {
        $T67().$l$gp__Site13d = $T2C().Create($T07().GetMember($T08().None, "scrollTop", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null)])));
      }
      var arg_4B6_2 = arg_461_0(arg_461_1, arg_461_2, $T67().$l$gp__Site13d.Target($T67().$l$gp__Site13d, element));
      if ($T67().$l$gp__Site13e === null) {
        $T67().$l$gp__Site13e = $T2C().Create($T07().GetMember($T08().None, "clientTop", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null)])));
      }
      yPosition = ($T67().$l$gp__Site138.Target(arg_4C0_1, $T67().$l$gp__Site139.Target(arg_4BB_1, arg_4BB_2, $T67().$l$gp__Site13a.Target(arg_4B6_1, arg_4B6_2, $T67().$l$gp__Site13e.Target($T67().$l$gp__Site13e, element)))) | 0);
      if ($T67().$l$gp__Site13f === null) {
        $T67().$l$gp__Site13f = $T2C().Create($T07().GetMember($T08().None, "offsetParent", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null)])));
      }
      element = $T67().$l$gp__Site13f.Target($T67().$l$gp__Site13f, element);
    }
    var ret = new ($T6A())();
    if ($T67().$l$gp__Site142 === null) {
      $T67().$l$gp__Site142 = $T45().Create($T07().SetMember($T08().None, "X", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null), $T09().Create($T0A().None, null)])));
    }
    var arg_6C5_0 = $T67().$l$gp__Site142.Target;
    var arg_6C5_1 = $T67().$l$gp__Site142;
    if ($T67().$l$gp__Site143 === null) {
      $T67().$l$gp__Site143 = $T48().Create($T07().BinaryOperation($T08().None, $T29().Subtract, $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null), $T09().Create($T0A().UseCompileTimeType, null)])));
    }
    var arg_6C0_0 = $T67().$l$gp__Site143.Target;
    var arg_6C0_1 = $T67().$l$gp__Site143;
    if ($T67().$l$gp__Site144 === null) {
      $T67().$l$gp__Site144 = $T2C().Create($T07().GetMember($T08().None, "clientX", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null)])));
    }
    arg_6C5_0(arg_6C5_1, ret, arg_6C0_0(arg_6C0_1, $T67().$l$gp__Site144.Target($T67().$l$gp__Site144, e), xPosition));
    if ($T67().$l$gp__Site145 === null) {
      $T67().$l$gp__Site145 = $T45().Create($T07().SetMember($T08().None, "Y", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null), $T09().Create($T0A().None, null)])));
    }
    var arg_7C9_0 = $T67().$l$gp__Site145.Target;
    var arg_7C9_1 = $T67().$l$gp__Site145;
    if ($T67().$l$gp__Site146 === null) {
      $T67().$l$gp__Site146 = $T48().Create($T07().BinaryOperation($T08().None, $T29().Subtract, $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null), $T09().Create($T0A().UseCompileTimeType, null)])));
    }
    var arg_7C4_0 = $T67().$l$gp__Site146.Target;
    var arg_7C4_1 = $T67().$l$gp__Site146;
    if ($T67().$l$gp__Site147 === null) {
      $T67().$l$gp__Site147 = $T2C().Create($T07().GetMember($T08().None, "clientY", $thisType.__Type__, JSIL.Array.New($T09(), [$T09().Create($T0A().None, null)])));
    }
    arg_7C9_0(arg_7C9_1, ret, arg_7C4_0(arg_7C4_1, $T67().$l$gp__Site147.Target($T67().$l$gp__Site147, e), yPosition));
    return ret;
  }; 
iskiselev commented 8 years ago

Could you additionally provide line which results in BinOp not supported result? Easies way to solve it - get rid of dynamic as soon as possible. It will be much better if you return PointD or Tuple<double, double> from Workspace.GetCanvasPosition

iskiselev commented 8 years ago

For now, please change:

while (element != null)
            {
                xPosition += (element.offsetLeft - element.scrollLeft + element.clientLeft);
                yPosition += (element.offsetTop - element.scrollTop + element.clientTop);
                element = element.offsetParent;
            }

Into:

while (element != null)
            {
                xPosition = xPosition + (element.offsetLeft - element.scrollLeft + element.clientLeft);
                yPosition = yPosition + (element.offsetTop - element.scrollTop + element.clientTop);
                element = element.offsetParent;
            }
wklingler commented 8 years ago

Is it better to avoid dynamic for everything even params or just return values?

iskiselev commented 8 years ago

Before JSIL tried to decompile C# dynamic construct back to it's code form. It was not correct for some dynamic code and it hasn't support Roslyn. So, some time ago I implemented some parts of C# binder, that support most of simple dynamic operations and disabled special translation for dynamic, so that it looks in translated code same way as it looks in C#. It means that it will also be much slower than non-dynamic version (but it could be ignored on non-hot path). I personally prefer to not use dynamic when it could be easilly solved with non-dynamic version, as even one using of dynamic may slow down entire function. It's your choice whether to use it or not, and at some point JSIL should support any form that C# supports, but now it doesn't support asiign-modify operations and constructor invocations.

wklingler commented 8 years ago

I tried making the changes you suggested but the only thing that seemed to work was changing the while loop code. If I use PointD or Tuple then the function InvokeConstructor is called which is hard coded to throw a not implemented exception so that solution didn't work. This is in the Microsoft.CSharp.RuntimeBinder.Binder.js and JSIL.Bootstrap.Dynamic.js

$.RawMethod(true, "InvokeConstructor",
    function(flags, context, argumentInfo) {
      throw new Error("Not implemented");
    });

My application is now working again with the updated JSIL code. Thank you for all your help

wklingler commented 8 years ago

Is better to avoid the += operator too? This is the first time I had problems with it.