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 new standalone types (AccessibilityValue, ContextValue) and enum (MatchType) may need JsonDerivedType attributes for proper serialization/deserialization, similar to how they were handled in the nested types.
Update the InnerTextLocator class to use the JsonPropertyName attribute for the MatchType property to ensure proper serialization with the BiDi protocol, which expects "match" as the property name.
public record InnerTextLocator(string Value) : Locator
{
public bool? IgnoreCase { get; set; }
+ [JsonPropertyName("match")]
public MatchType? MatchType { get; set; }
public long? MaxDepth { get; set; }
}
Apply this suggestion
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a potential serialization issue with the BiDi protocol. Adding the JsonPropertyName attribute ensures the MatchType property will be properly serialized as "match" in JSON, which is critical for protocol compatibility. This is an important fix that prevents potential runtime errors.
Medium
Learned best practice
Initialize nullable properties with meaningful default values to improve code clarity and prevent potential null reference issues
The InnerTextLocator record has nullable properties without default values. Consider initializing these properties with meaningful default values in the constructor to improve code clarity and prevent potential null reference issues.
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
Motivation and Context
Contributes to #15407
Types of changes
Checklist
PR Type
Enhancement
Description
Decoupled nested DTO types into standalone types for better flexibility.
Replaced nested types like
AccessibilityLocatorValuewith independent records.Introduced new standalone types:
AccessibilityValue,ContextValue, andMatchType.Improved maintainability and future extensibility of locator-related classes.
Changes walkthrough 📝
Locator.cs
Decoupled nested DTO types into standalone recordsdotnet/src/webdriver/BiDi/Modules/BrowsingContext/Locator.cs
AccessibilityValueandContextValueas independent records.MatchTypeenum forInnerTextLocator.