The Free Software Media System - Server Backend & API
Enable nullable for more files
Bond_009651681c27630
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex 745753440d..acabbb059b 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -146,7 +146,7 @@ namespace Emby.Server.Implementations_startupConfig = startupConfig;Logger = LoggerFactory.CreateLogger<ApplicationHost>();- _deviceId = new DeviceId(ApplicationPaths, LoggerFactory);+ _deviceId = new DeviceId(ApplicationPaths, LoggerFactory.CreateLogger<DeviceId>());ApplicationVersion = typeof(ApplicationHost).Assembly.GetName().Version;ApplicationVersionString = ApplicationVersion.ToString(3);diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.csindex b3f5549bcd..2459178d81 100644--- a/Emby.Server.Implementations/Devices/DeviceId.cs+++ b/Emby.Server.Implementations/Devices/DeviceId.cs@@ -1,5 +1,3 @@-#nullable disable-#pragma warning disable CS1591using System;@@ -17,19 +15,19 @@ namespace Emby.Server.Implementations.Devicesprivate readonly ILogger<DeviceId> _logger;private readonly object _syncLock = new object();- private string _id;+ private string? _id;- public DeviceId(IApplicationPaths appPaths, ILoggerFactory loggerFactory)+ public DeviceId(IApplicationPaths appPaths, ILogger<DeviceId> logger){_appPaths = appPaths;- _logger = loggerFactory.CreateLogger<DeviceId>();+ _logger = logger;}- public string Value => _id ?? (_id = GetDeviceId());+ public string Value => _id ??= GetDeviceId();private string CachePath => Path.Combine(_appPaths.DataPath, "device.txt");- private string GetCachedId()+ private string? GetCachedId(){try{@@ -65,7 +63,7 @@ namespace Emby.Server.Implementations.Devices{var path = CachePath;- Directory.CreateDirectory(Path.GetDirectoryName(path));+ Directory.CreateDirectory(Path.GetDirectoryName(path) ?? throw new InvalidOperationException("Path can't be a root directory."));lock (_syncLock){diff --git a/Emby.Server.Implementations/Library/LiveStreamHelper.cs b/Emby.Server.Implementations/Library/LiveStreamHelper.csindex d4aeae41a5..0ebfe3ae71 100644--- a/Emby.Server.Implementations/Library/LiveStreamHelper.cs+++ b/Emby.Server.Implementations/Library/LiveStreamHelper.cs@@ -1,5 +1,3 @@-#nullable disable-#pragma warning disable CS1591using System;@@ -37,16 +35,16 @@ namespace Emby.Server.Implementations.Library_appPaths = appPaths;}- public async Task AddMediaInfoWithProbe(MediaSourceInfo mediaSource, bool isAudio, string cacheKey, bool addProbeDelay, CancellationToken cancellationToken)+ public async Task AddMediaInfoWithProbe(MediaSourceInfo mediaSource, bool isAudio, string? cacheKey, bool addProbeDelay, CancellationToken cancellationToken){var originalRuntime = mediaSource.RunTimeTicks;var now = DateTime.UtcNow;- MediaInfo mediaInfo = null;+ MediaInfo? mediaInfo = null;var cacheFilePath = string.IsNullOrEmpty(cacheKey) ? null : Path.Combine(_appPaths.CachePath, "mediainfo", cacheKey.GetMD5().ToString("N", CultureInfo.InvariantCulture) + ".json");- if (!string.IsNullOrEmpty(cacheKey))+ if (cacheFilePath is not null){try{@@ -91,7 +89,7 @@ namespace Emby.Server.Implementations.Libraryif (cacheFilePath is not null){- Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath));+ Directory.CreateDirectory(Path.GetDirectoryName(cacheFilePath) ?? throw new InvalidOperationException("Path can't be a root directory."));FileStream createStream = AsyncFile.OpenWrite(cacheFilePath);await using (createStream.ConfigureAwait(false)){diff --git a/Emby.Server.Implementations/Library/MusicManager.cs b/Emby.Server.Implementations/Library/MusicManager.csindex 078f4ad219..a69a0f33f3 100644--- a/Emby.Server.Implementations/Library/MusicManager.cs+++ b/Emby.Server.Implementations/Library/MusicManager.cs@@ -1,5 +1,3 @@-#nullable disable-#pragma warning disable CS1591using System;@@ -13,7 +11,6 @@ using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Entities.Audio;using MediaBrowser.Controller.Library;using MediaBrowser.Controller.Playlists;-using MediaBrowser.Model.Querying;using MusicAlbum = MediaBrowser.Controller.Entities.Audio.MusicAlbum;namespace Emby.Server.Implementations.Library@@ -27,33 +24,35 @@ namespace Emby.Server.Implementations.Library_libraryManager = libraryManager;}- public List<BaseItem> GetInstantMixFromSong(Audio item, User user, DtoOptions dtoOptions)+ public List<BaseItem> GetInstantMixFromSong(Audio item, User? user, DtoOptions dtoOptions){- var list = new List<Audio>+ var list = new List<BaseItem>{item};- return list.Concat(GetInstantMixFromGenres(item.Genres, user, dtoOptions)).ToList();+ list.AddRange(GetInstantMixFromGenres(item.Genres, user, dtoOptions));++ return list;}/// <inheritdoc />- public List<BaseItem> GetInstantMixFromArtist(MusicArtist artist, User user, DtoOptions dtoOptions)+ public List<BaseItem> GetInstantMixFromArtist(MusicArtist artist, User? user, DtoOptions dtoOptions){return GetInstantMixFromGenres(artist.Genres, user, dtoOptions);}- public List<BaseItem> GetInstantMixFromAlbum(MusicAlbum item, User user, DtoOptions dtoOptions)+ public List<BaseItem> GetInstantMixFromAlbum(MusicAlbum item, User? user, DtoOptions dtoOptions){return GetInstantMixFromGenres(item.Genres, user, dtoOptions);}- public List<BaseItem> GetInstantMixFromFolder(Folder item, User user, DtoOptions dtoOptions)+ public List<BaseItem> GetInstantMixFromFolder(Folder item, User? user, DtoOptions dtoOptions){var genres = item.GetRecursiveChildren(user, new InternalItemsQuery(user){- IncludeItemTypes = new[] { BaseItemKind.Audio },+ IncludeItemTypes = [BaseItemKind.Audio],DtoOptions = dtoOptions}).Cast<Audio>()@@ -64,12 +63,12 @@ namespace Emby.Server.Implementations.Libraryreturn GetInstantMixFromGenres(genres, user, dtoOptions);}- public List<BaseItem> GetInstantMixFromPlaylist(Playlist item, User user, DtoOptions dtoOptions)+ public List<BaseItem> GetInstantMixFromPlaylist(Playlist item, User? user, DtoOptions dtoOptions){return GetInstantMixFromGenres(item.Genres, user, dtoOptions);}- public List<BaseItem> GetInstantMixFromGenres(IEnumerable<string> genres, User user, DtoOptions dtoOptions)+ public List<BaseItem> GetInstantMixFromGenres(IEnumerable<string> genres, User? user, DtoOptions dtoOptions){var genreIds = genres.DistinctNames().Select(i =>{@@ -86,27 +85,23 @@ namespace Emby.Server.Implementations.Libraryreturn GetInstantMixFromGenreIds(genreIds, user, dtoOptions);}- public List<BaseItem> GetInstantMixFromGenreIds(Guid[] genreIds, User user, DtoOptions dtoOptions)+ public List<BaseItem> GetInstantMixFromGenreIds(Guid[] genreIds, User? user, DtoOptions dtoOptions){return _libraryManager.GetItemList(new InternalItemsQuery(user){- IncludeItemTypes = new[] { BaseItemKind.Audio },-- GenreIds = genreIds.ToArray(),-+ IncludeItemTypes = [BaseItemKind.Audio],+ GenreIds = genreIds,Limit = 200,-- OrderBy = new[] { (ItemSortBy.Random, SortOrder.Ascending) },-+ OrderBy = [(ItemSortBy.Random, SortOrder.Ascending)],DtoOptions = dtoOptions});}- public List<BaseItem> GetInstantMixFromItem(BaseItem item, User user, DtoOptions dtoOptions)+ public List<BaseItem> GetInstantMixFromItem(BaseItem item, User? user, DtoOptions dtoOptions){if (item is MusicGenre){- return GetInstantMixFromGenreIds(new[] { item.Id }, user, dtoOptions);+ return GetInstantMixFromGenreIds([item.Id], user, dtoOptions);}if (item is Playlist playlist)diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.csindex 020cb517d1..7f3f8615e2 100644--- a/Emby.Server.Implementations/Library/SearchEngine.cs+++ b/Emby.Server.Implementations/Library/SearchEngine.cs@@ -1,5 +1,3 @@-#nullable disable-#pragma warning disable CS1591using System;@@ -29,7 +27,7 @@ namespace Emby.Server.Implementations.Librarypublic QueryResult<SearchHintInfo> GetSearchHints(SearchQuery query){- User user = null;+ User? user = null;if (!query.UserId.IsEmpty()){user = _userManager.GetUserById(query.UserId);@@ -69,7 +67,7 @@ namespace Emby.Server.Implementations.Library/// <param name="user">The user.</param>/// <returns>IEnumerable{SearchHintResult}.</returns>/// <exception cref="ArgumentException"><c>query.SearchTerm</c> is <c>null</c> or empty.</exception>- private List<SearchHintInfo> GetSearchHints(SearchQuery query, User user)+ private List<SearchHintInfo> GetSearchHints(SearchQuery query, User? user){var searchTerm = query.SearchTerm;@@ -78,7 +76,7 @@ namespace Emby.Server.Implementations.LibrarysearchTerm = searchTerm.Trim().RemoveDiacritics();var excludeItemTypes = query.ExcludeItemTypes.ToList();- var includeItemTypes = (query.IncludeItemTypes ?? Array.Empty<BaseItemKind>()).ToList();+ var includeItemTypes = query.IncludeItemTypes.ToList();excludeItemTypes.Add(BaseItemKind.Year);excludeItemTypes.Add(BaseItemKind.Folder);@@ -179,7 +177,7 @@ namespace Emby.Server.Implementations.Library{if (!searchQuery.ParentId.IsEmpty()){- searchQuery.AncestorIds = new[] { searchQuery.ParentId };+ searchQuery.AncestorIds = [searchQuery.ParentId];searchQuery.ParentId = Guid.Empty;}diff --git a/MediaBrowser.Controller/Channels/IHasCacheKey.cs b/MediaBrowser.Controller/Channels/IHasCacheKey.csindex 9fae43033e..7d5207c34a 100644--- a/MediaBrowser.Controller/Channels/IHasCacheKey.cs+++ b/MediaBrowser.Controller/Channels/IHasCacheKey.cs@@ -1,5 +1,3 @@-#nullable disable-#pragma warning disable CS1591namespace MediaBrowser.Controller.Channels@@ -11,6 +9,6 @@ namespace MediaBrowser.Controller.Channels/// </summary>/// <param name="userId">The user identifier.</param>/// <returns>System.String.</returns>- string GetCacheKey(string userId);+ string? GetCacheKey(string? userId);}}diff --git a/MediaBrowser.Controller/Channels/ISearchableChannel.cs b/MediaBrowser.Controller/Channels/ISearchableChannel.csdeleted file mode 100644index b87943a6ed..0000000000--- a/MediaBrowser.Controller/Channels/ISearchableChannel.cs+++ /dev/null@@ -1,21 +0,0 @@-#nullable disable--#pragma warning disable CS1591--using System.Collections.Generic;-using System.Threading;-using System.Threading.Tasks;--namespace MediaBrowser.Controller.Channels-{- public interface ISearchableChannel- {- /// <summary>- /// Searches the specified search term.- /// </summary>- /// <param name="searchInfo">The search information.</param>- /// <param name="cancellationToken">The cancellation token.</param>- /// <returns>Task{IEnumerable{ChannelItemInfo}}.</returns>- Task<IEnumerable<ChannelItemInfo>> Search(ChannelSearchInfo searchInfo, CancellationToken cancellationToken);- }-}diff --git a/MediaBrowser.Controller/Channels/ISupportsLatestMedia.cs b/MediaBrowser.Controller/Channels/ISupportsLatestMedia.csindex 8ad93387ee..8ecc68babf 100644--- a/MediaBrowser.Controller/Channels/ISupportsLatestMedia.cs+++ b/MediaBrowser.Controller/Channels/ISupportsLatestMedia.cs@@ -1,6 +1,4 @@-#nullable disable--#pragma warning disable CS1591+#pragma warning disable CS1591using System.Collections.Generic;using System.Threading;diff --git a/MediaBrowser.Controller/Library/IMusicManager.cs b/MediaBrowser.Controller/Library/IMusicManager.csindex ec34a868b3..93073cc79b 100644--- a/MediaBrowser.Controller/Library/IMusicManager.cs+++ b/MediaBrowser.Controller/Library/IMusicManager.cs@@ -1,5 +1,3 @@-#nullable disable-#pragma warning disable CA1002, CS1591using System.Collections.Generic;@@ -19,7 +17,7 @@ namespace MediaBrowser.Controller.Library/// <param name="user">The user to use.</param>/// <param name="dtoOptions">The options to use.</param>/// <returns>List of items.</returns>- List<BaseItem> GetInstantMixFromItem(BaseItem item, User user, DtoOptions dtoOptions);+ List<BaseItem> GetInstantMixFromItem(BaseItem item, User? user, DtoOptions dtoOptions);/// <summary>/// Gets the instant mix from artist.@@ -28,7 +26,7 @@ namespace MediaBrowser.Controller.Library/// <param name="user">The user to use.</param>/// <param name="dtoOptions">The options to use.</param>/// <returns>List of items.</returns>- List<BaseItem> GetInstantMixFromArtist(MusicArtist artist, User user, DtoOptions dtoOptions);+ List<BaseItem> GetInstantMixFromArtist(MusicArtist artist, User? user, DtoOptions dtoOptions);/// <summary>/// Gets the instant mix from genre.@@ -37,6 +35,6 @@ namespace MediaBrowser.Controller.Library/// <param name="user">The user to use.</param>/// <param name="dtoOptions">The options to use.</param>/// <returns>List of items.</returns>- List<BaseItem> GetInstantMixFromGenres(IEnumerable<string> genres, User user, DtoOptions dtoOptions);+ List<BaseItem> GetInstantMixFromGenres(IEnumerable<string> genres, User? user, DtoOptions dtoOptions);}}diff --git a/MediaBrowser.Model/Search/SearchQuery.cs b/MediaBrowser.Model/Search/SearchQuery.csindex b91fd86571..8126b8bfcc 100644--- a/MediaBrowser.Model/Search/SearchQuery.cs+++ b/MediaBrowser.Model/Search/SearchQuery.cs@@ -1,4 +1,3 @@-#nullable disable#pragma warning disable CS1591using System;@@ -31,7 +30,7 @@ namespace MediaBrowser.Model.Search/// Gets or sets the search term./// </summary>/// <value>The search term.</value>- public string SearchTerm { get; set; }+ public required string SearchTerm { get; set; }/// <summary>/// Gets or sets the start index. Used for paging.diff --git a/MediaBrowser.Model/System/LogFile.cs b/MediaBrowser.Model/System/LogFile.csindex aec910c92c..d4eb6bafc6 100644--- a/MediaBrowser.Model/System/LogFile.cs+++ b/MediaBrowser.Model/System/LogFile.cs@@ -1,4 +1,3 @@-#nullable disable#pragma warning disable CS1591using System;@@ -29,6 +28,6 @@ namespace MediaBrowser.Model.System/// Gets or sets the name./// </summary>/// <value>The name.</value>- public string Name { get; set; }+ public required string Name { get; set; }}}diff --git a/src/Jellyfin.LiveTv/Channels/ChannelManager.cs b/src/Jellyfin.LiveTv/Channels/ChannelManager.csindex 1948a9ab9b..cce2911dca 100644--- a/src/Jellyfin.LiveTv/Channels/ChannelManager.cs+++ b/src/Jellyfin.LiveTv/Channels/ChannelManager.cs@@ -570,7 +570,6 @@ namespace Jellyfin.LiveTv.Channelsreturn new ChannelFeatures(channel.Name, channel.Id){CanFilter = !features.MaxPageSize.HasValue,- CanSearch = provider is ISearchableChannel,ContentTypes = features.ContentTypes.ToArray(),DefaultSortFields = features.DefaultSortFields.ToArray(),MaxPageSize = features.MaxPageSize,