mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-04 06:48:35 +01:00
Mayor code cleanup
Add Argument*Exceptions now use proper nameof operators. Added exception messages to quite a few Argument*Exceptions. Fixed rethorwing to be proper syntax. Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling) Added some TODOs to log certain exceptions. Fix sln again. Fixed all AssemblyInfo's and added proper copyright (where I could find them) We live in *current year*. Fixed the use of braces. Fixed a ton of properties, and made a fair amount of functions static that should be and can be static. Made more Methods that should be static static. You can now use static to find bad functions! Removed unused variable. And added one more proper XML comment.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Dto;
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Channels;
|
||||
using MediaBrowser.Model.Dto;
|
||||
@@ -46,14 +46,12 @@ namespace MediaBrowser.Controller.Channels
|
||||
/// Gets the channels internal.
|
||||
/// </summary>
|
||||
/// <param name="query">The query.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
QueryResult<Channel> GetChannelsInternal(ChannelQuery query);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channels.
|
||||
/// </summary>
|
||||
/// <param name="query">The query.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
QueryResult<BaseItemDto> GetChannels(ChannelQuery query);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (child == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
throw new ArgumentNullException(nameof(child));
|
||||
}
|
||||
|
||||
_virtualChildren.Add(child);
|
||||
@@ -203,7 +203,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (id.Equals(Guid.Empty))
|
||||
{
|
||||
throw new ArgumentNullException("id");
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
|
||||
foreach (var child in _virtualChildren)
|
||||
|
||||
@@ -1139,7 +1139,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException("media");
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
var protocol = item.PathProtocol;
|
||||
@@ -1756,7 +1756,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException("user");
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
if (!IsVisibleViaTags(user))
|
||||
@@ -1906,7 +1906,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException("user");
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
return IsParentalAllowed(user);
|
||||
@@ -2087,7 +2087,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
var current = Studios;
|
||||
@@ -2120,7 +2120,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
var genres = Genres;
|
||||
@@ -2146,7 +2146,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
var data = UserDataManager.GetUserData(user, this);
|
||||
@@ -2181,7 +2181,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
var data = UserDataManager.GetUserData(user, this);
|
||||
@@ -2579,7 +2579,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException("user");
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
var userdata = UserDataManager.GetUserData(user, this);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentNullException("url");
|
||||
throw new ArgumentNullException(nameof(url));
|
||||
}
|
||||
|
||||
var current = item.RemoteTrailers.FirstOrDefault(i => string.Equals(i.Url, url, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
@@ -997,7 +997,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (items == null)
|
||||
{
|
||||
throw new ArgumentNullException("items");
|
||||
throw new ArgumentNullException(nameof(items));
|
||||
}
|
||||
|
||||
if (CollapseBoxSetItems(query, queryParent, user, configurationManager))
|
||||
@@ -1252,7 +1252,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
//the true root should return our users root folder children
|
||||
@@ -1332,7 +1332,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException("user");
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
||||
var result = new Dictionary<Guid, BaseItem>();
|
||||
|
||||
@@ -11,12 +11,12 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (person == null)
|
||||
{
|
||||
throw new ArgumentNullException("person");
|
||||
throw new ArgumentNullException(nameof(person));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(person.Name))
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
throw new ArgumentException("The person's name was empty or null.",nameof(person));
|
||||
}
|
||||
|
||||
// Normalize
|
||||
@@ -103,7 +103,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
foreach (var i in people)
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
var current = item.Tags;
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (string.IsNullOrEmpty(newName))
|
||||
{
|
||||
throw new ArgumentNullException("newName");
|
||||
throw new ArgumentNullException(nameof(newName));
|
||||
}
|
||||
|
||||
// If only the casing is changing, leave the file system alone
|
||||
@@ -259,7 +259,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (string.IsNullOrEmpty(username))
|
||||
{
|
||||
throw new ArgumentNullException("username");
|
||||
throw new ArgumentNullException(nameof(username));
|
||||
}
|
||||
|
||||
var safeFolderName = FileSystem.GetValidFilename(username);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (value.Value < 0 || value.Value > 10)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("value", "A 0 to 10 rating is required for UserItemData.");
|
||||
throw new ArgumentOutOfRangeException(nameof(value), "A 0 to 10 rating is required for UserItemData.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Library;
|
||||
using MediaBrowser.Model.Querying;
|
||||
@@ -78,7 +78,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return new QueryResult<BaseItem>
|
||||
{
|
||||
TotalRecordCount = totalCount,
|
||||
Items = itemsArray
|
||||
Items = itemsArray //TODO Fix The co-variant conversion between Folder[] and BaseItem[], this can generate runtime issues.
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -412,7 +412,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
return new QueryResult<BaseItem>
|
||||
{
|
||||
Items = result.Items,
|
||||
Items = result.Items, //TODO Fix The co-variant conversion between T[] and BaseItem[], this can generate runtime issues if T is not BaseItem.
|
||||
TotalRecordCount = result.TotalRecordCount
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,11 +46,11 @@ namespace MediaBrowser.Controller.IO
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
throw new ArgumentNullException(nameof(path));
|
||||
}
|
||||
if (args == null)
|
||||
{
|
||||
throw new ArgumentNullException("args");
|
||||
throw new ArgumentNullException(nameof(args));
|
||||
}
|
||||
|
||||
var entries = directoryService.GetFileSystemEntries(path);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
@@ -163,7 +163,6 @@ namespace MediaBrowser.Controller.Library
|
||||
/// Adds the parts.
|
||||
/// </summary>
|
||||
/// <param name="rules">The rules.</param>
|
||||
/// <param name="pluginFolders">The plugin folders.</param>
|
||||
/// <param name="resolvers">The resolvers.</param>
|
||||
/// <param name="introProviders">The intro providers.</param>
|
||||
/// <param name="itemComparers">The item comparers.</param>
|
||||
@@ -298,7 +297,7 @@ namespace MediaBrowser.Controller.Library
|
||||
string name,
|
||||
Guid parentId,
|
||||
string viewType,
|
||||
string sortNamen);
|
||||
string sortName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the named view.
|
||||
@@ -547,4 +546,4 @@ namespace MediaBrowser.Controller.Library
|
||||
string videoPath,
|
||||
string[] files);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
throw new ArgumentException("The path was empty or null.",nameof(path));
|
||||
}
|
||||
|
||||
if (AdditionalLocations == null)
|
||||
@@ -190,7 +190,7 @@ namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
throw new ArgumentException("The name was empty or null.", nameof(name));
|
||||
}
|
||||
|
||||
return GetFileSystemEntryByPath(System.IO.Path.Combine(Path, name));
|
||||
@@ -206,7 +206,7 @@ namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
throw new ArgumentException("The path was empty or null.", nameof(path));
|
||||
}
|
||||
|
||||
foreach (var file in FileSystemChildren)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
@@ -1137,7 +1137,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
/// <summary>
|
||||
/// Gets the number of audio channels to specify on the command line
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <param name="state">The state.</param>
|
||||
/// <param name="audioStream">The audio stream.</param>
|
||||
/// <param name="outputAudioCodec">The output audio codec.</param>
|
||||
/// <returns>System.Nullable{System.Int32}.</returns>
|
||||
@@ -1907,11 +1907,11 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
if (state == null)
|
||||
{
|
||||
throw new ArgumentNullException("state");
|
||||
throw new ArgumentNullException(nameof(state));
|
||||
}
|
||||
if (mediaSource == null)
|
||||
{
|
||||
throw new ArgumentNullException("mediaSource");
|
||||
throw new ArgumentNullException(nameof(mediaSource));
|
||||
}
|
||||
|
||||
var path = mediaSource.Path;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
@@ -39,6 +39,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
//TODO Investigate and properly fix.
|
||||
// Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -50,7 +50,7 @@ namespace MediaBrowser.Controller.Net
|
||||
{
|
||||
if (logger == null)
|
||||
{
|
||||
throw new ArgumentNullException("logger");
|
||||
throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
Logger = logger;
|
||||
@@ -65,7 +65,7 @@ namespace MediaBrowser.Controller.Net
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
throw new ArgumentNullException("message");
|
||||
throw new ArgumentNullException(nameof(message));
|
||||
}
|
||||
|
||||
if (string.Equals(message.MessageType, Name + "Start", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -269,7 +269,7 @@ namespace MediaBrowser.Controller.Net
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
|
||||
//TODO Investigate and properly fix.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,10 +280,13 @@ namespace MediaBrowser.Controller.Net
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
|
||||
//TODO Investigate and properly fix.
|
||||
}
|
||||
|
||||
ActiveConnections.Remove(connection);
|
||||
lock (ActiveConnections)
|
||||
{
|
||||
ActiveConnections.Remove(connection);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace MediaBrowser.Controller.Persistence
|
||||
/// Deletes the user.
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
void DeleteUser(User user);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
@@ -7,21 +8,14 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyTitle("MediaBrowser.Controller")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("MediaBrowser.Controller")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2012")]
|
||||
[assembly: AssemblyCompany("Jellyfin Project")]
|
||||
[assembly: AssemblyProduct("Jellyfin: The Free Software Media System")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019 Jellyfin Contributors. Code released under the GNU General Public License Version 2")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Model.Devices;
|
||||
using MediaBrowser.Model.Devices;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using System.Threading;
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace MediaBrowser.Controller.Security
|
||||
/// Creates the specified information.
|
||||
/// </summary>
|
||||
/// <param name="info">The information.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
void Create(AuthenticationInfo info);
|
||||
|
||||
@@ -18,7 +17,6 @@ namespace MediaBrowser.Controller.Security
|
||||
/// Updates the specified information.
|
||||
/// </summary>
|
||||
/// <param name="info">The information.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
void Update(AuthenticationInfo info);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user