Announcement

Collapse
No announcement yet.

Why 'XXX is marked as not usable from script'?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Why 'XXX is marked as not usable from script'?

    ... where 'XXX':
    - System.Threading.Interlocked (.CompareExchange method)
    - System.Threading.Monitor (.Enter and .Exit methods)

    We all understand that JavaScript is single threaded and methods above do not provide much value. However, at the same time they 'would not hurt' if they did what would be expected in a single thread environment which is:
    - System.Threading.Interlocked.CompareExchange = compare and set variable
    - System.Threading.Monitor.Enter/.Exit = just do nothing

    But the Bridge.NET compiler is giving me some headache as I now needed to find replacements for the code which makes perfect sense in the .NET world. More so, I even can't code up simple System.Threading.Interlocked/.Monitor classes, since there already are equivalents in Bridge which would prevent the code compiling.

    Instead of throwing 'is marked as not usable from script' exceptions, wouldn't it rather make sense to either:
    - have Bridge.NET support a class/method/... and do "what's expected" OR
    - not provide support at all and leave it to the user to code up replacements as needed (which I'm doing with other classes)
    Preventing compilation and not allowing to code up replacements is the worst choice in my eyes.

    What am I missing?

    #2
    I would appreciate any feedback on issue above. Thanks

    Comment


      #3
      We haven't had a chance to review or implement the System.Threading namespace.

      Preventing compilation and not allowing to code up replacements is the worst choice in my eyes.
      I'm not entirely sure what this means, but you are always free to implement the functionality if you require.

      Comment


        #4
        geoffrey.mcgill I don't think we're on the same page
        >> you are always free to implement the functionality if you require
        What I'm saying is that Bridge.NET prevents me exactly doing that.

        Here is why, let's take a look at the Interlocked.CompareExchange sample:
        a) if I would be using the Interlocked class as implemented by Bridge.NET then I would get
         Error: Type System.Threading.Interlocked is marked as not usable from script    at Bridge.Contract.BridgeTypes.ToJsName(IType type, IEmitter emitter, Boolean asDefinition, Boolean excludens, Boolean isAlias, Boolean skipMethodTypeParam, Boolean removeScope, Boolean nomodule, Boolean ignoreLiteralName)
        b) If I would code my own Interlocked class (+ .CompareExchange method) then I would get this error:
         The type 'Interlocked' in 'C:\Users\DDroth\Documents\NinjaTrader.8\NinjaTrader.Web\BridgeTheGap\Misc.cs' conflicts with the imported type 'Interlocked' in 'Bridge, Version=16.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\DDroth\Documents\NinjaTrader.8\NinjaTrader.Web\BridgeTheGap\Misc.cs'.
        So my only option is coding 'MyInterlocked' and replace all occurances of Interlocked in my code by 'MyInterlocked' which is bad.

        Hence, what I'm suggesting is: either Bridge.NET should implement a class/method which works 'as expected' (within JavaScript limitations) or leave it to the user to code up their own implementation. But it should not prevent the user coding up the missing functionality using the proper class/method names and signatures.

        Comment


          #5
          The reason why we included those Threading classes is that it is required to correct functionality of VS/msbuild (otherwise some errors appear during compilation)
          The reason why it is marked as NonScriptable is that we have no implementation in javascript, therefore, you cannot use it in your code (otherwise, you will get javascript errors).

          Once an implementation will be provided (via pull request, for example) then you will be able to use it

          Comment


            #6
            Understand, thanks

            I then suggest providing implementations for the methods as outlined in my original post.

            Comment

            Working...
            X