Просмотр исходного кода

Fix remaining MediaBrowser.Providers warnings

Rich Lander 3 лет назад
Родитель
Сommit
927b003143

+ 4 - 4
MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs

@@ -59,9 +59,9 @@ namespace MediaBrowser.Providers.BoxSets
         }
 
         /// <inheritdoc />
-        protected override ItemUpdateType BeforeSaveInternal(BoxSet item, bool isFullRefresh, ItemUpdateType currentUpdateType)
+        protected override ItemUpdateType BeforeSaveInternal(BoxSet item, bool isFullRefresh, ItemUpdateType updateType)
         {
-            var updateType = base.BeforeSaveInternal(item, isFullRefresh, currentUpdateType);
+            var updatedType = base.BeforeSaveInternal(item, isFullRefresh, updateType);
 
             var libraryFolderIds = item.GetLibraryFolderIds();
 
@@ -69,10 +69,10 @@ namespace MediaBrowser.Providers.BoxSets
             if (itemLibraryFolderIds == null || !libraryFolderIds.SequenceEqual(itemLibraryFolderIds))
             {
                 item.LibraryFolderIds = libraryFolderIds;
-                updateType |= ItemUpdateType.MetadataImport;
+                updatedType |= ItemUpdateType.MetadataImport;
             }
 
-            return updateType;
+            return updatedType;
         }
     }
 }

+ 2 - 1
MediaBrowser.Providers/Manager/ItemImageProvider.cs

@@ -1,7 +1,8 @@
-#pragma warning disable CS1591
+#pragma warning disable CA1002, CS1591
 
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.IO;
 using System.Linq;
 using System.Net;

+ 1 - 1
MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs

@@ -1,4 +1,4 @@
-#pragma warning disable CS1591
+#pragma warning disable CA1002, CS1591
 
 using System;
 using System.Collections.Generic;

+ 1 - 1
MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs

@@ -1,4 +1,4 @@
-#pragma warning disable CS1591
+#pragma warning disable CA1068, CS1591
 
 using System;
 using System.Collections.Generic;

+ 2 - 1
MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs

@@ -1,7 +1,8 @@
-#pragma warning disable CS1591
+#pragma warning disable CA1002, CS1591
 
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;

+ 2 - 1
MediaBrowser.Providers/MediaInfo/SubtitleResolver.cs

@@ -1,7 +1,8 @@
-#pragma warning disable CS1591
+#pragma warning disable CA1002, CS1591
 
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.IO;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Providers;

+ 4 - 3
MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumProvider.cs

@@ -1,4 +1,4 @@
-#pragma warning disable CS1591, SA1300
+#pragma warning disable CA1002, CS1591, SA1300
 
 using System;
 using System.Collections.Generic;
@@ -30,9 +30,9 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
         private readonly IHttpClientFactory _httpClientFactory;
         private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
 
-#pragma warning disable SA1401
+#pragma warning disable SA1401, CA2211
         public static AudioDbAlbumProvider Current;
-#pragma warning restore SA1401
+#pragma warning restore SA1401, CA2211
 
         public AudioDbAlbumProvider(IServerConfigurationManager config, IFileSystem fileSystem, IHttpClientFactory httpClientFactory)
         {
@@ -204,6 +204,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
             throw new NotImplementedException();
         }
 
+#pragma warning disable CA1034, CA2227
         public class Album
         {
             public string idAlbum { get; set; }

+ 2 - 1
MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistProvider.cs

@@ -1,4 +1,4 @@
-#pragma warning disable CS1591, SA1300
+#pragma warning disable CA1034, CS1591, CA1002, SA1028, SA1300
 
 using System;
 using System.Collections.Generic;
@@ -274,6 +274,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
             public string strLocked { get; set; }
         }
 
