-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[dotnet] Add nullability annotations to SessionId
#14841
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
What we have:
|
I think this whole class tries to be an opaque wrapper over a string. It already implements |
Not sure, Michael. Can you please research where this "opaque" functionality is used across whole code base? @jimevans do you remember why this class is better than native |
Looking through the history, this type used to live in the |
Once in the code (the selenium/dotnet/src/webdriver/Command.cs Line 59 in 40ea8a4
Which notably also accepts |
Big refactoring is definitely OOS. I propose to:
Nothing more. |
Fixed, all irrelevant changes are removed. |
SessionId
SessionId
Stop, not accepting |
SessionId
SessionId
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.
Thanks @RenderMichael !
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
Add nullability annotations to
SessionId
. Now,new SessionId(null)
throws an exception so we do a null check whenever we use it inWebDriver
.Since we overrideobject.Equals
, I also added some convenience interfaces and operators.Motivation and Context
Contributes to #14640
Types of changes
Checklist
PR Type
enhancement, bug_fix
Description
SessionId
class to improve type safety.SessionId.Create
to handle potential null values gracefully.IEquatable<SessionId>
andIEquatable<string>
interfaces for better equality checks.GetHashCode
andEquals
methods to handle null values safely.WebDriver
and test code to utilize the newSessionId.Create
method.Changes walkthrough 📝
SessionId.cs
Enhance `SessionId` with nullability and equality features
dotnet/src/webdriver/SessionId.cs
SessionId
.SessionId.Create
method to handle null values.IEquatable
interfaces forSessionId
andstring
.GetHashCode
andEquals
methods for null safety.WebDriver.cs
Use `SessionId.Create` for session initialization
dotnet/src/webdriver/WebDriver.cs
SessionId
constructor withSessionId.Create
method.CommandTests.cs
Update tests to use `SessionId.Create` method
dotnet/test/common/CommandTests.cs
SessionId.Create
.