Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'is' keyword does not work with Retyped.dom.HTMLElement class. #3892

Closed
fabriciomurta opened this Issue Apr 3, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@fabriciomurta
Copy link
Contributor

fabriciomurta commented Apr 3, 2019

Bridge outputs javascript code that incurs in wrong results when using the is test.

Steps To Reproduce

Added the using headers and namespace paths in class references for clarity:
https://deck.net/def161316f06e378469dd4886bb5faaa

using Bridge;
using System;
using Retyped;
using static Retyped.dom;

public class Program
{
    public static void Main()
    {
        var meta = document.createElement("meta");
        
        if (meta is Retyped.dom.HTMLScriptElement element) 
        {
        	System.Console.WriteLine("I'm a script");    
        }
        else 
        {
            System.Console.WriteLine("I'm not a script");
        }
    }
}

Javascript output:

/**
 * @compiler Bridge.NET 17.7.0
 */
Bridge.assembly("Demo", function ($asm, globals) {
    "use strict";

    Bridge.define("Program", {
        main: function Main () {
            var meta = document.createElement("meta");
            var element;
            if (((element = meta)) != null) {
                System.Console.WriteLine("I'm a script");
            } else {
                System.Console.WriteLine("I'm not a script");
            }
        }
    });
});

The test ((element = meta)) != null looks like something that would work for anything we bind.

Expected Result

Outputs "I'm not a script"

Actual Result

Outputs "I'm a script"

See also

Bridge.NET forum thread: "is" keywork not working as expected

@fabriciomurta fabriciomurta added the defect label Apr 3, 2019

@fabriciomurta fabriciomurta added this to the 17.x milestone Apr 3, 2019

@fabriciomurta fabriciomurta modified the milestones: 17.x, 17.8.0 Apr 3, 2019

@vladsch

This comment has been minimized.

Copy link
Member

vladsch commented Apr 11, 2019

It is Deck issue due ExternalCastRule.Plain rule
See the result without that rule
https://deck.net/5e98a0774dbe9f512aa99983fa39bc8f

@vladsch vladsch added the in-progress label Apr 11, 2019

@fabriciomurta

This comment has been minimized.

Copy link
Contributor Author

fabriciomurta commented Apr 15, 2019

So I take it that's not supposed to work when ExternalCastAttribute is set to plain. Updated the original issue message with a reference to the thread that originated it, and also posted a follow-up in the issue.

@fabriciomurta fabriciomurta removed this from the 17.8.0 milestone Apr 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.