mgusmano / sharpkit

Automatically exported from code.google.com/p/sharpkit
0 stars 0 forks source link

JS instanceof issue against C# is #227

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Js:
"foo" instanceof String //=> false
"foo" instanceof Object //=> false
true instanceof Boolean //=> false
true instanceof Object //=> false
false instanceof Boolean //=> false
false instanceof Object //=> false
link: 
http://stackoverflow.com/questions/203739/why-does-instanceof-return-false-for-s
ome-literals

while in c#
all should return true

C# example:
var b = "aaaa";
return (b is JsString); // should return true but return false

Original issue reported on code.google.com by Madnik7@gmail.com on 28 Sep 2012 at 6:41

GoogleCodeExporter commented 8 years ago

Original comment by yvan.rod...@gmail.com on 5 Dec 2012 at 5:03

GoogleCodeExporter commented 8 years ago
The native js types are currently configured to generate standard 'instanceof' 
when using the 'is' keyword on them. This behavior can be configured 
differently in any project, but currently, 'is' converts to 'instanceof' with 
any js issues related to it.  You can remove this behavior, and then implement 
the 'Is()' global method instead.
Please confirm before I close this issue.

Original comment by DanelK...@gmail.com on 18 Dec 2012 at 3:08

GoogleCodeExporter commented 8 years ago
How can I force SharpKit to use Is() in all types in project?

Original comment by Madnik7@gmail.com on 18 Dec 2012 at 3:11

GoogleCodeExporter commented 8 years ago
You should set NativeCasts=false on types that you wish to disable it. For 
native types, you might have to compile your own SharpKit.JavaScript.

Original comment by DanelK...@gmail.com on 18 Dec 2012 at 3:54

GoogleCodeExporter commented 8 years ago
Hi,
>> For native types, you might have to compile your own.

It is really not a solution, we constantly got your latest version and don't 
want to work with an un-official version. that solution may useful for 
single-time usage!
Wish you provide an attribute in assembly level. 
Regards

Original comment by Madnik7@gmail.com on 18 Dec 2012 at 3:57