Fix remaining MediaBrowser.Providers warnings

This commit is contained in:
Rich Lander 2021-07-22 20:16:38 -07:00
parent fb92eab69b
commit 927b003143
15 changed files with 82 additions and 37 deletions

View File

@ -59,9 +59,9 @@ namespace MediaBrowser.Providers.BoxSets
} }
/// <inheritdoc /> /// <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(); var libraryFolderIds = item.GetLibraryFolderIds();
@ -69,10 +69,10 @@ namespace MediaBrowser.Providers.BoxSets
if (itemLibraryFolderIds == null || !libraryFolderIds.SequenceEqual(itemLibraryFolderIds)) if (itemLibraryFolderIds == null || !libraryFolderIds.SequenceEqual(itemLibraryFolderIds))
{ {
item.LibraryFolderIds = libraryFolderIds; item.LibraryFolderIds = libraryFolderIds;
updateType |= ItemUpdateType.MetadataImport; updatedType |= ItemUpdateType.MetadataImport;
} }
return updateType; return updatedType;
} }
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,7 +23,7 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.Music namespace MediaBrowser.Providers.Music
{ {
public class MusicBrainzAlbumProvider : IRemoteMetadataProvider<MusicAlbum, AlbumInfo>, IHasOrder public class MusicBrainzAlbumProvider : IRemoteMetadataProvider<MusicAlbum, AlbumInfo>, IHasOrder, IDisposable
{ {
/// <summary> /// <summary>
/// For each single MB lookup/search, this is the maximum number of /// For each single MB lookup/search, this is the maximum number of
@ -592,6 +592,21 @@ namespace MediaBrowser.Providers.Music
throw new NotImplementedException(); 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 private class ReleaseResult
{ {
public string ReleaseId; public string ReleaseId;

View File

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

View File

@ -77,14 +77,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
return remoteSearchResults; 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 // We don't already have an Id, need to fetch it
if (personTmdbId <= 0) 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) if (personSearchResults.Count > 0)
{ {
personTmdbId = personSearchResults[0].Id; personTmdbId = personSearchResults[0].Id;
@ -95,7 +95,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
if (personTmdbId > 0) 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; result.HasMetadata = true;
@ -103,7 +103,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
{ {
// Take name from incoming info, don't rename the person // Take name from incoming info, don't rename the person
// TODO: This should go in PersonMetadataService, not each person provider // TODO: This should go in PersonMetadataService, not each person provider
Name = id.Name, Name = info.Name,
HomePageUrl = person.Homepage, HomePageUrl = person.Homepage,
Overview = person.Biography, Overview = person.Biography,
PremiereDate = person.Birthday?.ToUniversalTime(), PremiereDate = person.Birthday?.ToUniversalTime(),

View File

@ -18,7 +18,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
/// <summary> /// <summary>
/// Manager class for abstracting the TMDb API client library. /// Manager class for abstracting the TMDb API client library.
/// </summary> /// </summary>
public class TmdbClientManager public class TmdbClientManager : IDisposable
{ {
private const int CacheDurationInHours = 1; private const int CacheDurationInHours = 1;
@ -532,5 +532,23 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
{ {
return !_tmDbClient.HasConfig ? _tmDbClient.GetConfigAsync() : Task.CompletedTask; 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();
}
}
} }
} }

View File

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

View File

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

View File

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