-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] Replace Lazy<T> with ??= in BrowsingContext
#16664
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] Replace Lazy<T> with ??= in BrowsingContext
#16664
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
nvborisenko
left a comment
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.
Nice! Would also be good if we can make it thread-safe (here or later).
|
I realized you demonstrated the diff, alright. I also added thread-safety. |
|
@nvborisenko Did you use my sample code? What does your program look like? (I’m using .NET 10) |

User description
Sample program:
Size difference: 11.3MB -> 11.0MB
🔗 Related Issues
💥 What does this PR do?
🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
PR Type
Enhancement
Description
Replace
Lazy<T>with nullable fields and??=operatorSimplify lazy initialization pattern in BrowsingContext
Reduce binary size by ~300KB through pattern optimization
Improve code readability and maintainability
Diagram Walkthrough
File Walkthrough
BrowsingContext.cs
Refactor lazy initialization to use ??= operatordotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs
Lazyfield declarations with nullable field declarations??=operator for lazy initialization