diff --git a/src/NzbDrone.Common/Composition/AssemblyLoader.cs b/src/NzbDrone.Common/Composition/AssemblyLoader.cs index b8f0629b0..8587644fc 100644 --- a/src/NzbDrone.Common/Composition/AssemblyLoader.cs +++ b/src/NzbDrone.Common/Composition/AssemblyLoader.cs @@ -16,7 +16,7 @@ namespace NzbDrone.Common.Composition AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ContainerResolveEventHandler); } - public static IEnumerable Load(IEnumerable assemblyNames) + public static IList Load(IList assemblyNames) { var toLoad = assemblyNames.ToList(); toLoad.Add("Radarr.Common"); @@ -28,8 +28,9 @@ namespace NzbDrone.Common.Composition var startupPath = AppDomain.CurrentDomain.BaseDirectory; - return toLoad.Select(x => - AssemblyLoadContext.Default.LoadFromAssemblyPath(Path.Combine(startupPath, $"{x}.dll"))); + return toLoad + .Select(x => AssemblyLoadContext.Default.LoadFromAssemblyPath(Path.Combine(startupPath, $"{x}.dll"))) + .ToList(); } private static Assembly ContainerResolveEventHandler(object sender, ResolveEventArgs args) diff --git a/src/NzbDrone.Common/OAuth/WebParameterCollection.cs b/src/NzbDrone.Common/OAuth/WebParameterCollection.cs index cea68b114..9dbd90509 100644 --- a/src/NzbDrone.Common/OAuth/WebParameterCollection.cs +++ b/src/NzbDrone.Common/OAuth/WebParameterCollection.cs @@ -14,14 +14,14 @@ namespace NzbDrone.Common.OAuth { get { - var parameters = this.Where(p => p.Name.Equals(name)); + var parameters = this.Where(p => p.Name.Equals(name)).ToArray(); if (!parameters.Any()) { return null; } - if (parameters.Count() == 1) + if (parameters.Length == 1) { return parameters.Single(); } diff --git a/src/NzbDrone.Core/Datastore/BasicRepository.cs b/src/NzbDrone.Core/Datastore/BasicRepository.cs index 5443c0c1a..ce518f4b9 100644 --- a/src/NzbDrone.Core/Datastore/BasicRepository.cs +++ b/src/NzbDrone.Core/Datastore/BasicRepository.cs @@ -111,7 +111,7 @@ namespace NzbDrone.Core.Datastore { if (!ids.Any()) { - return new List(); + return Array.Empty(); } var result = Query(x => ids.Contains(x.Id)); diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxyV1.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxyV1.cs index 466a8c49c..13e5131fb 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxyV1.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxyV1.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Net.Http; using NLog; @@ -61,7 +62,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies catch (DownloadClientException e) { _logger.Error(e); - return new List(); + return Array.Empty(); } } diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxyV2.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxyV2.cs index 76222527f..6ebb4a7ca 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxyV2.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxyV2.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; @@ -135,7 +136,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies catch (DownloadClientException e) { _logger.Error(e); - return new List(); + return Array.Empty(); } } diff --git a/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs b/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs index 1282fa75c..d988ccdae 100644 --- a/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs +++ b/src/NzbDrone.Core/Extras/Metadata/MetadataService.cs @@ -132,7 +132,7 @@ namespace NzbDrone.Core.Extras.Metadata if (movieFolder.IsNullOrWhiteSpace()) { - return new List(); + return Array.Empty(); } var files = new List(); diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index f1f44f604..608a5273f 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -42,7 +42,7 @@ namespace NzbDrone.Core.Indexers { if (!SupportsRss) { - return new List(); + return Array.Empty(); } return FetchReleases(g => g.GetRecentRequests(), true); @@ -52,7 +52,7 @@ namespace NzbDrone.Core.Indexers { if (!SupportsSearch) { - return new List(); + return Array.Empty(); } return FetchReleases(g => g.GetSearchRequests(searchCriteria)); diff --git a/src/NzbDrone.Core/Indexers/RssParser.cs b/src/NzbDrone.Core/Indexers/RssParser.cs index 1c3a41c42..c370de316 100644 --- a/src/NzbDrone.Core/Indexers/RssParser.cs +++ b/src/NzbDrone.Core/Indexers/RssParser.cs @@ -85,7 +85,7 @@ namespace NzbDrone.Core.Indexers if (!PostProcess(indexerResponse, items, releases)) { - return new List(); + return Array.Empty(); } return releases; diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs index 34c5498e5..8d96c3a0f 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs @@ -57,12 +57,13 @@ namespace NzbDrone.Core.MediaFiles.MovieImport _logger.Debug("Decisions: {0}", decisions.Count); // I added a null op for the rare case that the quality is null. TODO: find out why that would even happen in the first place. - var qualifiedImports = decisions.Where(c => c.Approved) - .GroupBy(c => c.LocalMovie.Movie.Id, (i, s) => s - .OrderByDescending(c => c.LocalMovie.Quality ?? new QualityModel { Quality = Quality.Unknown }, new QualityModelComparer(s.First().LocalMovie.Movie.Profile)) - .ThenByDescending(c => c.LocalMovie.Size)) - .SelectMany(c => c) - .ToList(); + var qualifiedImports = decisions + .Where(decision => decision.Approved) + .GroupBy(decision => decision.LocalMovie.Movie.Id) + .SelectMany(group => group + .OrderByDescending(decision => decision.LocalMovie.Quality ?? new QualityModel { Quality = Quality.Unknown }, new QualityModelComparer(group.First().LocalMovie.Movie.Profile)) + .ThenByDescending(decision => decision.LocalMovie.Size)) + .ToList(); var importResults = new List(); diff --git a/src/Radarr.Api.V3/ProviderControllerBase.cs b/src/Radarr.Api.V3/ProviderControllerBase.cs index 872bc979d..9dad6d36d 100644 --- a/src/Radarr.Api.V3/ProviderControllerBase.cs +++ b/src/Radarr.Api.V3/ProviderControllerBase.cs @@ -43,11 +43,11 @@ namespace Radarr.Api.V3 [HttpGet] public List GetAll() { - var providerDefinitions = _providerFactory.All().OrderBy(p => p.ImplementationName); + var providerDefinitions = _providerFactory.All(); - var result = new List(providerDefinitions.Count()); + var result = new List(providerDefinitions.Count); - foreach (var definition in providerDefinitions) + foreach (var definition in providerDefinitions.OrderBy(p => p.ImplementationName)) { _providerFactory.SetProviderCharacteristics(definition); diff --git a/src/Radarr.Http/REST/RestController.cs b/src/Radarr.Http/REST/RestController.cs index a4c3d2c52..3ca4388c6 100644 --- a/src/Radarr.Http/REST/RestController.cs +++ b/src/Radarr.Http/REST/RestController.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using FluentValidation; using FluentValidation.Results; using Microsoft.AspNetCore.Mvc; @@ -79,7 +80,8 @@ namespace Radarr.Http.REST } } - var attributes = descriptor.MethodInfo.CustomAttributes; + var attributes = descriptor.MethodInfo.CustomAttributes as IReadOnlyCollection ?? + descriptor.MethodInfo.CustomAttributes.ToArray(); if (attributes.Any(x => VALIDATE_ID_ATTRIBUTES.Contains(x.AttributeType)) && !skipValidate) { if (context.ActionArguments.TryGetValue("id", out var idObj))