diff --git a/CSF.Extensions.WebDriver/Factories/WebDriverAndOptionsTypePair.cs b/CSF.Extensions.WebDriver/Factories/WebDriverAndOptionsTypePair.cs index 74a6702..e16321b 100644 --- a/CSF.Extensions.WebDriver/Factories/WebDriverAndOptionsTypePair.cs +++ b/CSF.Extensions.WebDriver/Factories/WebDriverAndOptionsTypePair.cs @@ -22,9 +22,6 @@ public sealed class WebDriverAndOptionsTypePair : IEquatable public override bool Equals(object obj) => Equals(obj as WebDriverAndOptionsTypePair); - /// - public override int GetHashCode() => WebDriverType.GetHashCode() ^ OptionsType.GetHashCode(); - /// public bool Equals(WebDriverAndOptionsTypePair other) { @@ -32,6 +29,9 @@ public bool Equals(WebDriverAndOptionsTypePair other) return other.WebDriverType == WebDriverType && other.OptionsType == OptionsType; } + /// + public override int GetHashCode() => WebDriverType.GetHashCode() ^ OptionsType.GetHashCode(); + /// /// Initialises a new instance of . /// diff --git a/CSF.Extensions.WebDriver/Factories/WebDriverCreationConfigureOptions.cs b/CSF.Extensions.WebDriver/Factories/WebDriverCreationConfigureOptions.cs index 6c63d95..07ab474 100644 --- a/CSF.Extensions.WebDriver/Factories/WebDriverCreationConfigureOptions.cs +++ b/CSF.Extensions.WebDriver/Factories/WebDriverCreationConfigureOptions.cs @@ -51,7 +51,7 @@ void ConfigureUsingConfig(WebDriverCreationOptionsCollection options) if(driverConfigsSection != null) options.DriverConfigurations = GetDriverConfigurations(driverConfigsSection); } - IDictionary GetDriverConfigurations(IConfigurationSection configuration) + Dictionary GetDriverConfigurations(IConfigurationSection configuration) => configuration.GetChildren() .Select(c => new { c.Key, Value = configParser.GetDriverConfiguration(c) }) .Where(x => x.Value != null) diff --git a/CSF.Extensions.WebDriver/Identification/BrowserVersion.cs b/CSF.Extensions.WebDriver/Identification/BrowserVersion.cs index 731cf56..ca7b98d 100644 --- a/CSF.Extensions.WebDriver/Identification/BrowserVersion.cs +++ b/CSF.Extensions.WebDriver/Identification/BrowserVersion.cs @@ -57,7 +57,7 @@ public abstract class BrowserVersion : IEquatable, IComparable. /// /// Whether or not this is a presumed version; see . - protected internal BrowserVersion(bool isPresumed = false) + private protected BrowserVersion(bool isPresumed = false) { IsPresumedVersion = isPresumed; } diff --git a/CSF.Extensions.WebDriver/Identification/MissingBrowserVersion.cs b/CSF.Extensions.WebDriver/Identification/MissingBrowserVersion.cs index 3791713..464fd5a 100644 --- a/CSF.Extensions.WebDriver/Identification/MissingBrowserVersion.cs +++ b/CSF.Extensions.WebDriver/Identification/MissingBrowserVersion.cs @@ -18,6 +18,9 @@ public sealed class MissingBrowserVersion : BrowserVersion /// public override bool Equals(BrowserVersion other) => other is MissingBrowserVersion; + /// + public override bool Equals(object obj) => obj is BrowserVersion ver && Equals(ver); + /// public override int GetHashCode() => 17; diff --git a/CSF.Extensions.WebDriver/Identification/UnrecognisedBrowserVersion.cs b/CSF.Extensions.WebDriver/Identification/UnrecognisedBrowserVersion.cs index 33421f1..912c453 100644 --- a/CSF.Extensions.WebDriver/Identification/UnrecognisedBrowserVersion.cs +++ b/CSF.Extensions.WebDriver/Identification/UnrecognisedBrowserVersion.cs @@ -27,17 +27,20 @@ public sealed class UnrecognisedBrowserVersion : BrowserVersion /// public override int CompareTo(BrowserVersion other) { - if (other is null || !(other is UnrecognisedBrowserVersion version)) return 1; + if (!(other is UnrecognisedBrowserVersion version)) return 1; return string.Compare(Version, version.Version, StringComparison.InvariantCulture); } /// public override bool Equals(BrowserVersion other) { - if (other is null || !(other is UnrecognisedBrowserVersion version)) return false; + if (!(other is UnrecognisedBrowserVersion version)) return false; return Version.Equals(version.Version, StringComparison.InvariantCulture); } + /// + public override bool Equals(object obj) => obj is BrowserVersion ver && Equals(ver); + /// public override int GetHashCode() => Version.GetHashCode(); diff --git a/CSF.Extensions.WebDriver/Proxies/Is.cs b/CSF.Extensions.WebDriver/Proxies/Is.cs index c7b0653..0ca8140 100644 --- a/CSF.Extensions.WebDriver/Proxies/Is.cs +++ b/CSF.Extensions.WebDriver/Proxies/Is.cs @@ -1,4 +1,3 @@ -using System; using System.Reflection; namespace CSF.Extensions.WebDriver.Proxies @@ -6,7 +5,7 @@ namespace CSF.Extensions.WebDriver.Proxies /// /// Utility/helper class to identify members. /// - internal class Is + internal static class Is { const string getterPrefix = "get_"; @@ -20,6 +19,6 @@ internal class Is /// if the is a getter for a property named /// , upon the type ; if not. internal static bool Getter(string name, MethodInfo method) where T : class - => method.DeclaringType == typeof(T) && method.Name == String.Concat(getterPrefix, name); + => method.DeclaringType == typeof(T) && method.Name == string.Concat(getterPrefix, name); } } \ No newline at end of file diff --git a/CSF.Extensions.WebDriver/Proxies/QuirksAugmenter.cs b/CSF.Extensions.WebDriver/Proxies/QuirksAugmenter.cs index 02e8e23..176714b 100644 --- a/CSF.Extensions.WebDriver/Proxies/QuirksAugmenter.cs +++ b/CSF.Extensions.WebDriver/Proxies/QuirksAugmenter.cs @@ -22,7 +22,7 @@ public void AugmentContext(WebDriverProxyCreationContext context) if (!context.CreationOptions.AddQuirks) return; context.Interfaces.Add(typeof(IHasQuirks)); - context.Interceptors.Add(ActivatorUtilities.CreateInstance(services, new [] {context.BrowserId})); + context.Interceptors.Add(ActivatorUtilities.CreateInstance(services, context.BrowserId)); } /// diff --git a/CSF.Extensions.WebDriver/Quirks/QuirksDataProvider.cs b/CSF.Extensions.WebDriver/Quirks/QuirksDataProvider.cs index 2cb923c..4619327 100644 --- a/CSF.Extensions.WebDriver/Quirks/QuirksDataProvider.cs +++ b/CSF.Extensions.WebDriver/Quirks/QuirksDataProvider.cs @@ -46,7 +46,7 @@ public class QuirksDataProvider : IGetsQuirksData /// public QuirksData GetQuirksData() => data; - QuirksData MergeQuirksData(QuirksData primary, QuirksData secondary = null) + static QuirksData MergeQuirksData(QuirksData primary, QuirksData secondary = null) { if (primary is null) throw new ArgumentNullException(nameof(primary)); if (secondary is null) return primary.DeepCopy(); diff --git a/CSF.Extensions.WebDriver/ServiceCollectionExtensions.cs b/CSF.Extensions.WebDriver/ServiceCollectionExtensions.cs index 36334a9..f576b08 100644 --- a/CSF.Extensions.WebDriver/ServiceCollectionExtensions.cs +++ b/CSF.Extensions.WebDriver/ServiceCollectionExtensions.cs @@ -230,7 +230,7 @@ public static IServiceCollection AddWebDriverQuirks(this IServiceCollection serv services.AddSingleton(s => { if (!useOptions) return new QuirksDataProvider(quirksData); - return ActivatorUtilities.CreateInstance(s, new[] { quirksData ?? QuirksData.Empty }); + return ActivatorUtilities.CreateInstance(s, quirksData ?? QuirksData.Empty); }); return services;