[dotnet] [bidi] Immutable user facing collections#17533
Conversation
Review Summary by QodoReplace mutable collections with ImmutableArray for BiDi API immutability
WalkthroughsDescription• Replace mutable collections with ImmutableArray throughout BiDi API • Enforce immutability contracts at compilation level for user-facing collections • Prevent accidental collection mutations during serialization and processing • Update test assertions to use .Length instead of .Count for immutable arrays Diagramflowchart LR
A["IEnumerable/IReadOnlyList"] -->|"Replace with"| B["ImmutableArray"]
B -->|"Guarantees"| C["Immutability by contract"]
C -->|"Prevents"| D["Accidental mutations"]
E["GlobalUsings.cs"] -->|"Add import"| B
F["Selenium.WebDriver.csproj"] -->|"Add dependency"| G["System.Collections.Immutable"]
File Changes1. dotnet/src/webdriver/Properties/GlobalUsings.cs
|
Code Review by Qodo
1. IBiDi overloads now ImmutableArray
|
|
Persistent review updated to latest commit 447d91d |
|
Persistent review updated to latest commit a46247c |
|
Persistent review updated to latest commit 142450a |
|
Persistent review updated to latest commit b01a2c0 |
|
Persistent review updated to latest commit 6ded6c1 |
Use
ImmutableArray<T>instead ofIEnumerable<T>andIReadOnlyList<T>.Now it is immutable everywhere by contract. Eliminating the following cases at compilation level:
Before:
After:
🔗 Related Issues
Contributes to #16095
💥 What does this PR do?
Strict intention of contract.
🤖
AI assistanceThanks to @RenderMichael and @YevgeniyShunevych🔄 Types of changes