The Free Software Media System - Server Backend & API
Apply suggestions from code review
ConfusedPolarBear7d9b5524031f
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex 0a349bb331..51e63ecfc2 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -646,7 +646,6 @@ namespace Emby.Server.ImplementationsserviceCollection.AddSingleton<IAttachmentExtractor, MediaBrowser.MediaEncoding.Attachments.AttachmentExtractor>();}-/// <summary>/// Create services registered with the service container that need to be initialized at application startup./// </summary>diff --git a/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs b/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.csindex 349010039b..596ded8caa 100644--- a/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs+++ b/Emby.Server.Implementations/QuickConnect/ConfigurationExtension.cs@@ -1,18 +1,17 @@-using System.Collections.Generic;using MediaBrowser.Common.Configuration;namespace Emby.Server.Implementations.QuickConnect{/// <summary>- /// Configuration extension to support persistent quick connect configuration+ /// Configuration extension to support persistent quick connect configuration./// </summary>public static class ConfigurationExtension{/// <summary>- /// Return the current quick connect configuration+ /// Return the current quick connect configuration./// </summary>- /// <param name="manager">Configuration manager</param>- /// <returns></returns>+ /// <param name="manager">Configuration manager.</param>+ /// <returns>Current quick connect configuration.</returns>public static QuickConnectConfiguration GetQuickConnectConfiguration(this IConfigurationManager manager){return manager.GetConfiguration<QuickConnectConfiguration>("quickconnect");@@ -20,17 +19,17 @@ namespace Emby.Server.Implementations.QuickConnect}/// <summary>- /// Configuration factory for quick connect+ /// Configuration factory for quick connect./// </summary>public class QuickConnectConfigurationFactory : IConfigurationFactory{/// <summary>- /// Returns the current quick connect configuration+ /// Returns the current quick connect configuration./// </summary>- /// <returns></returns>+ /// <returns>Current quick connect configuration.</returns>public IEnumerable<ConfigurationStore> GetConfigurations(){- return new ConfigurationStore[]+ return new[]{new ConfigurationStore{diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.csindex e1881f2783..2302ddbc3f 100644--- a/Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.cs+++ b/Emby.Server.Implementations/QuickConnect/QuickConnectConfiguration.cs@@ -3,19 +3,12 @@ using MediaBrowser.Model.QuickConnect;namespace Emby.Server.Implementations.QuickConnect{/// <summary>- /// Persistent quick connect configuration+ /// Persistent quick connect configuration./// </summary>public class QuickConnectConfiguration{/// <summary>- /// Quick connect configuration object- /// </summary>- public QuickConnectConfiguration()- {- }-- /// <summary>- /// Persistent quick connect availability state+ /// Gets or sets persistent quick connect availability state./// </summary>public QuickConnectState State { get; set; }}diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.csindex 929e021a3d..62b775fa60 100644--- a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs+++ b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs@@ -27,15 +27,11 @@ namespace Emby.Server.Implementations.QuickConnectprivate readonly RNGCryptoServiceProvider _rng = new RNGCryptoServiceProvider();private Dictionary<string, QuickConnectResult> _currentRequests = new Dictionary<string, QuickConnectResult>();- private IServerConfigurationManager _config;- private ILogger _logger;- private IUserManager _userManager;- private ILocalizationManager _localizationManager;- private IJsonSerializer _jsonSerializer;- private IAuthenticationRepository _authenticationRepository;- private IAuthorizationContext _authContext;- private IServerApplicationHost _appHost;- private ITaskManager _taskManager;+ private readonly IServerConfigurationManager _config;+ private readonly ILogger<QuickConnectManager> _logger;+ private readonly IAuthenticationRepository _authenticationRepository;+ private readonly IAuthorizationContext _authContext;+ private readonly IServerApplicationHost _appHost;/// <summary>/// Initializes a new instance of the <see cref="QuickConnectManager"/> class.@@ -207,7 +203,7 @@ namespace Emby.Server.Implementations.QuickConnectscale = BitConverter.ToUInt32(raw, 0);}- int code = (int)(min + (max - min) * (scale / (double)uint.MaxValue));+ int code = (int)(min + ((max - min) * (scale / (double)uint.MaxValue)));return code.ToString(CultureInfo.InvariantCulture);}@@ -272,7 +268,26 @@ namespace Emby.Server.Implementations.QuickConnectreturn tokens.Count();}+ /// <summary>+ /// Dispose.+ /// </summary>+ public void Dispose()+ {+ Dispose(true);+ GC.SuppressFinalize(this);+ }+ /// <summary>+ /// Dispose.+ /// </summary>+ /// <param name="disposing">Dispose unmanaged resources.</param>+ protected virtual void Dispose(bool disposing)+ {+ if (disposing)+ {+ _rng?.Dispose();+ }+ }private string GenerateSecureRandom(int length = 32){var bytes = new byte[length];diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.csindex d7054e0b11..188b366aae 100644--- a/Emby.Server.Implementations/Session/SessionManager.cs+++ b/Emby.Server.Implementations/Session/SessionManager.cs@@ -1413,7 +1413,7 @@ namespace Emby.Server.Implementations.SessionLimit = 1});- if(result.TotalRecordCount < 1)+ if (result.TotalRecordCount < 1){throw new SecurityException("Unknown quick connect token");}