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 DirectoryInfo.Parent property access in DeleteExtensionsCache() assumes the parent directory exists. While marked with '!', this could still throw NullReferenceException if the extensions directory is at root level.
Add null check for ProfileDirectory before using it in ToBase64String() to avoid potential NullReferenceException. The WriteToDisk() call may not have been made yet.
+if (string.IsNullOrEmpty(this.ProfileDirectory))+{+ throw new InvalidOperationException("Profile directory not created. Call WriteToDisk() first.");+}
string[] files = Directory.GetFiles(this.ProfileDirectory, "*.*", SearchOption.AllDirectories);
Apply this suggestion
Suggestion importance[1-10]: 8
Why: The suggestion addresses a critical null reference safety issue by adding a check for ProfileDirectory before using it in ToBase64String(). Without this check, the code could throw a NullReferenceException if WriteToDisk() hasn't been called.
8
Validate required method parameter
Add null check for profileDirectory parameter in DeleteLockFiles() to prevent potential NullReferenceException when combining paths.
Why: The suggestion improves code safety by adding parameter validation using ArgumentNullException.ThrowIfNull(), which aligns with the PR's focus on nullability and prevents potential runtime errors.
7
Learned best practice
Add null validation checks at the start of methods for required parameters marked as nullable to prevent NullReferenceExceptions
The SetPreference methods should validate the name parameter at the start of the method since it's required but marked as nullable. Add ArgumentNullException checks using the recommended pattern.
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.
Annotate nullability on Firefox profile
Motivation and Context
Contributes to #14640
Types of changes
Checklist
PR Type
Enhancement, Bug fix
Description
Annotated nullability for
FirefoxProfileand related classes.Refactored
FirefoxProfileto use nullable reference types and improve code clarity.Added nullability checks and exceptions for better error handling.
Updated utility methods to support nullable parameters and improve robustness.
Changes walkthrough 📝
FirefoxProfile.cs
Refactor and annotate nullability in FirefoxProfiledotnet/src/webdriver/Firefox/FirefoxProfile.cs
FirefoxProfileManager.cs
Add nullability and refactor FirefoxProfileManagerdotnet/src/webdriver/Firefox/FirefoxProfileManager.cs
GetProfilemethod to handle nullable inputs.ExistingProfilesproperty with expression-bodied syntax.FileUtilities.cs
Enhance FileUtilities with nullability supportdotnet/src/webdriver/Internal/FileUtilities.cs
DeleteDirectoryto accept nullable parameters.GenerateRandomTempDirectoryNameparameter attributes.