-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
v5.0.0 compatible with PuppeteerSharp >= 19.0.2 and tested #2
Conversation
PuppeteerSharp => 19.0.0 removed Newtonsoft.Json dependency * Update and fix * Bump PuppeteerSharp.Dom version
Update tests to use System.Text.Json
PuppeteerSharp use types of variables from JS (maybe due to transfer from Newtonsoft.Json to System.Text.Json) so it's not working and actually it make sense since C# is stronly typed Try to parse evaluation result to requested generic type
Optimize code Make public static
Use ParseJSValueTo to parse evaluation result
Missing ConfigureAwait
Unused using
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR 👍
Comments inline.
Given we are no responsible for type cohesion, I think whatever implementation is chosen we should look at allowing the user an extension point to hook the conversion and customize it. There are likely many changes in behavior that will be hard to account for.
|
||
## Values parsing | ||
|
||
**PuppeteerSharp** considers variable types from within JavaScript when requesting typed values on pages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure what you mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chech on this
hardkoded/puppeteer-sharp#2805
await page.EvaluateFunctionAsync<int>("() => '123'") dont work but
await page.EvaluateFunctionAsync<int>("() => Number('123')") works
And there's said
That's part of switching to
System.Text.Json
in v19.System.Text.Json
is more strict than Newtonsoft.
} | ||
var valueIsNull = value == null || value.Value.ValueKind == JsonValueKind.Null || value.Value.ValueKind == JsonValueKind.Undefined; | ||
var nullable = returnType.IsClass; | ||
if (Nullable.GetUnderlyingType(returnType) != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nullable.GetUnderlyingType
needs to only be called once and result stored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My laziness, though I'm not sure if it's really necessary. I believe that code like this is optimized during compilation. Is it not?
There was few reasons why I choose to manually cast. I suggested that there are few cases that will hit more often than other considering library wrappings so I play with order, however I didnt run any tests at that matter To be honest, I just wanted to fix it quickly and make it good enough so that if someone wants to improve code itself or performance, they can do it themselves and send a pull request :) |
I may look into using Actually I remember about custom type converter for To summarize my thoughts
Now, when I look at it as a whole and after using and experiencing I at least know point where it may break and how, so I think I can remake some things, test and commit as there is no hurry now when it's working. So what are we doing? |
Thanks for the 5.0.40 should be available for download shortly.
There were only a couple of methods that appear to be effected, I've removed those.
For now I'm not going to bring in the type conversion changes, can revisit this later if it looks like there are lots of issues. It'll highlight where the return types don't match the It might be worth trying to see if you can get the changes merged into Thanks again for the |
Not sure about removing types altogether, it feels like someone may relying on it. |
PuppeteerSharp => 19.0.0 removed Newtonsoft.Json dependency
Update and fix
Bump PuppeteerSharp.Dom version
Update tests to work with PuppeteerSharp>=19.0.2
Update tests to use System.Text.Json
Add DomHandle.ParseJSValueTo
Values parsing in DomHandle.Evaluate and CodeGen.Partial Element.GetAttributeAsync
PuppeteerSharp use types of variables from JS (maybe due to transfer from Newtonsoft.Json to System.Text.Json) so it's not working and actually it make sense since C# is stronly typed
Try to parse evaluation result to requested generic type
Use ParseJSValueTo to parse evaluation result