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
Here are some key observations to aid the review process:
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review
Validation Gap The AddPageRangeToPrint method validates the start page is >= 1 but allows end page to be int.MaxValue without validation. Consider adding an upper bound validation.
Possible Bug The ToDictionary method returns null values in the dictionary which could cause issues for consumers. Consider filtering out null values or documenting this behavior.
Error Handling The SaveAsFile method checks for null/empty filename but doesn't validate file extension or path validity before attempting to write.
Specify non-nullable dictionary value type to better reflect actual usage
The ToDictionary() method should specify a non-nullable return type since all dictionary values are non-null. Change the return type from Dictionary<string, object?> to Dictionary<string, object>.
Why: The suggestion improves type safety by making the dictionary value type non-nullable since the code never adds null values. This enhances code clarity and prevents potential null-related issues.
5
Initialize collection fields in constructor to ensure proper object initialization
The pageRanges field should be initialized in the constructor rather than at declaration to ensure proper initialization in all cases.
-private readonly HashSet<object> pageRanges = new HashSet<object>();+private readonly HashSet<object> pageRanges;+public PrintOptions()+{+ pageRanges = new HashSet<object>();+}+
Apply this suggestion
Suggestion importance[1-10]: 3
Why: While the suggestion follows a good practice of initializing collections in constructors, the current field initialization is already safe and works correctly. The change would be mostly stylistic with minimal impact.
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.
Description
This adds nullability annotations to the PDF-print stack, as well as documenting potential exceptions alongside some code modernization.
Motivation and Context
Contributes to #14640
Types of changes
Checklist
PR Type
Enhancement, Bug fix, Tests
Description
PrintOptions.Changes walkthrough 📝
EncodedFile.cs
Add nullability and refactor EncodedFile classdotnet/src/webdriver/EncodedFile.cs
ToStringmethod.ISupportsPrint.cs
Add nullability and exception documentation to ISupportsPrintdotnet/src/webdriver/ISupportsPrint.cs
Printmethod.PrintDocument.cs
Enhance PrintDocument with nullability and exceptionsdotnet/src/webdriver/PrintDocument.cs
SaveAsFilemethod.PrintOptions.cs
Improve PrintOptions with nullability and validationdotnet/src/webdriver/PrintOptions.cs
Screenshot.cs
Add nullability and exceptions to Screenshot classdotnet/src/webdriver/Screenshot.cs
WebDriver.cs
Add null check in WebDriver Print methoddotnet/src/webdriver/WebDriver.cs
printOptionsinPrintmethod.PrintTest.cs
Add validation tests for PrintOptionsdotnet/test/common/PrintTest.cs