Announcement

Collapse
No announcement yet.

Bridge 15.8 Bumped To 16.0

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

  • Bridge 15.8 Bumped To 16.0

    The planned 15.8 release is getting way more attention from the Bridge team than we initially envisioned. It's going to be a huge release, and includes a quickly growing list of exciting new features, as well as a few Breaking Changes that may (likely not) affect your project.

    Mostly because of the Breaking Changes, we're moving from a minor release to major release, and the next release will be Bridge 16.0. Any Issue previously tagged with the 16.0 milestone have been moved to the 17.0 milestone.

    Everything is being tracked with GitHub Issues, so feel free to review and follow along.

    The main Breaking Change involves refinements to the [ObjectLiteral] attribute, detailed in Issue #2276. A couple releases back, we added Type support to the default functionality of ObjectLiteral. Let's use the following simplified C# sample to demonstrate the differences in generated JavaScript between 15.7 and 16.0.

    http://deck.net/93ec7625835edd0429b9ca78693953b9

    Example (.cs)

    public class Program
    {
        public static void Main()
        {
            var person = new Person { Name = "Frank" };
        }
    
        [ObjectLiteral]
        public class Person
        {
            public string Name { get; set; }
        }
    }
    In Bridge 15.7, instantiating an instance of Person would generate the following JavaScript. An simple object is being created behind the scenes here, and Type information is being added to that object.

    var person = Demo.Program.Person.ctor({ name: "Frank" });
    
    // The class was also defined in JavaScript
    Bridge.define("Demo.Program.Person", {
        $literal: true
    });
    At the time we thought this was the best approach, but after living with the decision (and unforeseen consequences) for a while we had second thoughts and must simplify. Generating Object Literals using this technique, while still technically an object literal, does not reproduce the spirit of what an object literal should be.

    Refactoring has been finished, and as of Bridge 16.0 the following clean object literal syntax will be generated.

    var person = { name: "Frank" };
    
    // Now no class definition necessary!
    These changes actually revert back to the original Bridge [ObjectLiteral] functionality, so if you didn't notice the last changes, you will not be impacted by this 16.0 change either. The only scenario where these changes may affect applications is if you're checking the Type of an Object Literal instance.

    If you actually require that Type information from an Object Literal, just pass ObjectCreateMode.Constructor in the Attribute.

    [ObjectLiteral(ObjectCreateMode.Constructor)]
    public class Person
    {
        public string Name { get; set; }
    }
    There is no official release date for 16.0, but things are moving nicely, so it won't be long.
    Last edited by geoffrey.mcgill; 2017-02-07 @ 02:51 PM.
Working...
X