Skip to content

Commit

Permalink
Merge branch 'trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
VietND96 authored Jul 26, 2024
2 parents 8c22195 + 77010cd commit b162255
Show file tree
Hide file tree
Showing 47 changed files with 434 additions and 375 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ use_repo(esbuild, "esbuild_toolchains")
register_toolchains("@esbuild_toolchains//:all")

dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet")
dotnet.toolchain(dotnet_version = "7.0.400")
dotnet.toolchain(dotnet_version = "8.0.203")
use_repo(dotnet, "dotnet_toolchains")

selenium_paket = use_extension("//dotnet:paket.nuget_extension.bzl", "nuget_extension")
Expand Down
2 changes: 1 addition & 1 deletion dotnet/paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ nuget System.Diagnostics.Tools 4.3.0
nuget System.Drawing.Common 7.0.0
nuget System.Runtime 4.3.1
nuget System.Runtime.InteropServices 4.3.0
nuget System.Text.Json 6.0.9
nuget System.Text.Json 8.0.4
nuget Runfiles 0.12.0
23 changes: 11 additions & 12 deletions dotnet/paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NUGET
System.Reflection.TypeExtensions (>= 4.4)
Humanizer.Core (2.8.26)
Microsoft.AspNetCore.App.Ref (6.0.9)
Microsoft.Bcl.AsyncInterfaces (7.0) - restriction: || (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0)
Microsoft.Bcl.AsyncInterfaces (8.0) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< netstandard2.1)) (== netstandard2.0)
Microsoft.CSharp (4.5)
Microsoft.Extensions.DependencyInjection (3.1.9)
Expand All @@ -42,7 +42,7 @@ NUGET
NETStandard.Library (>= 2.0)
NUnit (3.13.2)
Runfiles (0.12)
System.Buffers (4.5.1) - restriction: || (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Buffers (4.5.1) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Diagnostics.EventLog (7.0)
System.Security.Principal.Windows (>= 5.0) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Diagnostics.Tools (4.3)
Expand All @@ -61,7 +61,7 @@ NUGET
System.Buffers (>= 4.5.1) - restriction: || (&& (== net7.0) (>= monotouch)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp2.0)) (&& (== net7.0) (< netstandard1.1)) (&& (== net7.0) (< netstandard2.0)) (&& (== net7.0) (>= xamarinios)) (&& (== net7.0) (>= xamarinmac)) (&& (== net7.0) (>= xamarintvos)) (&& (== net7.0) (>= xamarinwatchos)) (== netstandard2.0)
System.Numerics.Vectors (>= 4.4) - restriction: || (&& (== net7.0) (< netcoreapp2.0)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net7.0) (>= monotouch)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp2.0)) (&& (== net7.0) (< netcoreapp2.1)) (&& (== net7.0) (< netstandard1.1)) (&& (== net7.0) (< netstandard2.0)) (&& (== net7.0) (>= uap10.1)) (&& (== net7.0) (>= xamarinios)) (&& (== net7.0) (>= xamarinmac)) (&& (== net7.0) (>= xamarintvos)) (&& (== net7.0) (>= xamarinwatchos)) (== netstandard2.0)
System.Numerics.Vectors (4.5) - restriction: || (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Numerics.Vectors (4.5) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< netcoreapp2.0)) (== netstandard2.0)
System.Reflection (4.3)
Microsoft.NETCore.Platforms (>= 1.1)
Microsoft.NETCore.Targets (>= 1.1)
Expand All @@ -79,7 +79,7 @@ NUGET
System.Runtime (4.3.1)
Microsoft.NETCore.Platforms (>= 1.1.1)
Microsoft.NETCore.Targets (>= 1.1.3)
System.Runtime.CompilerServices.Unsafe (6.0)
System.Runtime.CompilerServices.Unsafe (6.0) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Runtime.Handles (4.3)
Microsoft.NETCore.Platforms (>= 1.1)
Microsoft.NETCore.Targets (>= 1.1)
Expand All @@ -100,14 +100,13 @@ NUGET
System.Buffers (>= 4.5.1) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Text.Json (6.0.9)
Microsoft.Bcl.AsyncInterfaces (>= 6.0) - restriction: || (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Memory (>= 4.5.4) - restriction: || (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Numerics.Vectors (>= 4.5) - restriction: || (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 6.0)
System.Text.Encodings.Web (>= 6.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp3.1)) (== netstandard2.0)
System.Text.Json (8.0.4)
Microsoft.Bcl.AsyncInterfaces (>= 8.0) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Text.Encodings.Web (>= 8.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net7.0) (>= net462)) (&& (== net7.0) (< net6.0)) (== netstandard2.0)
System.Threading.Tasks (4.3)
Microsoft.NETCore.Platforms (>= 1.1)
Microsoft.NETCore.Targets (>= 1.1)
Expand Down
4 changes: 2 additions & 2 deletions dotnet/paket.nuget.bzl

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions dotnet/src/support/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
load(
"//dotnet:defs.bzl",
"csharp_library",
"framework",
"generated_assembly_info",
"nuget_pack",
)
Expand Down Expand Up @@ -43,8 +42,7 @@ csharp_library(
"//dotnet:__subpackages__",
],
deps = [
"//dotnet/src/webdriver",
framework("nuget", "NETStandard.Library"),
"//dotnet/src/webdriver:webdriver-netstandard2.0",
],
)

