Skip to content

Conversation

@mxschmitt
Copy link
Contributor

@mxschmitt mxschmitt requested a review from yury-s May 24, 2025 06:02
@yury-s yury-s requested a review from Copilot May 27, 2025 16:59
Copy link

Copilot AI left a 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!;
Copy link

Copilot AI May 27, 2025

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.

Suggested change
string dataString = (!string.IsNullOrEmpty(options.Data) && options.Data != null) ? options.Data : options.DataString!;
string dataString = !string.IsNullOrEmpty(options.Data) ? options.Data : options.DataString!;

Copilot uses AI. Check for mistakes.
storageState = File.ReadAllText(options?.StorageStatePath);
}
if (!string.IsNullOrEmpty(storageState))
if (!string.IsNullOrEmpty(storageState) && storageState != null)
Copy link

Copilot AI May 27, 2025

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.

Suggested change
if (!string.IsNullOrEmpty(storageState) && storageState != null)
if (!string.IsNullOrEmpty(storageState))

Copilot uses AI. Check for mistakes.
{
timeoutAction();
return default;
return default!;
Copy link
Member

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.

@mxschmitt mxschmitt merged commit d0f2745 into main May 27, 2025
15 checks passed
@mxschmitt mxschmitt deleted the more-nullable branch May 27, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants