Merge pull request #6857 from Bond-009/warn56

This commit is contained in:
Cody Robibero 2021-11-16 12:25:54 -07:00 committed by GitHub
commit 84b8c9c2bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 34 additions and 46 deletions

View File

@ -1075,14 +1075,6 @@ namespace Emby.Server.Implementations.Channels
forceUpdate = true; forceUpdate = true;
} }
// was used for status
// if (!string.Equals(item.ExternalEtag ?? string.Empty, info.Etag ?? string.Empty, StringComparison.Ordinal))
// {
// item.ExternalEtag = info.Etag;
// forceUpdate = true;
// _logger.LogDebug("Forcing update due to ExternalEtag {0}", item.Name);
// }
if (!internalChannelId.Equals(item.ChannelId)) if (!internalChannelId.Equals(item.ChannelId))
{ {
forceUpdate = true; forceUpdate = true;

View File

@ -1,4 +1,6 @@
using System; #pragma warning disable CA1813 // Avoid unsealed attributes
using System;
namespace Jellyfin.Api.Attributes namespace Jellyfin.Api.Attributes
{ {

View File

@ -3,7 +3,7 @@
/// <summary> /// <summary>
/// Produces file attribute of "image/*". /// Produces file attribute of "image/*".
/// </summary> /// </summary>
public class AcceptsImageFileAttribute : AcceptsFileAttribute public sealed class AcceptsImageFileAttribute : AcceptsFileAttribute
{ {
private const string ContentType = "image/*"; private const string ContentType = "image/*";

View File

@ -7,7 +7,7 @@ namespace Jellyfin.Api.Attributes
/// <summary> /// <summary>
/// Identifies an action that supports the HTTP GET method. /// Identifies an action that supports the HTTP GET method.
/// </summary> /// </summary>
public class HttpSubscribeAttribute : HttpMethodAttribute public sealed class HttpSubscribeAttribute : HttpMethodAttribute
{ {
private static readonly IEnumerable<string> _supportedMethods = new[] { "SUBSCRIBE" }; private static readonly IEnumerable<string> _supportedMethods = new[] { "SUBSCRIBE" };

View File

@ -7,7 +7,7 @@ namespace Jellyfin.Api.Attributes
/// <summary> /// <summary>
/// Identifies an action that supports the HTTP GET method. /// Identifies an action that supports the HTTP GET method.
/// </summary> /// </summary>
public class HttpUnsubscribeAttribute : HttpMethodAttribute public sealed class HttpUnsubscribeAttribute : HttpMethodAttribute
{ {
private static readonly IEnumerable<string> _supportedMethods = new[] { "UNSUBSCRIBE" }; private static readonly IEnumerable<string> _supportedMethods = new[] { "UNSUBSCRIBE" };

View File

@ -6,7 +6,7 @@ namespace Jellyfin.Api.Attributes
/// Attribute to mark a parameter as obsolete. /// Attribute to mark a parameter as obsolete.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Parameter)] [AttributeUsage(AttributeTargets.Parameter)]
public class ParameterObsoleteAttribute : Attribute public sealed class ParameterObsoleteAttribute : Attribute
{ {
} }
} }

View File

@ -3,7 +3,7 @@
/// <summary> /// <summary>
/// Produces file attribute of "image/*". /// Produces file attribute of "image/*".
/// </summary> /// </summary>
public class ProducesAudioFileAttribute : ProducesFileAttribute public sealed class ProducesAudioFileAttribute : ProducesFileAttribute
{ {
private const string ContentType = "audio/*"; private const string ContentType = "audio/*";

View File

@ -1,4 +1,6 @@
using System; #pragma warning disable CA1813 // Avoid unsealed attributes
using System;
namespace Jellyfin.Api.Attributes namespace Jellyfin.Api.Attributes
{ {

View File

@ -3,7 +3,7 @@
/// <summary> /// <summary>
/// Produces file attribute of "image/*". /// Produces file attribute of "image/*".
/// </summary> /// </summary>
public class ProducesImageFileAttribute : ProducesFileAttribute public sealed class ProducesImageFileAttribute : ProducesFileAttribute
{ {
private const string ContentType = "image/*"; private const string ContentType = "image/*";

View File

@ -3,7 +3,7 @@
/// <summary> /// <summary>
/// Produces file attribute of "image/*". /// Produces file attribute of "image/*".
/// </summary> /// </summary>
public class ProducesPlaylistFileAttribute : ProducesFileAttribute public sealed class ProducesPlaylistFileAttribute : ProducesFileAttribute
{ {
private const string ContentType = "application/x-mpegURL"; private const string ContentType = "application/x-mpegURL";

View File

@ -3,7 +3,7 @@
/// <summary> /// <summary>
/// Produces file attribute of "video/*". /// Produces file attribute of "video/*".
/// </summary> /// </summary>
public class ProducesVideoFileAttribute : ProducesFileAttribute public sealed class ProducesVideoFileAttribute : ProducesFileAttribute
{ {
private const string ContentType = "video/*"; private const string ContentType = "video/*";

View File

@ -146,11 +146,7 @@ namespace MediaBrowser.Controller.Entities.Audio
return info; return info;
} }
protected override List<Tuple<BaseItem, MediaSourceType>> GetAllItemsForMediaSources() protected override IEnumerable<(BaseItem, MediaSourceType)> GetAllItemsForMediaSources()
{ => new[] { ((BaseItem)this, MediaSourceType.Default) };
var list = new List<Tuple<BaseItem, MediaSourceType>>();
list.Add(new Tuple<BaseItem, MediaSourceType>(this, MediaSourceType.Default));
return list;
}
} }
} }

View File

@ -5,7 +5,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@ -333,13 +332,6 @@ namespace MediaBrowser.Controller.Entities
[JsonIgnore] [JsonIgnore]
public string ExternalSeriesId { get; set; } public string ExternalSeriesId { get; set; }
/// <summary>
/// Gets or sets the etag.
/// </summary>
/// <value>The etag.</value>
[JsonIgnore]
public string ExternalEtag { get; set; }
[JsonIgnore] [JsonIgnore]
public virtual bool IsHidden => false; public virtual bool IsHidden => false;
@ -1161,9 +1153,9 @@ namespace MediaBrowser.Controller.Entities
.ToList(); .ToList();
} }
protected virtual List<Tuple<BaseItem, MediaSourceType>> GetAllItemsForMediaSources() protected virtual IEnumerable<(BaseItem, MediaSourceType)> GetAllItemsForMediaSources()
{ {
return new List<Tuple<BaseItem, MediaSourceType>>(); return Enumerable.Empty<(BaseItem, MediaSourceType)>();
} }
private MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, BaseItem item, MediaSourceType type) private MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, BaseItem item, MediaSourceType type)

View File

@ -509,35 +509,35 @@ namespace MediaBrowser.Controller.Entities
}).FirstOrDefault(); }).FirstOrDefault();
} }
protected override List<Tuple<BaseItem, MediaSourceType>> GetAllItemsForMediaSources() protected override IEnumerable<(BaseItem, MediaSourceType)> GetAllItemsForMediaSources()
{ {
var list = new List<Tuple<BaseItem, MediaSourceType>>(); var list = new List<(BaseItem, MediaSourceType)>
{
(this, MediaSourceType.Default)
};
list.Add(new Tuple<BaseItem, MediaSourceType>(this, MediaSourceType.Default)); list.AddRange(GetLinkedAlternateVersions().Select(i => ((BaseItem)i, MediaSourceType.Grouping)));
list.AddRange(GetLinkedAlternateVersions().Select(i => new Tuple<BaseItem, MediaSourceType>(i, MediaSourceType.Grouping)));
if (!string.IsNullOrEmpty(PrimaryVersionId)) if (!string.IsNullOrEmpty(PrimaryVersionId))
{ {
var primary = LibraryManager.GetItemById(PrimaryVersionId) as Video; if (LibraryManager.GetItemById(PrimaryVersionId) is Video primary)
if (primary != null)
{ {
var existingIds = list.Select(i => i.Item1.Id).ToList(); var existingIds = list.Select(i => i.Item1.Id).ToList();
list.Add(new Tuple<BaseItem, MediaSourceType>(primary, MediaSourceType.Grouping)); list.Add((primary, MediaSourceType.Grouping));
list.AddRange(primary.GetLinkedAlternateVersions().Where(i => !existingIds.Contains(i.Id)).Select(i => new Tuple<BaseItem, MediaSourceType>(i, MediaSourceType.Grouping))); list.AddRange(primary.GetLinkedAlternateVersions().Where(i => !existingIds.Contains(i.Id)).Select(i => ((BaseItem)i, MediaSourceType.Grouping)));
} }
} }
var localAlternates = list var localAlternates = list
.SelectMany(i => .SelectMany(i =>
{ {
var video = i.Item1 as Video; return i.Item1 is Video video ? video.GetLocalAlternateVersionIds() : Enumerable.Empty<Guid>();
return video == null ? new List<Guid>() : video.GetLocalAlternateVersionIds();
}) })
.Select(LibraryManager.GetItemById) .Select(LibraryManager.GetItemById)
.Where(i => i != null) .Where(i => i != null)
.ToList(); .ToList();
list.AddRange(localAlternates.Select(i => new Tuple<BaseItem, MediaSourceType>(i, MediaSourceType.Default))); list.AddRange(localAlternates.Select(i => (i, MediaSourceType.Default)));
return list; return list;
} }

View File

@ -191,7 +191,7 @@ namespace MediaBrowser.Model.Net
// Catch-all for all video types that don't require specific mime types // Catch-all for all video types that don't require specific mime types
if (_videoFileExtensions.Contains(ext)) if (_videoFileExtensions.Contains(ext))
{ {
return "video/" + ext.Substring(1); return string.Concat("video/", ext.AsSpan(1));
} }
// Type text // Type text

View File

@ -50,8 +50,12 @@
<Rule Id="CA1725" Action="Error" /> <Rule Id="CA1725" Action="Error" />
<!-- error on CA1725: Call async methods when in an async method --> <!-- error on CA1725: Call async methods when in an async method -->
<Rule Id="CA1727" Action="Error" /> <Rule Id="CA1727" Action="Error" />
<!-- error on CA1813: Avoid unsealed attributes -->
<Rule Id="CA1813" Action="Error" />
<!-- error on CA1843: Do not use 'WaitAll' with a single task --> <!-- error on CA1843: Do not use 'WaitAll' with a single task -->
<Rule Id="CA1843" Action="Error" /> <Rule Id="CA1843" Action="Error" />
<!-- error on CA1845: Use span-based 'string.Concat' -->
<Rule Id="CA1845" Action="Error" />
<!-- error on CA2016: Forward the CancellationToken parameter to methods that take one <!-- error on CA2016: Forward the CancellationToken parameter to methods that take one
or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token --> or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token -->
<Rule Id="CA2016" Action="Error" /> <Rule Id="CA2016" Action="Error" />