-
-
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] Enable NRT on exceptional types #14672
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
@nvborisenko PR feedback addressed, PTAL |
@nvborisenko I think everything's been addressed in this PR, it's ready for another look |
Sorry for the delay, paid work. Thanks, will review it (90% is already reviewed). For me it is conceptual basis for further upcoming PRs (especially for attributes), thus thanks for understanding. |
@nvborisenko Absolutely no worries! Yes the attributes are important here, and if we are serious about investing in AOT compatibility, those attributes are even more important (not realistic to suppress those warnings the same way as for nullability). Here is a guide from Microsoft that I use for AOT trimming, with an example of the two options for polyfilling attributes to netstandard (same guideline applies for nullability and AOT attributes). I think adding the attributes ourselves is fine as long as we hide behind |
Regarding AOT compatibility, we already made a big step forward: we made classic command/responses which are I understand the importance of attributes for nullability, and thanks for sharing the link: now I can vote for |
Changes are now implemented! Thanks for the feedback |
I am 99% confident with the proposed changes. Now, the question is: what if we enable nullable context globally? Given that I can disable it for "DevTools/CDP" namespace, how many warnings will we get related to nullability? |
For that, we can add #nullable disable warnings
#nullable enable annotations to the top of the generated CDP code. Ideally it would be nice to handle nullability on that side, as long as it’s simple enough. |
Sorry, misread your comment about nullability aside from the devtools code. After this PR, there’s still more code to enable nullability for. Some of it may even involve changing code to handle null values. After all the changes are done, we can set |
Just want to understand how far we are from nullable context enabled globally. If we enable it right now, then do you think we can achieve the goal soon?.. within your help. |
I’m not sure. It involves touching every file, but some files were trivial to enable. It all depends on the state of null-protection in the remaining code. |
OK, thank you, then let's continue enable it file by file. At the end of this story we will enable it globally, like big commit spread across all files. But please, if you feel that it would be better to enable it globally (to avoid one big boom commit), then let's do. BTW, how many warnings will we get? |
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.
Amazing start!
User description
Description
Adds nullable reference type annotations to exceptional types, such as exception types.
This also includes the polyfill nullability attributes, so this PR may block some other nullability work.
Contributes to #14640
Motivation and Context
Some easy wins on types whose nullability status is fairly unambiguous.
Types of changes
Checklist
PR Type
enhancement
Description
FirefoxDriver
with nullable reference types and addedMemberNotNullWhen
attribute.IFileDetector
andDefaultFileDetector
withNotNullWhen
attribute for method parameters.PRDescriptionHeader.CHANGES_WALKTHROUGH
15 files
DefaultFileDetector.cs
Enable nullable reference types and add NotNullWhen attribute
dotnet/src/webdriver/DefaultFileDetector.cs
NotNullWhen
attribute toIsFile
method parameter.DetachedShadowRootException.cs
Enable nullable reference types for exception class
dotnet/src/webdriver/DetachedShadowRootException.cs
CommandResponseException.cs
Update exception constructors with nullable parameters
dotnet/src/webdriver/DevTools/CommandResponseException.cs
DriverServiceNotFoundException.cs
Update exception constructors with nullable parameters
dotnet/src/webdriver/DriverServiceNotFoundException.cs
ElementClickInterceptedException.cs
Update exception constructors with nullable parameters
dotnet/src/webdriver/ElementClickInterceptedException.cs
ElementNotInteractableException.cs
Update exception constructors with nullable parameters
dotnet/src/webdriver/ElementNotInteractableException.cs
ElementNotSelectableException.cs
Update exception constructors with nullable parameters
dotnet/src/webdriver/ElementNotSelectableException.cs
ElementNotVisibleException.cs
Update exception constructors with nullable parameters
dotnet/src/webdriver/ElementNotVisibleException.cs
ErrorResponse.cs
Update ErrorResponse with nullable fields and parameters
dotnet/src/webdriver/ErrorResponse.cs
FirefoxDriver.cs
Enhance FirefoxDriver with nullable reference types
dotnet/src/webdriver/Firefox/FirefoxDriver.cs
MemberNotNullWhen
attribute forHasActiveDevToolsSession
.IFileDetector.cs
Enable nullable reference types and add NotNullWhen attribute
dotnet/src/webdriver/IFileDetector.cs
NotNullWhen
attribute toIsFile
method parameter.InsecureCertificateException.cs
Update exception constructors with nullable parameters
dotnet/src/webdriver/InsecureCertificateException.cs
NullableAttributes.cs
Add polyfill for nullable attributes
dotnet/src/webdriver/Internal/NullableAttributes.cs
InvalidCookieDomainException.cs
Update exception constructors with nullable parameters
dotnet/src/webdriver/InvalidCookieDomainException.cs
InvalidElementStateException.cs
Update exception constructors with nullable parameters
dotnet/src/webdriver/InvalidElementStateException.cs