You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The String method throws an ArgumentNullException if value is null, but the implicit operator for string doesn't perform this check, potentially leading to inconsistent behavior.
The Regex method uses regex.ToString() to get the pattern, but this returns the pattern with options which could lead to duplicate flags. Use regex.Pattern instead to get just the pattern without options.
Why: Using regex.ToString() returns the pattern with options included, which could lead to duplicate flags when the method explicitly adds flags. Using regex.Pattern provides just the pattern without options, preventing potential issues with duplicate or conflicting flags.
High
Use round-trip format for BigInteger
The BigInt method currently converts a BigInteger to string without any format specification, which could lead to incorrect representation. Use ToString("R") to ensure the round-trip format is used for accurate numeric representation.
public static BigIntLocalValue BigInt(BigInteger value)
{
- return new BigIntLocalValue(value.ToString());+ return new BigIntLocalValue(value.ToString("R"));
}
Apply this suggestion
Suggestion importance[1-10]: 7
__
Why: Using ToString("R") for BigInteger ensures accurate numeric representation with the round-trip format, preventing potential data loss or incorrect representation when converting between .NET and JavaScript BigInt values.
I am concerned in general to introduce "implicit/explicit" casting. In my mind .NET types and BiDi types have to be mapped 1 to 1. I feel it should be a rule, exactly 1 to 1. I agree that this feature is amazing and very helpful, but I guess we are missing something that will be painful in the future. Do you feel the same?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Motivation and Context
Types of changes
Checklist
PR Type
Enhancement, Tests
Description
Simplified the usage of
LocalValueby introducing static factory methods.Added comprehensive type conversion support for
LocalValue, including JSON nodes and .NET types.Enhanced test coverage for
LocalValueconversions and usage in function calls.Improved readability and maintainability of
LocalValue-related code.Changes walkthrough 📝
LocalValue.cs
Enhanced `LocalValue` with static methods and type conversionsdotnet/src/webdriver/BiDi/Modules/Script/LocalValue.cs
LocalValueinstances.LocalValue.LocalValuetypes.CallFunctionLocalValueTest.cs
Updated and extended tests for `LocalValue` functionalitydotnet/test/common/BiDi/Script/CallFunctionLocalValueTest.cs
LocalValuestatic factory methods.LocalValuetypes likeTrue,False, andBigInt.LocalValueusage.