Announcement

Collapse
No announcement yet.

[CLOSED] [#3892] "is" keywork not working as expected

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

    [CLOSED] [#3892] "is" keywork not working as expected

    In this deck.net example

    https://deck.net/32afc8529bbc3e21f628fdfb82c1a81d

    public class Program
    {
        public static void Main()
        {
            var meta = document.createElement("meta");
    
            if (meta is HTMLScriptElement element)
            {
                Console.WriteLine("I'm a script");    
            }
            else
            {
                Console.WriteLine("I'm not a script");
            }
        }
    }
    I expect the else block to execute because meta is not an HTMLScriptElement. Instead the if condition evaluates to true.
    Last edited by fabricio.murta; 2019-04-15 @ 08:46 PM.

    #2
    Hi. Thanks for the report. It does appear there is a defect here. Some form of Bridge.is(meta, HTMLScriptElement) check might be required.

    We will investigate and try to fix for the next release.

    Comment


      #3
      Thanks, I do have a workaround so this isn't high priority. I just look at tagName on the HTMLElement and do a string compare.

      Comment


        #4
        Hello @selinc!

        We've created issue #3892 a few days ago and had @vladsch take a look on it. It turns out as a situation that shouldn't work whenever the ExternalCast rule is set to plain, which is the case in Deck. See more about the rule in the wiki documentation entry for the Rules config. You can set this rule in a class level (besides whole assembly via AssemblyInfo.cs or bridge.json) like used in the Deck Vladimir shared in the issue.

        Hope this helps!

        Comment


          #5
          I'm tagging it after "closed" as we believe the rule should be set accordingly for that case to work. If you have arguments/reasons/conflicts that support the situation to work with the rules set, please let us know (probably a deck showing a conflicting situation would help), we can always reopen the issue for revisiting!

          Comment

          Working...
          X