Announcement

Collapse
No announcement yet.

[CLOSED] [#3365] [16.7.0] Bridge Name attribute overwrites generic parameter in Typescript definition : BUG?

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

    [CLOSED] [#3365] [16.7.0] Bridge Name attribute overwrites generic parameter in Typescript definition : BUG?

    There are several problems with the transformation on the given simple code:
    1. The Name attribute removes the generic on the Typescript definition.
    2. The namespace declaration is removed (and thus braces are mismatched and cause more compilation errors.
    3. The export keyword is lost on the named type (GenericNamed)
    4. The declare keyword is added to (GenericNamed: GenericNamedFunc;) because of the scope being messed up.
    Note: I'm wasn't sure if this belonged under Bug topic because its under the Premium hierarchy (the title doesn't include the premium prefix). Our company is interested in getting premium and wanted to check it out first.
    Anyway--If this should be moved please do so or indicate it so it may be moved or linked.

    using Bridge;
    
    namespace TestBridge
    {
        public class App
        {
            public static void Main()
            {
                var named = new GenericNamed<int>();
                var unnamed = new Generic<int>();
            }
        }
    
        [Name("GenericNamed")]
        public class GenericNamed<T>
        {
            public T Item;
        }
        public class Generic<T>
        {
            public T Item;
        }
    }
    This is incorrectly generated: (both on Deck.NET and my machine)
    /// <reference path="./bridge.d.ts" />
    
    interface GenericNamed {
        Item: T;
    }
    interface GenericNamedFunc extends Function {
        <T>($T: Bridge.TypeRef<T>): {
            prototype: GenericNamed;
            new (): GenericNamed;
        }
    }
    declare var GenericNamed: GenericNamedFunc;
    
    export interface Generic$1<T> {
        Item: T;
    }
    export interface Generic$1Func extends Function {
        <T>($T: Bridge.TypeRef<T>): {
            prototype: Generic$1<T>;
            new (): Generic$1<T>;
        }
    }
    var Generic$1: Generic$1Func;
    
    export interface App {
    }
    export interface AppFunc extends Function {
        prototype: App;
        new (): App;
        Main(): void;
    }
    var App: AppFunc;
    }// ### This brace here has no matching opening brace before it. It looks like the namespace{ was removed but the ending brace left in.
    Rather than the correct result:
    /// <reference path="./bridge.d.ts" />
    
    declare namespace TestBridge {
        export interface App {
        }
        export interface AppFunc extends Function {
            prototype: App;
            new (): App;
            Main(): void;
        }
        var App: AppFunc;
    
        export interface Generic$1<T> {
            Item: T;
        }
        export interface Generic$1Func extends Function {
            <T>($T: Bridge.TypeRef<T>): {
                prototype: Generic$1<T>;
                new (): Generic$1<T>;
            }
        }
        var Generic$1: Generic$1Func;
    
    export interface GenericNamed<T> {
        Item: T;
    }
    export interface GenericNamedFunc extends Function {
        <T>($T: Bridge.TypeRef<T>): {
            prototype: GenericNamed<T>;
            new (): GenericNamed<T>;
        }
    }
    var GenericNamed: GenericNamedFunc;
    
    }
    Last edited by selinc; 2018-01-12 @ 08:25 PM. Reason: Adding tags

    #2
    Hi selinc – Thanks for the report and excellent samples. We are investigating.

    Comment


      #3
      Hi,

      The Name attribute removes the generic on the Typescript definition.
      Agreed, should be fixed

      The namespace declaration is removed (and thus braces are mismatched and cause more compilation errors.
      Yes, Name attribute replaces full name of a type, it is expected behavior. If you need a namespace then need to add it to the Name attribute, like
      [Name("TestBridge.GenericNamed")]
      However, still, there are few issues in typescript definition. We will fix it but adding the namespace to the attribute is required because Name is handled like FullName.
      Can you explain about "braces are mismatched"?

      Item 3 and 4 from your list is expected because there is no namespace in your Name.

      I will add an update here when the fix will be committed to repository.

      Comment


        #4
        The namespace was removed (which is correct for the GenericNamed as you said, But the rest of the types are still in the TestBridge namespace (so it shouldn't have been removed, but rather have the GenericNamed type be moved out of the namespace).

        Regarding the mismatch-- In the second code block (the incorrect code piece), the last brace is an extra brace (presumably left over from the namespace that was removed).

        Given the new information about the namespace/Name attribute, the code I believe should be:
        /// <reference path="./bridge.d.ts" />
        
        declare namespace TestBridge {
            export interface App {
            }
            export interface AppFunc extends Function {
                prototype: App;
                new (): App;
                Main(): void;
            }
            var App: AppFunc;
        
            export interface Generic$1<T> {
                Item: T;
            }
            export interface Generic$1Func extends Function {
                <T>($T: Bridge.TypeRef<T>): {
                    prototype: Generic$1<T>;
                    new (): Generic$1<T>;
                }
            }
            var Generic$1: Generic$1Func;
        } // End namespace
        
        // GenericNamed<T> type outside of the namespace
        export interface GenericNamed<T> {
            Item: T;
        }
        export interface GenericNamedFunc extends Function {
            <T>($T: Bridge.TypeRef<T>): {
                prototype: GenericNamed<T>;
                new (): GenericNamed<T>;
            }
        }
        declare var GenericNamed: GenericNamedFunc;
        Last edited by selinc; 2018-01-14 @ 09:27 PM. Reason: Adding final correct code.

        Comment


          #5
          I see different results in deck
          https://deck.net/603128ee94a974e1c7c76508dd6b75ad

          Generic$1 class inside the namespace.

          Comment


            #6

            Hmm, it appears that the Deck.NET output is not the same as what I have installed via Visual Studio (2017).
            Deck.NET source says its on 16.6.1, mine says 16.6.0 (but the Nuget package says 16.6.1). Not sure why this is--seems inconsistent at best.
            Click image for larger version

Name:	TestBridge.png
Views:	1
Size:	83.1 KB
ID:	5132

            Comment


              #7
              Hello selinc! We've just fixed the issue Vlad agreed that should be fixed (mentioned here) is effectively fixed! It will be part of next Bridge release (currently, that would be Bridge 16.7.0).

              I see you have last posted about a problem with printed Bridge version, I'm also using Visual Studio 2017 and I get the correct output on projects linked against Bridge 16.6.1 libraries, you probably have a leftover file or not rebuilt (maybe the output changed to another file and the old was not cleaned up?). Please double check everything, I'm sure you'll find why the file was not updated (or why the built project's reference did not update to Bridge 16.6.1).

              Anyway, if you triple check that this is really an issue with Bridge 16.6.1, we're still improving our release process and there may be a fail on our part somewhere. If that's the case, please let us know in a new thread (so we keep the threads' subject focusing on a single issue).

              Thank you!

              Comment


                #8
                Okay sounds good. I'll try cleaning up and a reinstall.

                Thanks for the prompt support!

                Comment

                Working...
                X