Expand Down Expand Up @@ -83,8 +81,7 @@ csharp_library(
"//dotnet:__subpackages__",
],
deps = [
"//dotnet/src/webdriver:webdriver-strongnamed",
framework("nuget", "NETStandard.Library"),
"//dotnet/src/webdriver:webdriver-netstandard2.0-strongnamed",
],
)

Expand Down
76 changes: 68 additions & 8 deletions dotnet/src/webdriver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ generated_assembly_info(
)

csharp_library(
name = "webdriver",
name = "webdriver-netstandard2.0",
srcs = [
":assembly-info",
] + glob([
Expand All @@ -36,7 +36,7 @@ csharp_library(
internals_visible_to = [
"WebDriver.Common.Tests",
],
langversion = "10.0",
langversion = "12.0",
resources = [
"//javascript/atoms/fragments:find-elements.js",
"//javascript/atoms/fragments:is-displayed.js",
Expand All @@ -52,20 +52,50 @@ csharp_library(
],
deps = [
framework("nuget", "NETStandard.Library"),
framework("nuget", "Newtonsoft.Json"),
framework("nuget", "System.Memory"),
framework("nuget", "System.Text.Json"),
],
)

csharp_library(
name = "webdriver-strongnamed",
name = "webdriver-net8.0",
srcs = [
":assembly-info",
] + glob([
"**/*.cs",
]) + devtools_version_targets(),
out = "WebDriver",
internals_visible_to = [
"WebDriver.Common.Tests",
],
langversion = "12.0",
resources = [
"//javascript/atoms/fragments:find-elements.js",
"//javascript/atoms/fragments:is-displayed.js",
"//javascript/cdp-support:mutation-listener.js",
"//javascript/webdriver/atoms:get-attribute.js",
"//third_party/js/selenium:webdriver_json",
],
target_frameworks = [
"net8.0",
],
visibility = [
"//dotnet:__subpackages__",
],
deps = [
],
)

csharp_library(
name = "webdriver-netstandard2.0-strongnamed",
srcs = [
":assembly-info",
] + glob([
"**/*.cs",
]) + devtools_version_targets(),
out = "WebDriver.StrongNamed",
keyfile = "//dotnet:WebDriver.snk",
langversion = "10.0",
langversion = "12.0",
resources = [
"//javascript/atoms/fragments:find-elements.js",
"//javascript/atoms/fragments:is-displayed.js",
Expand All @@ -81,7 +111,35 @@ csharp_library(
],
deps = [
framework("nuget", "NETStandard.Library"),
framework("nuget", "Newtonsoft.Json"),
framework("nuget", "System.Memory"),
framework("nuget", "System.Text.Json"),
],
)

csharp_library(
name = "webdriver-net8.0-strongnamed",
srcs = [
":assembly-info",
] + glob([
"**/*.cs",
]) + devtools_version_targets(),
out = "WebDriver.StrongNamed",
keyfile = "//dotnet:WebDriver.snk",
langversion = "12.0",
resources = [
"//javascript/atoms/fragments:find-elements.js",
"//javascript/atoms/fragments:is-displayed.js",
"//javascript/cdp-support:mutation-listener.js",
"//javascript/webdriver/atoms:get-attribute.js",
"//third_party/js/selenium:webdriver_json",
],
target_frameworks = [
"net8.0",
],
visibility = [
"//dotnet:__subpackages__",
],
deps = [
],
)

Expand Down Expand Up @@ -137,7 +195,8 @@ nuget_pack(
},
id = "Selenium.WebDriver",
libs = {
":webdriver": "WebDriver",
":webdriver-net8.0": "WebDriver",
":webdriver-netstandard2.0": "WebDriver",
},
nuspec_template = "WebDriver.nuspec",
tags = [
Expand All @@ -162,7 +221,8 @@ nuget_pack(
},
id = "Selenium.WebDriver.StrongNamed",
libs = {
":webdriver-strongnamed": "WebDriver.StrongNamed",
":webdriver-net8.0-strongnamed": "WebDriver.StrongNamed",
":webdriver-netstandard2.0-strongnamed": "WebDriver.StrongNamed",
},
nuspec_template = "WebDriver.StrongNamed.nuspec",
property_group_vars = {
Expand Down
14 changes: 8 additions & 6 deletions dotnet/src/webdriver/Chromium/ChromiumNetworkConditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
// limitations under the License.
// </copyright>

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.Chromium
{
/// <summary>
/// Provides manipulation of getting and setting network conditions from Chromium.
/// </summary>
[JsonObject(MemberSerialization.OptIn)]
public class ChromiumNetworkConditions
{
private bool offline;
Expand All @@ -36,7 +35,7 @@ public class ChromiumNetworkConditions
/// <summary>
/// Gets or sets a value indicating whether the network is offline. Defaults to <see langword="false"/>.
/// </summary>
[JsonProperty("offline")]
[JsonPropertyName("offline")]
public bool IsOffline
{
get { return this.offline; }
Expand All @@ -46,6 +45,7 @@ public bool IsOffline
/// <summary>
/// Gets or sets the simulated latency of the connection. Typically given in milliseconds.
/// </summary>
[JsonIgnore]
public TimeSpan Latency
{
get { return this.latency; }
Expand All @@ -55,7 +55,7 @@ public TimeSpan Latency
/// <summary>
/// Gets or sets the throughput of the network connection in bytes/second for downloading.
/// </summary>
[JsonProperty("download_throughput")]
[JsonPropertyName("download_throughput")]
public long DownloadThroughput
{
get { return this.downloadThroughput; }
Expand All @@ -73,7 +73,7 @@ public long DownloadThroughput
/// <summary>
/// Gets or sets the throughput of the network connection in bytes/second for uploading.
/// </summary>
[JsonProperty("upload_throughput")]
[JsonPropertyName("upload_throughput")]
public long UploadThroughput
{
get { return this.uploadThroughput; }
Expand All @@ -88,7 +88,9 @@ public long UploadThroughput
}
}

[JsonProperty("latency", NullValueHandling = NullValueHandling.Ignore)]
[JsonPropertyName("latency")]
[JsonInclude]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
internal long? SerializableLatency
{
get
Expand Down
18 changes: 12 additions & 6 deletions dotnet/src/webdriver/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
// limitations under the License.
// </copyright>

using Newtonsoft.Json;
using OpenQA.Selenium.Internal;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium
{
Expand All @@ -27,6 +28,11 @@ namespace OpenQA.Selenium
/// </summary>
public class Command
{
private readonly static JsonSerializerOptions s_jsonSerializerOptions = new()
{
Converters = { new ResponseValueJsonConverter() }
};

private SessionId commandSessionId;
private string commandName;
private Dictionary<string, object> commandParameters = new Dictionary<string, object>();
Expand Down Expand Up @@ -61,7 +67,7 @@ public Command(SessionId sessionId, string name, Dictionary<string, object> para
/// <summary>
/// Gets the SessionID of the command
/// </summary>
[JsonProperty("sessionId")]
[JsonPropertyName("sessionId")]
public SessionId SessionId
{
get { return this.commandSessionId; }
Expand All @@ -70,7 +76,7 @@ public SessionId SessionId
/// <summary>
/// Gets the command name
/// </summary>
[JsonProperty("name")]
[JsonPropertyName("name")]
public string Name
{
get { return this.commandName; }
Expand All @@ -79,7 +85,7 @@ public string Name
/// <summary>
/// Gets the parameters of the command
/// </summary>
[JsonProperty("parameters")]
[JsonPropertyName("parameters")]
public Dictionary<string, object> Parameters
{
get { return this.commandParameters; }
Expand All @@ -95,7 +101,7 @@ public string ParametersAsJsonString
string parametersString = string.Empty;
if (this.commandParameters != null && this.commandParameters.Count > 0)
{
parametersString = JsonConvert.SerializeObject(this.commandParameters);
parametersString = JsonSerializer.Serialize(this.commandParameters);
}

if (string.IsNullOrEmpty(parametersString))
Expand Down Expand Up @@ -123,7 +129,7 @@ public override string ToString()
/// <returns>A <see cref="Dictionary{K, V}"/> with a string keys, and an object value. </returns>
private static Dictionary<string, object> ConvertParametersFromJson(string value)
{
Dictionary<string, object> parameters = JsonConvert.DeserializeObject<Dictionary<string, object>>(value, new ResponseValueJsonConverter());
Dictionary<string, object> parameters = JsonSerializer.Deserialize<Dictionary<string, object>>(value, s_jsonSerializerOptions);
return parameters;
}
}
Expand Down
Loading

0 comments on commit b162255

Please sign in to comment.