aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Library')
-rw-r--r--Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs4
-rw-r--r--Emby.Server.Implementations/Library/LibraryManager.cs185
-rw-r--r--Emby.Server.Implementations/Library/LiveStreamHelper.cs8
-rw-r--r--Emby.Server.Implementations/Library/MediaSourceManager.cs50
-rw-r--r--Emby.Server.Implementations/Library/MediaStreamSelector.cs2
-rw-r--r--Emby.Server.Implementations/Library/ResolverHelper.cs15
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs10
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs4
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs2
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs2
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs2
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs20
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs12
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs2
-rw-r--r--Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs6
-rw-r--r--Emby.Server.Implementations/Library/SearchEngine.cs5
-rw-r--r--Emby.Server.Implementations/Library/UserDataManager.cs2
-rw-r--r--Emby.Server.Implementations/Library/UserViewManager.cs10
-rw-r--r--Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs2
19 files changed, 156 insertions, 187 deletions
diff --git a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
index e558fbe27..665d70a41 100644
--- a/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
+++ b/Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
@@ -52,7 +52,7 @@ namespace Emby.Server.Implementations.Library
if (fileInfo.IsDirectory)
{
- if (parent != null)
+ if (parent is not null)
{
// Ignore extras folders but allow it at the collection level
if (_namingOptions.AllExtrasTypesFolderNames.ContainsKey(filename)
@@ -65,7 +65,7 @@ namespace Emby.Server.Implementations.Library
}
else
{
- if (parent != null)
+ if (parent is not null)
{
// Don't resolve these into audio files
if (Path.GetFileNameWithoutExtension(filename.AsSpan()).Equals(BaseItem.ThemeSongFileName, StringComparison.Ordinal)
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index b688af528..70439d258 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -176,7 +176,7 @@ namespace Emby.Server.Implementations.Library
{
get
{
- if (_rootFolder == null)
+ if (_rootFolder is null)
{
lock (_rootFolderSyncLock)
{
@@ -465,9 +465,9 @@ namespace Emby.Server.Implementations.Library
private BaseItem ResolveItem(ItemResolveArgs args, IItemResolver[] resolvers)
{
var item = (resolvers ?? EntityResolvers).Select(r => Resolve(args, r))
- .FirstOrDefault(i => i != null);
+ .FirstOrDefault(i => i is not null);
- if (item != null)
+ if (item is not null)
{
ResolverHelper.SetInitialItemValues(item, args, _fileSystem, this);
}
@@ -495,11 +495,7 @@ namespace Emby.Server.Implementations.Library
private Guid GetNewItemIdInternal(string key, Type type, bool forceCaseInsensitive)
{
- if (string.IsNullOrEmpty(key))
- {
- throw new ArgumentNullException(nameof(key));
- }
-
+ ArgumentException.ThrowIfNullOrEmpty(key);
ArgumentNullException.ThrowIfNull(type);
string programDataPath = _configurationManager.ApplicationPaths.ProgramDataPath;
@@ -536,7 +532,7 @@ namespace Emby.Server.Implementations.Library
var fullPath = fileInfo.FullName;
- if (string.IsNullOrEmpty(collectionType) && parent != null)
+ if (string.IsNullOrEmpty(collectionType) && parent is not null)
{
collectionType = GetContentTypeOverride(fullPath, true);
}
@@ -572,7 +568,7 @@ namespace Emby.Server.Implementations.Library
}
catch (Exception ex)
{
- if (parent != null && parent.IsPhysicalRoot)
+ if (parent is not null && parent.IsPhysicalRoot)
{
_logger.LogError(ex, "Error in GetFilteredFileSystemEntries isPhysicalRoot: {0} IsVf: {1}", isPhysicalRoot, isVf);
@@ -654,9 +650,9 @@ namespace Emby.Server.Implementations.Library
{
var fileList = files.Where(i => !IgnoreFile(i, parent)).ToList();
- if (parent != null)
+ if (parent is not null)
{
- var multiItemResolvers = resolvers == null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>().ToArray();
+ var multiItemResolvers = resolvers is null ? MultiItemResolvers : resolvers.OfType<IMultiItemResolver>().ToArray();
foreach (var resolver in multiItemResolvers)
{
@@ -697,7 +693,7 @@ namespace Emby.Server.Implementations.Library
_logger.LogError(ex, "Error resolving path {Path}", file.FullName);
}
- if (result != null)
+ if (result is not null)
{
yield return result;
}
@@ -750,7 +746,7 @@ namespace Emby.Server.Implementations.Library
var dbItem = GetItemById(folder.Id) as BasePluginFolder;
- if (dbItem != null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase))
+ if (dbItem is not null && string.Equals(dbItem.Path, folder.Path, StringComparison.OrdinalIgnoreCase))
{
folder = dbItem;
}
@@ -770,11 +766,11 @@ namespace Emby.Server.Implementations.Library
public Folder GetUserRootFolder()
{
- if (_userRootFolder == null)
+ if (_userRootFolder is null)
{
lock (_userRootFolderSyncLock)
{
- if (_userRootFolder == null)
+ if (_userRootFolder is null)
{
var userRootPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
@@ -792,7 +788,7 @@ namespace Emby.Server.Implementations.Library
_logger.LogError(ex, "Error creating UserRootFolder {Path}", newItemId);
}
- if (tmpItem == null)
+ if (tmpItem is null)
{
_logger.LogDebug("Creating new userRootFolder with DeepCopy");
tmpItem = ((Folder)ResolvePath(_fileSystem.GetDirectoryInfo(userRootPath))).DeepCopy<Folder, UserRootFolder>();
@@ -818,10 +814,7 @@ namespace Emby.Server.Implementations.Library
{
// If this returns multiple items it could be tricky figuring out which one is correct.
// In most cases, the newest one will be and the others obsolete but not yet cleaned up
- if (string.IsNullOrEmpty(path))
- {
- throw new ArgumentNullException(nameof(path));
- }
+ ArgumentException.ThrowIfNullOrEmpty(path);
var query = new InternalItemsQuery
{
@@ -952,7 +945,7 @@ namespace Emby.Server.Implementations.Library
.Cast<T>()
.FirstOrDefault();
- if (existing != null)
+ if (existing is not null)
{
return existing;
}
@@ -961,7 +954,7 @@ namespace Emby.Server.Implementations.Library
var path = getPathFn(name);
var id = GetItemByNameId<T>(path);
var item = GetItemById(id) as T;
- if (item == null)
+ if (item is null)
{
item = new T
{
@@ -1181,7 +1174,7 @@ namespace Emby.Server.Implementations.Library
return null;
}
})
- .Where(i => i != null)
+ .Where(i => i is not null)
.OrderBy(i => i)
.ToArray(),
@@ -1190,17 +1183,17 @@ namespace Emby.Server.Implementations.Library
var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase));
- if (libraryFolder != null && libraryFolder.HasImage(ImageType.Primary))
+ if (libraryFolder is not null && libraryFolder.HasImage(ImageType.Primary))
{
info.PrimaryImageItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
}
- if (libraryFolder != null)
+ if (libraryFolder is not null)
{
info.ItemId = libraryFolder.Id.ToString("N", CultureInfo.InvariantCulture);
info.LibraryOptions = GetLibraryOptions(libraryFolder);
- if (refreshQueue != null)
+ if (refreshQueue is not null)
{
info.RefreshProgress = libraryFolder.GetRefreshProgress();
@@ -1245,7 +1238,7 @@ namespace Emby.Server.Implementations.Library
item = RetrieveItem(id);
- if (item != null)
+ if (item is not null)
{
RegisterItem(item);
}
@@ -1258,13 +1251,13 @@ namespace Emby.Server.Implementations.Library
if (query.Recursive && !query.ParentId.Equals(default))
{
var parent = GetItemById(query.ParentId);
- if (parent != null)
+ if (parent is not null)
{
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
}
}
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User, allowExternalContent);
}
@@ -1282,13 +1275,13 @@ namespace Emby.Server.Implementations.Library
if (query.Recursive && !query.ParentId.Equals(default))
{
var parent = GetItemById(query.ParentId);
- if (parent != null)
+ if (parent is not null)
{
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
}
}
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1302,7 +1295,7 @@ namespace Emby.Server.Implementations.Library
if (query.AncestorIds.Length == 0 && query.TopParentIds.Length == 0)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1313,7 +1306,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<BaseItem> QueryItems(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1331,7 +1324,7 @@ namespace Emby.Server.Implementations.Library
public List<Guid> GetItemIds(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1341,7 +1334,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1352,7 +1345,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1363,7 +1356,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1374,7 +1367,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1385,7 +1378,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1426,7 +1419,7 @@ namespace Emby.Server.Implementations.Library
public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery query)
{
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1440,13 +1433,13 @@ namespace Emby.Server.Implementations.Library
if (query.Recursive && !query.ParentId.Equals(default))
{
var parent = GetItemById(query.ParentId);
- if (parent != null)
+ if (parent is not null)
{
SetTopParentIdsOrAncestors(query, new List<BaseItem> { parent });
}
}
- if (query.User != null)
+ if (query.User is not null)
{
AddUserToQuery(query, query.User);
}
@@ -1524,7 +1517,7 @@ namespace Emby.Server.Implementations.Library
if (!view.DisplayParentId.Equals(default))
{
var displayParent = GetItemById(view.DisplayParentId);
- if (displayParent != null)
+ if (displayParent is not null)
{
return GetTopParentIdsForQuery(displayParent, user);
}
@@ -1535,7 +1528,7 @@ namespace Emby.Server.Implementations.Library
if (!view.ParentId.Equals(default))
{
var displayParent = GetItemById(view.ParentId);
- if (displayParent != null)
+ if (displayParent is not null)
{
return GetTopParentIdsForQuery(displayParent, user);
}
@@ -1544,7 +1537,7 @@ namespace Emby.Server.Implementations.Library
}
// Handle grouping
- if (user != null && !string.IsNullOrEmpty(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType)
+ if (user is not null && !string.IsNullOrEmpty(view.ViewType) && UserView.IsEligibleForGrouping(view.ViewType)
&& user.GetPreference(PreferenceKind.GroupedFolders).Length > 0)
{
return GetUserRootFolder()
@@ -1564,7 +1557,7 @@ namespace Emby.Server.Implementations.Library
}
var topParent = item.GetTopParent();
- if (topParent != null)
+ if (topParent is not null)
{
return new[] { topParent.Id };
}
@@ -1589,7 +1582,7 @@ namespace Emby.Server.Implementations.Library
return items
.SelectMany(i => i.ToArray())
.Select(ResolveIntro)
- .Where(i => i != null);
+ .Where(i => i is not null);
}
/// <summary>
@@ -1627,7 +1620,7 @@ namespace Emby.Server.Implementations.Library
// Get an existing item by Id
video = GetItemById(info.ItemId.Value) as Video;
- if (video == null)
+ if (video is null)
{
_logger.LogError("Unable to locate item with Id {ID}.", info.ItemId.Value);
}
@@ -1639,7 +1632,7 @@ namespace Emby.Server.Implementations.Library
// Try to resolve the path into a video
video = ResolvePath(_fileSystem.GetFileSystemInfo(info.Path)) as Video;
- if (video == null)
+ if (video is null)
{
_logger.LogError("Intro resolver returned null for {Path}.", info.Path);
}
@@ -1648,7 +1641,7 @@ namespace Emby.Server.Implementations.Library
// Pull the saved db item that will include metadata
var dbItem = GetItemById(video.Id) as Video;
- if (dbItem != null)
+ if (dbItem is not null)
{
video = dbItem;
}
@@ -1685,7 +1678,7 @@ namespace Emby.Server.Implementations.Library
IOrderedEnumerable<BaseItem> orderedItems = null;
- foreach (var orderBy in sortBy.Select(o => GetComparer(o, user)).Where(c => c != null))
+ foreach (var orderBy in sortBy.Select(o => GetComparer(o, user)).Where(c => c is not null))
{
if (isFirst)
{
@@ -1711,7 +1704,7 @@ namespace Emby.Server.Implementations.Library
foreach (var (name, sortOrder) in orderBy)
{
var comparer = GetComparer(name, user);
- if (comparer == null)
+ if (comparer is null)
{
continue;
}
@@ -1781,7 +1774,7 @@ namespace Emby.Server.Implementations.Library
RegisterItem(item);
}
- if (ItemAdded != null)
+ if (ItemAdded is not null)
{
foreach (var item in items)
{
@@ -1811,7 +1804,7 @@ namespace Emby.Server.Implementations.Library
private bool ImageNeedsRefresh(ItemImageInfo image)
{
- if (image.Path != null && image.IsLocalFile)
+ if (image.Path is not null && image.IsLocalFile)
{
if (image.Width == 0 || image.Height == 0 || string.IsNullOrEmpty(image.BlurHash))
{
@@ -1829,7 +1822,7 @@ namespace Emby.Server.Implementations.Library
}
}
- return image.Path != null && !image.IsLocalFile;
+ return image.Path is not null && !image.IsLocalFile;
}
/// <inheritdoc />
@@ -1838,7 +1831,7 @@ namespace Emby.Server.Implementations.Library
ArgumentNullException.ThrowIfNull(item);
var outdated = forceUpdate
- ? item.ImageInfos.Where(i => i.Path != null).ToArray()
+ ? item.ImageInfos.Where(i => i.Path is not null).ToArray()
: item.ImageInfos.Where(ImageNeedsRefresh).ToArray();
// Skip image processing if current or live tv source
if (outdated.Length == 0 || item.SourceType != SourceType.Library)
@@ -1923,7 +1916,7 @@ namespace Emby.Server.Implementations.Library
_itemRepository.SaveItems(items, cancellationToken);
- if (ItemUpdated != null)
+ if (ItemUpdated is not null)
{
foreach (var item in items)
{
@@ -1975,7 +1968,7 @@ namespace Emby.Server.Implementations.Library
/// <param name="parent">The parent item.</param>
public void ReportItemRemoved(BaseItem item, BaseItem parent)
{
- if (ItemRemoved != null)
+ if (ItemRemoved is not null)
{
try
{
@@ -2006,11 +1999,11 @@ namespace Emby.Server.Implementations.Library
public List<Folder> GetCollectionFolders(BaseItem item)
{
- while (item != null)
+ while (item is not null)
{
var parent = item.GetParent();
- if (parent == null || parent is AggregateFolder)
+ if (parent is null || parent is AggregateFolder)
{
break;
}
@@ -2018,7 +2011,7 @@ namespace Emby.Server.Implementations.Library
item = parent;
}
- if (item == null)
+ if (item is null)
{
return new List<Folder>();
}
@@ -2028,11 +2021,11 @@ namespace Emby.Server.Implementations.Library
public List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren)
{
- while (item != null)
+ while (item is not null)
{
var parent = item.GetParent();
- if (parent == null || parent is AggregateFolder)
+ if (parent is null || parent is AggregateFolder)
{
break;
}
@@ -2040,7 +2033,7 @@ namespace Emby.Server.Implementations.Library
item = parent;
}
- if (item == null)
+ if (item is null)
{
return new List<Folder>();
}
@@ -2064,7 +2057,7 @@ namespace Emby.Server.Implementations.Library
.Find(folder => folder is CollectionFolder) as CollectionFolder;
}
- return collectionFolder == null ? new LibraryOptions() : collectionFolder.GetLibraryOptions();
+ return collectionFolder is null ? new LibraryOptions() : collectionFolder.GetLibraryOptions();
}
public string GetContentType(BaseItem item)
@@ -2129,7 +2122,7 @@ namespace Emby.Server.Implementations.Library
private string GetTopFolderContentType(BaseItem item)
{
- if (item == null)
+ if (item is null)
{
return null;
}
@@ -2137,7 +2130,7 @@ namespace Emby.Server.Implementations.Library
while (!item.ParentId.Equals(default))
{
var parent = item.GetParent();
- if (parent == null || parent is AggregateFolder)
+ if (parent is null || parent is AggregateFolder)
{
break;
}
@@ -2177,7 +2170,7 @@ namespace Emby.Server.Implementations.Library
var refresh = false;
- if (item == null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase))
+ if (item is null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase))
{
Directory.CreateDirectory(path);
@@ -2225,7 +2218,7 @@ namespace Emby.Server.Implementations.Library
var isNew = false;
- if (item == null)
+ if (item is null)
{
Directory.CreateDirectory(path);
@@ -2251,7 +2244,7 @@ namespace Emby.Server.Implementations.Library
if (!refresh && !item.DisplayParentId.Equals(default))
{
var displayParent = GetItemById(item.DisplayParentId);
- refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
+ refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
}
if (refresh)
@@ -2289,7 +2282,7 @@ namespace Emby.Server.Implementations.Library
var isNew = false;
- if (item == null)
+ if (item is null)
{
Directory.CreateDirectory(path);
@@ -2315,7 +2308,7 @@ namespace Emby.Server.Implementations.Library
if (!refresh && !item.DisplayParentId.Equals(default))
{
var displayParent = GetItemById(item.DisplayParentId);
- refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
+ refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
}
if (refresh)
@@ -2340,10 +2333,7 @@ namespace Emby.Server.Implementations.Library
string sortName,
string uniqueId)
{
- if (string.IsNullOrEmpty(name))
- {
- throw new ArgumentNullException(nameof(name));
- }
+ ArgumentException.ThrowIfNullOrEmpty(name);
var parentIdString = parentId.Equals(default)
? null
@@ -2362,7 +2352,7 @@ namespace Emby.Server.Implementations.Library
var isNew = false;
- if (item == null)
+ if (item is null)
{
Directory.CreateDirectory(path);
@@ -2394,7 +2384,7 @@ namespace Emby.Server.Implementations.Library
if (!refresh && !item.DisplayParentId.Equals(default))
{
var displayParent = GetItemById(item.DisplayParentId);
- refresh = displayParent != null && displayParent.DateLastSaved > item.DateLastRefreshed;
+ refresh = displayParent is not null && displayParent.DateLastSaved > item.DateLastRefreshed;
}
if (refresh)
@@ -2441,7 +2431,7 @@ namespace Emby.Server.Implementations.Library
public bool FillMissingEpisodeNumbersFromPath(Episode episode, bool forceRefresh)
{
var series = episode.Series;
- bool? isAbsoluteNaming = series != null && string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase);
+ bool? isAbsoluteNaming = series is not null && string.Equals(series.DisplayOrder, "absolute", StringComparison.OrdinalIgnoreCase);
if (!isAbsoluteNaming.Value)
{
// In other words, no filter applied
@@ -2459,10 +2449,10 @@ namespace Emby.Server.Implementations.Library
episodeInfo = resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming);
// Resolve from parent folder if it's not the Season folder
var parent = episode.GetParent();
- if (episodeInfo == null && parent.GetType() == typeof(Folder))
+ if (episodeInfo is null && parent.GetType() == typeof(Folder))
{
episodeInfo = resolver.Resolve(parent.Path, true, null, null, isAbsoluteNaming);
- if (episodeInfo != null)
+ if (episodeInfo is not null)
{
// add the container
episodeInfo.Container = Path.GetExtension(episode.Path)?.TrimStart('.');
@@ -2582,7 +2572,7 @@ namespace Emby.Server.Implementations.Library
{
var season = episode.Season;
- if (season != null)
+ if (season is not null)
{
episode.ParentIndexNumber = season.IndexNumber;
}
@@ -2620,7 +2610,7 @@ namespace Emby.Server.Implementations.Library
public IEnumerable<BaseItem> FindExtras(BaseItem owner, IReadOnlyList<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService)
{
var ownerVideoInfo = VideoResolver.Resolve(owner.Path, owner.IsFolder, _namingOptions);
- if (ownerVideoInfo == null)
+ if (ownerVideoInfo is null)
{
yield break;
}
@@ -2640,7 +2630,7 @@ namespace Emby.Server.Implementations.Library
}
var extra = GetExtra(file, extraType.Value);
- if (extra != null)
+ if (extra is not null)
{
yield return extra;
}
@@ -2649,7 +2639,7 @@ namespace Emby.Server.Implementations.Library
else if (!current.IsDirectory && _extraResolver.TryGetExtraTypeForOwner(current.FullName, ownerVideoInfo, out var extraType))
{
var extra = GetExtra(current, extraType.Value);
- if (extra != null)
+ if (extra is not null)
{
yield return extra;
}
@@ -2666,7 +2656,7 @@ namespace Emby.Server.Implementations.Library
// Try to retrieve it from the db. If we don't find it, use the resolved version
var itemById = GetItemById(extra.Id);
- if (itemById != null)
+ if (itemById is not null)
{
extra = itemById;
}
@@ -2681,10 +2671,10 @@ namespace Emby.Server.Implementations.Library
public string GetPathAfterNetworkSubstitution(string path, BaseItem ownerItem)
{
string newPath;
- if (ownerItem != null)
+ if (ownerItem is not null)
{
var libraryOptions = GetLibraryOptions(ownerItem);
- if (libraryOptions != null)
+ if (libraryOptions is not null)
{
foreach (var pathInfo in libraryOptions.PathInfos)
{
@@ -2753,8 +2743,8 @@ namespace Emby.Server.Implementations.Library
return null;
}
})
- .Where(i => i != null)
- .Where(i => query.User == null ?
+ .Where(i => i is not null)
+ .Where(i => query.User is null ?
true :
i.IsVisible(query.User))
.ToList();
@@ -2838,10 +2828,10 @@ namespace Emby.Server.Implementations.Library
}
var mediaPathInfos = options.PathInfos;
- if (mediaPathInfos != null)
+ if (mediaPathInfos is not null)
{
var invalidpath = mediaPathInfos.FirstOrDefault(i => !Directory.Exists(i.Path));
- if (invalidpath != null)
+ if (invalidpath is not null)
{
throw new ArgumentException("The specified path does not exist: " + invalidpath.Path + ".");
}
@@ -2853,7 +2843,7 @@ namespace Emby.Server.Implementations.Library
{
Directory.CreateDirectory(virtualFolderPath);
- if (collectionType != null)
+ if (collectionType is not null)
{
var path = Path.Combine(virtualFolderPath, collectionType.ToString().ToLowerInvariant() + ".collection");
@@ -2862,7 +2852,7 @@ namespace Emby.Server.Implementations.Library
CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
- if (mediaPathInfos != null)
+ if (mediaPathInfos is not null)
{
foreach (var path in mediaPathInfos)
{
@@ -3125,10 +3115,7 @@ namespace Emby.Server.Implementations.Library
public void RemoveMediaPath(string virtualFolderName, string mediaPath)
{
- if (string.IsNullOrEmpty(mediaPath))
- {
- throw new ArgumentNullException(nameof(mediaPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(mediaPath);
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
diff --git a/Emby.Server.Implementations/Library/LiveStreamHelper.cs b/Emby.Server.Implementations/Library/LiveStreamHelper.cs
index 20624cc7a..936a08da8 100644
--- a/Emby.Server.Implementations/Library/LiveStreamHelper.cs
+++ b/Emby.Server.Implementations/Library/LiveStreamHelper.cs
@@ -60,7 +60,7 @@ namespace Emby.Server.Implementations.Library
}
}
- if (mediaInfo == null)
+ if (mediaInfo is null)
{
if (addProbeDelay)
{
@@ -81,7 +81,7 @@ namespace Emby.Server.Implementations.Library
},
cancellationToken).ConfigureAwait(false);
- if (cacheFilePath != null)
+ if (cacheFilePath is not null)
{
Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
await using FileStream createStream = AsyncFile.OpenWrite(cacheFilePath);
@@ -130,7 +130,7 @@ namespace Emby.Server.Implementations.Library
var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
- if (audioStream == null || audioStream.Index == -1)
+ if (audioStream is null || audioStream.Index == -1)
{
mediaSource.DefaultAudioStreamIndex = null;
}
@@ -140,7 +140,7 @@ namespace Emby.Server.Implementations.Library
}
var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
- if (videoStream != null)
+ if (videoStream is not null)
{
if (!videoStream.BitRate.HasValue)
{
diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs
index bfccc7db7..eadfa5dfe 100644
--- a/Emby.Server.Implementations/Library/MediaSourceManager.cs
+++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs
@@ -182,7 +182,7 @@ namespace Emby.Server.Implementations.Library
source.SupportsDirectStream = SupportsDirectStream(source.Path, source.Protocol);
}
- if (user != null)
+ if (user is not null)
{
SetDefaultAudioAndSubtitleStreamIndexes(item, source, user);
@@ -248,7 +248,7 @@ namespace Emby.Server.Implementations.Library
if (protocol == MediaProtocol.Http)
{
- if (path != null)
+ if (path is not null)
{
if (path.Contains(".m3u", StringComparison.OrdinalIgnoreCase))
{
@@ -328,7 +328,7 @@ namespace Emby.Server.Implementations.Library
var sources = hasMediaSources.GetMediaSources(enablePathSubstitution);
- if (user != null)
+ if (user is not null)
{
foreach (var source in sources)
{
@@ -357,7 +357,7 @@ namespace Emby.Server.Implementations.Library
}
var culture = _localizationManager.FindLanguageInfo(language);
- if (culture != null)
+ if (culture is not null)
{
return culture.ThreeLetterISOLanguageNames;
}
@@ -383,7 +383,7 @@ namespace Emby.Server.Implementations.Library
var preferredSubs = NormalizeLanguage(user.SubtitleLanguagePreference);
var defaultAudioIndex = source.DefaultAudioStreamIndex;
- var audioLangage = defaultAudioIndex == null
+ var audioLangage = defaultAudioIndex is null
? null
: source.MediaStreams.Where(i => i.Type == MediaStreamType.Audio && i.Index == defaultAudioIndex).Select(i => i.Language).FirstOrDefault();
@@ -417,13 +417,13 @@ namespace Emby.Server.Implementations.Library
public void SetDefaultAudioAndSubtitleStreamIndexes(BaseItem item, MediaSourceInfo source, User user)
{
// Item would only be null if the app didn't supply ItemId as part of the live stream open request
- var mediaType = item == null ? MediaType.Video : item.MediaType;
+ var mediaType = item is null ? MediaType.Video : item.MediaType;
if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
{
- var userData = item == null ? new UserItemData() : _userDataManager.GetUserData(user, item);
+ var userData = item is null ? new UserItemData() : _userDataManager.GetUserData(user, item);
- var allowRememberingSelection = item == null || item.EnableRememberingTrackSelections;
+ var allowRememberingSelection = item is null || item.EnableRememberingTrackSelections;
SetDefaultAudioStreamIndex(source, userData, user, allowRememberingSelection);
SetDefaultSubtitleStreamIndex(source, userData, user, allowRememberingSelection);
@@ -432,7 +432,7 @@ namespace Emby.Server.Implementations.Library
{
var audio = source.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
- if (audio != null)
+ if (audio is not null)
{
source.DefaultAudioStreamIndex = audio.Index;
}
@@ -543,7 +543,7 @@ namespace Emby.Server.Implementations.Library
var audioStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
- if (audioStream == null || audioStream.Index == -1)
+ if (audioStream is null || audioStream.Index == -1)
{
mediaSource.DefaultAudioStreamIndex = null;
}
@@ -553,7 +553,7 @@ namespace Emby.Server.Implementations.Library
}
var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
- if (videoStream != null)
+ if (videoStream is not null)
{
if (!videoStream.BitRate.HasValue)
{
@@ -638,7 +638,7 @@ namespace Emby.Server.Implementations.Library
}
}
- if (mediaInfo == null)
+ if (mediaInfo is null)
{
if (addProbeDelay)
{
@@ -661,7 +661,7 @@ namespace Emby.Server.Implementations.Library
},
cancellationToken).ConfigureAwait(false);
- if (cacheFilePath != null)
+ if (cacheFilePath is not null)
{
Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
await using FileStream createStream = File.Create(cacheFilePath);
@@ -713,7 +713,7 @@ namespace Emby.Server.Implementations.Library
var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
- if (audioStream == null || audioStream.Index == -1)
+ if (audioStream is null || audioStream.Index == -1)
{
mediaSource.DefaultAudioStreamIndex = null;
}
@@ -723,7 +723,7 @@ namespace Emby.Server.Implementations.Library
}
var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
- if (videoStream != null)
+ if (videoStream is not null)
{
if (!videoStream.BitRate.HasValue)
{
@@ -762,10 +762,7 @@ namespace Emby.Server.Implementations.Library
public Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetLiveStreamWithDirectStreamProvider(string id, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(id))
- {
- throw new ArgumentNullException(nameof(id));
- }
+ ArgumentException.ThrowIfNullOrEmpty(id);
// TODO probably shouldn't throw here but it is kept for "backwards compatibility"
var info = GetLiveStreamInfo(id) ?? throw new ResourceNotFoundException();
@@ -774,10 +771,7 @@ namespace Emby.Server.Implementations.Library
public ILiveStream GetLiveStreamInfo(string id)
{
- if (string.IsNullOrEmpty(id))
- {
- throw new ArgumentNullException(nameof(id));
- }
+ ArgumentException.ThrowIfNullOrEmpty(id);
if (_openStreams.TryGetValue(id, out ILiveStream info))
{
@@ -801,10 +795,7 @@ namespace Emby.Server.Implementations.Library
public async Task CloseLiveStream(string id)
{
- if (string.IsNullOrEmpty(id))
- {
- throw new ArgumentNullException(nameof(id));
- }
+ ArgumentException.ThrowIfNullOrEmpty(id);
await _liveStreamSemaphore.WaitAsync().ConfigureAwait(false);
@@ -835,10 +826,7 @@ namespace Emby.Server.Implementations.Library
private (IMediaSourceProvider MediaSourceProvider, string KeyId) GetProvider(string key)
{
- if (string.IsNullOrEmpty(key))
- {
- throw new ArgumentException("Key can't be empty.", nameof(key));
- }
+ ArgumentException.ThrowIfNullOrEmpty(key);
var keys = key.Split(LiveStreamIdDelimeter, 2);
diff --git a/Emby.Server.Implementations/Library/MediaStreamSelector.cs b/Emby.Server.Implementations/Library/MediaStreamSelector.cs
index 609b95772..74c53b2da 100644
--- a/Emby.Server.Implementations/Library/MediaStreamSelector.cs
+++ b/Emby.Server.Implementations/Library/MediaStreamSelector.cs
@@ -19,7 +19,7 @@ namespace Emby.Server.Implementations.Library
{
var defaultStream = sortedStreams.FirstOrDefault(i => i.IsDefault);
- if (defaultStream != null)
+ if (defaultStream is not null)
{
return defaultStream.Index;
}
diff --git a/Emby.Server.Implementations/Library/ResolverHelper.cs b/Emby.Server.Implementations/Library/ResolverHelper.cs
index 4100a74a5..7a61e2607 100644
--- a/Emby.Server.Implementations/Library/ResolverHelper.cs
+++ b/Emby.Server.Implementations/Library/ResolverHelper.cs
@@ -25,13 +25,10 @@ namespace Emby.Server.Implementations.Library
public static bool SetInitialItemValues(BaseItem item, Folder? parent, ILibraryManager libraryManager, IDirectoryService directoryService)
{
// This version of the below method has no ItemResolveArgs, so we have to require the path already being set
- if (string.IsNullOrEmpty(item.Path))
- {
- throw new ArgumentException("Item must have a Path");
- }
+ ArgumentException.ThrowIfNullOrEmpty(item.Path);
// If the resolver didn't specify this
- if (parent != null)
+ if (parent is not null)
{
item.SetParent(parent);
}
@@ -43,7 +40,7 @@ namespace Emby.Server.Implementations.Library
// Make sure DateCreated and DateModified have values
var fileInfo = directoryService.GetFile(item.Path);
- if (fileInfo == null)
+ if (fileInfo is null)
{
return false;
}
@@ -71,7 +68,7 @@ namespace Emby.Server.Implementations.Library
}
// If the resolver didn't specify this
- if (args.Parent != null)
+ if (args.Parent is not null)
{
item.SetParent(args.Parent);
}
@@ -113,7 +110,7 @@ namespace Emby.Server.Implementations.Library
{
var childData = args.IsDirectory ? args.GetFileSystemEntryByPath(item.Path) : null;
- if (childData != null)
+ if (childData is not null)
{
SetDateCreated(item, childData);
}
@@ -140,7 +137,7 @@ namespace Emby.Server.Implementations.Library
if (config.UseFileCreationTimeForDateAdded)
{
// directoryService.getFile may return null
- if (info != null)
+ if (info is not null)
{
var dateCreated = info.CreationTimeUtc;
diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
index 7a6aea9c1..06621700a 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs
@@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
{
var result = ResolveMultipleInternal(parent, files, collectionType);
- if (result != null)
+ if (result is not null)
{
foreach (var item in result.Items)
{
@@ -116,7 +116,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
// Use regular audio type for mixed libraries, owned items and music
if (isMixedCollectionType ||
- args.Parent == null ||
+ args.Parent is null ||
isMusicCollectionType)
{
item = new MediaBrowser.Controller.Entities.Audio.Audio();
@@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
item = new AudioBook();
}
- if (item != null)
+ if (item is not null)
{
item.IsShortcut = string.Equals(extension, ".strm", StringComparison.OrdinalIgnoreCase);
@@ -144,7 +144,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
// TODO: Allow GetMultiDiscMovie in here
var result = ResolveMultipleAudio(args.Parent, args.GetActualFileSystemChildren(), parseName);
- if (result == null || result.Items.Count != 1 || result.Items[0] is not AudioBook item)
+ if (result is null || result.Items.Count != 1 || result.Items[0] is not AudioBook item)
{
return null;
}
@@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
Items = items
};
- var isInMixedFolder = resolverResult.Count > 1 || (parent != null && parent.IsTopParent);
+ var isInMixedFolder = resolverResult.Count > 1 || (parent is not null && parent.IsTopParent);
foreach (var resolvedItem in resolverResult)
{
diff --git a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
index b2a7abb1b..cb377136a 100644
--- a/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs
@@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
videoType = VideoType.Dvd;
}
- if (videoType == null)
+ if (videoType is null)
{
continue;
}
@@ -93,7 +93,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
videoInfo = VideoResolver.Resolve(args.Path, false, NamingOptions, parseName);
}
- if (videoInfo == null || (!videoInfo.IsStub && !VideoResolver.IsVideoFile(args.Path, NamingOptions)))
+ if (videoInfo is null || (!videoInfo.IsStub && !VideoResolver.IsVideoFile(args.Path, NamingOptions)))
{
return null;
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
index 6fc200e3b..042422c6f 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Books/BookResolver.cs
@@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Books
var extension = Path.GetExtension(args.Path);
- if (extension != null && _validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase))
+ if (extension is not null && _validExtensions.Contains(extension, StringComparison.OrdinalIgnoreCase))
{
// It's a book
return new Book
diff --git a/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs b/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs
index 408e640f9..30c52e19d 100644
--- a/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs
@@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
public bool TryGetExtraTypeForOwner(string path, VideoFileInfo ownerVideoFileInfo, [NotNullWhen(true)] out ExtraType? extraType)
{
var extraResult = GetExtraInfo(path, _namingOptions);
- if (extraResult.ExtraType == null)
+ if (extraResult.ExtraType is null)
{
extraType = null;
return false;
diff --git a/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs
index 079962282..1c2de912a 100644
--- a/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/GenericFolderResolver.cs
@@ -22,7 +22,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
{
base.SetInitialItemValues(item, args);
- item.IsRoot = args.Parent == null;
+ item.IsRoot = args.Parent is null;
}
}
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
index 84d4688af..5f1a3ec6d 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
@@ -64,7 +64,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
{
var result = ResolveMultipleInternal(parent, files, collectionType);
- if (result != null)
+ if (result is not null)
{
foreach (var item in result.Items)
{
@@ -108,7 +108,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
if (string.IsNullOrEmpty(collectionType))
{
// Owned items will be caught by the video extra resolver
- if (args.Parent == null)
+ if (args.Parent is null)
{
return null;
}
@@ -127,10 +127,10 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
}
// ignore extras
- return movie?.ExtraType == null ? movie : null;
+ return movie?.ExtraType is null ? movie : null;
}
- if (args.Parent == null)
+ if (args.Parent is null)
{
return base.Resolve(args);
}
@@ -168,12 +168,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
}
// Ignore extras
- if (item?.ExtraType != null)
+ if (item?.ExtraType is not null)
{
return null;
}
- if (item != null)
+ if (item is not null)
{
item.IsInMixedFolder = true;
}
@@ -205,7 +205,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
if (string.IsNullOrEmpty(collectionType))
{
// Owned items should just use the plain video type
- if (parent == null)
+ if (parent is null)
{
return ResolveVideos<Video>(parent, files, false, collectionType, false);
}
@@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
var videoInfos = files
.Select(i => VideoResolver.Resolve(i.FullName, i.IsDirectory, NamingOptions, parseName))
- .Where(f => f != null)
+ .Where(f => f is not null)
.ToList();
var resolverResult = VideoListResolver.Resolve(videoInfos, NamingOptions, supportMultiEditions, parseName);
@@ -284,7 +284,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
{
var firstVideo = video.Files[0];
var path = firstVideo.Path;
- if (video.ExtraType != null)
+ if (video.ExtraType is not null)
{
result.ExtraFiles.Add(files.Find(f => string.Equals(f.FullName, path, StringComparison.OrdinalIgnoreCase)));
continue;
@@ -568,7 +568,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
private bool IsInvalid(Folder parent, ReadOnlySpan<char> collectionType)
{
- if (parent != null)
+ if (parent is not null)
{
if (parent.IsRoot)
{
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
index 9ba079edf..0fcc5070b 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/EpisodeResolver.cs
@@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
{
var parent = args.Parent;
- if (parent == null)
+ if (parent is null)
{
return null;
}
@@ -46,34 +46,34 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
// If the parent is a Season or Series and the parent is not an extras folder, then this is an Episode if the VideoResolver returns something
// Also handle flat tv folders
- if (season != null ||
+ if (season is not null ||
string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) ||
args.HasParent<Series>())
{
var episode = ResolveVideo<Episode>(args, false);
// Ignore extras
- if (episode == null || episode.ExtraType != null)
+ if (episode is null || episode.ExtraType is not null)
{
return null;
}
var series = parent as Series ?? parent.GetParents().OfType<Series>().FirstOrDefault();
- if (series != null)
+ if (series is not null)
{
episode.SeriesId = series.Id;
episode.SeriesName = series.Name;
}
- if (season != null)
+ if (season is not null)
{
episode.SeasonId = season.Id;
episode.SeasonName = season.Name;
}
// Assume season 1 if there's no season folder and a season number could not be determined
- if (season == null && !episode.ParentIndexNumber.HasValue && (episode.IndexNumber.HasValue || episode.PremiereDate.HasValue))
+ if (season is null && !episode.ParentIndexNumber.HasValue && (episode.IndexNumber.HasValue || episode.PremiereDate.HasValue))
{
episode.ParentIndexNumber = 1;
}
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
index ea4851458..62a524d2e 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
@@ -66,7 +66,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
var episodeInfo = resolver.Resolve(testPath, true);
- if (episodeInfo?.EpisodeNumber != null && episodeInfo.SeasonNumber.HasValue)
+ if (episodeInfo?.EpisodeNumber is not null && episodeInfo.SeasonNumber.HasValue)
{
_logger.LogDebug(
"Found folder underneath series with episode number: {0}. Season {1}. Episode {2}",
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
index f5ac3c665..8f69175d0 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
@@ -76,7 +76,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
{
if (args.ContainsFileSystemEntryByName("tvshow.nfo"))
{
- if (args.Parent != null && args.Parent.IsRoot)
+ if (args.Parent is not null && args.Parent.IsRoot)
{
// For now, return null, but if we want to allow this in the future then add some additional checks to guard against a misplaced tvshow.nfo
return null;
@@ -89,7 +89,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
};
}
- if (args.Parent != null && args.Parent.IsRoot)
+ if (args.Parent is not null && args.Parent.IsRoot)
{
return null;
}
@@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions);
var episodeInfo = episodeResolver.Resolve(fullName, false, true, false, fillExtendedInfo: false);
- if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue)
+ if (episodeInfo is not null && episodeInfo.EpisodeNumber.HasValue)
{
return true;
}
diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.cs
index 60778a443..b916b9170 100644
--- a/Emby.Server.Implementations/Library/SearchEngine.cs
+++ b/Emby.Server.Implementations/Library/SearchEngine.cs
@@ -73,10 +73,7 @@ namespace Emby.Server.Implementations.Library
{
var searchTerm = query.SearchTerm;
- if (string.IsNullOrEmpty(searchTerm))
- {
- throw new ArgumentException("SearchTerm can't be empty.", nameof(query));
- }
+ ArgumentException.ThrowIfNullOrEmpty(searchTerm);
searchTerm = searchTerm.Trim().RemoveDiacritics();
diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs
index aecab7d9c..a0a90b129 100644
--- a/Emby.Server.Implementations/Library/UserDataManager.cs
+++ b/Emby.Server.Implementations/Library/UserDataManager.cs
@@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.Library
{
var userData = _repository.GetUserData(internalUserId, keys);
- if (userData != null)
+ if (userData is not null)
{
return userData;
}
diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs
index ec411aa3b..1137625f4 100644
--- a/Emby.Server.Implementations/Library/UserViewManager.cs
+++ b/Emby.Server.Implementations/Library/UserViewManager.cs
@@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.Library
{
var user = _userManager.GetUserById(query.UserId);
- if (user == null)
+ if (user is null)
{
throw new ArgumentException("User Id specified in the query does not exist.", nameof(query));
}
@@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.Library
continue;
}
- if (collectionFolder != null && UserView.IsEligibleForGrouping(folder) && user.IsFolderGrouped(folder.Id))
+ if (collectionFolder is not null && UserView.IsEligibleForGrouping(folder) && user.IsFolderGrouped(folder.Id))
{
groupedFolders.Add(collectionFolder);
continue;
@@ -208,15 +208,15 @@ namespace Emby.Server.Implementations.Library
// Only grab the index container for media
var container = item.IsFolder || !request.GroupItems ? null : item.LatestItemsIndexContainer;
- if (container == null)
+ if (container is null)
{
list.Add(new Tuple<BaseItem, List<BaseItem>>(null, new List<BaseItem> { item }));
}
else
{
- var current = list.FirstOrDefault(i => i.Item1 != null && i.Item1.Id.Equals(container.Id));
+ var current = list.FirstOrDefault(i => i.Item1 is not null && i.Item1.Id.Equals(container.Id));
- if (current != null)
+ if (current is not null)
{
current.Item2.Add(item);
}
diff --git a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
index 88b93a211..df45793c3 100644
--- a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
+++ b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
@@ -118,7 +118,7 @@ namespace Emby.Server.Implementations.Library.Validators
try
{
var boxSet = boxSets.FirstOrDefault(b => b?.Name == collectionName) as BoxSet;
- if (boxSet == null)
+ if (boxSet is null)
{
// won't automatically create collection if only one movie in it
if (movieIds.Count >= 2)