mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-07 23:02:57 +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:
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user