-
Notifications
You must be signed in to change notification settings - Fork 293
chore: enable #nullable iteration 3 #3172
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
Conversation
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.
Pull Request Overview
This PR enables nullable reference types across the Playwright repository to improve code clarity and null-safety.
- Added "#nullable enable" directives to multiple files.
- Updated type declarations and method signatures to use nullable annotations consistently.
Reviewed Changes
Copilot reviewed 52 out of 52 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Playwright/Core/APIRequestContext.cs | Enabled nullability and updated field and parameter types. |
| src/Playwright/Core/APIRequest.cs | Enabled nullability and updated option handling for new context. |
| src/Playwright/BrowserType.cs | Added "#nullable enable" directive. |
| src/Playwright/Assertions.cs | Added "#nullable enable" directive. |
| src/Playwright/API/Types/ViewportSize.cs | Added "#nullable enable" directive. |
| src/Playwright/API/Types/RequestAbortErrorCode.cs | Added "#nullable enable" directive. |
| src/Playwright/API/Types/PaperFormat.cs | Added "#nullable enable" directive. |
| src/Playwright/API/Types/DialogType.cs | Added "#nullable enable" directive. |
| src/Playwright/API/Types/BindingSource.cs | Added "#nullable enable" directive and updated constructor usage. |
| src/Playwright/API/TargetClosedException.cs | Updated constructor parameter to allow nullability. |
| src/Playwright/API/Supplements/IResponse.cs | Added "#nullable enable" directive. |
| src/Playwright/API/Supplements/IPlaywright.cs | Added "#nullable enable" directive. |
| src/Playwright/API/Supplements/ILocator.cs | Updated method signatures to use nullable parameters. |
| src/Playwright/API/Supplements/IJSHandle.cs | Updated method signatures to use nullable parameters. |
| src/Playwright/API/Supplements/IFrame.cs | Updated method signatures to use nullable parameters. |
| src/Playwright/API/Supplements/IElementHandle.cs | Updated method signatures to use nullable parameters. |
| src/Playwright/API/Supplements/ICDPSession.cs | Added "#nullable enable" directive. |
| src/Playwright/API/Supplements/IBrowser.cs | Added "#nullable enable" directive. |
| src/Playwright/API/Supplements/IAPIRequestContext.cs | Added "#nullable enable" directive. |
| src/Playwright/API/PlaywrightException.cs | Added "#nullable enable" directive. |
| string dataString = !string.IsNullOrEmpty(options.Data) ? options.Data : options.DataString; | ||
| byte[]? postData = null; | ||
| object? jsonData = null; | ||
| string dataString = (!string.IsNullOrEmpty(options.Data) && options.Data != null) ? options.Data : options.DataString!; |
Copilot
AI
May 27, 2025
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.
The condition '(!string.IsNullOrEmpty(options.Data) && options.Data != null)' is redundant; 'string.IsNullOrEmpty(options.Data)' already checks for null. Consider simplifying the conditional.
| string dataString = (!string.IsNullOrEmpty(options.Data) && options.Data != null) ? options.Data : options.DataString!; | |
| string dataString = !string.IsNullOrEmpty(options.Data) ? options.Data : options.DataString!; |
| storageState = File.ReadAllText(options?.StorageStatePath); | ||
| } | ||
| if (!string.IsNullOrEmpty(storageState)) | ||
| if (!string.IsNullOrEmpty(storageState) && storageState != null) |
Copilot
AI
May 27, 2025
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.
The check '&& storageState != null' is redundant since 'string.IsNullOrEmpty' covers null; consider simplifying the condition.
| if (!string.IsNullOrEmpty(storageState) && storageState != null) | |
| if (!string.IsNullOrEmpty(storageState)) |
| { | ||
| timeoutAction(); | ||
| return default; | ||
| return default!; |
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.
Maybe leave a comment that this line is unreachable? Or better yet throw timeoutAction(); or something like that, so that you don't have to add unreachable return statement.
#3163