No announcement yet.

[FIXED] [#3886] Incorrect code when using Template for a prop w/ class initializer.

  • Filter
  • Time
  • Show
Clear All
new posts

    [FIXED] [#3886] Incorrect code when using Template for a prop w/ class initializer.

    For example if I do this

        public class Test
            public TimeSpan One {
                [Template("{this}.One = Bridge.toString({value})")]
            public TimeSpan Two {
                [Template("{this}.Two = Bridge.toString({value})")]
            public TimeSpan Three {
                [Template("{this}.Three = Bridge.toString({value})")]
    then, this

                        var test = new Test()
                            One = TimeSpan.FromDays(1),
                            Two = TimeSpan.FromDays(2),
                            Three = TimeSpan.FromDays(3)
    the generated code is this

    test = ($t = new PortalScript.Components.Ring.Test()$t.One = Bridge.toString(System.TimeSpan.fromDays(1))$t.Two = Bridge.toString(System.TimeSpan.fromDays(2))$t.Three = Bridge.toString(System.TimeSpan.fromDays(3)), $t);
    It is missing commas between property initialization.
    However if I do this

                        test.One = TimeSpan.FromDays(1);
                        test.Two = TimeSpan.FromDays(2);
                        test.Three = TimeSpan.FromDays(3);
    Everything looks fine, semi-colons are there

                                                    test.One = Bridge.toString(System.TimeSpan.fromDays(1));
                                                    test.Two = Bridge.toString(System.TimeSpan.fromDays(2));
                                                    test.Three = Bridge.toString(System.TimeSpan.fromDays(3));
    The goal of using those Template attributes is to use TimeSpan property type in the C# code but string type in the JavaScript code. It is needed for a third-party library which expects these properties to be string representations of TimeSpan, such as "1.00:00:00". Please, let me know if there is a workaround besides using non-class initializer initialization.

    Thank you
    Last edited by fabricio.murta; 2019-05-14 @ 12:12 PM.

    Hello alex4998 !

    Thanks for reporting it. No matter how I look at the report, I see a missing feature, to just prepent comma in object initializer within the code.

    I've created github issue #3886 to track this defect, and we'll post an update here as soon as we get this fixed upstream (when it will become slated to be fixed the coming release).

    Unfortunately at the moment I don't have a workaround that does not involve not using object initializer syntax.


      Hello again, alex4998 !

      We have fixed this issue and the fix is going to make it to the next, 17.8.0, Bridge release! Thanks again for reporting the issue!