diff --git a/dotnet/paket.dependencies b/dotnet/paket.dependencies index d1f2a529ad80b..b352fafbf3351 100644 --- a/dotnet/paket.dependencies +++ b/dotnet/paket.dependencies @@ -15,6 +15,7 @@ nuget NUnit.Analyzers 4.13.0 nuget NUnit3TestAdapter 6.2.0 nuget Microsoft.Testing.Platform 2.1.0 nuget Microsoft.Testing.Extensions.VSTestBridge 2.1.0 +nuget System.Collections.Immutable 8.0.0 nuget System.Text.Json 8.0.6 nuget System.Threading.Channels 8.0.0 nuget Runfiles 0.14.0 diff --git a/dotnet/src/webdriver/BUILD.bazel b/dotnet/src/webdriver/BUILD.bazel index d8530047253a9..79cfb38199640 100644 --- a/dotnet/src/webdriver/BUILD.bazel +++ b/dotnet/src/webdriver/BUILD.bazel @@ -62,6 +62,7 @@ csharp_sourcelink_library( deps = [ nuget_package("Microsoft.Bcl.AsyncInterfaces"), nuget_package("System.Buffers"), + nuget_package("System.Collections.Immutable"), nuget_package("System.Threading.Tasks.Extensions"), nuget_package("System.Memory"), nuget_package("System.Runtime.CompilerServices.Unsafe"), @@ -95,6 +96,7 @@ csharp_sourcelink_library( nuget_package("NETStandard.Library"), nuget_package("Microsoft.Bcl.AsyncInterfaces"), nuget_package("System.Buffers"), + nuget_package("System.Collections.Immutable"), nuget_package("System.Threading.Channels"), nuget_package("System.Threading.Tasks.Extensions"), nuget_package("System.Memory"), diff --git a/dotnet/src/webdriver/BiDi/BiDi.cs b/dotnet/src/webdriver/BiDi/BiDi.cs index 3ac7e4089e89c..aa357152b5410 100644 --- a/dotnet/src/webdriver/BiDi/BiDi.cs +++ b/dotnet/src/webdriver/BiDi/BiDi.cs @@ -101,17 +101,15 @@ public Task SubscribeAsync(EventDescriptor SubscribeAsync(IEnumerable descriptors, Action handler, CancellationToken cancellationToken = default) where TEventArgs : EventArgs + public async Task SubscribeAsync(ImmutableArray descriptors, Action handler, CancellationToken cancellationToken = default) where TEventArgs : EventArgs { - ArgumentNullException.ThrowIfNull(descriptors); ArgumentNullException.ThrowIfNull(handler); return await EventDispatcher.SubscribeAsync(descriptors, e => { handler(e); return default; }, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task SubscribeAsync(IEnumerable descriptors, Func handler, CancellationToken cancellationToken = default) where TEventArgs : EventArgs + public async Task SubscribeAsync(ImmutableArray descriptors, Func handler, CancellationToken cancellationToken = default) where TEventArgs : EventArgs { - ArgumentNullException.ThrowIfNull(descriptors); ArgumentNullException.ThrowIfNull(handler); return await EventDispatcher.SubscribeAsync(descriptors, e => new ValueTask(handler(e)), cancellationToken: cancellationToken).ConfigureAwait(false); @@ -124,10 +122,8 @@ public Task> StreamAsync(EventDescriptor([descriptor], cancellationToken); } - public async Task> StreamAsync(IEnumerable descriptors, CancellationToken cancellationToken = default) where TEventArgs : EventArgs + public async Task> StreamAsync(ImmutableArray descriptors, CancellationToken cancellationToken = default) where TEventArgs : EventArgs { - ArgumentNullException.ThrowIfNull(descriptors); - return await EventDispatcher.SubscribeReaderAsync(descriptors, cancellationToken: cancellationToken).ConfigureAwait(false); } diff --git a/dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs b/dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs index c64f92b2f7e4e..6411a55f0cc31 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs @@ -21,4 +21,4 @@ namespace OpenQA.Selenium.BiDi.Browser; public sealed record GetClientWindowsOptions : CommandOptions; -public sealed record GetClientWindowsResult(IReadOnlyList ClientWindows) : EmptyResult; +public sealed record GetClientWindowsResult(ImmutableArray ClientWindows) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs b/dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs index f8e9ca7dffcd7..5d90e7f48eb57 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs @@ -21,4 +21,4 @@ namespace OpenQA.Selenium.BiDi.Browser; public record GetUserContextsOptions : CommandOptions; -public sealed record GetUserContextsResult(IReadOnlyList UserContexts) : EmptyResult; +public sealed record GetUserContextsResult(ImmutableArray UserContexts) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs b/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs index cd3f6fab9c34f..42f09324dd95d 100644 --- a/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs +++ b/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Browser; -internal sealed record SetDownloadBehaviorParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] DownloadBehavior? DownloadBehavior, IEnumerable? UserContexts) : Parameters; +internal sealed record SetDownloadBehaviorParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] DownloadBehavior? DownloadBehavior, ImmutableArray? UserContexts) : Parameters; [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] [JsonDerivedType(typeof(DownloadBehaviorAllowed), "allowed")] @@ -37,7 +37,7 @@ public sealed record DownloadBehaviorDenied : DownloadBehavior; public sealed record SetDownloadBehaviorOptions : CommandOptions { - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record SetDownloadBehaviorResult : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs index bf35a2647f7e2..92a5d0b9a12b0 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; internal sealed class BrowsingContextInputModule(BrowsingContext context, IInputModule inputModule, EventDispatcher dispatcher) : IBrowsingContextInputModule { - public Task PerformActionsAsync(IEnumerable actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default) + public Task PerformActionsAsync(ImmutableArray actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default) { return inputModule.PerformActionsAsync(context, actions, options, cancellationToken); } @@ -33,7 +33,7 @@ public Task ReleaseActionsAsync(ReleaseActionsOptions? opt return inputModule.ReleaseActionsAsync(context, options, cancellationToken); } - public Task SetFilesAsync(Script.ISharedReference element, IEnumerable files, SetFilesOptions? options = null, CancellationToken cancellationToken = default) + public Task SetFilesAsync(Script.ISharedReference element, ImmutableArray files, SetFilesOptions? options = null, CancellationToken cancellationToken = default) { return inputModule.SetFilesAsync(context, element, files, options, cancellationToken); } diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextNetworkModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextNetworkModule.cs index 3e9dc1b6b71cd..a2d6b0717ad9b 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextNetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextNetworkModule.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; internal sealed class BrowsingContextNetworkModule(BrowsingContext context, INetworkModule networkModule, EventDispatcher dispatcher) : IBrowsingContextNetworkModule { - public Task AddDataCollectorAsync(IEnumerable dataTypes, int maxEncodedDataSize, ContextAddDataCollectorOptions? options = null, CancellationToken cancellationToken = default) + public Task AddDataCollectorAsync(ImmutableArray dataTypes, int maxEncodedDataSize, ContextAddDataCollectorOptions? options = null, CancellationToken cancellationToken = default) { return networkModule.AddDataCollectorAsync(dataTypes, maxEncodedDataSize, ContextAddDataCollectorOptions.WithContext(options, context), cancellationToken); } diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/ContextCreatedEvent.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/ContextCreatedEvent.cs index cbac360a96af9..39c156e8a94dd 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/ContextCreatedEvent.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/ContextCreatedEvent.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; public sealed record ContextCreatedEventArgs( IBiDi BiDi, - IReadOnlyList? Children, + ImmutableArray? Children, Browser.ClientWindow ClientWindow, BrowsingContext Context, BrowsingContext? OriginalOpener, diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/ContextDestroyedEvent.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/ContextDestroyedEvent.cs index 3b4c7a986dd63..d901cdf84e08a 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/ContextDestroyedEvent.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/ContextDestroyedEvent.cs @@ -19,7 +19,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -public sealed record ContextDestroyedEventArgs(IBiDi BiDi, IReadOnlyList? Children, +public sealed record ContextDestroyedEventArgs(IBiDi BiDi, ImmutableArray? Children, Browser.ClientWindow ClientWindow, BrowsingContext Context, BrowsingContext? OriginalOpener, diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs index 8c862bb368185..526ff3d2b983d 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs @@ -40,4 +40,4 @@ public sealed record ContextGetTreeOptions : CommandOptions }; } -public sealed record GetTreeResult(IReadOnlyList Contexts) : EmptyResult; +public sealed record GetTreeResult(ImmutableArray Contexts) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextInputModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextInputModule.cs index 990389b97afa1..3a4de917b83bb 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextInputModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextInputModule.cs @@ -24,7 +24,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; public interface IBrowsingContextInputModule { IEventSource FileDialogOpened { get; } - Task PerformActionsAsync(IEnumerable actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default); + Task PerformActionsAsync(ImmutableArray actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default); Task ReleaseActionsAsync(ReleaseActionsOptions? options = null, CancellationToken cancellationToken = default); - Task SetFilesAsync(Script.ISharedReference element, IEnumerable files, SetFilesOptions? options = null, CancellationToken cancellationToken = default); + Task SetFilesAsync(Script.ISharedReference element, ImmutableArray files, SetFilesOptions? options = null, CancellationToken cancellationToken = default); } diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextNetworkModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextNetworkModule.cs index 024d18018c58e..ea18e5cb123c0 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextNetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/IBrowsingContextNetworkModule.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; public interface IBrowsingContextNetworkModule { - Task AddDataCollectorAsync(IEnumerable dataTypes, int maxEncodedDataSize, ContextAddDataCollectorOptions? options = null, CancellationToken cancellationToken = default); + Task AddDataCollectorAsync(ImmutableArray dataTypes, int maxEncodedDataSize, ContextAddDataCollectorOptions? options = null, CancellationToken cancellationToken = default); IEventSource AuthRequired { get; } IEventSource BeforeRequestSent { get; } IEventSource FetchError { get; } diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/Info.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Info.cs index de1289c9d79cc..111856c0c6594 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/Info.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Info.cs @@ -20,7 +20,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; public sealed record Info( - IReadOnlyList? Children, + ImmutableArray? Children, Browser.ClientWindow ClientWindow, BrowsingContext Context, BrowsingContext? OriginalOpener, diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs index ba26c934d91cb..78f63753d462e 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs @@ -19,7 +19,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed record LocateNodesParameters(BrowsingContext Context, Locator Locator, long? MaxNodeCount, Script.SerializationOptions? SerializationOptions, IEnumerable? StartNodes) : Parameters; +internal sealed record LocateNodesParameters(BrowsingContext Context, Locator Locator, long? MaxNodeCount, Script.SerializationOptions? SerializationOptions, ImmutableArray? StartNodes) : Parameters; public sealed record LocateNodesOptions : CommandOptions { @@ -27,7 +27,7 @@ public sealed record LocateNodesOptions : CommandOptions public Script.SerializationOptions? SerializationOptions { get; init; } - public IEnumerable? StartNodes { get; init; } + public ImmutableArray? StartNodes { get; init; } } -public sealed record LocateNodesResult(IReadOnlyList Nodes) : EmptyResult; +public sealed record LocateNodesResult(ImmutableArray Nodes) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs index 886645743fb82..d8a82210c0614 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed record PrintParameters(BrowsingContext Context, bool? Background, PrintMargin? Margin, PrintOrientation? Orientation, PrintPage? Page, IEnumerable? PageRanges, double? Scale, bool? ShrinkToFit) : Parameters; +internal sealed record PrintParameters(BrowsingContext Context, bool? Background, PrintMargin? Margin, PrintOrientation? Orientation, PrintPage? Page, ImmutableArray? PageRanges, double? Scale, bool? ShrinkToFit) : Parameters; public sealed record PrintOptions : CommandOptions { @@ -34,7 +34,7 @@ public sealed record PrintOptions : CommandOptions public PrintPage? Page { get; init; } - public IEnumerable? PageRanges { get; init; } + public ImmutableArray? PageRanges { get; init; } public double? Scale { get; init; } diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs index 9df7438701872..28f3b4b255ada 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs @@ -26,7 +26,7 @@ internal sealed record SetViewportParameters( BrowsingContext? Context, [property: JsonConverter(typeof(OptionalConverter))] Optional? Viewport, [property: JsonConverter(typeof(OptionalConverter))] Optional? DevicePixelRatio, - IEnumerable? UserContexts) + ImmutableArray? UserContexts) : Parameters; public sealed record SetViewportOptions : CommandOptions @@ -37,7 +37,7 @@ public sealed record SetViewportOptions : CommandOptions public Optional? DevicePixelRatio { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record ContextSetViewportOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverride.cs index 4a47f47015ab4..e6e9c9acfb5f0 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverride.cs @@ -22,13 +22,13 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed record SetForcedColorsModeThemeOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ForcedColorsModeTheme? Theme, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetForcedColorsModeThemeOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ForcedColorsModeTheme? Theme, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; public sealed record SetForcedColorsModeThemeOverrideOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } [JsonConverter(typeof(CamelCaseEnumConverter))] diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs index d8f42daa48f3e..4acdce6e08dcb 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs @@ -36,11 +36,11 @@ public sealed record GeolocationPositionErrorOverride : GeolocationOverride; [JsonDerivedType(typeof(SetGeolocationOverrideCoordinatesParameters))] [JsonDerivedType(typeof(SetGeolocationOverridePositionErrorParameters))] -internal abstract record SetGeolocationOverrideParameters(IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal abstract record SetGeolocationOverrideParameters(ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; -internal sealed record SetGeolocationOverrideCoordinatesParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] GeolocationCoordinates? Coordinates, IEnumerable? Contexts, IEnumerable? UserContexts) : SetGeolocationOverrideParameters(Contexts, UserContexts); +internal sealed record SetGeolocationOverrideCoordinatesParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] GeolocationCoordinates? Coordinates, ImmutableArray? Contexts, ImmutableArray? UserContexts) : SetGeolocationOverrideParameters(Contexts, UserContexts); -internal sealed record SetGeolocationOverridePositionErrorParameters(GeolocationPositionError Error, IEnumerable? Contexts, IEnumerable? UserContexts) : SetGeolocationOverrideParameters(Contexts, UserContexts); +internal sealed record SetGeolocationOverridePositionErrorParameters(GeolocationPositionError Error, ImmutableArray? Contexts, ImmutableArray? UserContexts) : SetGeolocationOverrideParameters(Contexts, UserContexts); internal sealed record GeolocationCoordinates(double Latitude, double Longitude, double? Accuracy, double? Altitude, double? AltitudeAccuracy, double? Heading, double? Speed); @@ -52,9 +52,9 @@ internal sealed record GeolocationPositionError public sealed record SetGeolocationOverrideOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record SetGeolocationOverrideResult : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs index e3c0338c1e167..6c87a9de4da7e 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs @@ -21,13 +21,13 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed record SetLocaleOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? Locale, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetLocaleOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? Locale, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; public sealed record SetLocaleOverrideOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record SetLocaleOverrideResult : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs b/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs index cd16e78557ec3..7a83b1de3b7a0 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed record SetNetworkConditionsParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] NetworkConditions? NetworkConditions, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetNetworkConditionsParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] NetworkConditions? NetworkConditions, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] [JsonDerivedType(typeof(NetworkConditionsOffline), "offline")] @@ -31,9 +31,9 @@ public sealed record NetworkConditionsOffline : NetworkConditions; public sealed record SetNetworkConditionsOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record SetNetworkConditionsResult : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs index b68b5b6dfe174..4820e9957a2e9 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs @@ -22,13 +22,13 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed record SetScreenOrientationOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScreenOrientation? ScreenOrientation, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetScreenOrientationOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScreenOrientation? ScreenOrientation, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; public sealed record SetScreenOrientationOverrideOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } [JsonConverter(typeof(CamelCaseEnumConverter))] diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs index c2d2076608f3b..209b193d3d04a 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs @@ -21,13 +21,13 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed record SetScreenSettingsOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScreenArea? ScreenArea, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetScreenSettingsOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScreenArea? ScreenArea, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; public sealed record SetScreenSettingsOverrideOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record ScreenArea(long Width, long Height); diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs index d38e840659be7..aca944ce20304 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs @@ -21,13 +21,13 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed record SetScriptingEnabledParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] bool? Enabled, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetScriptingEnabledParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] bool? Enabled, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; public sealed record SetScriptingEnabledOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record SetScriptingEnabledResult : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs index 9c700d2d1f016..a1414973d1402 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs @@ -22,13 +22,13 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed record SetScrollbarTypeOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScrollbarType? ScrollbarType, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetScrollbarTypeOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScrollbarType? ScrollbarType, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; public sealed record SetScrollbarTypeOverrideOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } [JsonConverter(typeof(CamelCaseEnumConverter))] diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs index f1e3854ad8e08..780f6b4ce01eb 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs @@ -21,13 +21,13 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed record SetTimezoneOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? Timezone, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetTimezoneOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? Timezone, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; public sealed record SetTimezoneOverrideOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record SetTimezoneOverrideResult : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs index aa1fcda9044df..00445fec5c58a 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs @@ -21,13 +21,13 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed record SetTouchOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] long? MaxTouchPoints, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetTouchOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] long? MaxTouchPoints, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; public sealed record SetTouchOverrideOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record SetTouchOverrideResult : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs index 8aafecd0fced5..8325514a72e52 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs @@ -21,13 +21,13 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed record SetUserAgentOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? UserAgent, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetUserAgentOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? UserAgent, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; public sealed record SetUserAgentOverrideOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record SetUserAgentOverrideResult : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/EventDispatcher.cs b/dotnet/src/webdriver/BiDi/EventDispatcher.cs index c3a3a686c3d65..7cf330764329b 100644 --- a/dotnet/src/webdriver/BiDi/EventDispatcher.cs +++ b/dotnet/src/webdriver/BiDi/EventDispatcher.cs @@ -28,15 +28,15 @@ internal sealed class EventDispatcher : IAsyncDisposable { private static readonly ILogger _logger = Internal.Logging.Log.GetLogger(); - private readonly Func, Session.SubscribeOptions?, CancellationToken, Task> _wireSubscribe; - private readonly Func, Session.UnsubscribeByIdOptions?, CancellationToken, Task> _wireUnsubscribe; + private readonly Func, Session.SubscribeOptions?, CancellationToken, Task> _wireSubscribe; + private readonly Func, Session.UnsubscribeByIdOptions?, CancellationToken, Task> _wireUnsubscribe; private readonly IBiDi _bidi; private readonly ConcurrentDictionary _events = new(); public EventDispatcher( - Func, Session.SubscribeOptions?, CancellationToken, Task> wireSubscribe, - Func, Session.UnsubscribeByIdOptions?, CancellationToken, Task> wireUnsubscribe, + Func, Session.SubscribeOptions?, CancellationToken, Task> wireSubscribe, + Func, Session.UnsubscribeByIdOptions?, CancellationToken, Task> wireUnsubscribe, IBiDi bidi) { _wireSubscribe = wireSubscribe; @@ -47,7 +47,7 @@ public EventDispatcher( public Task SubscribeAsync( EventDescriptor descriptor, Func handler, - IEnumerable? contexts = null, + ImmutableArray? contexts = null, Func? filter = null, CancellationToken cancellationToken = default) where TEventArgs : EventArgs @@ -58,7 +58,7 @@ public Task SubscribeAsync( public async Task SubscribeAsync( IEnumerable descriptors, Func handler, - IEnumerable? contexts = null, + ImmutableArray? contexts = null, Func? filter = null, CancellationToken cancellationToken = default) where TEventArgs : EventArgs @@ -81,7 +81,7 @@ public async Task SubscribeAsync( public Task> SubscribeReaderAsync( EventDescriptor descriptor, - IEnumerable? contexts = null, + ImmutableArray? contexts = null, Func? filter = null, CancellationToken cancellationToken = default) where TEventArgs : EventArgs @@ -91,7 +91,7 @@ public Task> SubscribeReaderAsync( public async Task> SubscribeReaderAsync( IEnumerable descriptors, - IEnumerable? contexts = null, + ImmutableArray? contexts = null, Func? filter = null, CancellationToken cancellationToken = default) where TEventArgs : EventArgs @@ -173,8 +173,8 @@ public async ValueTask DisposeAsync() private async Task<(Session.Subscription SubscribeResult, EventSlot[] Slots)> SubscribeCoreAsync( IEnumerable descriptors, - IEnumerable? contexts, - IEnumerable? userContexts, + ImmutableArray? contexts, + ImmutableArray? userContexts, CancellationToken cancellationToken) { var uniqueNames = new HashSet(); @@ -195,7 +195,7 @@ public async ValueTask DisposeAsync() throw new ArgumentException("At least one event descriptor must be provided.", nameof(descriptors)); } - var subscribeResult = await _wireSubscribe(names, new() { Contexts = contexts, UserContexts = userContexts }, cancellationToken) + var subscribeResult = await _wireSubscribe([.. names], new() { Contexts = contexts, UserContexts = userContexts }, cancellationToken) .ConfigureAwait(false); return (subscribeResult.Subscription, slots.ToArray()); diff --git a/dotnet/src/webdriver/BiDi/IBiDi.cs b/dotnet/src/webdriver/BiDi/IBiDi.cs index 6d9d2af678d45..aa89a4e04b88b 100644 --- a/dotnet/src/webdriver/BiDi/IBiDi.cs +++ b/dotnet/src/webdriver/BiDi/IBiDi.cs @@ -61,13 +61,13 @@ public interface IBiDi : IAsyncDisposable Task SubscribeAsync(EventDescriptor descriptor, Func handler, CancellationToken cancellationToken = default) where TEventArgs : EventArgs; - Task SubscribeAsync(IEnumerable descriptors, Action handler, CancellationToken cancellationToken = default) where TEventArgs : EventArgs; + Task SubscribeAsync(ImmutableArray descriptors, Action handler, CancellationToken cancellationToken = default) where TEventArgs : EventArgs; - Task SubscribeAsync(IEnumerable descriptors, Func handler, CancellationToken cancellationToken = default) where TEventArgs : EventArgs; + Task SubscribeAsync(ImmutableArray descriptors, Func handler, CancellationToken cancellationToken = default) where TEventArgs : EventArgs; Task> StreamAsync(EventDescriptor descriptor, CancellationToken cancellationToken = default) where TEventArgs : EventArgs; - Task> StreamAsync(IEnumerable descriptors, CancellationToken cancellationToken = default) where TEventArgs : EventArgs; + Task> StreamAsync(ImmutableArray descriptors, CancellationToken cancellationToken = default) where TEventArgs : EventArgs; [EditorBrowsable(EditorBrowsableState.Never)] T AsModule() where T : Module, new(); diff --git a/dotnet/src/webdriver/BiDi/Input/IInputModule.cs b/dotnet/src/webdriver/BiDi/Input/IInputModule.cs index d9135a8d6a1b7..ab8f319cee572 100644 --- a/dotnet/src/webdriver/BiDi/Input/IInputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/IInputModule.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Input; public interface IInputModule { IEventSource FileDialogOpened { get; } - Task PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default); + Task PerformActionsAsync(BrowsingContext.BrowsingContext context, ImmutableArray actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default); Task ReleaseActionsAsync(BrowsingContext.BrowsingContext context, ReleaseActionsOptions? options = null, CancellationToken cancellationToken = default); - Task SetFilesAsync(BrowsingContext.BrowsingContext context, Script.ISharedReference element, IEnumerable files, SetFilesOptions? options = null, CancellationToken cancellationToken = default); + Task SetFilesAsync(BrowsingContext.BrowsingContext context, Script.ISharedReference element, ImmutableArray files, SetFilesOptions? options = null, CancellationToken cancellationToken = default); } diff --git a/dotnet/src/webdriver/BiDi/Input/InputModule.cs b/dotnet/src/webdriver/BiDi/Input/InputModule.cs index 4ccebcec38fbb..5f448ea16eb06 100644 --- a/dotnet/src/webdriver/BiDi/Input/InputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/InputModule.cs @@ -33,7 +33,7 @@ internal sealed class InputModule : Module, IInputModule private static readonly Command SetFilesCommand = new( "input.setFiles", Default.SetFilesParameters, Default.SetFilesResult); - public async Task PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default) + public async Task PerformActionsAsync(BrowsingContext.BrowsingContext context, ImmutableArray actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default) { var @params = new PerformActionsParameters(context, actions); @@ -47,7 +47,7 @@ public async Task ReleaseActionsAsync(BrowsingContext.Brow return await ExecuteAsync(ReleaseActionsCommand, @params, options, cancellationToken).ConfigureAwait(false); } - public async Task SetFilesAsync(BrowsingContext.BrowsingContext context, Script.ISharedReference element, IEnumerable files, SetFilesOptions? options = null, CancellationToken cancellationToken = default) + public async Task SetFilesAsync(BrowsingContext.BrowsingContext context, Script.ISharedReference element, ImmutableArray files, SetFilesOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetFilesParameters(context, element, files); diff --git a/dotnet/src/webdriver/BiDi/Input/PerformActions.cs b/dotnet/src/webdriver/BiDi/Input/PerformActions.cs index 4ec68d9608914..2d536b24b856a 100644 --- a/dotnet/src/webdriver/BiDi/Input/PerformActions.cs +++ b/dotnet/src/webdriver/BiDi/Input/PerformActions.cs @@ -19,7 +19,7 @@ namespace OpenQA.Selenium.BiDi.Input; -internal sealed record PerformActionsParameters(BrowsingContext.BrowsingContext Context, IEnumerable Actions) : Parameters; +internal sealed record PerformActionsParameters(BrowsingContext.BrowsingContext Context, ImmutableArray Actions) : Parameters; public sealed record PerformActionsOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Input/SetFiles.cs b/dotnet/src/webdriver/BiDi/Input/SetFiles.cs index 5271088b4e784..00d5bcdb8bbf6 100644 --- a/dotnet/src/webdriver/BiDi/Input/SetFiles.cs +++ b/dotnet/src/webdriver/BiDi/Input/SetFiles.cs @@ -19,7 +19,7 @@ namespace OpenQA.Selenium.BiDi.Input; -internal sealed record SetFilesParameters(BrowsingContext.BrowsingContext Context, Script.ISharedReference Element, IEnumerable Files) : Parameters; +internal sealed record SetFilesParameters(BrowsingContext.BrowsingContext Context, Script.ISharedReference Element, ImmutableArray Files) : Parameters; public sealed record SetFilesOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Input/SourceActions.cs b/dotnet/src/webdriver/BiDi/Input/SourceActions.cs index a91e3e0b3e19f..b4d6d39376a4b 100644 --- a/dotnet/src/webdriver/BiDi/Input/SourceActions.cs +++ b/dotnet/src/webdriver/BiDi/Input/SourceActions.cs @@ -29,7 +29,7 @@ namespace OpenQA.Selenium.BiDi.Input; [JsonDerivedType(typeof(NoneSourceActions), "none")] public abstract record SourceActions; -public abstract record SourceActions(string Id, IEnumerable Actions) +public abstract record SourceActions(string Id, ImmutableArray Actions) : SourceActions where TSourceAction : ISourceAction; public interface ISourceAction; @@ -40,7 +40,7 @@ public interface ISourceAction; [JsonDerivedType(typeof(KeyUpAction), "keyUp")] public interface IKeySourceAction : ISourceAction; -public sealed record KeySourceActions(string Id, IEnumerable Actions) +public sealed record KeySourceActions(string Id, ImmutableArray Actions) : SourceActions(Id, Actions) { [Obsolete("This helper method will be removed in a future version. Use KeyDownAction and KeyUpAction directly instead.")] @@ -57,7 +57,7 @@ public KeySourceActions Type(string text) => this with [JsonDerivedType(typeof(PointerMoveAction), "pointerMove")] public interface IPointerSourceAction : ISourceAction; -public sealed record PointerSourceActions(string Id, IEnumerable Actions) +public sealed record PointerSourceActions(string Id, ImmutableArray Actions) : SourceActions(Id, Actions) { public PointerParameters? Parameters { get; init; } @@ -68,14 +68,14 @@ public sealed record PointerSourceActions(string Id, IEnumerable Actions) +public sealed record WheelSourceActions(string Id, ImmutableArray Actions) : SourceActions(Id, Actions); [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] [JsonDerivedType(typeof(PauseAction), "pause")] public interface INoneSourceAction : ISourceAction; -public sealed record NoneSourceActions(string Id, IEnumerable Actions) +public sealed record NoneSourceActions(string Id, ImmutableArray Actions) : SourceActions(Id, Actions); public sealed record KeyDownAction(char Value) : IKeySourceAction; diff --git a/dotnet/src/webdriver/BiDi/Log/EntryAddedEvent.cs b/dotnet/src/webdriver/BiDi/Log/EntryAddedEvent.cs index 383abfc04a6a2..a789329ee92d6 100644 --- a/dotnet/src/webdriver/BiDi/Log/EntryAddedEvent.cs +++ b/dotnet/src/webdriver/BiDi/Log/EntryAddedEvent.cs @@ -51,7 +51,7 @@ public sealed record ConsoleEntryAddedEventArgs( string? Text, DateTimeOffset Timestamp, string Method, - IReadOnlyList Args) + ImmutableArray Args) : EntryAddedEventArgs(BiDi, Level, Source, Text, Timestamp); public sealed record JavascriptEntryAddedEventArgs( @@ -100,7 +100,7 @@ internal sealed record ConsoleLogEntry( string? Text, DateTimeOffset Timestamp, string Method, - IReadOnlyList Args) + ImmutableArray Args) : LogEntry(Level, Source, Text, Timestamp); internal sealed record JavascriptLogEntry( diff --git a/dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs b/dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs index a5db15c0843b5..4c7dc75352d19 100644 --- a/dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs +++ b/dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs @@ -22,22 +22,22 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed record AddDataCollectorParameters(IEnumerable DataTypes, int MaxEncodedDataSize, CollectorType? CollectorType, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record AddDataCollectorParameters(ImmutableArray DataTypes, int MaxEncodedDataSize, CollectorType? CollectorType, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; public sealed record AddDataCollectorOptions : CommandOptions { public CollectorType? CollectorType { get; init; } - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record ContextAddDataCollectorOptions : CommandOptions { public CollectorType? CollectorType { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } internal static AddDataCollectorOptions WithContext(ContextAddDataCollectorOptions? options, BrowsingContext.BrowsingContext context) => new() { diff --git a/dotnet/src/webdriver/BiDi/Network/AddIntercept.cs b/dotnet/src/webdriver/BiDi/Network/AddIntercept.cs index c8dbf1eca435d..ec4a6666890b7 100644 --- a/dotnet/src/webdriver/BiDi/Network/AddIntercept.cs +++ b/dotnet/src/webdriver/BiDi/Network/AddIntercept.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed record AddInterceptParameters(IEnumerable Phases, IEnumerable? Contexts, IEnumerable? UrlPatterns) : Parameters; +internal sealed record AddInterceptParameters(ImmutableArray Phases, ImmutableArray? Contexts, ImmutableArray? UrlPatterns) : Parameters; public record AddInterceptOptions() : CommandOptions { @@ -32,14 +32,14 @@ internal AddInterceptOptions(ContextAddInterceptOptions? options) : this() Timeout = options?.Timeout; } - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UrlPatterns { get; init; } + public ImmutableArray? UrlPatterns { get; init; } } public record ContextAddInterceptOptions : CommandOptions { - public IEnumerable? UrlPatterns { get; init; } + public ImmutableArray? UrlPatterns { get; init; } } public sealed record AddInterceptResult(Intercept Intercept) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Network/AuthRequiredEvent.cs b/dotnet/src/webdriver/BiDi/Network/AuthRequiredEvent.cs index 073674e6bd3ef..9a4c727f34880 100644 --- a/dotnet/src/webdriver/BiDi/Network/AuthRequiredEvent.cs +++ b/dotnet/src/webdriver/BiDi/Network/AuthRequiredEvent.cs @@ -28,7 +28,7 @@ public record AuthRequiredEventArgs( RequestData Request, DateTimeOffset Timestamp, Browser.UserContext? UserContext, - IReadOnlyList? Intercepts, + ImmutableArray? Intercepts, ResponseData Response) : EventArgs(BiDi); @@ -41,5 +41,5 @@ internal record AuthRequiredParameters( DateTimeOffset Timestamp, ResponseData Response, Browser.UserContext? UserContext, - IReadOnlyList? Intercepts) + ImmutableArray? Intercepts) : BaseParameters(Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, UserContext, Intercepts); diff --git a/dotnet/src/webdriver/BiDi/Network/BaseParameters.cs b/dotnet/src/webdriver/BiDi/Network/BaseParameters.cs index 63e06dad0e847..f305307da97ad 100644 --- a/dotnet/src/webdriver/BiDi/Network/BaseParameters.cs +++ b/dotnet/src/webdriver/BiDi/Network/BaseParameters.cs @@ -30,4 +30,4 @@ internal abstract record BaseParameters( RequestData Request, [property: JsonConverter(typeof(DateTimeOffsetConverter))] DateTimeOffset Timestamp, Browser.UserContext? UserContext, - IReadOnlyList? Intercepts); + ImmutableArray? Intercepts); diff --git a/dotnet/src/webdriver/BiDi/Network/BeforeRequestSentEvent.cs b/dotnet/src/webdriver/BiDi/Network/BeforeRequestSentEvent.cs index e9ddbe9d8de19..be8de05634a60 100644 --- a/dotnet/src/webdriver/BiDi/Network/BeforeRequestSentEvent.cs +++ b/dotnet/src/webdriver/BiDi/Network/BeforeRequestSentEvent.cs @@ -31,7 +31,7 @@ public record BeforeRequestSentEventArgs( DateTimeOffset Timestamp, Initiator Initiator, Browser.UserContext? UserContext, - IReadOnlyList? Intercepts) : EventArgs(BiDi); + ImmutableArray? Intercepts) : EventArgs(BiDi); internal record BeforeRequestSentParameters( BrowsingContext.BrowsingContext? Context, @@ -42,5 +42,5 @@ internal record BeforeRequestSentParameters( DateTimeOffset Timestamp, Initiator Initiator, Browser.UserContext? UserContext, - IReadOnlyList? Intercepts) + ImmutableArray? Intercepts) : BaseParameters(Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, UserContext, Intercepts); diff --git a/dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs b/dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs index 5515ed8bd50de..62ebecf740a98 100644 --- a/dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs +++ b/dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs @@ -19,15 +19,15 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed record ContinueRequestParameters(Request Request, BytesValue? Body, IEnumerable? Cookies, IEnumerable
? Headers, string? Method, string? Url) : Parameters; +internal sealed record ContinueRequestParameters(Request Request, BytesValue? Body, ImmutableArray? Cookies, ImmutableArray
? Headers, string? Method, string? Url) : Parameters; public sealed record ContinueRequestOptions : CommandOptions { public BytesValue? Body { get; init; } - public IEnumerable? Cookies { get; init; } + public ImmutableArray? Cookies { get; init; } - public IEnumerable
? Headers { get; init; } + public ImmutableArray
? Headers { get; init; } public string? Method { get; init; } diff --git a/dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs b/dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs index fe2c73289f9bc..b7b2bcc281ae0 100644 --- a/dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs +++ b/dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs @@ -19,15 +19,15 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed record ContinueResponseParameters(Request Request, IEnumerable? Cookies, IEnumerable? Credentials, IEnumerable
? Headers, string? ReasonPhrase, long? StatusCode) : Parameters; +internal sealed record ContinueResponseParameters(Request Request, ImmutableArray? Cookies, ImmutableArray? Credentials, ImmutableArray
? Headers, string? ReasonPhrase, long? StatusCode) : Parameters; public sealed record ContinueResponseOptions : CommandOptions { - public IEnumerable? Cookies { get; init; } + public ImmutableArray? Cookies { get; init; } - public IEnumerable? Credentials { get; init; } + public ImmutableArray? Credentials { get; init; } - public IEnumerable
? Headers { get; init; } + public ImmutableArray
? Headers { get; init; } public string? ReasonPhrase { get; init; } diff --git a/dotnet/src/webdriver/BiDi/Network/FetchErrorEvent.cs b/dotnet/src/webdriver/BiDi/Network/FetchErrorEvent.cs index b7057f720f367..72ae88a982f1a 100644 --- a/dotnet/src/webdriver/BiDi/Network/FetchErrorEvent.cs +++ b/dotnet/src/webdriver/BiDi/Network/FetchErrorEvent.cs @@ -31,7 +31,7 @@ public sealed record FetchErrorEventArgs( DateTimeOffset Timestamp, string ErrorText, Browser.UserContext? UserContext, - IReadOnlyList? Intercepts) + ImmutableArray? Intercepts) : EventArgs(BiDi); internal sealed record FetchErrorParameters( @@ -43,5 +43,5 @@ internal sealed record FetchErrorParameters( DateTimeOffset Timestamp, string ErrorText, Browser.UserContext? UserContext, - IReadOnlyList? Intercepts) + ImmutableArray? Intercepts) : BaseParameters(Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, UserContext, Intercepts); diff --git a/dotnet/src/webdriver/BiDi/Network/INetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/INetworkModule.cs index a7c71cf2dce18..48e0406e70700 100644 --- a/dotnet/src/webdriver/BiDi/Network/INetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/INetworkModule.cs @@ -21,8 +21,8 @@ namespace OpenQA.Selenium.BiDi.Network; public interface INetworkModule { - Task AddDataCollectorAsync(IEnumerable dataTypes, int maxEncodedDataSize, AddDataCollectorOptions? options = null, CancellationToken cancellationToken = default); - Task AddInterceptAsync(IEnumerable phases, AddInterceptOptions? options = null, CancellationToken cancellationToken = default); + Task AddDataCollectorAsync(ImmutableArray dataTypes, int maxEncodedDataSize, AddDataCollectorOptions? options = null, CancellationToken cancellationToken = default); + Task AddInterceptAsync(ImmutableArray phases, AddInterceptOptions? options = null, CancellationToken cancellationToken = default); Task DisownDataAsync(DataType dataType, Collector collector, Request request, DisownDataOptions? options = null, CancellationToken cancellationToken = default); Task ContinueRequestAsync(Request request, ContinueRequestOptions? options = null, CancellationToken cancellationToken = default); Task ContinueResponseAsync(Request request, ContinueResponseOptions? options = null, CancellationToken cancellationToken = default); @@ -38,5 +38,5 @@ public interface INetworkModule Task RemoveDataCollectorAsync(Collector collector, RemoveDataCollectorOptions? options = null, CancellationToken cancellationToken = default); Task RemoveInterceptAsync(Intercept intercept, RemoveInterceptOptions? options = null, CancellationToken cancellationToken = default); Task SetCacheBehaviorAsync(CacheBehavior behavior, SetCacheBehaviorOptions? options = null, CancellationToken cancellationToken = default); - Task SetExtraHeadersAsync(IEnumerable
headers, SetExtraHeadersOptions? options = null, CancellationToken cancellationToken = default); + Task SetExtraHeadersAsync(ImmutableArray
headers, SetExtraHeadersOptions? options = null, CancellationToken cancellationToken = default); } diff --git a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs index ca5f9d29b9f52..65b4b727f79dd 100644 --- a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs @@ -64,14 +64,14 @@ internal sealed partial class NetworkModule : Module, INetworkModule private static readonly Command ContinueWithAuthCommand = new( "network.continueWithAuth", Default.ContinueWithAuthParameters, Default.ContinueWithAuthResult); - public async Task AddDataCollectorAsync(IEnumerable dataTypes, int maxEncodedDataSize, AddDataCollectorOptions? options = null, CancellationToken cancellationToken = default) + public async Task AddDataCollectorAsync(ImmutableArray dataTypes, int maxEncodedDataSize, AddDataCollectorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new AddDataCollectorParameters(dataTypes, maxEncodedDataSize, options?.CollectorType, options?.Contexts, options?.UserContexts); return await ExecuteAsync(AddDataCollectorCommand, @params, options, cancellationToken).ConfigureAwait(false); } - public async Task AddInterceptAsync(IEnumerable phases, AddInterceptOptions? options = null, CancellationToken cancellationToken = default) + public async Task AddInterceptAsync(ImmutableArray phases, AddInterceptOptions? options = null, CancellationToken cancellationToken = default) { var @params = new AddInterceptParameters(phases, options?.Contexts, options?.UrlPatterns); @@ -99,7 +99,7 @@ public async Task SetCacheBehaviorAsync(CacheBehavior be return await ExecuteAsync(SetCacheBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); } - public async Task SetExtraHeadersAsync(IEnumerable
headers, SetExtraHeadersOptions? options = null, CancellationToken cancellationToken = default) + public async Task SetExtraHeadersAsync(ImmutableArray
headers, SetExtraHeadersOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetExtraHeadersParameters(headers, options?.Contexts, options?.UserContexts); diff --git a/dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs b/dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs index 7564e5897ad2e..91fbb0a5a3acb 100644 --- a/dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs +++ b/dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs @@ -19,15 +19,15 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed record ProvideResponseParameters(Request Request, BytesValue? Body, IEnumerable? Cookies, IEnumerable
? Headers, string? ReasonPhrase, long? StatusCode) : Parameters; +internal sealed record ProvideResponseParameters(Request Request, BytesValue? Body, ImmutableArray? Cookies, ImmutableArray
? Headers, string? ReasonPhrase, long? StatusCode) : Parameters; public sealed record ProvideResponseOptions : CommandOptions { public BytesValue? Body { get; init; } - public IEnumerable? Cookies { get; init; } + public ImmutableArray? Cookies { get; init; } - public IEnumerable
? Headers { get; init; } + public ImmutableArray
? Headers { get; init; } public string? ReasonPhrase { get; init; } diff --git a/dotnet/src/webdriver/BiDi/Network/RequestData.cs b/dotnet/src/webdriver/BiDi/Network/RequestData.cs index 3806452e421ec..c602efe037929 100644 --- a/dotnet/src/webdriver/BiDi/Network/RequestData.cs +++ b/dotnet/src/webdriver/BiDi/Network/RequestData.cs @@ -23,8 +23,8 @@ public sealed record RequestData( Request Request, string Url, string Method, - IReadOnlyList
Headers, - IReadOnlyList Cookies, + ImmutableArray
Headers, + ImmutableArray Cookies, long? HeadersSize, long? BodySize, string Destination, diff --git a/dotnet/src/webdriver/BiDi/Network/ResponseCompletedEvent.cs b/dotnet/src/webdriver/BiDi/Network/ResponseCompletedEvent.cs index 3cdb670c25f54..a17e0daa517d4 100644 --- a/dotnet/src/webdriver/BiDi/Network/ResponseCompletedEvent.cs +++ b/dotnet/src/webdriver/BiDi/Network/ResponseCompletedEvent.cs @@ -31,7 +31,7 @@ public sealed record ResponseCompletedEventArgs( DateTimeOffset Timestamp, ResponseData Response, Browser.UserContext? UserContext, - IReadOnlyList? Intercepts) + ImmutableArray? Intercepts) : EventArgs(BiDi); internal sealed record ResponseCompletedParameters( @@ -42,6 +42,6 @@ internal sealed record ResponseCompletedParameters( RequestData Request, DateTimeOffset Timestamp, Browser.UserContext? UserContext, - IReadOnlyList? Intercepts, + ImmutableArray? Intercepts, ResponseData Response) : BaseParameters(Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, UserContext, Intercepts); diff --git a/dotnet/src/webdriver/BiDi/Network/ResponseData.cs b/dotnet/src/webdriver/BiDi/Network/ResponseData.cs index 071b5fefa4e12..a9cdbee49e8de 100644 --- a/dotnet/src/webdriver/BiDi/Network/ResponseData.cs +++ b/dotnet/src/webdriver/BiDi/Network/ResponseData.cs @@ -24,10 +24,10 @@ public record ResponseData(string Url, int Status, // TODO: should be unit string StatusText, bool FromCache, - IReadOnlyList
Headers, + ImmutableArray
Headers, string MimeType, long BytesReceived, long? HeadersSize, long? BodySize, ResponseContent Content, - IReadOnlyList? AuthChallenges); + ImmutableArray? AuthChallenges); diff --git a/dotnet/src/webdriver/BiDi/Network/ResponseStartedEvent.cs b/dotnet/src/webdriver/BiDi/Network/ResponseStartedEvent.cs index cfe543c07b0c9..1686d7411d6c7 100644 --- a/dotnet/src/webdriver/BiDi/Network/ResponseStartedEvent.cs +++ b/dotnet/src/webdriver/BiDi/Network/ResponseStartedEvent.cs @@ -31,7 +31,7 @@ public record ResponseStartedEventArgs( DateTimeOffset Timestamp, ResponseData Response, Browser.UserContext? UserContext, - IReadOnlyList? Intercepts) + ImmutableArray? Intercepts) : EventArgs(BiDi); internal record ResponseStartedParameters( @@ -43,5 +43,5 @@ internal record ResponseStartedParameters( DateTimeOffset Timestamp, ResponseData Response, Browser.UserContext? UserContext, - IReadOnlyList? Intercepts) + ImmutableArray? Intercepts) : BaseParameters(Context, IsBlocked, Navigation, RedirectCount, Request, Timestamp, UserContext, Intercepts); diff --git a/dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs b/dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs index 7307aff1a72cc..8ae745939c4c3 100644 --- a/dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs +++ b/dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs @@ -22,11 +22,11 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed record SetCacheBehaviorParameters(CacheBehavior CacheBehavior, IEnumerable? Contexts) : Parameters; +internal sealed record SetCacheBehaviorParameters(CacheBehavior CacheBehavior, ImmutableArray? Contexts) : Parameters; public sealed record SetCacheBehaviorOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } } public sealed record ContextSetCacheBehaviorOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs b/dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs index c3305301085dc..d787282a78bfb 100644 --- a/dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs +++ b/dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs @@ -19,13 +19,13 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed record SetExtraHeadersParameters(IEnumerable
Headers, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; +internal sealed record SetExtraHeadersParameters(ImmutableArray
Headers, ImmutableArray? Contexts, ImmutableArray? UserContexts) : Parameters; public sealed record SetExtraHeadersOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } public sealed record SetExtraHeadersResult : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs b/dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs index d4601cc730fc3..2a859cee1fb42 100644 --- a/dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs +++ b/dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs @@ -21,22 +21,22 @@ namespace OpenQA.Selenium.BiDi.Script; -internal sealed record AddPreloadScriptParameters([StringSyntax(StringSyntaxConstants.JavaScript)] string FunctionDeclaration, IEnumerable? Arguments, IEnumerable? Contexts, IEnumerable? UserContexts, string? Sandbox) : Parameters; +internal sealed record AddPreloadScriptParameters([StringSyntax(StringSyntaxConstants.JavaScript)] string FunctionDeclaration, ImmutableArray? Arguments, ImmutableArray? Contexts, ImmutableArray? UserContexts, string? Sandbox) : Parameters; public sealed record AddPreloadScriptOptions : CommandOptions { - public IEnumerable? Arguments { get; init; } + public ImmutableArray? Arguments { get; init; } - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } public string? Sandbox { get; init; } } public sealed record ContextAddPreloadScriptOptions : CommandOptions { - public IEnumerable? Arguments { get; init; } + public ImmutableArray? Arguments { get; init; } public string? Sandbox { get; init; } diff --git a/dotnet/src/webdriver/BiDi/Script/CallFunction.cs b/dotnet/src/webdriver/BiDi/Script/CallFunction.cs index 2adbc739ecc38..ce614131bb912 100644 --- a/dotnet/src/webdriver/BiDi/Script/CallFunction.cs +++ b/dotnet/src/webdriver/BiDi/Script/CallFunction.cs @@ -21,11 +21,11 @@ namespace OpenQA.Selenium.BiDi.Script; -internal sealed record CallFunctionParameters([StringSyntax(StringSyntaxConstants.JavaScript)] string FunctionDeclaration, bool AwaitPromise, Target Target, IEnumerable? Arguments, ResultOwnership? ResultOwnership, SerializationOptions? SerializationOptions, LocalValue? This, bool? UserActivation) : Parameters; +internal sealed record CallFunctionParameters([StringSyntax(StringSyntaxConstants.JavaScript)] string FunctionDeclaration, bool AwaitPromise, Target Target, ImmutableArray? Arguments, ResultOwnership? ResultOwnership, SerializationOptions? SerializationOptions, LocalValue? This, bool? UserActivation) : Parameters; public sealed record CallFunctionOptions : CommandOptions { - public IEnumerable? Arguments { get; init; } + public ImmutableArray? Arguments { get; init; } public ResultOwnership? ResultOwnership { get; init; } diff --git a/dotnet/src/webdriver/BiDi/Script/Disown.cs b/dotnet/src/webdriver/BiDi/Script/Disown.cs index cefd9d1bb520d..9f31b01681ee0 100644 --- a/dotnet/src/webdriver/BiDi/Script/Disown.cs +++ b/dotnet/src/webdriver/BiDi/Script/Disown.cs @@ -19,7 +19,7 @@ namespace OpenQA.Selenium.BiDi.Script; -internal sealed record DisownParameters(IEnumerable Handles, Target Target) : Parameters; +internal sealed record DisownParameters(ImmutableArray Handles, Target Target) : Parameters; public sealed record DisownOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Script/GetRealms.cs b/dotnet/src/webdriver/BiDi/Script/GetRealms.cs index 8530150c508cc..b4916e3abbcd5 100644 --- a/dotnet/src/webdriver/BiDi/Script/GetRealms.cs +++ b/dotnet/src/webdriver/BiDi/Script/GetRealms.cs @@ -40,4 +40,4 @@ public sealed record ContextGetRealmsOptions : CommandOptions }; } -public sealed record GetRealmsResult(IReadOnlyList Realms) : EmptyResult; +public sealed record GetRealmsResult(ImmutableArray Realms) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Script/IScriptModule.cs b/dotnet/src/webdriver/BiDi/Script/IScriptModule.cs index 1995bda6c9a53..39311e3be9952 100644 --- a/dotnet/src/webdriver/BiDi/Script/IScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Script/IScriptModule.cs @@ -26,7 +26,7 @@ public interface IScriptModule Task AddPreloadScriptAsync([StringSyntax("javascript")] string functionDeclaration, AddPreloadScriptOptions? options = null, CancellationToken cancellationToken = default); Task CallFunctionAsync([StringSyntax("javascript")] string functionDeclaration, bool awaitPromise, Target target, CallFunctionOptions? options = null, CancellationToken cancellationToken = default); Task CallFunctionAsync([StringSyntax("javascript")] string functionDeclaration, bool awaitPromise, Target target, CallFunctionOptions? options = null, CancellationToken cancellationToken = default); - Task DisownAsync(IEnumerable handles, Target target, DisownOptions? options = null, CancellationToken cancellationToken = default); + Task DisownAsync(ImmutableArray handles, Target target, DisownOptions? options = null, CancellationToken cancellationToken = default); Task EvaluateAsync([StringSyntax("javascript")] string expression, bool awaitPromise, Target target, EvaluateOptions? options = null, CancellationToken cancellationToken = default); Task EvaluateAsync([StringSyntax("javascript")] string expression, bool awaitPromise, Target target, EvaluateOptions? options = null, CancellationToken cancellationToken = default); Task GetRealmsAsync(GetRealmsOptions? options = null, CancellationToken cancellationToken = default); diff --git a/dotnet/src/webdriver/BiDi/Script/LocalValue.cs b/dotnet/src/webdriver/BiDi/Script/LocalValue.cs index 233fb15cd5366..0f555854f0671 100644 --- a/dotnet/src/webdriver/BiDi/Script/LocalValue.cs +++ b/dotnet/src/webdriver/BiDi/Script/LocalValue.cs @@ -89,14 +89,7 @@ public static LocalValue ConvertFrom(object? value) { IEnumerable set = (IEnumerable)value; - List setValues = []; - - foreach (var obj in set) - { - setValues.Add(ConvertFrom(obj)); - } - - return new SetLocalValue(setValues); + return new SetLocalValue([.. set.Cast().Select(ConvertFrom)]); } case IDictionary dictionary: @@ -208,14 +201,7 @@ public static LocalValue ConvertFrom(IEnumerable? value) return new NullLocalValue(); } - List list = []; - - foreach (var element in value) - { - list.Add(ConvertFrom(element)); - } - - return new ArrayLocalValue(list); + return new ArrayLocalValue([.. value.Cast().Select(ConvertFrom)]); } public static LocalValue ConvertFrom(IDictionary? value) @@ -225,14 +211,14 @@ public static LocalValue ConvertFrom(IDictionary? value) return new NullLocalValue(); } - var bidiObject = new List>(value.Count); + var builder = ImmutableArray.CreateBuilder>(value.Count); - foreach (var key in value.Keys) + foreach (DictionaryEntry entry in value) { - bidiObject.Add([ConvertFrom(key), ConvertFrom(value[key])]); + builder.Add([ConvertFrom(entry.Key), ConvertFrom(entry.Value)]); } - return new MapLocalValue(bidiObject); + return new MapLocalValue(builder.MoveToImmutable()); } public static LocalValue ConvertFrom(ISet? value) @@ -242,9 +228,7 @@ public static LocalValue ConvertFrom(ISet? value) return new NullLocalValue(); } - LocalValue[] convertedValues = [.. value.Select(x => ConvertFrom(x))]; - - return new SetLocalValue(convertedValues); + return new SetLocalValue([.. value.Select(x => ConvertFrom(x))]); } private static LocalValue ReflectionBasedConvertFrom(object? value) @@ -258,7 +242,7 @@ private static LocalValue ReflectionBasedConvertFrom(object? value) System.Reflection.PropertyInfo[] properties = value.GetType().GetProperties(Flags); - var values = new List>(properties.Length); + var builder = ImmutableArray.CreateBuilder>(properties.Length); foreach (System.Reflection.PropertyInfo? property in properties) { @@ -273,10 +257,10 @@ private static LocalValue ReflectionBasedConvertFrom(object? value) throw new BiDiException($"Could not retrieve property {property.Name} from {property.DeclaringType}", ex); } - values.Add([property.Name, ConvertFrom(propertyValue)]); + builder.Add([property.Name, ConvertFrom(propertyValue)]); } - return new ObjectLocalValue(values); + return new ObjectLocalValue(builder.MoveToImmutable()); } [JsonInclude] @@ -338,7 +322,7 @@ public sealed record ChannelLocalValue(ChannelProperties Value) : LocalValue internal override string Type { get; } = "channel"; } -public sealed record ArrayLocalValue(IEnumerable Value) : LocalValue +public sealed record ArrayLocalValue(ImmutableArray Value) : LocalValue { internal override string Type { get; } = "array"; } @@ -348,12 +332,12 @@ public sealed record DateLocalValue(string Value) : LocalValue internal override string Type { get; } = "date"; } -public sealed record MapLocalValue(IEnumerable> Value) : LocalValue +public sealed record MapLocalValue(ImmutableArray> Value) : LocalValue { internal override string Type { get; } = "map"; } -public sealed record ObjectLocalValue(IEnumerable> Value) : LocalValue +public sealed record ObjectLocalValue(ImmutableArray> Value) : LocalValue { internal override string Type { get; } = "object"; } @@ -363,7 +347,7 @@ public sealed record RegExpLocalValue(RegExpValue Value) : LocalValue internal override string Type { get; } = "regexp"; } -public sealed record SetLocalValue(IEnumerable Value) : LocalValue +public sealed record SetLocalValue(ImmutableArray Value) : LocalValue { internal override string Type { get; } = "set"; } diff --git a/dotnet/src/webdriver/BiDi/Script/NodeProperties.cs b/dotnet/src/webdriver/BiDi/Script/NodeProperties.cs index 6e0e776269894..2cd1357111f9d 100644 --- a/dotnet/src/webdriver/BiDi/Script/NodeProperties.cs +++ b/dotnet/src/webdriver/BiDi/Script/NodeProperties.cs @@ -19,4 +19,4 @@ namespace OpenQA.Selenium.BiDi.Script; -public sealed record NodeProperties(long NodeType, long ChildNodeCount, IReadOnlyDictionary? Attributes, IReadOnlyList? Children, string? LocalName, Mode? Mode, string? NamespaceUri, string? NodeValue, NodeRemoteValue? ShadowRoot); +public sealed record NodeProperties(long NodeType, long ChildNodeCount, ImmutableDictionary? Attributes, ImmutableArray? Children, string? LocalName, Mode? Mode, string? NamespaceUri, string? NodeValue, NodeRemoteValue? ShadowRoot); diff --git a/dotnet/src/webdriver/BiDi/Script/RealmInfo.cs b/dotnet/src/webdriver/BiDi/Script/RealmInfo.cs index 2081b841669ca..07f83293e210f 100644 --- a/dotnet/src/webdriver/BiDi/Script/RealmInfo.cs +++ b/dotnet/src/webdriver/BiDi/Script/RealmInfo.cs @@ -51,7 +51,7 @@ public sealed record WindowRealmInfo( public sealed record DedicatedWorkerRealmInfo( Realm Realm, string Origin, - IReadOnlyList Owners) : RealmInfo(Realm, Origin); + ImmutableArray Owners) : RealmInfo(Realm, Origin); public sealed record SharedWorkerRealmInfo( Realm Realm, diff --git a/dotnet/src/webdriver/BiDi/Script/RealmInfoEvent.cs b/dotnet/src/webdriver/BiDi/Script/RealmInfoEvent.cs index c4db4386f1e75..78e71ac406070 100644 --- a/dotnet/src/webdriver/BiDi/Script/RealmInfoEvent.cs +++ b/dotnet/src/webdriver/BiDi/Script/RealmInfoEvent.cs @@ -36,7 +36,7 @@ public sealed record DedicatedWorkerRealmCreatedEventArgs( IBiDi BiDi, Realm Realm, string Origin, - IReadOnlyList Owners) : RealmCreatedEventArgs(BiDi, Realm, Origin); + ImmutableArray Owners) : RealmCreatedEventArgs(BiDi, Realm, Origin); public sealed record SharedWorkerRealmCreatedEventArgs( IBiDi BiDi, diff --git a/dotnet/src/webdriver/BiDi/Script/RemoteValue.cs b/dotnet/src/webdriver/BiDi/Script/RemoteValue.cs index 530fcc7839904..e996b0325b0c1 100644 --- a/dotnet/src/webdriver/BiDi/Script/RemoteValue.cs +++ b/dotnet/src/webdriver/BiDi/Script/RemoteValue.cs @@ -117,7 +117,7 @@ private TResult ConvertToNullable(Type underlyingType) return (TResult)value!; } - private static TResult ConvertRemoteValuesToArray(IEnumerable? remoteValues, Type elementType) + private static TResult ConvertRemoteValuesToArray(ImmutableArray? remoteValues, Type elementType) { if (remoteValues is null) { @@ -125,10 +125,10 @@ private static TResult ConvertRemoteValuesToArray(IEnumerable(IEnumerable(IEnumerable? remoteValues, Type listType) + private static TResult ConvertRemoteValuesToGenericList(ImmutableArray? remoteValues, Type listType) { var elementType = listType.GetGenericArguments()[0]; var list = (System.Collections.IList)Activator.CreateInstance(listType)!; @@ -146,7 +146,7 @@ private static TResult ConvertRemoteValuesToGenericList(IEnumerable(IEnumerable(IReadOnlyList>? remoteValues, Type dictionaryType) + private static TResult ConvertRemoteValuesToDictionary(ImmutableArray>? remoteValues, Type dictionaryType) { var typeArgs = dictionaryType.GetGenericArguments(); var dict = (System.Collections.IDictionary)Activator.CreateInstance(dictionaryType)!; @@ -166,11 +166,11 @@ private static TResult ConvertRemoteValuesToDictionary(IReadOnlyList? Value { get; init; } + public ImmutableArray? Value { get; init; } } public sealed record ObjectRemoteValue : RemoteValue @@ -219,7 +219,7 @@ public sealed record ObjectRemoteValue : RemoteValue public InternalId? InternalId { get; init; } - public IReadOnlyList>? Value { get; init; } + public ImmutableArray>? Value { get; init; } } public sealed record FunctionRemoteValue : RemoteValue @@ -249,7 +249,7 @@ public sealed record MapRemoteValue : RemoteValue public InternalId? InternalId { get; init; } - public IReadOnlyList>? Value { get; init; } + public ImmutableArray>? Value { get; init; } } public sealed record SetRemoteValue : RemoteValue @@ -258,7 +258,7 @@ public sealed record SetRemoteValue : RemoteValue public InternalId? InternalId { get; init; } - public IReadOnlyList? Value { get; init; } + public ImmutableArray? Value { get; init; } } public sealed record WeakMapRemoteValue : RemoteValue @@ -323,7 +323,7 @@ public sealed record NodeListRemoteValue : RemoteValue public InternalId? InternalId { get; init; } - public IReadOnlyList? Value { get; init; } + public ImmutableArray? Value { get; init; } } public sealed record HtmlCollectionRemoteValue : RemoteValue @@ -332,7 +332,7 @@ public sealed record HtmlCollectionRemoteValue : RemoteValue public InternalId? InternalId { get; init; } - public IReadOnlyList? Value { get; init; } + public ImmutableArray? Value { get; init; } } public sealed record NodeRemoteValue(string SharedId, NodeProperties? Value) : RemoteValue, ISharedReference diff --git a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs index 060264bf5ab16..17f45aa0c9962 100644 --- a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs @@ -71,7 +71,7 @@ public async Task CallFunctionAsync([StringSyntax(StringSyntaxCo return result.AsSuccessResult().ConvertTo(); } - public async Task DisownAsync(IEnumerable handles, Target target, DisownOptions? options = null, CancellationToken cancellationToken = default) + public async Task DisownAsync(ImmutableArray handles, Target target, DisownOptions? options = null, CancellationToken cancellationToken = default) { var @params = new DisownParameters(handles, target); diff --git a/dotnet/src/webdriver/BiDi/Script/StackTrace.cs b/dotnet/src/webdriver/BiDi/Script/StackTrace.cs index cab31ec97bc26..81087b3203c56 100644 --- a/dotnet/src/webdriver/BiDi/Script/StackTrace.cs +++ b/dotnet/src/webdriver/BiDi/Script/StackTrace.cs @@ -19,4 +19,4 @@ namespace OpenQA.Selenium.BiDi.Script; -public sealed record StackTrace(IReadOnlyList CallFrames); +public sealed record StackTrace(ImmutableArray CallFrames); diff --git a/dotnet/src/webdriver/BiDi/Session/CapabilitiesRequest.cs b/dotnet/src/webdriver/BiDi/Session/CapabilitiesRequest.cs index 77c405b473e4f..9163324eab2fd 100644 --- a/dotnet/src/webdriver/BiDi/Session/CapabilitiesRequest.cs +++ b/dotnet/src/webdriver/BiDi/Session/CapabilitiesRequest.cs @@ -23,5 +23,5 @@ public sealed record CapabilitiesRequest { public CapabilityRequest? AlwaysMatch { get; init; } - public IEnumerable? FirstMatch { get; init; } + public ImmutableArray? FirstMatch { get; init; } } diff --git a/dotnet/src/webdriver/BiDi/Session/ISessionModule.cs b/dotnet/src/webdriver/BiDi/Session/ISessionModule.cs index ec51ed7ccb55a..b79ec4e1e90ab 100644 --- a/dotnet/src/webdriver/BiDi/Session/ISessionModule.cs +++ b/dotnet/src/webdriver/BiDi/Session/ISessionModule.cs @@ -24,6 +24,6 @@ internal interface ISessionModule Task EndAsync(EndOptions? options = null, CancellationToken cancellationToken = default); Task NewAsync(CapabilitiesRequest capabilities, NewOptions? options = null, CancellationToken cancellationToken = default); Task StatusAsync(StatusOptions? options = null, CancellationToken cancellationToken = default); - Task SubscribeAsync(IEnumerable events, SubscribeOptions? options = null, CancellationToken cancellationToken = default); - Task UnsubscribeAsync(IEnumerable subscriptions, UnsubscribeByIdOptions? options = null, CancellationToken cancellationToken = default); + Task SubscribeAsync(ImmutableArray events, SubscribeOptions? options = null, CancellationToken cancellationToken = default); + Task UnsubscribeAsync(ImmutableArray subscriptions, UnsubscribeByIdOptions? options = null, CancellationToken cancellationToken = default); } diff --git a/dotnet/src/webdriver/BiDi/Session/ProxyConfiguration.cs b/dotnet/src/webdriver/BiDi/Session/ProxyConfiguration.cs index 51eff5970210b..259c48cbb3689 100644 --- a/dotnet/src/webdriver/BiDi/Session/ProxyConfiguration.cs +++ b/dotnet/src/webdriver/BiDi/Session/ProxyConfiguration.cs @@ -43,7 +43,7 @@ public sealed record ManualProxyConfiguration : ProxyConfiguration, ISocksProxyC public int? SocksVersion { get; init; } - public IEnumerable? NoProxy { get; init; } + public ImmutableArray? NoProxy { get; init; } } public sealed record PacProxyConfiguration(string ProxyAutoConfigUrl) : ProxyConfiguration; diff --git a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs index f9234efae1ff9..3dc0c69d75f5c 100644 --- a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs +++ b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs @@ -44,14 +44,14 @@ public async Task StatusAsync(StatusOptions? options = null, Cance return await ExecuteAsync(StatusCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); } - public async Task SubscribeAsync(IEnumerable events, SubscribeOptions? options = null, CancellationToken cancellationToken = default) + public async Task SubscribeAsync(ImmutableArray events, SubscribeOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SubscribeParameters(events, options?.Contexts); return await ExecuteAsync(SubscribeCommand, @params, options, cancellationToken).ConfigureAwait(false); } - public async Task UnsubscribeAsync(IEnumerable subscriptions, UnsubscribeByIdOptions? options = null, CancellationToken cancellationToken = default) + public async Task UnsubscribeAsync(ImmutableArray subscriptions, UnsubscribeByIdOptions? options = null, CancellationToken cancellationToken = default) { var @params = new UnsubscribeByIdParameters(subscriptions); diff --git a/dotnet/src/webdriver/BiDi/Session/Subscribe.cs b/dotnet/src/webdriver/BiDi/Session/Subscribe.cs index ac6031262efd3..82891df9df296 100644 --- a/dotnet/src/webdriver/BiDi/Session/Subscribe.cs +++ b/dotnet/src/webdriver/BiDi/Session/Subscribe.cs @@ -19,13 +19,13 @@ namespace OpenQA.Selenium.BiDi.Session; -internal sealed record SubscribeParameters(IEnumerable Events, IEnumerable? Contexts) : Parameters; +internal sealed record SubscribeParameters(ImmutableArray Events, ImmutableArray? Contexts) : Parameters; public sealed record SubscribeOptions : CommandOptions { - public IEnumerable? Contexts { get; init; } + public ImmutableArray? Contexts { get; init; } - public IEnumerable? UserContexts { get; init; } + public ImmutableArray? UserContexts { get; init; } } internal sealed record SubscribeResult(Subscription Subscription) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs b/dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs index cd84ffab46346..ec695e73eeeca 100644 --- a/dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs +++ b/dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs @@ -19,7 +19,7 @@ namespace OpenQA.Selenium.BiDi.Session; -internal sealed record UnsubscribeByIdParameters(IEnumerable Subscriptions) : Parameters; +internal sealed record UnsubscribeByIdParameters(ImmutableArray Subscriptions) : Parameters; public sealed record UnsubscribeByIdOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Storage/GetCookies.cs b/dotnet/src/webdriver/BiDi/Storage/GetCookies.cs index 1518312ab8e38..e51b483aa276d 100644 --- a/dotnet/src/webdriver/BiDi/Storage/GetCookies.cs +++ b/dotnet/src/webdriver/BiDi/Storage/GetCookies.cs @@ -43,7 +43,7 @@ public sealed record ContextGetCookiesOptions : CommandOptions }; } -public sealed record GetCookiesResult(IReadOnlyList Cookies, PartitionKey PartitionKey) : EmptyResult; +public sealed record GetCookiesResult(ImmutableArray Cookies, PartitionKey PartitionKey) : EmptyResult; public sealed record CookieFilter { diff --git a/dotnet/src/webdriver/Properties/GlobalUsings.cs b/dotnet/src/webdriver/Properties/GlobalUsings.cs index ff37a11f0ee47..1d4ff94dd85d8 100644 --- a/dotnet/src/webdriver/Properties/GlobalUsings.cs +++ b/dotnet/src/webdriver/Properties/GlobalUsings.cs @@ -19,6 +19,7 @@ global using global::System; global using global::System.Collections.Generic; +global using global::System.Collections.Immutable; global using global::System.IO; global using global::System.Linq; global using global::System.Net.Http; diff --git a/dotnet/src/webdriver/Selenium.WebDriver.csproj b/dotnet/src/webdriver/Selenium.WebDriver.csproj index ff959161a9850..ea2f8a07a7997 100644 --- a/dotnet/src/webdriver/Selenium.WebDriver.csproj +++ b/dotnet/src/webdriver/Selenium.WebDriver.csproj @@ -55,6 +55,7 @@ + diff --git a/dotnet/src/webdriver/Selenium.WebDriver.nuspec b/dotnet/src/webdriver/Selenium.WebDriver.nuspec index 825fb73c0f02c..ee82fe2d42370 100644 --- a/dotnet/src/webdriver/Selenium.WebDriver.nuspec +++ b/dotnet/src/webdriver/Selenium.WebDriver.nuspec @@ -25,11 +25,13 @@ + + diff --git a/dotnet/test/webdriver/BiDi/Browser/BrowserTests.cs b/dotnet/test/webdriver/BiDi/Browser/BrowserTests.cs index 548c64cd3c6e9..5c1438964cb6f 100644 --- a/dotnet/test/webdriver/BiDi/Browser/BrowserTests.cs +++ b/dotnet/test/webdriver/BiDi/Browser/BrowserTests.cs @@ -40,7 +40,7 @@ public async Task CanGetUserContexts() var userContextsResult = await bidi.Browser.GetUserContextsAsync(); Assert.That(userContextsResult, Is.Not.Null); - Assert.That(userContextsResult.UserContexts, Has.Count.GreaterThanOrEqualTo(2)); + Assert.That(userContextsResult.UserContexts, Has.Length.GreaterThanOrEqualTo(2)); Assert.That(userContextsResult.UserContexts.Select(contextInfo => contextInfo.UserContext), Does.Contain(userContext1.UserContext)); Assert.That(userContextsResult.UserContexts.Select(contextInfo => contextInfo.UserContext), Does.Contain(userContext2.UserContext)); } @@ -65,7 +65,7 @@ public async Task CanGetClientWindows() var clientWindowsResult = await bidi.Browser.GetClientWindowsAsync(); Assert.That(clientWindowsResult, Is.Not.Null); - Assert.That(clientWindowsResult.ClientWindows, Has.Count.GreaterThanOrEqualTo(1)); + Assert.That(clientWindowsResult.ClientWindows, Has.Length.GreaterThanOrEqualTo(1)); Assert.That(clientWindowsResult.ClientWindows[0].ClientWindow, Is.Not.Null); } diff --git a/dotnet/test/webdriver/BiDi/BrowsingContext/BrowsingContextTests.cs b/dotnet/test/webdriver/BiDi/BrowsingContext/BrowsingContextTests.cs index 3ad07d6856b93..e60f7fb650a7d 100644 --- a/dotnet/test/webdriver/BiDi/BrowsingContext/BrowsingContextTests.cs +++ b/dotnet/test/webdriver/BiDi/BrowsingContext/BrowsingContextTests.cs @@ -103,10 +103,11 @@ public async Task CanGetTreeWithChild() var tree = await context.GetTreeAsync(); - Assert.That(tree.Contexts, Has.Count.EqualTo(1)); + Assert.That(tree.Contexts, Has.Length.EqualTo(1)); Assert.That(tree.Contexts[0].Context, Is.EqualTo(context)); - Assert.That(tree.Contexts[0].Children, Has.Count.EqualTo(1)); - Assert.That(tree.Contexts[0].Children[0].Url, Does.Contain("formPage.html")); + Assert.That(tree.Contexts[0].Children, Is.Not.Null); + Assert.That(tree.Contexts[0].Children.Value, Has.Length.EqualTo(1)); + Assert.That(tree.Contexts[0].Children.Value[0].Url, Does.Contain("formPage.html")); } [Test] @@ -116,7 +117,7 @@ public async Task CanGetTreeWithDepth() var tree = await context.GetTreeAsync(new() { MaxDepth = 0 }); - Assert.That(tree.Contexts, Has.Count.EqualTo(1)); + Assert.That(tree.Contexts, Has.Length.EqualTo(1)); Assert.That(tree.Contexts[0].Context, Is.EqualTo(context)); Assert.That(tree.Contexts[0].Children, Is.Null); } @@ -129,7 +130,7 @@ public async Task CanGetTreeTopLevel() var tree = await bidi.BrowsingContext.GetTreeAsync(); - Assert.That(tree.Contexts, Has.Count.GreaterThanOrEqualTo(2)); + Assert.That(tree.Contexts, Has.Length.GreaterThanOrEqualTo(2)); } [Test] diff --git a/dotnet/test/webdriver/BiDi/Log/LogTests.cs b/dotnet/test/webdriver/BiDi/Log/LogTests.cs index c8b84238bc439..f67e70191e694 100644 --- a/dotnet/test/webdriver/BiDi/Log/LogTests.cs +++ b/dotnet/test/webdriver/BiDi/Log/LogTests.cs @@ -48,8 +48,7 @@ public async Task CanListenToConsoleLog() Assert.That(consoleLogEntry.Method, Is.EqualTo("log")); - Assert.That(consoleLogEntry.Args, Is.Not.Null); - Assert.That(consoleLogEntry.Args, Has.Count.EqualTo(1)); + Assert.That(consoleLogEntry.Args, Has.Length.EqualTo(1)); Assert.That(consoleLogEntry.Args[0], Is.AssignableFrom()); } diff --git a/dotnet/test/webdriver/BiDi/Network/NetworkEventsTests.cs b/dotnet/test/webdriver/BiDi/Network/NetworkEventsTests.cs index ba023a127eb90..92811c67a5301 100644 --- a/dotnet/test/webdriver/BiDi/Network/NetworkEventsTests.cs +++ b/dotnet/test/webdriver/BiDi/Network/NetworkEventsTests.cs @@ -97,7 +97,7 @@ public async Task CanListenToBeforeRequestSentEventWithCookie() var req = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); - Assert.That(req.Request.Cookies, Has.Count.EqualTo(1)); + Assert.That(req.Request.Cookies, Has.Length.EqualTo(1)); Assert.That(req.Request.Cookies[0].Name, Is.EqualTo("foo")); Assert.That((req.Request.Cookies[0].Value as StringBytesValue).Value, Is.EqualTo("bar")); } @@ -119,7 +119,7 @@ public async Task CanListenToOnAuthRequiredEvent() Assert.That(res.Request, Is.Not.Null); Assert.That(res.Request.Method, Is.EqualTo("GET")); Assert.That(res.Request.Url, Does.Contain("basicAuth")); - Assert.That(res.Response.Headers, Is.Not.Null.And.Count.GreaterThanOrEqualTo(1)); + Assert.That(res.Response.Headers, Has.Length.GreaterThanOrEqualTo(1)); Assert.That(res.Response.Status, Is.EqualTo(401)); } diff --git a/dotnet/test/webdriver/BiDi/Script/CallFunctionParameterTests.cs b/dotnet/test/webdriver/BiDi/Script/CallFunctionParameterTests.cs index dde8f80410fea..90cbb65186bad 100644 --- a/dotnet/test/webdriver/BiDi/Script/CallFunctionParameterTests.cs +++ b/dotnet/test/webdriver/BiDi/Script/CallFunctionParameterTests.cs @@ -76,8 +76,8 @@ public async Task CanCallFunctionWithArguments() }); Assert.That(res.AsSuccessResult(), Is.AssignableFrom()); - Assert.That((string)(res.AsSuccessResult() as ArrayRemoteValue).Value[0], Is.EqualTo("abc")); - Assert.That((int)(res.AsSuccessResult() as ArrayRemoteValue).Value[1], Is.EqualTo(42)); + Assert.That((string)(res.AsSuccessResult() as ArrayRemoteValue).Value.Value[0], Is.EqualTo("abc")); + Assert.That((int)(res.AsSuccessResult() as ArrayRemoteValue).Value.Value[1], Is.EqualTo(42)); } [Test] @@ -160,8 +160,8 @@ public async Task CanCallFunctionWithOwnershipRoot() Assert.That(res, Is.Not.Null); Assert.That((res.AsSuccessResult() as ObjectRemoteValue).Handle, Is.Not.Null); - Assert.That((string)(res.AsSuccessResult() as ObjectRemoteValue).Value[0][0], Is.EqualTo("a")); - Assert.That((int)(res.AsSuccessResult() as ObjectRemoteValue).Value[0][1], Is.EqualTo(1)); + Assert.That((string)(res.AsSuccessResult() as ObjectRemoteValue).Value.Value[0][0], Is.EqualTo("a")); + Assert.That((int)(res.AsSuccessResult() as ObjectRemoteValue).Value.Value[0][1], Is.EqualTo(1)); } [Test] @@ -174,8 +174,8 @@ public async Task CanCallFunctionWithOwnershipNone() Assert.That(res, Is.Not.Null); Assert.That((res.AsSuccessResult() as ObjectRemoteValue).Handle, Is.Null); - Assert.That((string)(res.AsSuccessResult() as ObjectRemoteValue).Value[0][0], Is.EqualTo("a")); - Assert.That((int)(res.AsSuccessResult() as ObjectRemoteValue).Value[0][1], Is.EqualTo(1)); + Assert.That((string)(res.AsSuccessResult() as ObjectRemoteValue).Value.Value[0][0], Is.EqualTo("a")); + Assert.That((int)(res.AsSuccessResult() as ObjectRemoteValue).Value.Value[0][1], Is.EqualTo(1)); } [Test] diff --git a/dotnet/test/webdriver/BiDi/Script/EvaluateParametersTests.cs b/dotnet/test/webdriver/BiDi/Script/EvaluateParametersTests.cs index 7fe999f66707c..0ee0d39850313 100644 --- a/dotnet/test/webdriver/BiDi/Script/EvaluateParametersTests.cs +++ b/dotnet/test/webdriver/BiDi/Script/EvaluateParametersTests.cs @@ -85,8 +85,8 @@ public async Task CanEvaluateScriptWithResulWithOwnership() Assert.That(res, Is.Not.Null); Assert.That((res.AsSuccessResult() as ObjectRemoteValue).Handle, Is.Not.Null); - Assert.That((string)(res.AsSuccessResult() as ObjectRemoteValue).Value[0][0], Is.EqualTo("a")); - Assert.That((int)(res.AsSuccessResult() as ObjectRemoteValue).Value[0][1], Is.EqualTo(1)); + Assert.That((string)(res.AsSuccessResult() as ObjectRemoteValue).Value.Value[0][0], Is.EqualTo("a")); + Assert.That((int)(res.AsSuccessResult() as ObjectRemoteValue).Value.Value[0][1], Is.EqualTo(1)); } [Test] diff --git a/dotnet/test/webdriver/BiDi/Script/LocalValueConversionTests.cs b/dotnet/test/webdriver/BiDi/Script/LocalValueConversionTests.cs index 4c8bd9e9e4949..6f6ee37810615 100644 --- a/dotnet/test/webdriver/BiDi/Script/LocalValueConversionTests.cs +++ b/dotnet/test/webdriver/BiDi/Script/LocalValueConversionTests.cs @@ -234,6 +234,6 @@ public void CanConvertObjectValue() var objValue = value as ObjectLocalValue; - Assert.That(objValue.Value, Has.Exactly(5).Count); + Assert.That(objValue.Value, Has.Length.EqualTo(5)); } } diff --git a/dotnet/test/webdriver/BiDi/Script/ScriptCommandsTests.cs b/dotnet/test/webdriver/BiDi/Script/ScriptCommandsTests.cs index 00b3909e51a1e..b0f031850713e 100644 --- a/dotnet/test/webdriver/BiDi/Script/ScriptCommandsTests.cs +++ b/dotnet/test/webdriver/BiDi/Script/ScriptCommandsTests.cs @@ -33,7 +33,7 @@ public async Task CanGetAllRealms() var realmsResult = await bidi.Script.GetRealmsAsync(); Assert.That(realmsResult, Is.Not.Null); - Assert.That(realmsResult.Realms, Has.Count.EqualTo(2)); + Assert.That(realmsResult.Realms, Has.Length.EqualTo(2)); Assert.That(realmsResult.Realms[0], Is.AssignableFrom()); Assert.That(realmsResult.Realms[0].Realm, Is.Not.Null); @@ -50,7 +50,7 @@ public async Task CanGetAllRealmsByType() var realmsResult = await bidi.Script.GetRealmsAsync(new() { Type = RealmType.Window }); Assert.That(realmsResult, Is.Not.Null); - Assert.That(realmsResult.Realms, Has.Count.EqualTo(2)); + Assert.That(realmsResult.Realms, Has.Length.EqualTo(2)); Assert.That(realmsResult.Realms[0], Is.AssignableFrom()); Assert.That(realmsResult.Realms[0].Realm, Is.Not.Null); diff --git a/dotnet/test/webdriver/BiDi/Storage/StorageTests.cs b/dotnet/test/webdriver/BiDi/Storage/StorageTests.cs index 1a2d452e95793..371a795a74022 100644 --- a/dotnet/test/webdriver/BiDi/Storage/StorageTests.cs +++ b/dotnet/test/webdriver/BiDi/Storage/StorageTests.cs @@ -92,7 +92,7 @@ await context.Storage.SetCookieAsync(new("fish", "cod", UrlBuilder.HostName) var cookiesResult = await context.Storage.GetCookiesAsync(); Assert.That(cookiesResult, Is.Not.Null); - Assert.That(cookiesResult.Cookies, Has.Count.EqualTo(1)); + Assert.That(cookiesResult.Cookies, Has.Length.EqualTo(1)); var cookie = cookiesResult.Cookies[0]; @@ -118,7 +118,7 @@ public async Task CanGetAllCookies() var cookiesResult = await bidi.Storage.GetCookiesAsync(); Assert.That(cookiesResult, Is.Not.Null); - Assert.That(cookiesResult.Cookies, Has.Count.EqualTo(2)); + Assert.That(cookiesResult.Cookies, Has.Length.EqualTo(2)); Assert.That(cookiesResult.Cookies[0].Name, Is.EqualTo("key1")); Assert.That(cookiesResult.Cookies[1].Name, Is.EqualTo("key2")); } @@ -157,7 +157,7 @@ public async Task CanDeleteCookieWithName() var cookiesResult = await bidi.Storage.GetCookiesAsync(); Assert.That(cookiesResult, Is.Not.Null); - Assert.That(cookiesResult.Cookies, Has.Count.EqualTo(1)); + Assert.That(cookiesResult.Cookies, Has.Length.EqualTo(1)); Assert.That(cookiesResult.Cookies[0].Name, Is.EqualTo("key2")); }