diff --git a/dotnet/src/webdriver/Chromium/ChromiumDriver.cs b/dotnet/src/webdriver/Chromium/ChromiumDriver.cs
index f577c7439a940..afe3d1b551fc3 100644
--- a/dotnet/src/webdriver/Chromium/ChromiumDriver.cs
+++ b/dotnet/src/webdriver/Chromium/ChromiumDriver.cs
@@ -361,6 +361,8 @@ public DevToolsSession GetDevToolsSession(int devToolsProtocolVersion)
///
/// Closes a DevTools session.
///
+ [RequiresUnreferencedCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
+ [RequiresDynamicCode(DevToolsSession.CDP_AOTIncompatibilityMessage)]
public void CloseDevToolsSession()
{
if (this.devToolsSession != null)
diff --git a/dotnet/src/webdriver/Command.cs b/dotnet/src/webdriver/Command.cs
index b3bce18434aa2..ddf6ed4228995 100644
--- a/dotnet/src/webdriver/Command.cs
+++ b/dotnet/src/webdriver/Command.cs
@@ -33,7 +33,11 @@ public class Command
{
private readonly static JsonSerializerOptions s_jsonSerializerOptions = new()
{
- TypeInfoResolver = JsonTypeInfoResolver.Combine(CommandJsonSerializerContext.Default, new DefaultJsonTypeInfoResolver()),
+ TypeInfoResolverChain =
+ {
+ CommandJsonSerializerContext.Default,
+ new DefaultJsonTypeInfoResolver()
+ },
Converters = { new ResponseValueJsonConverter() }
};
@@ -86,17 +90,14 @@ public string ParametersAsJsonString
{
get
{
- string parametersString;
if (this.Parameters != null && this.Parameters.Count > 0)
{
- parametersString = JsonSerializer.Serialize(this.Parameters, s_jsonSerializerOptions);
+ return JsonSerializer.Serialize(this.Parameters, s_jsonSerializerOptions);
}
else
{
- parametersString = "{}";
+ return "{}";
}
-
- return parametersString;
}
}
@@ -118,7 +119,7 @@ public override string ToString()
/// If is .
private static Dictionary? ConvertParametersFromJson(string value)
{
- Dictionary? parameters = JsonSerializer.Deserialize>(value, s_jsonSerializerOptions);
+ Dictionary? parameters = JsonSerializer.Deserialize>(value, CommandJsonSerializerContext.Default.DictionaryStringObject!);
return parameters;
}
}
@@ -167,5 +168,6 @@ public override string ToString()
[JsonSerializable(typeof(Dictionary))]
[JsonSerializable(typeof(Dictionary))]
[JsonSerializable(typeof(Dictionary))]
+ [JsonSourceGenerationOptions(Converters = [typeof(ResponseValueJsonConverter)])]
internal partial class CommandJsonSerializerContext : JsonSerializerContext;
}
diff --git a/dotnet/src/webdriver/Internal/FileUtilities.cs b/dotnet/src/webdriver/Internal/FileUtilities.cs
index b3bff70bd1b76..5d0aeadd6ed37 100644
--- a/dotnet/src/webdriver/Internal/FileUtilities.cs
+++ b/dotnet/src/webdriver/Internal/FileUtilities.cs
@@ -168,9 +168,10 @@ public static string GetCurrentDirectory()
string? location = null;
// Make sure not to call Path.GetDirectoryName if assembly location is null or empty
- if (!string.IsNullOrEmpty(executingAssembly.Location))
+ string assemblyLocation = executingAssembly.Location;
+ if (!string.IsNullOrEmpty(assemblyLocation))
{
- location = Path.GetDirectoryName(executingAssembly.Location);
+ location = Path.GetDirectoryName(assemblyLocation);
}
if (string.IsNullOrEmpty(location))