diff --git a/dotnet/src/webdriver/Cookie.cs b/dotnet/src/webdriver/Cookie.cs index b15dca6d196fe..dac30e0522629 100644 --- a/dotnet/src/webdriver/Cookie.cs +++ b/dotnet/src/webdriver/Cookie.cs @@ -277,7 +277,7 @@ public static Cookie FromDictionary(Dictionary rawCookie) { if (rawCookie == null) { - throw new ArgumentNullException(nameof(rawCookie), "Dictionary cannot be null"); + throw new ArgumentNullException(nameof(rawCookie)); } string name = rawCookie["name"].ToString(); diff --git a/dotnet/src/webdriver/CookieJar.cs b/dotnet/src/webdriver/CookieJar.cs index 470d81653cdff..32674b24c4e43 100644 --- a/dotnet/src/webdriver/CookieJar.cs +++ b/dotnet/src/webdriver/CookieJar.cs @@ -127,7 +127,7 @@ public void DeleteAllCookies() { var rawCookie = driver.InternalExecute(DriverCommand.GetCookie, new() { { "name", name } }).Value; - return Cookie.FromDictionary((Dictionary)rawCookie); + return Cookie.FromDictionary((Dictionary)rawCookie!); } catch (NoSuchCookieException) { diff --git a/dotnet/src/webdriver/Internal/FileUtilities.cs b/dotnet/src/webdriver/Internal/FileUtilities.cs index d288a58e5f296..ff23a34a1cf86 100644 --- a/dotnet/src/webdriver/Internal/FileUtilities.cs +++ b/dotnet/src/webdriver/Internal/FileUtilities.cs @@ -188,12 +188,18 @@ public static string GetCurrentDirectory() string currentDirectory = location!; +#if !NET8_0_OR_GREATER // If we're shadow copying, get the directory from the codebase instead if (AppDomain.CurrentDomain.ShadowCopyFiles) { - Uri uri = new Uri(executingAssembly.CodeBase); - currentDirectory = Path.GetDirectoryName(uri.LocalPath)!; + var codeBase = executingAssembly.CodeBase; + + if (codeBase is not null) + { + currentDirectory = Path.GetDirectoryName(codeBase); + } } +#endif return currentDirectory; }