diff --git a/src/NzbDrone.Common/Extensions/DictionaryExtensions.cs b/src/NzbDrone.Common/Extensions/DictionaryExtensions.cs index db84e6139..e2b7529c3 100644 --- a/src/NzbDrone.Common/Extensions/DictionaryExtensions.cs +++ b/src/NzbDrone.Common/Extensions/DictionaryExtensions.cs @@ -6,11 +6,13 @@ namespace NzbDrone.Common.Extensions { public static class DictionaryExtensions { - public static TValue GetValueOrDefault(this IDictionary dictionary, TKey key, TValue defaultValue = default(TValue)) +#if !NETCOREAPP3_0 + public static TValue GetValueOrDefault(this IReadOnlyDictionary dictionary, TKey key, TValue defaultValue = default(TValue)) { TValue value; return dictionary.TryGetValue(key, out value) ? value : defaultValue; } +#endif public static Dictionary Merge(this Dictionary first, Dictionary second) { diff --git a/src/NzbDrone.Core/Blacklisting/BlacklistService.cs b/src/NzbDrone.Core/Blacklisting/BlacklistService.cs index e92b7f878..af71f0c0d 100644 --- a/src/NzbDrone.Core/Blacklisting/BlacklistService.cs +++ b/src/NzbDrone.Core/Blacklisting/BlacklistService.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using NzbDrone.Common.Extensions; using NzbDrone.Core.Datastore; diff --git a/src/NzbDrone.Core/CustomFormats/FormatTag.cs b/src/NzbDrone.Core/CustomFormats/FormatTag.cs index 1aeefc359..5a0ca7b92 100644 --- a/src/NzbDrone.Core/CustomFormats/FormatTag.cs +++ b/src/NzbDrone.Core/CustomFormats/FormatTag.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text.RegularExpressions; diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index 96b9d2bdb..a5df89276 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -1,23 +1,21 @@ using System; -using System.Linq; using System.Collections.Generic; +using System.Linq; +using System.Net; +using FluentValidation.Results; +using NLog; using NzbDrone.Common.Disk; +using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; +using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles.TorrentInfo; +using NzbDrone.Core.Organizer; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Configuration; -using NzbDrone.Core.Validation; -using NLog; -using FluentValidation.Results; -using System.Net; using NzbDrone.Core.RemotePathMappings; -using NzbDrone.Core.Organizer; +using NzbDrone.Core.Validation; namespace NzbDrone.Core.Download.Clients.Deluge { - // this is here to resolve ambiguity in GetValueOrDefault extension method in net core 3 - using NzbDrone.Common.Extensions; - public class Deluge : TorrentClientBase { private readonly IDelugeProxy _proxy; diff --git a/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs b/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs index a2a706d1e..7dee6fb32 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs @@ -12,7 +12,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken { HadoukenSystemInfo GetSystemInfo(HadoukenSettings settings); HadoukenTorrent[] GetTorrents(HadoukenSettings settings); - IDictionary GetConfig(HadoukenSettings settings); + IReadOnlyDictionary GetConfig(HadoukenSettings settings); string AddTorrentFile(HadoukenSettings settings, byte[] fileContent); void AddTorrentUri(HadoukenSettings settings, string torrentUrl); void RemoveTorrent(HadoukenSettings settings, string downloadId); @@ -42,9 +42,9 @@ namespace NzbDrone.Core.Download.Clients.Hadouken return GetTorrents(result.Torrents); } - public IDictionary GetConfig(HadoukenSettings settings) + public IReadOnlyDictionary GetConfig(HadoukenSettings settings) { - return ProcessRequest>(settings, "webui.getSettings"); + return ProcessRequest>(settings, "webui.getSettings"); } public string AddTorrentFile(HadoukenSettings settings, byte[] fileContent) diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index c7429f814..ad9a496aa 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -6,6 +6,7 @@ using System.Linq; using FluentValidation.Results; using NLog; using NzbDrone.Common.Disk; +using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.Exceptions; @@ -16,9 +17,6 @@ using NzbDrone.Core.Organizer; namespace NzbDrone.Core.Download.Clients.Nzbget { - // this is here to resolve ambiguity in GetValueOrDefault extension method in net core 3 - using NzbDrone.Common.Extensions; - public class Nzbget : UsenetClientBase { private readonly INzbgetProxy _proxy; diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index 562536001..ff3afd934 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -311,7 +311,7 @@ namespace NzbDrone.Core.Organizer } private const string MediaInfoVideoDynamicRangeToken = "{MediaInfo VideoDynamicRange}"; - private static readonly IDictionary MinimumMediaInfoSchemaRevisions = + private static readonly IReadOnlyDictionary MinimumMediaInfoSchemaRevisions = new Dictionary(FileNameBuilderTokenEqualityComparer.Instance) { {MediaInfoVideoDynamicRangeToken, 5} diff --git a/src/NzbDrone.Core/Parser/Model/ParsedMovieInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedMovieInfo.cs index bbcd0989e..f1be1499f 100644 --- a/src/NzbDrone.Core/Parser/Model/ParsedMovieInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ParsedMovieInfo.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Parser.Model /// It is expanded by the augmenters. /// [JsonIgnore] - public IDictionary ExtraInfo = new Dictionary(); + public Dictionary ExtraInfo = new Dictionary(); public List Languages = new List(); public string ReleaseGroup { get; set; } public string ReleaseHash { get; set; } diff --git a/src/NzbDrone.Mono/Disk/ProcMountProvider.cs b/src/NzbDrone.Mono/Disk/ProcMountProvider.cs index 3f456b499..88e834d8a 100644 --- a/src/NzbDrone.Mono/Disk/ProcMountProvider.cs +++ b/src/NzbDrone.Mono/Disk/ProcMountProvider.cs @@ -5,12 +5,10 @@ using System.Linq; using System.Text.RegularExpressions; using NLog; using NzbDrone.Common.Disk; +using NzbDrone.Common.Extensions; namespace NzbDrone.Mono.Disk { - // this is here to resolve ambiguity in GetValueOrDefault extension method in net core 3 - using NzbDrone.Common.Extensions; - public interface IProcMountProvider { List GetMounts(); diff --git a/src/Radarr.Http/Extensions/Pipelines/GZipPipeline.cs b/src/Radarr.Http/Extensions/Pipelines/GZipPipeline.cs index e2ff93cff..3d8804195 100644 --- a/src/Radarr.Http/Extensions/Pipelines/GZipPipeline.cs +++ b/src/Radarr.Http/Extensions/Pipelines/GZipPipeline.cs @@ -6,7 +6,6 @@ using Nancy; using Nancy.Bootstrapper; using NLog; using NzbDrone.Common.EnvironmentInfo; -using NzbDrone.Common.Extensions; namespace Radarr.Http.Extensions.Pipelines { @@ -81,7 +80,7 @@ namespace Radarr.Http.Extensions.Pipelines private static bool ContentLengthIsTooSmall(Response response) { - var contentLength = response.Headers.GetValueOrDefault("Content-Length"); + var contentLength = response.Headers.TryGetValue("Content-Length", out var value) ? value : null; if (contentLength != null && long.Parse(contentLength) < 1024) { @@ -93,7 +92,7 @@ namespace Radarr.Http.Extensions.Pipelines private static bool AlreadyGzipEncoded(Response response) { - var contentEncoding = response.Headers.GetValueOrDefault("Content-Encoding"); + var contentEncoding = response.Headers.TryGetValue("Content-Encoding", out var value) ? value : null; if (contentEncoding == "gzip") {