+#pragma warning disable CA2227
         public class RootObject
         {
             public List<Artist> artists { get; set; }

+ 16 - 1
MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzAlbumProvider.cs

@@ -23,7 +23,7 @@ using Microsoft.Extensions.Logging;
 
 namespace MediaBrowser.Providers.Music
 {
-    public class MusicBrainzAlbumProvider : IRemoteMetadataProvider<MusicAlbum, AlbumInfo>, IHasOrder
+    public class MusicBrainzAlbumProvider : IRemoteMetadataProvider<MusicAlbum, AlbumInfo>, IHasOrder, IDisposable
     {
         /// <summary>
         /// For each single MB lookup/search, this is the maximum number of
@@ -592,6 +592,21 @@ namespace MediaBrowser.Providers.Music
             throw new NotImplementedException();
         }
 
+        protected virtual void Dispose(bool disposing)
+        {
+            if (disposing)
+            {
+                _apiRequestLock?.Dispose();
+            }
+        }
+
+        /// <summary>IDisposable implementation.</summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
         private class ReleaseResult
         {
             public string ReleaseId;

+ 1 - 0
MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs

@@ -577,6 +577,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
             }
         }
 
+#pragma warning disable CA1034
         /// <summary>Describes OMDB rating.</summary>
         public class OmdbRating
         {

+ 5 - 5
MediaBrowser.Providers/Plugins/Tmdb/People/TmdbPersonProvider.cs

@@ -77,14 +77,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
             return remoteSearchResults;
         }
 
-        public async Task<MetadataResult<Person>> GetMetadata(PersonLookupInfo id, CancellationToken cancellationToken)
+        public async Task<MetadataResult<Person>> GetMetadata(PersonLookupInfo info, CancellationToken cancellationToken)
         {
-            var personTmdbId = Convert.ToInt32(id.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture);
+            var personTmdbId = Convert.ToInt32(info.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture);
 
             // We don't already have an Id, need to fetch it
             if (personTmdbId <= 0)
             {
-                var personSearchResults = await _tmdbClientManager.SearchPersonAsync(id.Name, cancellationToken).ConfigureAwait(false);
+                var personSearchResults = await _tmdbClientManager.SearchPersonAsync(info.Name, cancellationToken).ConfigureAwait(false);
                 if (personSearchResults.Count > 0)
                 {
                     personTmdbId = personSearchResults[0].Id;
@@ -95,7 +95,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
 
             if (personTmdbId > 0)
             {
-                var person = await _tmdbClientManager.GetPersonAsync(personTmdbId, id.MetadataLanguage, cancellationToken).ConfigureAwait(false);
+                var person = await _tmdbClientManager.GetPersonAsync(personTmdbId, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
 
                 result.HasMetadata = true;
 
@@ -103,7 +103,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
                 {
                     // Take name from incoming info, don't rename the person
                     // TODO: This should go in PersonMetadataService, not each person provider
-                    Name = id.Name,
+                    Name = info.Name,
                     HomePageUrl = person.Homepage,
                     Overview = person.Biography,
                     PremiereDate = person.Birthday?.ToUniversalTime(),

+ 19 - 1
MediaBrowser.Providers/Plugins/Tmdb/TmdbClientManager.cs

@@ -18,7 +18,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
     /// <summary>
     /// Manager class for abstracting the TMDb API client library.
     /// </summary>
-    public class TmdbClientManager
+    public class TmdbClientManager : IDisposable
     {
         private const int CacheDurationInHours = 1;
 
@@ -532,5 +532,23 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
         {
             return !_tmDbClient.HasConfig ? _tmDbClient.GetConfigAsync() : Task.CompletedTask;
         }
+
+        /// <summary>Dispose method.</summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        /// <summary>IDispose implementation.</summary>
+        /// <param name="disposing">Specify true to dispose.</param>
+        protected virtual void Dispose(bool disposing)
+        {
+            if (disposing)
+            {
+                _memoryCache?.Dispose();
+                _tmDbClient?.Dispose();
+            }
+        }
     }
 }

+ 8 - 2
MediaBrowser.Providers/Subtitles/SubtitleManager.cs

@@ -252,8 +252,14 @@ namespace MediaBrowser.Providers.Subtitles
                 }
                 catch (Exception ex)
                 {
-                    (exs ??= new List<Exception>()).Add(ex);
-                }
+#pragma warning disable CA1508
+                    exs ??= new List<Exception>()
+                            {
+                                ex
+                            };
+#pragma warning restore CA1508
+
+            }
                 finally
                 {
                     _monitor.ReportFileSystemChangeComplete(savePath, false);

+ 8 - 8
MediaBrowser.Providers/TV/EpisodeMetadataService.cs

@@ -25,46 +25,46 @@ namespace MediaBrowser.Providers.TV
         }
 
         /// <inheritdoc />
-        protected override ItemUpdateType BeforeSaveInternal(Episode item, bool isFullRefresh, ItemUpdateType currentUpdateType)
+        protected override ItemUpdateType BeforeSaveInternal(Episode item, bool isFullRefresh, ItemUpdateType updateType)
         {
-            var updateType = base.BeforeSaveInternal(item, isFullRefresh, currentUpdateType);
+            var updatedType = base.BeforeSaveInternal(item, isFullRefresh, updateType);
 
             var seriesName = item.FindSeriesName();
             if (!string.Equals(item.SeriesName, seriesName, StringComparison.Ordinal))
             {
                 item.SeriesName = seriesName;
-                updateType |= ItemUpdateType.MetadataImport;
+                updatedType |= ItemUpdateType.MetadataImport;
             }
 
             var seasonName = item.FindSeasonName();
             if (!string.Equals(item.SeasonName, seasonName, StringComparison.Ordinal))
             {
                 item.SeasonName = seasonName;
-                updateType |= ItemUpdateType.MetadataImport;
+                updatedType |= ItemUpdateType.MetadataImport;
             }
 
             var seriesId = item.FindSeriesId();
             if (!item.SeriesId.Equals(seriesId))
             {
                 item.SeriesId = seriesId;
-                updateType |= ItemUpdateType.MetadataImport;
+                updatedType |= ItemUpdateType.MetadataImport;
             }
 
             var seasonId = item.FindSeasonId();
             if (!item.SeasonId.Equals(seasonId))
             {
                 item.SeasonId = seasonId;
-                updateType |= ItemUpdateType.MetadataImport;
+                updatedType |= ItemUpdateType.MetadataImport;
             }
 
             var seriesPresentationUniqueKey = item.FindSeriesPresentationUniqueKey();
             if (!string.Equals(item.SeriesPresentationUniqueKey, seriesPresentationUniqueKey, StringComparison.Ordinal))
             {
                 item.SeriesPresentationUniqueKey = seriesPresentationUniqueKey;
-                updateType |= ItemUpdateType.MetadataImport;
+                updatedType |= ItemUpdateType.MetadataImport;
             }
 
-            return updateType;
+            return updatedType;
         }
 
         /// <inheritdoc />

+ 7 - 7
MediaBrowser.Providers/TV/SeasonMetadataService.cs

@@ -31,9 +31,9 @@ namespace MediaBrowser.Providers.TV
         protected override bool EnableUpdatingPremiereDateFromChildren => true;
 
         /// <inheritdoc />
-        protected override ItemUpdateType BeforeSaveInternal(Season item, bool isFullRefresh, ItemUpdateType currentUpdateType)
+        protected override ItemUpdateType BeforeSaveInternal(Season item, bool isFullRefresh, ItemUpdateType updateType)
         {
-            var updateType = base.BeforeSaveInternal(item, isFullRefresh, currentUpdateType);
+            var updatedType = base.BeforeSaveInternal(item, isFullRefresh, updateType);
 
             if (item.IndexNumber.HasValue && item.IndexNumber.Value == 0)
             {
@@ -42,7 +42,7 @@ namespace MediaBrowser.Providers.TV
                 if (!string.Equals(item.Name, seasonZeroDisplayName, StringComparison.OrdinalIgnoreCase))
                 {
                     item.Name = seasonZeroDisplayName;
-                    updateType = updateType | ItemUpdateType.MetadataEdit;
+                    updatedType = updatedType | ItemUpdateType.MetadataEdit;
                 }
             }
 
@@ -50,24 +50,24 @@ namespace MediaBrowser.Providers.TV
             if (!string.Equals(item.SeriesName, seriesName, StringComparison.Ordinal))
             {
                 item.SeriesName = seriesName;
-                updateType |= ItemUpdateType.MetadataImport;
+                updatedType |= ItemUpdateType.MetadataImport;
             }
 
             var seriesPresentationUniqueKey = item.FindSeriesPresentationUniqueKey();
             if (!string.Equals(item.SeriesPresentationUniqueKey, seriesPresentationUniqueKey, StringComparison.Ordinal))
             {
                 item.SeriesPresentationUniqueKey = seriesPresentationUniqueKey;
-                updateType |= ItemUpdateType.MetadataImport;
+                updatedType |= ItemUpdateType.MetadataImport;
             }
 
             var seriesId = item.FindSeriesId();
             if (!item.SeriesId.Equals(seriesId))
             {
                 item.SeriesId = seriesId;
-                updateType |= ItemUpdateType.MetadataImport;
+                updatedType |= ItemUpdateType.MetadataImport;
             }
 
-            return updateType;
+            return updatedType;
         }
 
         /// <inheritdoc />