rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
153 stars 47 forks source link

stringarray field in xml are not compiled correctly #549

Closed T-Pham closed 2 years ago

T-Pham commented 2 years ago

Hi, I would like to report an issue as below.

Let's say we have a custom SceneGraph component called Animated which has a frames field of type stringarray:

<component name="Animated" extends="Poster">
  <interface>
    <field id="frames" type="stringarray" />
  </interface>
</component>

In an xml where we use Animated, we can pass in an array of strings for the frames field using double quotes within single quotes as below:

<Animated
    id="animation"
    frames='["pkg:/images/animation-1.png","pkg:/images/animation-2.png","pkg:/images/animation-3.png","pkg:/images/animation-4.png"]'
/>

This runs fine if packaged and side loaded to a Roku manually. However, when compiled with bsc command, the XML is converted to an XML with error as below. Notice the double quotes within double quotes.

 <Animated id="animation" frames="["pkg:/images/animation-1.png","pkg:/images/animation-2.png","pkg:/images/animation-3.png","pkg:/images/animation-4.png"]" translation="[554,314]" width="172" height="92" />

Attached is an example project where the issue can be reproduced: animationreprex.zip

TwitchBronBron commented 2 years ago

Thanks for the detailed writeup. This issue was fixed a while ago in the v1 alpha branch. You can get that version by running npm install brighterscript@next.

If your project doesn't use any brighterscript plugins (such as a custom plugin, or @rokucommunity/bslint), then you can switch to using the v1 branch right now with little risk.

I'll look into porting the fix back to v0 since this is a pretty bad bug.