Announcement

Collapse
No announcement yet.

[CLOSED] [#785] [1.11] Script.Write with param do escape problem with renaming variable

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

    [CLOSED] [#785] [1.11] Script.Write with param do escape problem with renaming variable

    Hi,

    As i learned, var in JavaScript are function scoped but your library does a great job to rename conflicting variable, but this can cause some problem.
            {
               var i = 1;
               var j = Script.Write<int>("i");
            }
            {
               var i = 2;
               var j = Script.Write<int>("i");
            }
    gives
                {
                    var i = 1;
                    var j = i;
                }
                {
                    var i1 = 2;
                    var j1 = i;
                }
    it should be j1 = i is bad.

    A new feature can be like :

    Script.Write<int>("{0}",i)
    Thanks to all of your work.
    Last edited by geoffrey.mcgill; 2015-12-18 @ 05:47 PM.

    #2
    Hi @Cestbienmoi,

    Thank you for pointing the problem out.

    Well, a developer can emit anything by Script.Write(). It doesn't look like there is a generic manner to control such things. Script.Write() should be used carefully.

    Could you, please, elaborate on your suggestion? What does {0} mean?
    Script.Write<int>("{0}",i)

    Comment


      #3
      I take the idea from the old script#, because variable can be renamed (it is more the case with script# that generates a special minification and the variable become $1 by example), you pass the variable (and only the variable).
      Script.Write<int>("{0}",i)
      => generates
      i
      or
      i2
      if the variable has be renamed to something else.
      {0},{1},.. is just a placeholder and a standard way in .net (and you need to dubble { } like string.Format) (if no variable, the old behaviour is used).

      Comment


        #4
        Thank you for clarifying. Created a feature issue:
        https://github.com/bridgedotnet/Bridge/issues/785
        Last edited by Daniil; 2016-01-19 @ 06:04 AM.

        Comment


          #5
          Hi Cestbienmoi,

          Thanks for this feature request. We're going to take a crack at implementing for the upcoming v1.11 release.

          Comment


            #6
            Hi Cestbienmoi ,

            We have implemeted the feature, it will be included in 1.11 release.

            Thank you for interesting suggestion.

            Comment

            Working...
            X