From 32dcd372f475f3609e4d085a37e7f766b4ecaab5 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Tue, 4 Feb 2020 02:10:44 +0100 Subject: [PATCH 1/3] Fix some warnings in MediaBrowser.Controller --- MediaBrowser.Controller/Entities/Person.cs | 53 ---------------- .../Entities/PersonInfo.cs | 63 +++++++++++++++++++ .../MediaBrowser.Controller.csproj | 12 ++++ .../Net/BasePeriodicWebSocketListener.cs | 22 +++---- 4 files changed, 86 insertions(+), 64 deletions(-) create mode 100644 MediaBrowser.Controller/Entities/PersonInfo.cs diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index d9b4b22067..64e216e69f 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -135,57 +135,4 @@ namespace MediaBrowser.Controller.Entities return hasChanges; } } - - /// - /// This is the small Person stub that is attached to BaseItems - /// - public class PersonInfo : IHasProviderIds - { - public PersonInfo() - { - ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); - } - - public Guid ItemId { get; set; } - - /// - /// Gets or sets the name. - /// - /// The name. - public string Name { get; set; } - /// - /// Gets or sets the role. - /// - /// The role. - public string Role { get; set; } - /// - /// Gets or sets the type. - /// - /// The type. - public string Type { get; set; } - - /// - /// Gets or sets the sort order - ascending - /// - /// The sort order. - public int? SortOrder { get; set; } - - public string ImageUrl { get; set; } - - public Dictionary ProviderIds { get; set; } - - /// - /// Returns a that represents this instance. - /// - /// A that represents this instance. - public override string ToString() - { - return Name; - } - - public bool IsType(string type) - { - return string.Equals(Type, type, StringComparison.OrdinalIgnoreCase) || string.Equals(Role, type, StringComparison.OrdinalIgnoreCase); - } - } } diff --git a/MediaBrowser.Controller/Entities/PersonInfo.cs b/MediaBrowser.Controller/Entities/PersonInfo.cs new file mode 100644 index 0000000000..600c6f590e --- /dev/null +++ b/MediaBrowser.Controller/Entities/PersonInfo.cs @@ -0,0 +1,63 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Controller.Entities +{ + /// + /// This is the small Person stub that is attached to BaseItems + /// + public sealed class PersonInfo : IHasProviderIds + { + public PersonInfo() + { + ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); + } + + public Guid ItemId { get; set; } + + /// + /// Gets or sets the name. + /// + /// The name. + public string Name { get; set; } + + /// + /// Gets or sets the role. + /// + /// The role. + public string Role { get; set; } + + /// + /// Gets or sets the type. + /// + /// The type. + public string Type { get; set; } + + /// + /// Gets or sets the sort order - ascending + /// + /// The sort order. + public int? SortOrder { get; set; } + + public string ImageUrl { get; set; } + + public Dictionary ProviderIds { get; set; } + + /// + /// Returns a that represents this instance. + /// + /// A that represents this instance. + public override string ToString() + { + return Name; + } + + public bool IsType(string type) + { + return string.Equals(Type, type, StringComparison.OrdinalIgnoreCase) + || string.Equals(Role, type, StringComparison.OrdinalIgnoreCase); + } + } +} diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index f85b0949a1..88e9055e84 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -26,4 +26,16 @@ true + + + + + + + + + + ../jellyfin.ruleset + + diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs index ee5c1a165a..b710318eee 100644 --- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs +++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Net /// /// The _active connections /// - protected readonly List> ActiveConnections = + private readonly List> _activeConnections = new List>(); /// @@ -100,9 +100,9 @@ namespace MediaBrowser.Controller.Net InitialDelayMs = dueTimeMs }; - lock (ActiveConnections) + lock (_activeConnections) { - ActiveConnections.Add(new Tuple(message.Connection, cancellationTokenSource, state)); + _activeConnections.Add(new Tuple(message.Connection, cancellationTokenSource, state)); } } @@ -110,9 +110,9 @@ namespace MediaBrowser.Controller.Net { Tuple[] tuples; - lock (ActiveConnections) + lock (_activeConnections) { - tuples = ActiveConnections + tuples = _activeConnections .Where(c => { if (c.Item1.State == WebSocketState.Open && !c.Item2.IsCancellationRequested) @@ -180,9 +180,9 @@ namespace MediaBrowser.Controller.Net /// The 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) { @@ -212,9 +212,9 @@ namespace MediaBrowser.Controller.Net //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) { - lock (ActiveConnections) + lock (_activeConnections) { - foreach (var connection in ActiveConnections.ToArray()) + foreach (var connection in _activeConnections.ToArray()) { DisposeConnection(connection); } From c9e11c95ee11a718c176a9bae08865ab5ef6b323 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 4 Feb 2020 12:05:14 +0100 Subject: [PATCH 2/3] Apply suggestions from code review Co-Authored-By: dkanada --- MediaBrowser.Controller/Entities/PersonInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/Entities/PersonInfo.cs b/MediaBrowser.Controller/Entities/PersonInfo.cs index 600c6f590e..5a27cbe1a9 100644 --- a/MediaBrowser.Controller/Entities/PersonInfo.cs +++ b/MediaBrowser.Controller/Entities/PersonInfo.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.Entities public string Type { get; set; } /// - /// Gets or sets the sort order - ascending + /// Gets or sets the ascending sort order. /// /// The sort order. public int? SortOrder { get; set; } From 6a6472bb8a9731e4fc9d69be6b6a398aaf99477d Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 4 Feb 2020 12:28:16 +0100 Subject: [PATCH 3/3] Update MediaBrowser.Controller/Entities/PersonInfo.cs Co-Authored-By: dkanada --- MediaBrowser.Controller/Entities/PersonInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/Entities/PersonInfo.cs b/MediaBrowser.Controller/Entities/PersonInfo.cs index 5a27cbe1a9..e90c55a8ac 100644 --- a/MediaBrowser.Controller/Entities/PersonInfo.cs +++ b/MediaBrowser.Controller/Entities/PersonInfo.cs @@ -6,7 +6,7 @@ using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Entities { /// - /// This is the small Person stub that is attached to BaseItems + /// This is a small Person stub that is attached to BaseItems. /// public sealed class PersonInfo : IHasProviderIds {