The Free Software Media System - Server Backend & API
Use ArgumentNullException.ThrowIfNull helper method
Bond_009a9a5fcde8106
diff --git a/Emby.Dlna/ContentDirectory/ContentDirectoryService.cs b/Emby.Dlna/ContentDirectory/ContentDirectoryService.csindex 9020dea994..319a9f5500 100644--- a/Emby.Dlna/ContentDirectory/ContentDirectoryService.cs+++ b/Emby.Dlna/ContentDirectory/ContentDirectoryService.cs@@ -103,10 +103,7 @@ namespace Emby.Dlna.ContentDirectory/// <inheritdoc />public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request){- if (request == null)- {- throw new ArgumentNullException(nameof(request));- }+ ArgumentNullException.ThrowIfNull(request);var profile = _dlna.GetProfile(request.Headers) ?? _dlna.GetDefaultProfile();diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.csindex 57170bb316..fc69960fd6 100644--- a/Emby.Dlna/ContentDirectory/ControlHandler.cs+++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs@@ -114,15 +114,9 @@ namespace Emby.Dlna.ContentDirectory/// <inheritdoc />protected override void WriteResult(string methodName, IReadOnlyDictionary<string, string> methodParams, XmlWriter xmlWriter){- if (xmlWriter == null)- {- throw new ArgumentNullException(nameof(xmlWriter));- }+ ArgumentNullException.ThrowIfNull(xmlWriter);- if (methodParams == null)- {- throw new ArgumentNullException(nameof(methodParams));- }+ ArgumentNullException.ThrowIfNull(methodParams);const string DeviceId = "test";diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.csindex 74624334bb..57864d2780 100644--- a/Emby.Dlna/DlnaManager.cs+++ b/Emby.Dlna/DlnaManager.cs@@ -100,10 +100,7 @@ namespace Emby.Dlna/// <inheritdoc />public DeviceProfile? GetProfile(DeviceIdentification deviceInfo){- if (deviceInfo == null)- {- throw new ArgumentNullException(nameof(deviceInfo));- }+ ArgumentNullException.ThrowIfNull(deviceInfo);var profile = GetProfiles().FirstOrDefault(i => i.Identification != null && IsMatch(deviceInfo, i.Identification));@@ -170,10 +167,7 @@ namespace Emby.Dlna/// <inheritdoc />public DeviceProfile? GetProfile(IHeaderDictionary headers){- if (headers == null)- {- throw new ArgumentNullException(nameof(headers));- }+ ArgumentNullException.ThrowIfNull(headers);var profile = GetProfiles().FirstOrDefault(i => i.Identification != null && IsMatch(headers, i.Identification));if (profile == null)diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.csindex 0b480f5ab0..34981bd3f4 100644--- a/Emby.Dlna/PlayTo/Device.cs+++ b/Emby.Dlna/PlayTo/Device.cs@@ -931,10 +931,7 @@ namespace Emby.Dlna.PlayToprivate static UBaseObject CreateUBaseObject(XElement container, string trackUri){- if (container == null)- {- throw new ArgumentNullException(nameof(container));- }+ ArgumentNullException.ThrowIfNull(container);var url = container.GetValue(UPnpNamespaces.Res);@@ -958,10 +955,7 @@ namespace Emby.Dlna.PlayToprivate static string[] GetProtocolInfo(XElement container){- if (container == null)- {- throw new ArgumentNullException(nameof(container));- }+ ArgumentNullException.ThrowIfNull(container);var resElement = container.Element(UPnpNamespaces.Res);@@ -1183,10 +1177,7 @@ namespace Emby.Dlna.PlayTo#nullable enableprivate static DeviceIcon CreateIcon(XElement element){- if (element == null)- {- throw new ArgumentNullException(nameof(element));- }+ ArgumentNullException.ThrowIfNull(element);var width = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("width"));var height = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("height"));diff --git a/Emby.Dlna/PlayTo/TransportCommands.cs b/Emby.Dlna/PlayTo/TransportCommands.csindex d373b57f55..9c3a9103be 100644--- a/Emby.Dlna/PlayTo/TransportCommands.cs+++ b/Emby.Dlna/PlayTo/TransportCommands.cs@@ -61,10 +61,7 @@ namespace Emby.Dlna.PlayToprivate static Argument ArgumentFromXml(XElement container){- if (container == null)- {- throw new ArgumentNullException(nameof(container));- }+ ArgumentNullException.ThrowIfNull(container);return new Argument{diff --git a/Emby.Dlna/PlayTo/UpnpContainer.cs b/Emby.Dlna/PlayTo/UpnpContainer.csindex 05f27603fb..017d51e606 100644--- a/Emby.Dlna/PlayTo/UpnpContainer.cs+++ b/Emby.Dlna/PlayTo/UpnpContainer.cs@@ -10,10 +10,7 @@ namespace Emby.Dlna.PlayTo{public static UBaseObject Create(XElement container){- if (container == null)- {- throw new ArgumentNullException(nameof(container));- }+ ArgumentNullException.ThrowIfNull(container);return new UBaseObject{diff --git a/Emby.Dlna/PlayTo/uBaseObject.cs b/Emby.Dlna/PlayTo/uBaseObject.csindex 02d2da58d6..2e0f2063be 100644--- a/Emby.Dlna/PlayTo/uBaseObject.cs+++ b/Emby.Dlna/PlayTo/uBaseObject.cs@@ -54,10 +54,7 @@ namespace Emby.Dlna.PlayTopublic bool Equals(UBaseObject obj){- if (obj == null)- {- throw new ArgumentNullException(nameof(obj));- }+ ArgumentNullException.ThrowIfNull(obj);return string.Equals(Id, obj.Id, StringComparison.Ordinal);}diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.csindex c42cec593a..26b4649dd8 100644--- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs+++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs@@ -210,10 +210,7 @@ namespace Emby.Server.Implementations.AppBase/// <exception cref="ArgumentNullException"><c>newConfiguration</c> is <c>null</c>.</exception>public virtual void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration){- if (newConfiguration == null)- {- throw new ArgumentNullException(nameof(newConfiguration));- }+ ArgumentNullException.ThrowIfNull(newConfiguration);ValidateCachePath(newConfiguration);diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.csindex 92a85e8626..6837cce5cc 100644--- a/Emby.Server.Implementations/Channels/ChannelManager.cs+++ b/Emby.Server.Implementations/Channels/ChannelManager.cs@@ -1188,10 +1188,7 @@ namespace Emby.Server.Implementations.Channelsinternal IChannel GetChannelProvider(Channel channel){- if (channel == null)- {- throw new ArgumentNullException(nameof(channel));- }+ ArgumentNullException.ThrowIfNull(channel);var result = GetAllChannels().FirstOrDefault(i => GetInternalChannelId(i.Name).Equals(channel.ChannelId) || string.Equals(i.Name, channel.Name, StringComparison.OrdinalIgnoreCase));diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.csindex 381eb92a88..736b8125d7 100644--- a/Emby.Server.Implementations/Data/SqliteExtensions.cs+++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs@@ -54,10 +54,7 @@ namespace Emby.Server.Implementations.Datapublic static void RunQueries(this SQLiteDatabaseConnection connection, string[] queries){- if (queries == null)- {- throw new ArgumentNullException(nameof(queries));- }+ ArgumentNullException.ThrowIfNull(queries);connection.RunInTransaction(conn =>{diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.csindex 1b176e60d7..9c9fa73830 100644--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs+++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs@@ -583,10 +583,7 @@ namespace Emby.Server.Implementations.Datapublic void SaveImages(BaseItem item){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);CheckDisposed();@@ -617,10 +614,7 @@ namespace Emby.Server.Implementations.Data/// </exception>public void SaveItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken){- if (items == null)- {- throw new ArgumentNullException(nameof(items));- }+ ArgumentNullException.ThrowIfNull(items);cancellationToken.ThrowIfCancellationRequested();@@ -2085,10 +2079,7 @@ namespace Emby.Server.Implementations.Datathrow new ArgumentNullException(nameof(id));}- if (chapters == null)- {- throw new ArgumentNullException(nameof(chapters));- }+ ArgumentNullException.ThrowIfNull(chapters);var idBlob = id.ToByteArray();@@ -2557,10 +2548,7 @@ namespace Emby.Server.Implementations.Datapublic int GetCount(InternalItemsQuery query){- if (query == null)- {- throw new ArgumentNullException(nameof(query));- }+ ArgumentNullException.ThrowIfNull(query);CheckDisposed();@@ -2613,10 +2601,7 @@ namespace Emby.Server.Implementations.Datapublic List<BaseItem> GetItemList(InternalItemsQuery query){- if (query == null)- {- throw new ArgumentNullException(nameof(query));- }+ ArgumentNullException.ThrowIfNull(query);CheckDisposed();@@ -2794,10 +2779,7 @@ namespace Emby.Server.Implementations.Datapublic QueryResult<BaseItem> GetItems(InternalItemsQuery query){- if (query == null)- {- throw new ArgumentNullException(nameof(query));- }+ ArgumentNullException.ThrowIfNull(query);CheckDisposed();@@ -3174,10 +3156,7 @@ namespace Emby.Server.Implementations.Datapublic List<Guid> GetItemIdsList(InternalItemsQuery query){- if (query == null)- {- throw new ArgumentNullException(nameof(query));- }+ ArgumentNullException.ThrowIfNull(query);CheckDisposed();@@ -4837,10 +4816,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Typepublic List<string> GetPeopleNames(InternalPeopleQuery query){- if (query == null)- {- throw new ArgumentNullException(nameof(query));- }+ ArgumentNullException.ThrowIfNull(query);CheckDisposed();@@ -4880,10 +4856,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Typepublic List<PersonInfo> GetPeople(InternalPeopleQuery query){- if (query == null)- {- throw new ArgumentNullException(nameof(query));- }+ ArgumentNullException.ThrowIfNull(query);CheckDisposed();@@ -4999,10 +4972,7 @@ AND Type = @InternalPersonType)");throw new ArgumentNullException(nameof(itemId));}- if (ancestorIds == null)- {- throw new ArgumentNullException(nameof(ancestorIds));- }+ ArgumentNullException.ThrowIfNull(ancestorIds);CheckDisposed();@@ -5175,10 +5145,7 @@ AND Type = @InternalPersonType)");private QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetItemValues(InternalItemsQuery query, int[] itemValueTypes, string returnType){- if (query == null)- {- throw new ArgumentNullException(nameof(query));- }+ ArgumentNullException.ThrowIfNull(query);if (!query.Limit.HasValue){@@ -5531,10 +5498,7 @@ AND Type = @InternalPersonType)");throw new ArgumentNullException(nameof(itemId));}- if (values == null)- {- throw new ArgumentNullException(nameof(values));- }+ ArgumentNullException.ThrowIfNull(values);CheckDisposed();@@ -5607,10 +5571,7 @@ AND Type = @InternalPersonType)");throw new ArgumentNullException(nameof(itemId));}- if (people == null)- {- throw new ArgumentNullException(nameof(people));- }+ ArgumentNullException.ThrowIfNull(people);CheckDisposed();@@ -5710,10 +5671,7 @@ AND Type = @InternalPersonType)");{CheckDisposed();- if (query == null)- {- throw new ArgumentNullException(nameof(query));- }+ ArgumentNullException.ThrowIfNull(query);var cmdText = _mediaStreamSaveColumnsSelectQuery;@@ -5766,10 +5724,7 @@ AND Type = @InternalPersonType)");throw new ArgumentNullException(nameof(id));}- if (streams == null)- {- throw new ArgumentNullException(nameof(streams));- }+ ArgumentNullException.ThrowIfNull(streams);cancellationToken.ThrowIfCancellationRequested();@@ -6107,10 +6062,7 @@ AND Type = @InternalPersonType)");{CheckDisposed();- if (query == null)- {- throw new ArgumentNullException(nameof(query));- }+ ArgumentNullException.ThrowIfNull(query);var cmdText = _mediaAttachmentSaveColumnsSelectQuery;@@ -6152,10 +6104,7 @@ AND Type = @InternalPersonType)");throw new ArgumentException("Guid can't be empty.", nameof(id));}- if (attachments == null)- {- throw new ArgumentNullException(nameof(attachments));- }+ ArgumentNullException.ThrowIfNull(attachments);cancellationToken.ThrowIfCancellationRequested();diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.csindex ba86dc156e..8d78d644dc 100644--- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs+++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs@@ -133,10 +133,7 @@ namespace Emby.Server.Implementations.Data/// <inheritdoc />public void SaveUserData(long userId, string key, UserItemData userData, CancellationToken cancellationToken){- if (userData == null)- {- throw new ArgumentNullException(nameof(userData));- }+ ArgumentNullException.ThrowIfNull(userData);if (userId <= 0){@@ -154,10 +151,7 @@ namespace Emby.Server.Implementations.Data/// <inheritdoc />public void SaveAllUserData(long userId, UserItemData[] userData, CancellationToken cancellationToken){- if (userData == null)- {- throw new ArgumentNullException(nameof(userData));- }+ ArgumentNullException.ThrowIfNull(userData);if (userId <= 0){@@ -304,10 +298,7 @@ namespace Emby.Server.Implementations.Datapublic UserItemData GetUserData(long userId, List<string> keys){- if (keys == null)- {- throw new ArgumentNullException(nameof(keys));- }+ ArgumentNullException.ThrowIfNull(keys);if (keys.Count == 0){diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.csindex 67f9c57658..ee94670eb0 100644--- a/Emby.Server.Implementations/Library/LibraryManager.cs+++ b/Emby.Server.Implementations/Library/LibraryManager.cs@@ -281,10 +281,7 @@ namespace Emby.Server.Implementations.Librarypublic void RegisterItem(BaseItem item){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);if (item is IItemByName){@@ -311,10 +308,7 @@ namespace Emby.Server.Implementations.Librarypublic void DeleteItem(BaseItem item, DeleteOptions options, bool notifyParentItem){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);var parent = item.GetOwner() ?? item.GetParent();@@ -323,10 +317,7 @@ namespace Emby.Server.Implementations.Librarypublic void DeleteItem(BaseItem item, DeleteOptions options, BaseItem parent, bool notifyParentItem){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);if (item.SourceType == SourceType.Channel){@@ -509,10 +500,7 @@ namespace Emby.Server.Implementations.Librarythrow new ArgumentNullException(nameof(key));}- if (type == null)- {- throw new ArgumentNullException(nameof(type));- }+ ArgumentNullException.ThrowIfNull(type);string programDataPath = _configurationManager.ApplicationPaths.ProgramDataPath;if (key.StartsWith(programDataPath, StringComparison.Ordinal))@@ -544,10 +532,7 @@ namespace Emby.Server.Implementations.Librarystring collectionType = null,LibraryOptions libraryOptions = null){- if (fileInfo == null)- {- throw new ArgumentNullException(nameof(fileInfo));- }+ ArgumentNullException.ThrowIfNull(fileInfo);var fullPath = fileInfo.FullName;@@ -1854,10 +1839,7 @@ namespace Emby.Server.Implementations.Library/// <inheritdoc />public async Task UpdateImagesAsync(BaseItem item, bool forceUpdate = false){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);var outdated = forceUpdate? item.ImageInfos.Where(i => i.Path != null).ToArray()@@ -2296,10 +2278,7 @@ namespace Emby.Server.Implementations.Librarystring viewType,string sortName){- if (parent == null)- {- throw new ArgumentNullException(nameof(parent));- }+ ArgumentNullException.ThrowIfNull(parent);var name = parent.Name;var parentId = parent.Id;@@ -2779,7 +2758,7 @@ namespace Emby.Server.Implementations.Library}}).Where(i => i != null)- .Where(i => query.User == null ?+ .Where(i => query.User == null ?true :i.IsVisible(query.User)).ToList();@@ -2983,10 +2962,7 @@ namespace Emby.Server.Implementations.Libraryprivate void AddMediaPathInternal(string virtualFolderName, MediaPathInfo pathInfo, bool saveLibraryOptions){- if (pathInfo == null)- {- throw new ArgumentNullException(nameof(pathInfo));- }+ ArgumentNullException.ThrowIfNull(pathInfo);var path = pathInfo.Path;@@ -3033,10 +3009,7 @@ namespace Emby.Server.Implementations.Librarypublic void UpdateMediaPath(string virtualFolderName, MediaPathInfo mediaPath){- if (mediaPath == null)- {- throw new ArgumentNullException(nameof(mediaPath));- }+ ArgumentNullException.ThrowIfNull(mediaPath);var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.csindex c0aef18997..bfccc7db72 100644--- a/Emby.Server.Implementations/Library/MediaSourceManager.cs+++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs@@ -322,10 +322,7 @@ namespace Emby.Server.Implementations.Librarypublic List<MediaSourceInfo> GetStaticMediaSources(BaseItem item, bool enablePathSubstitution, User user = null){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);var hasMediaSources = (IHasMediaSources)item;diff --git a/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs b/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.csindex bc2915db62..af4abfb805 100644--- a/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs+++ b/Emby.Server.Implementations/Library/Resolvers/PhotoResolver.cs@@ -91,10 +91,7 @@ namespace Emby.Server.Implementations.Library.Resolversinternal static bool IsImageFile(string path, IImageProcessor imageProcessor){- if (path == null)- {- throw new ArgumentNullException(nameof(path));- }+ ArgumentNullException.ThrowIfNull(path);var filename = Path.GetFileNameWithoutExtension(path);diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.csindex 3810a76c45..aecab7d9c8 100644--- a/Emby.Server.Implementations/Library/UserDataManager.cs+++ b/Emby.Server.Implementations/Library/UserDataManager.cs@@ -53,15 +53,9 @@ namespace Emby.Server.Implementations.Librarypublic void SaveUserData(User user, BaseItem item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken){- if (userData == null)- {- throw new ArgumentNullException(nameof(userData));- }+ ArgumentNullException.ThrowIfNull(userData);- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);cancellationToken.ThrowIfCancellationRequested();@@ -194,10 +188,7 @@ namespace Emby.Server.Implementations.Library/// <exception cref="ArgumentNullException"><paramref name="data"/> is <c>null</c>.</exception>private UserItemDataDto GetUserItemDataDto(UserItemData data){- if (data == null)- {- throw new ArgumentNullException(nameof(data));- }+ ArgumentNullException.ThrowIfNull(data);return new UserItemDataDto{diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.csindex 065309688c..4da6776369 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs@@ -1223,10 +1223,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVprivate async Task RecordStream(TimerInfo timer, DateTime recordingEndDate, ActiveRecordingInfo activeRecordingInfo){- if (timer == null)- {- throw new ArgumentNullException(nameof(timer));- }+ ArgumentNullException.ThrowIfNull(timer);LiveTvProgram programInfo = null;@@ -2347,10 +2344,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVprivate IEnumerable<TimerInfo> GetTimersForSeries(SeriesTimerInfo seriesTimer){- if (seriesTimer == null)- {- throw new ArgumentNullException(nameof(seriesTimer));- }+ ArgumentNullException.ThrowIfNull(seriesTimer);var query = new InternalItemsQuery{diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.csindex 46979bfc57..58b798ce67 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs@@ -84,10 +84,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVpublic virtual void Update(T item){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);lock (_fileDataLock){@@ -107,10 +104,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVpublic virtual void Add(T item){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);lock (_fileDataLock){diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.csindex be06356a4f..a423ec8f48 100644--- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs@@ -44,10 +44,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHostspublic async Task<Stream> GetListingsStream(TunerHostInfo info, CancellationToken cancellationToken){- if (info == null)- {- throw new ArgumentNullException(nameof(info));- }+ ArgumentNullException.ThrowIfNull(info);if (!info.Url.StartsWith("http", StringComparison.OrdinalIgnoreCase)){diff --git a/Emby.Server.Implementations/Net/SocketFactory.cs b/Emby.Server.Implementations/Net/SocketFactory.csindex 21795c8f86..303875df55 100644--- a/Emby.Server.Implementations/Net/SocketFactory.cs+++ b/Emby.Server.Implementations/Net/SocketFactory.cs@@ -63,10 +63,7 @@ namespace Emby.Server.Implementations.Net/// <inheritdoc />public ISocket CreateUdpMulticastSocket(IPAddress ipAddress, int multicastTimeToLive, int localPort){- if (ipAddress == null)- {- throw new ArgumentNullException(nameof(ipAddress));- }+ ArgumentNullException.ThrowIfNull(ipAddress);if (multicastTimeToLive <= 0){diff --git a/Emby.Server.Implementations/Net/UdpSocket.cs b/Emby.Server.Implementations/Net/UdpSocket.csindex 2c20daa57f..c3994fc040 100644--- a/Emby.Server.Implementations/Net/UdpSocket.cs+++ b/Emby.Server.Implementations/Net/UdpSocket.cs@@ -35,10 +35,7 @@ namespace Emby.Server.Implementations.Netpublic UdpSocket(Socket socket, int localPort, IPAddress ip){- if (socket == null)- {- throw new ArgumentNullException(nameof(socket));- }+ ArgumentNullException.ThrowIfNull(socket);_socket = socket;_localPort = localPort;@@ -51,10 +48,7 @@ namespace Emby.Server.Implementations.Netpublic UdpSocket(Socket socket, IPEndPoint endPoint){- if (socket == null)- {- throw new ArgumentNullException(nameof(socket));- }+ ArgumentNullException.ThrowIfNull(socket);_socket = socket;_socket.Connect(endPoint);diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.csindex 45ef36441d..ec4e0dbeb9 100644--- a/Emby.Server.Implementations/Plugins/PluginManager.cs+++ b/Emby.Server.Implementations/Plugins/PluginManager.cs@@ -234,10 +234,7 @@ namespace Emby.Server.Implementations.Plugins/// <returns>Outcome of the operation.</returns>public bool RemovePlugin(LocalPlugin plugin){- if (plugin == null)- {- throw new ArgumentNullException(nameof(plugin));- }+ ArgumentNullException.ThrowIfNull(plugin);if (DeletePlugin(plugin)){@@ -288,10 +285,7 @@ namespace Emby.Server.Implementations.Plugins/// <param name="plugin">The <see cref="LocalPlugin"/> of the plug to disable.</param>public void EnablePlugin(LocalPlugin plugin){- if (plugin == null)- {- throw new ArgumentNullException(nameof(plugin));- }+ ArgumentNullException.ThrowIfNull(plugin);if (ChangePluginState(plugin, PluginStatus.Active)){@@ -306,10 +300,7 @@ namespace Emby.Server.Implementations.Plugins/// <param name="plugin">The <see cref="LocalPlugin"/> of the plug to disable.</param>public void DisablePlugin(LocalPlugin plugin){- if (plugin == null)- {- throw new ArgumentNullException(nameof(plugin));- }+ ArgumentNullException.ThrowIfNull(plugin);// Update the manifest on diskif (ChangePluginState(plugin, PluginStatus.Disabled))@@ -326,10 +317,7 @@ namespace Emby.Server.Implementations.Pluginspublic void FailPlugin(Assembly assembly){// Only save if disabled.- if (assembly == null)- {- throw new ArgumentNullException(nameof(assembly));- }+ ArgumentNullException.ThrowIfNull(assembly);var plugin = _plugins.FirstOrDefault(p => p.DllFiles.Contains(assembly.Location));if (plugin == null)diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.csindex 2c4d6884d2..b370e06efa 100644--- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs+++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs@@ -92,25 +92,13 @@ namespace Emby.Server.Implementations.ScheduledTasks/// </exception>public ScheduledTaskWorker(IScheduledTask scheduledTask, IApplicationPaths applicationPaths, ITaskManager taskManager, ILogger logger){- if (scheduledTask == null)- {- throw new ArgumentNullException(nameof(scheduledTask));- }+ ArgumentNullException.ThrowIfNull(scheduledTask);- if (applicationPaths == null)- {- throw new ArgumentNullException(nameof(applicationPaths));- }+ ArgumentNullException.ThrowIfNull(applicationPaths);- if (taskManager == null)- {- throw new ArgumentNullException(nameof(taskManager));- }+ ArgumentNullException.ThrowIfNull(taskManager);- if (logger == null)- {- throw new ArgumentNullException(nameof(logger));- }+ ArgumentNullException.ThrowIfNull(logger);ScheduledTask = scheduledTask;_applicationPaths = applicationPaths;@@ -249,10 +237,7 @@ namespace Emby.Server.Implementations.ScheduledTasksget => _triggers;set{- if (value == null)- {- throw new ArgumentNullException(nameof(value));- }+ ArgumentNullException.ThrowIfNull(value);// Cleanup current triggersif (_triggers != null)@@ -281,10 +266,7 @@ namespace Emby.Server.Implementations.ScheduledTasksset{- if (value == null)- {- throw new ArgumentNullException(nameof(value));- }+ ArgumentNullException.ThrowIfNull(value);// This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectlyvar triggerList = value.Where(i => i != null).ToArray();diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.csindex 7f927e2709..0d1029882b 100644--- a/Emby.Server.Implementations/Session/SessionManager.cs+++ b/Emby.Server.Implementations/Session/SessionManager.cs@@ -665,10 +665,7 @@ namespace Emby.Server.Implementations.Session{CheckDisposed();- if (info == null)- {- throw new ArgumentNullException(nameof(info));- }+ ArgumentNullException.ThrowIfNull(info);var session = GetSession(info.SessionId);@@ -762,10 +759,7 @@ namespace Emby.Server.Implementations.Session{CheckDisposed();- if (info == null)- {- throw new ArgumentNullException(nameof(info));- }+ ArgumentNullException.ThrowIfNull(info);var session = GetSession(info.SessionId);@@ -897,10 +891,7 @@ namespace Emby.Server.Implementations.Session{CheckDisposed();- if (info == null)- {- throw new ArgumentNullException(nameof(info));- }+ ArgumentNullException.ThrowIfNull(info);if (info.PositionTicks.HasValue && info.PositionTicks.Value < 0){@@ -1341,15 +1332,9 @@ namespace Emby.Server.Implementations.Sessionprivate static void AssertCanControl(SessionInfo session, SessionInfo controllingSession){- if (session == null)- {- throw new ArgumentNullException(nameof(session));- }+ ArgumentNullException.ThrowIfNull(session);- if (controllingSession == null)- {- throw new ArgumentNullException(nameof(controllingSession));- }+ ArgumentNullException.ThrowIfNull(controllingSession);}/// <summary>@@ -1688,10 +1673,7 @@ namespace Emby.Server.Implementations.Session/// </summary>private BaseItemDto GetItemInfo(BaseItem item, MediaSourceInfo mediaSource){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);var dtoOptions = _itemInfoDtoOptions;@@ -1802,10 +1784,7 @@ namespace Emby.Server.Implementations.Session/// <inheritdoc />public Task<SessionInfo> GetSessionByAuthenticationToken(Device info, string deviceId, string remoteEndpoint, string appVersion){- if (info == null)- {- throw new ArgumentNullException(nameof(info));- }+ ArgumentNullException.ThrowIfNull(info);var user = info.UserId.Equals(default)? nulldiff --git a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.csindex db8b689491..2d21bd9c2a 100644--- a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs+++ b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs@@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting/// <returns>System.Int32.</returns>public int Compare(BaseItem? x, BaseItem? y){- if (x == null)- {- throw new ArgumentNullException(nameof(x));- }+ ArgumentNullException.ThrowIfNull(x);- if (y == null)- {- throw new ArgumentNullException(nameof(y));- }+ ArgumentNullException.ThrowIfNull(y);var episode1 = x as Episode;var episode2 = y as Episode;diff --git a/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs b/Emby.Server.Implementations/Sorting/CommunityRatingComparer.csindex 5f142fa4bb..5cb11ab465 100644--- a/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs+++ b/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs@@ -23,15 +23,9 @@ namespace Emby.Server.Implementations.Sorting/// <returns>System.Int32.</returns>public int Compare(BaseItem? x, BaseItem? y){- if (x == null)- {- throw new ArgumentNullException(nameof(x));- }+ ArgumentNullException.ThrowIfNull(x);- if (y == null)- {- throw new ArgumentNullException(nameof(y));- }+ ArgumentNullException.ThrowIfNull(y);return (x.CommunityRating ?? 0).CompareTo(y.CommunityRating ?? 0);}diff --git a/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs b/Emby.Server.Implementations/Sorting/DateCreatedComparer.csindex 8b460166ca..6133aaccc6 100644--- a/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs+++ b/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs@@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting/// <returns>System.Int32.</returns>public int Compare(BaseItem? x, BaseItem? y){- if (x == null)- {- throw new ArgumentNullException(nameof(x));- }+ ArgumentNullException.ThrowIfNull(x);- if (y == null)- {- throw new ArgumentNullException(nameof(y));- }+ ArgumentNullException.ThrowIfNull(y);return DateTime.Compare(x.DateCreated, y.DateCreated);}diff --git a/Emby.Server.Implementations/Sorting/IndexNumberComparer.cs b/Emby.Server.Implementations/Sorting/IndexNumberComparer.csindex c5b00afb15..1bcaccd8a3 100644--- a/Emby.Server.Implementations/Sorting/IndexNumberComparer.cs+++ b/Emby.Server.Implementations/Sorting/IndexNumberComparer.cs@@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting/// <returns>System.Int32.</returns>public int Compare(BaseItem? x, BaseItem? y){- if (x == null)- {- throw new ArgumentNullException(nameof(x));- }+ ArgumentNullException.ThrowIfNull(x);- if (y == null)- {- throw new ArgumentNullException(nameof(y));- }+ ArgumentNullException.ThrowIfNull(y);if (!x.IndexNumber.HasValue && !y.IndexNumber.HasValue){diff --git a/Emby.Server.Implementations/Sorting/NameComparer.cs b/Emby.Server.Implementations/Sorting/NameComparer.csindex c2875eeb97..93bec4db99 100644--- a/Emby.Server.Implementations/Sorting/NameComparer.cs+++ b/Emby.Server.Implementations/Sorting/NameComparer.cs@@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting/// <returns>System.Int32.</returns>public int Compare(BaseItem? x, BaseItem? y){- if (x == null)- {- throw new ArgumentNullException(nameof(x));- }+ ArgumentNullException.ThrowIfNull(x);- if (y == null)- {- throw new ArgumentNullException(nameof(y));- }+ ArgumentNullException.ThrowIfNull(y);return string.Compare(x.Name, y.Name, StringComparison.OrdinalIgnoreCase);}diff --git a/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs b/Emby.Server.Implementations/Sorting/OfficialRatingComparer.csindex a81f78ebfc..ce44f99a69 100644--- a/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs+++ b/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs@@ -31,15 +31,9 @@ namespace Emby.Server.Implementations.Sorting/// <returns>System.Int32.</returns>public int Compare(BaseItem? x, BaseItem? y){- if (x == null)- {- throw new ArgumentNullException(nameof(x));- }-- if (y == null)- {- throw new ArgumentNullException(nameof(y));- }+ ArgumentNullException.ThrowIfNull(x);++ ArgumentNullException.ThrowIfNull(y);var levelX = string.IsNullOrEmpty(x.OfficialRating) ? 0 : _localization.GetRatingLevel(x.OfficialRating) ?? 0;var levelY = string.IsNullOrEmpty(y.OfficialRating) ? 0 : _localization.GetRatingLevel(y.OfficialRating) ?? 0;diff --git a/Emby.Server.Implementations/Sorting/ParentIndexNumberComparer.cs b/Emby.Server.Implementations/Sorting/ParentIndexNumberComparer.csindex 8c408bb4d2..c54750843e 100644--- a/Emby.Server.Implementations/Sorting/ParentIndexNumberComparer.cs+++ b/Emby.Server.Implementations/Sorting/ParentIndexNumberComparer.cs@@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting/// <returns>System.Int32.</returns>public int Compare(BaseItem? x, BaseItem? y){- if (x == null)- {- throw new ArgumentNullException(nameof(x));- }+ ArgumentNullException.ThrowIfNull(x);- if (y == null)- {- throw new ArgumentNullException(nameof(y));- }+ ArgumentNullException.ThrowIfNull(y);if (!x.ParentIndexNumber.HasValue && !y.ParentIndexNumber.HasValue){diff --git a/Emby.Server.Implementations/Sorting/RuntimeComparer.cs b/Emby.Server.Implementations/Sorting/RuntimeComparer.csindex e32e5552e4..646bafbb54 100644--- a/Emby.Server.Implementations/Sorting/RuntimeComparer.cs+++ b/Emby.Server.Implementations/Sorting/RuntimeComparer.cs@@ -26,15 +26,9 @@ namespace Emby.Server.Implementations.Sorting/// <returns>System.Int32.</returns>public int Compare(BaseItem x, BaseItem y){- if (x == null)- {- throw new ArgumentNullException(nameof(x));- }+ ArgumentNullException.ThrowIfNull(x);- if (y == null)- {- throw new ArgumentNullException(nameof(y));- }+ ArgumentNullException.ThrowIfNull(y);return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0);}diff --git a/Emby.Server.Implementations/Sorting/SortNameComparer.cs b/Emby.Server.Implementations/Sorting/SortNameComparer.csindex 79be9a89a4..628b9b3dda 100644--- a/Emby.Server.Implementations/Sorting/SortNameComparer.cs+++ b/Emby.Server.Implementations/Sorting/SortNameComparer.cs@@ -26,15 +26,9 @@ namespace Emby.Server.Implementations.Sorting/// <returns>System.Int32.</returns>public int Compare(BaseItem x, BaseItem y){- if (x == null)- {- throw new ArgumentNullException(nameof(x));- }+ ArgumentNullException.ThrowIfNull(x);- if (y == null)- {- throw new ArgumentNullException(nameof(y));- }+ ArgumentNullException.ThrowIfNull(y);return string.Compare(x.SortName, y.SortName, StringComparison.OrdinalIgnoreCase);}diff --git a/Emby.Server.Implementations/Sorting/StudioComparer.cs b/Emby.Server.Implementations/Sorting/StudioComparer.csindex c917daaad1..457c062714 100644--- a/Emby.Server.Implementations/Sorting/StudioComparer.cs+++ b/Emby.Server.Implementations/Sorting/StudioComparer.cs@@ -26,15 +26,9 @@ namespace Emby.Server.Implementations.Sorting/// <returns>System.Int32.</returns>public int Compare(BaseItem x, BaseItem y){- if (x == null)- {- throw new ArgumentNullException(nameof(x));- }+ ArgumentNullException.ThrowIfNull(x);- if (y == null)- {- throw new ArgumentNullException(nameof(y));- }+ ArgumentNullException.ThrowIfNull(y);return AlphanumericComparator.CompareValues(x.Studios.FirstOrDefault(), y.Studios.FirstOrDefault());}diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.csindex 40c386e823..550f0e0755 100644--- a/Emby.Server.Implementations/Updates/InstallationManager.cs+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs@@ -294,10 +294,7 @@ namespace Emby.Server.Implementations.Updates/// <inheritdoc />public async Task InstallPackage(InstallationInfo package, CancellationToken cancellationToken){- if (package == null)- {- throw new ArgumentNullException(nameof(package));- }+ ArgumentNullException.ThrowIfNull(package);var innerCancellationTokenSource = new CancellationTokenSource();diff --git a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs b/Jellyfin.Drawing.Skia/StripCollageBuilder.csindex 6bece9db6e..b55a994056 100644--- a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs+++ b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs@@ -29,10 +29,7 @@ namespace Jellyfin.Drawing.Skia/// <returns>The image format.</returns>public static SKEncodedImageFormat GetEncodedFormat(string outputPath){- if (outputPath == null)- {- throw new ArgumentNullException(nameof(outputPath));- }+ ArgumentNullException.ThrowIfNull(outputPath);var ext = Path.GetExtension(outputPath);diff --git a/Jellyfin.Networking/Manager/NetworkManager.cs b/Jellyfin.Networking/Manager/NetworkManager.csindex fd0665dbdd..9e06cdfe71 100644--- a/Jellyfin.Networking/Manager/NetworkManager.cs+++ b/Jellyfin.Networking/Manager/NetworkManager.cs@@ -353,10 +353,7 @@ namespace Jellyfin.Networking.Managerpublic string GetBindInterface(IPObject source, out int? port){port = null;- if (source == null)- {- throw new ArgumentNullException(nameof(source));- }+ ArgumentNullException.ThrowIfNull(source);// Do we have a source?bool haveSource = !source.Address.Equals(IPAddress.None);@@ -476,10 +473,7 @@ namespace Jellyfin.Networking.Manager/// <inheritdoc/>public bool IsInLocalNetwork(IPAddress address){- if (address == null)- {- throw new ArgumentNullException(nameof(address));- }+ ArgumentNullException.ThrowIfNull(address);if (address.Equals(IPAddress.None)){@@ -499,10 +493,7 @@ namespace Jellyfin.Networking.Manager/// <inheritdoc/>public bool IsPrivateAddressRange(IPObject address){- if (address == null)- {- throw new ArgumentNullException(nameof(address));- }+ ArgumentNullException.ThrowIfNull(address);// See conversation at https://github.com/jellyfin/jellyfin/pull/3515.if (TrustAllIP6Interfaces && address.AddressFamily == AddressFamily.InterNetworkV6)diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.csindex 3203bed183..0728f11799 100644--- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs+++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs@@ -201,10 +201,7 @@ namespace Jellyfin.Server.Implementations.Devices/// <inheritdoc />public bool CanAccessDevice(User user, string deviceId){- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }+ ArgumentNullException.ThrowIfNull(user);if (string.IsNullOrEmpty(deviceId)){diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.csindex 6a2ef74dd2..ed90e81c6f 100644--- a/Jellyfin.Server.Implementations/Users/UserManager.cs+++ b/Jellyfin.Server.Implementations/Users/UserManager.cs@@ -130,10 +130,7 @@ namespace Jellyfin.Server.Implementations.Users/// <inheritdoc/>public async Task RenameUser(User user, string newName){- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }+ ArgumentNullException.ThrowIfNull(user);ThrowIfInvalidUsername(newName);@@ -267,10 +264,7 @@ namespace Jellyfin.Server.Implementations.Users/// <inheritdoc/>public async Task ChangePassword(User user, string newPassword){- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }+ ArgumentNullException.ThrowIfNull(user);await GetAuthenticationProvider(user).ChangePassword(user, newPassword).ConfigureAwait(false);await UpdateUserAsync(user).ConfigureAwait(false);diff --git a/MediaBrowser.Common/Net/IPNetAddress.cs b/MediaBrowser.Common/Net/IPNetAddress.csindex f1428d4bef..98d1c2d97b 100644--- a/MediaBrowser.Common/Net/IPNetAddress.cs+++ b/MediaBrowser.Common/Net/IPNetAddress.cs@@ -160,10 +160,7 @@ namespace MediaBrowser.Common.Net/// <inheritdoc/>public override bool Contains(IPAddress address){- if (address == null)- {- throw new ArgumentNullException(nameof(address));- }+ ArgumentNullException.ThrowIfNull(address);if (address.IsIPv4MappedToIPv6){diff --git a/MediaBrowser.Common/Net/IPObject.cs b/MediaBrowser.Common/Net/IPObject.csindex 3a5187bc3d..37385972f7 100644--- a/MediaBrowser.Common/Net/IPObject.cs+++ b/MediaBrowser.Common/Net/IPObject.cs@@ -55,10 +55,7 @@ namespace MediaBrowser.Common.Net/// <returns>IPAddress.</returns>public static (IPAddress Address, byte PrefixLength) NetworkAddressOf(IPAddress address, byte prefixLength){- if (address == null)- {- throw new ArgumentNullException(nameof(address));- }+ ArgumentNullException.ThrowIfNull(address);if (address.IsIPv4MappedToIPv6){@@ -109,10 +106,7 @@ namespace MediaBrowser.Common.Net/// <returns>True if it is.</returns>public static bool IsIP6(IPAddress address){- if (address == null)- {- throw new ArgumentNullException(nameof(address));- }+ ArgumentNullException.ThrowIfNull(address);if (address.IsIPv4MappedToIPv6){@@ -129,10 +123,7 @@ namespace MediaBrowser.Common.Net/// <returns>True if it contains a private address.</returns>public static bool IsPrivateAddressRange(IPAddress address){- if (address == null)- {- throw new ArgumentNullException(nameof(address));- }+ ArgumentNullException.ThrowIfNull(address);if (!address.Equals(IPAddress.None)){@@ -179,10 +170,7 @@ namespace MediaBrowser.Common.Net/// </remarks>public static bool IsIPv6LinkLocal(IPAddress address){- if (address == null)- {- throw new ArgumentNullException(nameof(address));- }+ ArgumentNullException.ThrowIfNull(address);if (address.IsIPv4MappedToIPv6){@@ -226,10 +214,7 @@ namespace MediaBrowser.Common.Net/// <returns>Byte CIDR representing the mask.</returns>public static byte MaskToCidr(IPAddress mask){- if (mask == null)- {- throw new ArgumentNullException(nameof(mask));- }+ ArgumentNullException.ThrowIfNull(mask);byte cidrnet = 0;if (!mask.Equals(IPAddress.Any))diff --git a/MediaBrowser.Common/Net/NetworkExtensions.cs b/MediaBrowser.Common/Net/NetworkExtensions.csindex 264bfacb49..7ad0058540 100644--- a/MediaBrowser.Common/Net/NetworkExtensions.cs+++ b/MediaBrowser.Common/Net/NetworkExtensions.cs@@ -61,10 +61,7 @@ namespace MediaBrowser.Common.Netreturn false;}- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);if (item.IsIPv4MappedToIPv6){@@ -96,10 +93,7 @@ namespace MediaBrowser.Common.Netreturn false;}- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);foreach (var i in source){@@ -153,10 +147,7 @@ namespace MediaBrowser.Common.Net/// <returns>Collection{IPObject} object containing the subnets.</returns>public static Collection<IPObject> AsNetworks(this Collection<IPObject> source){- if (source == null)- {- throw new ArgumentNullException(nameof(source));- }+ ArgumentNullException.ThrowIfNull(source);Collection<IPObject> res = new Collection<IPObject>();@@ -239,10 +230,7 @@ namespace MediaBrowser.Common.Netreturn new Collection<IPObject>();}- if (target == null)- {- throw new ArgumentNullException(nameof(target));- }+ ArgumentNullException.ThrowIfNull(target);Collection<IPObject> nc = new Collection<IPObject>();diff --git a/MediaBrowser.Common/Plugins/BasePluginOfT.cs b/MediaBrowser.Common/Plugins/BasePluginOfT.csindex afda83a7c5..0da5592d38 100644--- a/MediaBrowser.Common/Plugins/BasePluginOfT.cs+++ b/MediaBrowser.Common/Plugins/BasePluginOfT.cs@@ -164,10 +164,7 @@ namespace MediaBrowser.Common.Plugins/// <inheritdoc />public virtual void UpdateConfiguration(BasePluginConfiguration configuration){- if (configuration == null)- {- throw new ArgumentNullException(nameof(configuration));- }+ ArgumentNullException.ThrowIfNull(configuration);Configuration = (TConfigurationType)configuration;diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.csindex 77a857b785..e671e5c711 100644--- a/MediaBrowser.Controller/Entities/AggregateFolder.cs+++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs@@ -171,10 +171,7 @@ namespace MediaBrowser.Controller.Entities/// <exception cref="ArgumentNullException">Throws if child is null.</exception>public void AddVirtualChild(BaseItem child){- if (child == null)- {- throw new ArgumentNullException(nameof(child));- }+ ArgumentNullException.ThrowIfNull(child);_virtualChildren.Add(child);}diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.csindex 9461b01e31..41fce67fa7 100644--- a/MediaBrowser.Controller/Entities/BaseItem.cs+++ b/MediaBrowser.Controller/Entities/BaseItem.cs@@ -1101,10 +1101,7 @@ namespace MediaBrowser.Controller.Entitiesprivate MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, BaseItem item, MediaSourceType type){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);var protocol = item.PathProtocol;@@ -1544,10 +1541,7 @@ namespace MediaBrowser.Controller.Entities/// <exception cref="ArgumentNullException">If user is null.</exception>public bool IsParentalAllowed(User user){- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }+ ArgumentNullException.ThrowIfNull(user);if (!IsVisibleViaTags(user)){@@ -1667,10 +1661,7 @@ namespace MediaBrowser.Controller.Entities/// <exception cref="ArgumentNullException"><paramref name="user" /> is <c>null</c>.</exception>public virtual bool IsVisible(User user){- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }+ ArgumentNullException.ThrowIfNull(user);return IsParentalAllowed(user);}@@ -1842,10 +1833,7 @@ namespace MediaBrowser.Controller.EntitiesDateTime? datePlayed,bool resetPosition){- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }+ ArgumentNullException.ThrowIfNull(user);var data = UserDataManager.GetUserData(user, this);@@ -1876,10 +1864,7 @@ namespace MediaBrowser.Controller.Entities/// <exception cref="ArgumentNullException">Throws if user is null.</exception>public virtual void MarkUnplayed(User user){- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }+ ArgumentNullException.ThrowIfNull(user);var data = UserDataManager.GetUserData(user, this);@@ -2110,10 +2095,7 @@ namespace MediaBrowser.Controller.Entities/// <returns>Image index.</returns>public int GetImageIndex(ItemImageInfo image){- if (image == null)- {- throw new ArgumentNullException(nameof(image));- }+ ArgumentNullException.ThrowIfNull(image);if (image.Type == ImageType.Chapter){@@ -2320,10 +2302,7 @@ namespace MediaBrowser.Controller.Entitiespublic virtual bool IsUnplayed(User user){- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }+ ArgumentNullException.ThrowIfNull(user);var userdata = UserDataManager.GetUserData(user, this);diff --git a/MediaBrowser.Controller/Entities/BaseItemExtensions.cs b/MediaBrowser.Controller/Entities/BaseItemExtensions.csindex e0583e6308..948eb43754 100644--- a/MediaBrowser.Controller/Entities/BaseItemExtensions.cs+++ b/MediaBrowser.Controller/Entities/BaseItemExtensions.cs@@ -71,15 +71,9 @@ namespace MediaBrowser.Controller.Entitieswhere T : BaseItemwhere TU : BaseItem{- if (source == null)- {- throw new ArgumentNullException(nameof(source));- }+ ArgumentNullException.ThrowIfNull(source);- if (dest == null)- {- throw new ArgumentNullException(nameof(dest));- }+ ArgumentNullException.ThrowIfNull(dest);var destProps = typeof(TU).GetProperties().Where(x => x.CanWrite).ToList();diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.csindex 92d12a86ca..808f918104 100644--- a/MediaBrowser.Controller/Entities/Folder.cs+++ b/MediaBrowser.Controller/Entities/Folder.cs@@ -1023,10 +1023,7 @@ namespace MediaBrowser.Controller.EntitiesIServerConfigurationManager configurationManager,ICollectionManager collectionManager){- if (items == null)- {- throw new ArgumentNullException(nameof(items));- }+ ArgumentNullException.ThrowIfNull(items);if (CollapseBoxSetItems(query, queryParent, user, configurationManager)){@@ -1273,20 +1270,14 @@ namespace MediaBrowser.Controller.Entitiespublic List<BaseItem> GetChildren(User user, bool includeLinkedChildren){- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }+ ArgumentNullException.ThrowIfNull(user);return GetChildren(user, includeLinkedChildren, null);}public virtual List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query){- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }+ ArgumentNullException.ThrowIfNull(user);// the true root should return our users root folder childrenif (IsPhysicalRoot)@@ -1367,10 +1358,7 @@ namespace MediaBrowser.Controller.Entitiespublic virtual IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query){- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }+ ArgumentNullException.ThrowIfNull(user);var result = new Dictionary<Guid, BaseItem>();diff --git a/MediaBrowser.Controller/Entities/PeopleHelper.cs b/MediaBrowser.Controller/Entities/PeopleHelper.csindex 687ce1ec8d..8571bfcea5 100644--- a/MediaBrowser.Controller/Entities/PeopleHelper.cs+++ b/MediaBrowser.Controller/Entities/PeopleHelper.cs@@ -11,10 +11,7 @@ namespace MediaBrowser.Controller.Entities{public static void AddPerson(List<PersonInfo> people, PersonInfo person){- if (person == null)- {- throw new ArgumentNullException(nameof(person));- }+ ArgumentNullException.ThrowIfNull(person);if (string.IsNullOrEmpty(person.Name)){diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.csindex 2429ac42db..71feae536c 100644--- a/MediaBrowser.Controller/IO/FileData.cs+++ b/MediaBrowser.Controller/IO/FileData.cs@@ -40,10 +40,7 @@ namespace MediaBrowser.Controller.IOthrow new ArgumentNullException(nameof(path));}- if (args == null)- {- throw new ArgumentNullException(nameof(args));- }+ ArgumentNullException.ThrowIfNull(args);var entries = directoryService.GetFileSystemEntries(path);diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.csindex 42c5517f9d..d0362b128c 100644--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs@@ -5105,15 +5105,9 @@ namespace MediaBrowser.Controller.MediaEncodingMediaSourceInfo mediaSource,string requestedUrl){- if (state == null)- {- throw new ArgumentNullException(nameof(state));- }+ ArgumentNullException.ThrowIfNull(state);- if (mediaSource == null)- {- throw new ArgumentNullException(nameof(mediaSource));- }+ ArgumentNullException.ThrowIfNull(mediaSource);var path = mediaSource.Path;var protocol = mediaSource.Protocol;diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.csindex eadc09fd4b..647de50030 100644--- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs+++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs@@ -38,10 +38,7 @@ namespace MediaBrowser.Controller.Netprotected BasePeriodicWebSocketListener(ILogger<BasePeriodicWebSocketListener<TReturnDataType, TStateType>> logger){- if (logger == null)- {- throw new ArgumentNullException(nameof(logger));- }+ ArgumentNullException.ThrowIfNull(logger);Logger = logger;}@@ -77,10 +74,7 @@ namespace MediaBrowser.Controller.Net/// <returns>Task.</returns>public Task ProcessMessageAsync(WebSocketMessageInfo message){- if (message == null)- {- throw new ArgumentNullException(nameof(message));- }+ ArgumentNullException.ThrowIfNull(message);if (message.MessageType == StartType){diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.csindex 777fe67746..a9e1b4a51e 100644--- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs+++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs@@ -53,10 +53,7 @@ namespace MediaBrowser.LocalMetadata.Parsers/// <exception cref="ArgumentNullException">Item is null.</exception>public void Fetch(MetadataResult<T> item, string metadataFile, CancellationToken cancellationToken){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);if (string.IsNullOrEmpty(metadataFile)){diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.csindex 142571e8f6..22abf93ac3 100644--- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs+++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs@@ -52,10 +52,7 @@ namespace MediaBrowser.MediaEncoding.Attachments/// <inheritdoc />public async Task<(MediaAttachment Attachment, Stream Stream)> GetAttachment(BaseItem item, string mediaSourceId, int attachmentStreamIndex, CancellationToken cancellationToken){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);if (string.IsNullOrWhiteSpace(mediaSourceId)){diff --git a/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs b/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.csindex a9e753726d..205e84153b 100644--- a/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs+++ b/MediaBrowser.MediaEncoding/Probing/FFProbeHelpers.cs@@ -15,10 +15,7 @@ namespace MediaBrowser.MediaEncoding.Probing/// <param name="result">The result.</param>public static void NormalizeFFProbeResult(InternalMediaInfoResult result){- if (result == null)- {- throw new ArgumentNullException(nameof(result));- }+ ArgumentNullException.ThrowIfNull(result);if (result.Format?.Tags != null){diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.csindex 115f085ff8..9185faf67b 100644--- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs+++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs@@ -120,10 +120,7 @@ namespace MediaBrowser.MediaEncoding.Subtitlesasync Task<Stream> ISubtitleEncoder.GetSubtitles(BaseItem item, string mediaSourceId, int subtitleStreamIndex, string outputFormat, long startTimeTicks, long endTimeTicks, bool preserveOriginalTimestamps, CancellationToken cancellationToken){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);if (string.IsNullOrWhiteSpace(mediaSourceId)){diff --git a/MediaBrowser.Model/Cryptography/PasswordHash.cs b/MediaBrowser.Model/Cryptography/PasswordHash.csindex eec5410411..32a34d23c1 100644--- a/MediaBrowser.Model/Cryptography/PasswordHash.cs+++ b/MediaBrowser.Model/Cryptography/PasswordHash.cs@@ -29,10 +29,7 @@ namespace MediaBrowser.Model.Cryptographypublic PasswordHash(string id, byte[] hash, byte[] salt, Dictionary<string, string> parameters){- if (id == null)- {- throw new ArgumentNullException(nameof(id));- }+ ArgumentNullException.ThrowIfNull(id);if (id.Length == 0){diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.csindex fdb9fd5d54..b121a29058 100644--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs@@ -565,10 +565,7 @@ namespace MediaBrowser.Model.Dlnaprivate StreamInfo BuildVideoItem(MediaSourceInfo item, VideoOptions options){- if (item == null)- {- throw new ArgumentNullException(nameof(item));- }+ ArgumentNullException.ThrowIfNull(item);StreamInfo playlistItem = new StreamInfo{diff --git a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs b/MediaBrowser.Model/Entities/ProviderIdsExtensions.csindex 62a2f3ce84..d3b8400f34 100644--- a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs+++ b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs@@ -28,10 +28,7 @@ namespace MediaBrowser.Model.Entities/// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns>public static bool HasProviderId(this IHasProviderIds instance, string name){- if (instance == null)- {- throw new ArgumentNullException(nameof(instance));- }+ ArgumentNullException.ThrowIfNull(instance);return instance.TryGetProviderId(name, out _);}@@ -56,10 +53,7 @@ namespace MediaBrowser.Model.Entities/// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns>public static bool TryGetProviderId(this IHasProviderIds instance, string name, [NotNullWhen(true)] out string? id){- if (instance == null)- {- throw new ArgumentNullException(nameof(instance));- }+ ArgumentNullException.ThrowIfNull(instance);if (instance.ProviderIds == null){@@ -121,10 +115,7 @@ namespace MediaBrowser.Model.Entities/// <param name="value">The value.</param>public static void SetProviderId(this IHasProviderIds instance, string name, string? value){- if (instance == null)- {- throw new ArgumentNullException(nameof(instance));- }+ ArgumentNullException.ThrowIfNull(instance);// If it's null remove the key from the dictionaryif (string.IsNullOrEmpty(value))diff --git a/src/Jellyfin.Extensions/EnumerableExtensions.cs b/src/Jellyfin.Extensions/EnumerableExtensions.csindex b5fe933571..a31a57dc65 100644--- a/src/Jellyfin.Extensions/EnumerableExtensions.cs+++ b/src/Jellyfin.Extensions/EnumerableExtensions.cs@@ -18,10 +18,7 @@ namespace Jellyfin.Extensions/// <exception cref="ArgumentNullException">The source is null.</exception>public static bool Contains(this IEnumerable<string> source, ReadOnlySpan<char> value, StringComparison stringComparison){- if (source == null)- {- throw new ArgumentNullException(nameof(source));- }+ ArgumentNullException.ThrowIfNull(source);if (source is IList<string> list){diff --git a/tests/Jellyfin.Networking.Tests/NetworkParseTests.cs b/tests/Jellyfin.Networking.Tests/NetworkParseTests.csindex 52b0e5a955..166bc0513a 100644--- a/tests/Jellyfin.Networking.Tests/NetworkParseTests.cs+++ b/tests/Jellyfin.Networking.Tests/NetworkParseTests.cs@@ -103,10 +103,7 @@ namespace Jellyfin.Networking.Tests"[192.158.0.0/16,192.0.0.0/8]")]public void TestCollections(string settings, string result1, string result2, string result3, string result4, string result5){- if (settings == null)- {- throw new ArgumentNullException(nameof(settings));- }+ ArgumentNullException.ThrowIfNull(settings);var conf = new NetworkConfiguration(){@@ -155,20 +152,11 @@ namespace Jellyfin.Networking.Tests[InlineData("127.0.0.1", "127.0.0.1/8", "[127.0.0.1/32]")]public void UnionCheck(string settings, string compare, string result){- if (settings == null)- {- throw new ArgumentNullException(nameof(settings));- }+ ArgumentNullException.ThrowIfNull(settings);- if (compare == null)- {- throw new ArgumentNullException(nameof(compare));- }+ ArgumentNullException.ThrowIfNull(compare);- if (result == null)- {- throw new ArgumentNullException(nameof(result));- }+ ArgumentNullException.ThrowIfNull(result);var conf = new NetworkConfiguration(){@@ -264,20 +252,11 @@ namespace Jellyfin.Networking.Testspublic void TestCollectionEquality(string source, string dest, string result){- if (source == null)- {- throw new ArgumentNullException(nameof(source));- }+ ArgumentNullException.ThrowIfNull(source);- if (dest == null)- {- throw new ArgumentNullException(nameof(dest));- }+ ArgumentNullException.ThrowIfNull(dest);- if (result == null)- {- throw new ArgumentNullException(nameof(result));- }+ ArgumentNullException.ThrowIfNull(result);var conf = new NetworkConfiguration(){@@ -331,20 +310,11 @@ namespace Jellyfin.Networking.Tests[InlineData("", "", false, "eth16")]public void TestBindInterfaces(string source, string bindAddresses, bool ipv6enabled, string result){- if (source == null)- {- throw new ArgumentNullException(nameof(source));- }+ ArgumentNullException.ThrowIfNull(source);- if (bindAddresses == null)- {- throw new ArgumentNullException(nameof(bindAddresses));- }+ ArgumentNullException.ThrowIfNull(bindAddresses);- if (result == null)- {- throw new ArgumentNullException(nameof(result));- }+ ArgumentNullException.ThrowIfNull(result);var conf = new NetworkConfiguration(){@@ -403,15 +373,9 @@ namespace Jellyfin.Networking.Tests[InlineData("192.168.1.1", "192.168.1.0/24", "", false, "eth16=http://helloworld.com", "http://helloworld.com")]public void TestBindInterfaceOverrides(string source, string lan, string bindAddresses, bool ipv6enabled, string publishedServers, string result){- if (lan == null)- {- throw new ArgumentNullException(nameof(lan));- }+ ArgumentNullException.ThrowIfNull(lan);- if (bindAddresses == null)- {- throw new ArgumentNullException(nameof(bindAddresses));- }+ ArgumentNullException.ThrowIfNull(bindAddresses);var conf = new NetworkConfiguration(){