Fix some warnings in MediaBrowser.Controller

This commit is contained in:
Bond_009 2020-02-04 02:10:44 +01:00
parent 176e850973
commit 32dcd372f4
4 changed files with 86 additions and 64 deletions

View file

@ -135,57 +135,4 @@ namespace MediaBrowser.Controller.Entities
return hasChanges; return hasChanges;
} }
} }
/// <summary>
/// This is the small Person stub that is attached to BaseItems
/// </summary>
public class PersonInfo : IHasProviderIds
{
public PersonInfo()
{
ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
public Guid ItemId { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the role.
/// </summary>
/// <value>The role.</value>
public string Role { get; set; }
/// <summary>
/// Gets or sets the type.
/// </summary>
/// <value>The type.</value>
public string Type { get; set; }
/// <summary>
/// Gets or sets the sort order - ascending
/// </summary>
/// <value>The sort order.</value>
public int? SortOrder { get; set; }
public string ImageUrl { get; set; }
public Dictionary<string, string> ProviderIds { get; set; }
/// <summary>
/// Returns a <see cref="string" /> that represents this instance.
/// </summary>
/// <returns>A <see cref="string" /> that represents this instance.</returns>
public override string ToString()
{
return Name;
}
public bool IsType(string type)
{
return string.Equals(Type, type, StringComparison.OrdinalIgnoreCase) || string.Equals(Role, type, StringComparison.OrdinalIgnoreCase);
}
}
} }

View file

@ -0,0 +1,63 @@
using System;
using System.Linq;
using System.Collections.Generic;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Entities
{
/// <summary>
/// This is the small Person stub that is attached to BaseItems
/// </summary>
public sealed class PersonInfo : IHasProviderIds
{
public PersonInfo()
{
ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
public Guid ItemId { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the role.
/// </summary>
/// <value>The role.</value>
public string Role { get; set; }
/// <summary>
/// Gets or sets the type.
/// </summary>
/// <value>The type.</value>
public string Type { get; set; }
/// <summary>
/// Gets or sets the sort order - ascending
/// </summary>
/// <value>The sort order.</value>
public int? SortOrder { get; set; }
public string ImageUrl { get; set; }
public Dictionary<string, string> ProviderIds { get; set; }
/// <summary>
/// Returns a <see cref="string" /> that represents this instance.
/// </summary>
/// <returns>A <see cref="string" /> that represents this instance.</returns>
public override string ToString()
{
return Name;
}
public bool IsType(string type)
{
return string.Equals(Type, type, StringComparison.OrdinalIgnoreCase)
|| string.Equals(Role, type, StringComparison.OrdinalIgnoreCase);
}
}
}

View file

@ -26,4 +26,16 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>
<!-- Code Analyzers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</Project> </Project>

View file

@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Net
/// <summary> /// <summary>
/// The _active connections /// The _active connections
/// </summary> /// </summary>
protected readonly List<Tuple<IWebSocketConnection, CancellationTokenSource, TStateType>> ActiveConnections = private readonly List<Tuple<IWebSocketConnection, CancellationTokenSource, TStateType>> _activeConnections =
new List<Tuple<IWebSocketConnection, CancellationTokenSource, TStateType>>(); new List<Tuple<IWebSocketConnection, CancellationTokenSource, TStateType>>();
/// <summary> /// <summary>
@ -100,9 +100,9 @@ namespace MediaBrowser.Controller.Net
InitialDelayMs = dueTimeMs InitialDelayMs = dueTimeMs
}; };
lock (ActiveConnections) lock (_activeConnections)
{ {
ActiveConnections.Add(new Tuple<IWebSocketConnection, CancellationTokenSource, TStateType>(message.Connection, cancellationTokenSource, state)); _activeConnections.Add(new Tuple<IWebSocketConnection, CancellationTokenSource, TStateType>(message.Connection, cancellationTokenSource, state));
} }
} }
@ -110,9 +110,9 @@ namespace MediaBrowser.Controller.Net
{ {
Tuple<IWebSocketConnection, CancellationTokenSource, TStateType>[] tuples; Tuple<IWebSocketConnection, CancellationTokenSource, TStateType>[] tuples;
lock (ActiveConnections) lock (_activeConnections)
{ {
tuples = ActiveConnections tuples = _activeConnections
.Where(c => .Where(c =>
{ {
if (c.Item1.State == WebSocketState.Open && !c.Item2.IsCancellationRequested) if (c.Item1.State == WebSocketState.Open && !c.Item2.IsCancellationRequested)
@ -180,9 +180,9 @@ namespace MediaBrowser.Controller.Net
/// <param name="message">The message.</param> /// <param name="message">The message.</param>
private void Stop(WebSocketMessageInfo message) private void Stop(WebSocketMessageInfo message)
{ {
lock (ActiveConnections) lock (_activeConnections)
{ {
var connection = ActiveConnections.FirstOrDefault(c => c.Item1 == message.Connection); var connection = _activeConnections.FirstOrDefault(c => c.Item1 == message.Connection);
if (connection != null) if (connection != null)
{ {
@ -212,9 +212,9 @@ namespace MediaBrowser.Controller.Net
//TODO Investigate and properly fix. //TODO Investigate and properly fix.
} }
lock (ActiveConnections) lock (_activeConnections)
{ {
ActiveConnections.Remove(connection); _activeConnections.Remove(connection);
} }
} }
@ -226,9 +226,9 @@ namespace MediaBrowser.Controller.Net
{ {
if (dispose) if (dispose)
{ {
lock (ActiveConnections) lock (_activeConnections)
{ {
foreach (var connection in ActiveConnections.ToArray()) foreach (var connection in _activeConnections.ToArray())
{ {
DisposeConnection(connection); DisposeConnection(connection);
} }