Repository navigation
[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. |
SessionIdSessionId
|
Stop, not accepting |
SessionIdSessionId
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
SessionIdclass to improve type safety.SessionId.Createto handle potential null values gracefully.IEquatable<SessionId>andIEquatable<string>interfaces for better equality checks.GetHashCodeandEqualsmethods to handle null values safely.WebDriverand test code to utilize the newSessionId.Createmethod.Changes walkthrough 📝
SessionId.cs
Enhance `SessionId` with nullability and equality featuresdotnet/src/webdriver/SessionId.cs
SessionId.SessionId.Createmethod to handle null values.IEquatableinterfaces forSessionIdandstring.GetHashCodeandEqualsmethods for null safety.WebDriver.cs
Use `SessionId.Create` for session initializationdotnet/src/webdriver/WebDriver.cs
SessionIdconstructor withSessionId.Createmethod.CommandTests.cs
Update tests to use `SessionId.Create` methoddotnet/test/common/CommandTests.cs
SessionId.Create.