Replies: 1 comment
-
Thanks for following up.
It's simply a matter of testing. An |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When calling C# code from Javascript one can send objects as parameters.
These objects get translated to C# as
System.Dynamic.ExpandoObject
instances.The types of these properties are inferred by the
SerializeV8Object
method inCefSharp.BrowserSubprocess.Core\Serialization\V8Serialization.cpp
.If setting a numeric property's value to something that fits into 32 bits, the property's type is inferred to be
System.Int32
.If the value is greater than 2147483647 (which is 2^31-1) then the value is mistakenly interpreted to be a negative number:
2147483647
is correctly seen as2147483647
2147483648
is incorrectly seen as-2147483648
2147483649
is incorrectly seen as-2147483647
and so onOne can easily test this by evaluating the following code in the CefSharp.Wpf.Example project, under "Evaluate Javascript (Async)"
(() => { var a = { s: 2147483648 }; return a.s; })()
and see that the result is a negative number.
@amaitland has suggested a workaround in a discussion in Gitter:
which does the trick in both the code I posted above, and my team's specific case.
Seeing as Javascript always treats numbers as double anyway, is there a reason not to apply the suggested fix?
I can create a pull request if need be, just wondering if/what I'm missing.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions