Merge pull request #8503 from Bond-009/ThrowIfNull

This commit is contained in:
Claus Vium 2022-10-07 07:50:39 +02:00 committed by GitHub
commit 719e5eae16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 160 additions and 622 deletions

View File

@ -103,10 +103,7 @@ namespace Emby.Dlna.ContentDirectory
/// <inheritdoc /> /// <inheritdoc />
public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request) public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request)
{ {
if (request == null) ArgumentNullException.ThrowIfNull(request);
{
throw new ArgumentNullException(nameof(request));
}
var profile = _dlna.GetProfile(request.Headers) ?? _dlna.GetDefaultProfile(); var profile = _dlna.GetProfile(request.Headers) ?? _dlna.GetDefaultProfile();

View File

@ -114,15 +114,9 @@ namespace Emby.Dlna.ContentDirectory
/// <inheritdoc /> /// <inheritdoc />
protected override void WriteResult(string methodName, IReadOnlyDictionary<string, string> methodParams, XmlWriter xmlWriter) protected override void WriteResult(string methodName, IReadOnlyDictionary<string, string> methodParams, XmlWriter xmlWriter)
{ {
if (xmlWriter == null) ArgumentNullException.ThrowIfNull(xmlWriter);
{
throw new ArgumentNullException(nameof(xmlWriter));
}
if (methodParams == null) ArgumentNullException.ThrowIfNull(methodParams);
{
throw new ArgumentNullException(nameof(methodParams));
}
const string DeviceId = "test"; const string DeviceId = "test";

View File

@ -100,10 +100,7 @@ namespace Emby.Dlna
/// <inheritdoc /> /// <inheritdoc />
public DeviceProfile? GetProfile(DeviceIdentification deviceInfo) public DeviceProfile? GetProfile(DeviceIdentification deviceInfo)
{ {
if (deviceInfo == null) ArgumentNullException.ThrowIfNull(deviceInfo);
{
throw new ArgumentNullException(nameof(deviceInfo));
}
var profile = GetProfiles() var profile = GetProfiles()
.FirstOrDefault(i => i.Identification != null && IsMatch(deviceInfo, i.Identification)); .FirstOrDefault(i => i.Identification != null && IsMatch(deviceInfo, i.Identification));
@ -170,10 +167,7 @@ namespace Emby.Dlna
/// <inheritdoc /> /// <inheritdoc />
public DeviceProfile? GetProfile(IHeaderDictionary headers) public DeviceProfile? GetProfile(IHeaderDictionary headers)
{ {
if (headers == null) ArgumentNullException.ThrowIfNull(headers);
{
throw new ArgumentNullException(nameof(headers));
}
var profile = GetProfiles().FirstOrDefault(i => i.Identification != null && IsMatch(headers, i.Identification)); var profile = GetProfiles().FirstOrDefault(i => i.Identification != null && IsMatch(headers, i.Identification));
if (profile == null) if (profile == null)

View File

@ -931,10 +931,7 @@ namespace Emby.Dlna.PlayTo
private static UBaseObject CreateUBaseObject(XElement container, string trackUri) private static UBaseObject CreateUBaseObject(XElement container, string trackUri)
{ {
if (container == null) ArgumentNullException.ThrowIfNull(container);
{
throw new ArgumentNullException(nameof(container));
}
var url = container.GetValue(UPnpNamespaces.Res); var url = container.GetValue(UPnpNamespaces.Res);
@ -958,10 +955,7 @@ namespace Emby.Dlna.PlayTo
private static string[] GetProtocolInfo(XElement container) private static string[] GetProtocolInfo(XElement container)
{ {
if (container == null) ArgumentNullException.ThrowIfNull(container);
{
throw new ArgumentNullException(nameof(container));
}
var resElement = container.Element(UPnpNamespaces.Res); var resElement = container.Element(UPnpNamespaces.Res);
@ -1183,10 +1177,7 @@ namespace Emby.Dlna.PlayTo
#nullable enable #nullable enable
private static DeviceIcon CreateIcon(XElement element) private static DeviceIcon CreateIcon(XElement element)
{ {
if (element == null) ArgumentNullException.ThrowIfNull(element);
{
throw new ArgumentNullException(nameof(element));
}
var width = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("width")); var width = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("width"));
var height = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("height")); var height = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("height"));

View File

@ -61,10 +61,7 @@ namespace Emby.Dlna.PlayTo
private static Argument ArgumentFromXml(XElement container) private static Argument ArgumentFromXml(XElement container)
{ {
if (container == null) ArgumentNullException.ThrowIfNull(container);
{
throw new ArgumentNullException(nameof(container));
}
return new Argument return new Argument
{ {

View File

@ -10,10 +10,7 @@ namespace Emby.Dlna.PlayTo
{ {
public static UBaseObject Create(XElement container) public static UBaseObject Create(XElement container)
{ {
if (container == null) ArgumentNullException.ThrowIfNull(container);
{
throw new ArgumentNullException(nameof(container));
}
return new UBaseObject return new UBaseObject
{ {

View File

@ -54,10 +54,7 @@ namespace Emby.Dlna.PlayTo
public bool Equals(UBaseObject obj) public bool Equals(UBaseObject obj)
{ {
if (obj == null) ArgumentNullException.ThrowIfNull(obj);
{
throw new ArgumentNullException(nameof(obj));
}
return string.Equals(Id, obj.Id, StringComparison.Ordinal); return string.Equals(Id, obj.Id, StringComparison.Ordinal);
} }

View File

@ -210,10 +210,7 @@ namespace Emby.Server.Implementations.AppBase
/// <exception cref="ArgumentNullException"><c>newConfiguration</c> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><c>newConfiguration</c> is <c>null</c>.</exception>
public virtual void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration) public virtual void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration)
{ {
if (newConfiguration == null) ArgumentNullException.ThrowIfNull(newConfiguration);
{
throw new ArgumentNullException(nameof(newConfiguration));
}
ValidateCachePath(newConfiguration); ValidateCachePath(newConfiguration);

View File

@ -1188,10 +1188,7 @@ namespace Emby.Server.Implementations.Channels
internal IChannel GetChannelProvider(Channel channel) internal IChannel GetChannelProvider(Channel channel)
{ {
if (channel == null) ArgumentNullException.ThrowIfNull(channel);
{
throw new ArgumentNullException(nameof(channel));
}
var result = GetAllChannels() var result = GetAllChannels()
.FirstOrDefault(i => GetInternalChannelId(i.Name).Equals(channel.ChannelId) || string.Equals(i.Name, channel.Name, StringComparison.OrdinalIgnoreCase)); .FirstOrDefault(i => GetInternalChannelId(i.Name).Equals(channel.ChannelId) || string.Equals(i.Name, channel.Name, StringComparison.OrdinalIgnoreCase));

View File

@ -54,10 +54,7 @@ namespace Emby.Server.Implementations.Data
public static void RunQueries(this SQLiteDatabaseConnection connection, string[] queries) public static void RunQueries(this SQLiteDatabaseConnection connection, string[] queries)
{ {
if (queries == null) ArgumentNullException.ThrowIfNull(queries);
{
throw new ArgumentNullException(nameof(queries));
}
connection.RunInTransaction(conn => connection.RunInTransaction(conn =>
{ {

View File

@ -583,10 +583,7 @@ namespace Emby.Server.Implementations.Data
public void SaveImages(BaseItem item) public void SaveImages(BaseItem item)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
CheckDisposed(); CheckDisposed();
@ -617,10 +614,7 @@ namespace Emby.Server.Implementations.Data
/// </exception> /// </exception>
public void SaveItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken) public void SaveItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken)
{ {
if (items == null) ArgumentNullException.ThrowIfNull(items);
{
throw new ArgumentNullException(nameof(items));
}
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -2085,10 +2079,7 @@ namespace Emby.Server.Implementations.Data
throw new ArgumentNullException(nameof(id)); throw new ArgumentNullException(nameof(id));
} }
if (chapters == null) ArgumentNullException.ThrowIfNull(chapters);
{
throw new ArgumentNullException(nameof(chapters));
}
var idBlob = id.ToByteArray(); var idBlob = id.ToByteArray();
@ -2557,10 +2548,7 @@ namespace Emby.Server.Implementations.Data
public int GetCount(InternalItemsQuery query) public int GetCount(InternalItemsQuery query)
{ {
if (query == null) ArgumentNullException.ThrowIfNull(query);
{
throw new ArgumentNullException(nameof(query));
}
CheckDisposed(); CheckDisposed();
@ -2613,10 +2601,7 @@ namespace Emby.Server.Implementations.Data
public List<BaseItem> GetItemList(InternalItemsQuery query) public List<BaseItem> GetItemList(InternalItemsQuery query)
{ {
if (query == null) ArgumentNullException.ThrowIfNull(query);
{
throw new ArgumentNullException(nameof(query));
}
CheckDisposed(); CheckDisposed();
@ -2794,10 +2779,7 @@ namespace Emby.Server.Implementations.Data
public QueryResult<BaseItem> GetItems(InternalItemsQuery query) public QueryResult<BaseItem> GetItems(InternalItemsQuery query)
{ {
if (query == null) ArgumentNullException.ThrowIfNull(query);
{
throw new ArgumentNullException(nameof(query));
}
CheckDisposed(); CheckDisposed();
@ -3174,10 +3156,7 @@ namespace Emby.Server.Implementations.Data
public List<Guid> GetItemIdsList(InternalItemsQuery query) public List<Guid> GetItemIdsList(InternalItemsQuery query)
{ {
if (query == null) ArgumentNullException.ThrowIfNull(query);
{
throw new ArgumentNullException(nameof(query));
}
CheckDisposed(); CheckDisposed();
@ -4837,10 +4816,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
public List<string> GetPeopleNames(InternalPeopleQuery query) public List<string> GetPeopleNames(InternalPeopleQuery query)
{ {
if (query == null) ArgumentNullException.ThrowIfNull(query);
{
throw new ArgumentNullException(nameof(query));
}
CheckDisposed(); CheckDisposed();
@ -4880,10 +4856,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
public List<PersonInfo> GetPeople(InternalPeopleQuery query) public List<PersonInfo> GetPeople(InternalPeopleQuery query)
{ {
if (query == null) ArgumentNullException.ThrowIfNull(query);
{
throw new ArgumentNullException(nameof(query));
}
CheckDisposed(); CheckDisposed();
@ -4999,10 +4972,7 @@ AND Type = @InternalPersonType)");
throw new ArgumentNullException(nameof(itemId)); throw new ArgumentNullException(nameof(itemId));
} }
if (ancestorIds == null) ArgumentNullException.ThrowIfNull(ancestorIds);
{
throw new ArgumentNullException(nameof(ancestorIds));
}
CheckDisposed(); CheckDisposed();
@ -5175,10 +5145,7 @@ AND Type = @InternalPersonType)");
private QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetItemValues(InternalItemsQuery query, int[] itemValueTypes, string returnType) private QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetItemValues(InternalItemsQuery query, int[] itemValueTypes, string returnType)
{ {
if (query == null) ArgumentNullException.ThrowIfNull(query);
{
throw new ArgumentNullException(nameof(query));
}
if (!query.Limit.HasValue) if (!query.Limit.HasValue)
{ {
@ -5531,10 +5498,7 @@ AND Type = @InternalPersonType)");
throw new ArgumentNullException(nameof(itemId)); throw new ArgumentNullException(nameof(itemId));
} }
if (values == null) ArgumentNullException.ThrowIfNull(values);
{
throw new ArgumentNullException(nameof(values));
}
CheckDisposed(); CheckDisposed();
@ -5607,10 +5571,7 @@ AND Type = @InternalPersonType)");
throw new ArgumentNullException(nameof(itemId)); throw new ArgumentNullException(nameof(itemId));
} }
if (people == null) ArgumentNullException.ThrowIfNull(people);
{
throw new ArgumentNullException(nameof(people));
}
CheckDisposed(); CheckDisposed();
@ -5710,10 +5671,7 @@ AND Type = @InternalPersonType)");
{ {
CheckDisposed(); CheckDisposed();
if (query == null) ArgumentNullException.ThrowIfNull(query);
{
throw new ArgumentNullException(nameof(query));
}
var cmdText = _mediaStreamSaveColumnsSelectQuery; var cmdText = _mediaStreamSaveColumnsSelectQuery;
@ -5766,10 +5724,7 @@ AND Type = @InternalPersonType)");
throw new ArgumentNullException(nameof(id)); throw new ArgumentNullException(nameof(id));
} }
if (streams == null) ArgumentNullException.ThrowIfNull(streams);
{
throw new ArgumentNullException(nameof(streams));
}
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -6107,10 +6062,7 @@ AND Type = @InternalPersonType)");
{ {
CheckDisposed(); CheckDisposed();
if (query == null) ArgumentNullException.ThrowIfNull(query);
{
throw new ArgumentNullException(nameof(query));
}
var cmdText = _mediaAttachmentSaveColumnsSelectQuery; var cmdText = _mediaAttachmentSaveColumnsSelectQuery;
@ -6152,10 +6104,7 @@ AND Type = @InternalPersonType)");
throw new ArgumentException("Guid can't be empty.", nameof(id)); throw new ArgumentException("Guid can't be empty.", nameof(id));
} }
if (attachments == null) ArgumentNullException.ThrowIfNull(attachments);
{
throw new ArgumentNullException(nameof(attachments));
}
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();

View File

@ -133,10 +133,7 @@ namespace Emby.Server.Implementations.Data
/// <inheritdoc /> /// <inheritdoc />
public void SaveUserData(long userId, string key, UserItemData userData, CancellationToken cancellationToken) public void SaveUserData(long userId, string key, UserItemData userData, CancellationToken cancellationToken)
{ {
if (userData == null) ArgumentNullException.ThrowIfNull(userData);
{
throw new ArgumentNullException(nameof(userData));
}
if (userId <= 0) if (userId <= 0)
{ {
@ -154,10 +151,7 @@ namespace Emby.Server.Implementations.Data
/// <inheritdoc /> /// <inheritdoc />
public void SaveAllUserData(long userId, UserItemData[] userData, CancellationToken cancellationToken) public void SaveAllUserData(long userId, UserItemData[] userData, CancellationToken cancellationToken)
{ {
if (userData == null) ArgumentNullException.ThrowIfNull(userData);
{
throw new ArgumentNullException(nameof(userData));
}
if (userId <= 0) if (userId <= 0)
{ {
@ -304,10 +298,7 @@ namespace Emby.Server.Implementations.Data
public UserItemData GetUserData(long userId, List<string> keys) public UserItemData GetUserData(long userId, List<string> keys)
{ {
if (keys == null) ArgumentNullException.ThrowIfNull(keys);
{
throw new ArgumentNullException(nameof(keys));
}
if (keys.Count == 0) if (keys.Count == 0)
{ {

View File

@ -281,10 +281,7 @@ namespace Emby.Server.Implementations.Library
public void RegisterItem(BaseItem item) public void RegisterItem(BaseItem item)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
if (item is IItemByName) if (item is IItemByName)
{ {
@ -311,10 +308,7 @@ namespace Emby.Server.Implementations.Library
public void DeleteItem(BaseItem item, DeleteOptions options, bool notifyParentItem) public void DeleteItem(BaseItem item, DeleteOptions options, bool notifyParentItem)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
var parent = item.GetOwner() ?? item.GetParent(); var parent = item.GetOwner() ?? item.GetParent();
@ -323,10 +317,7 @@ namespace Emby.Server.Implementations.Library
public void DeleteItem(BaseItem item, DeleteOptions options, BaseItem parent, bool notifyParentItem) public void DeleteItem(BaseItem item, DeleteOptions options, BaseItem parent, bool notifyParentItem)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
if (item.SourceType == SourceType.Channel) if (item.SourceType == SourceType.Channel)
{ {
@ -509,10 +500,7 @@ namespace Emby.Server.Implementations.Library
throw new ArgumentNullException(nameof(key)); throw new ArgumentNullException(nameof(key));
} }
if (type == null) ArgumentNullException.ThrowIfNull(type);
{
throw new ArgumentNullException(nameof(type));
}
string programDataPath = _configurationManager.ApplicationPaths.ProgramDataPath; string programDataPath = _configurationManager.ApplicationPaths.ProgramDataPath;
if (key.StartsWith(programDataPath, StringComparison.Ordinal)) if (key.StartsWith(programDataPath, StringComparison.Ordinal))
@ -544,10 +532,7 @@ namespace Emby.Server.Implementations.Library
string collectionType = null, string collectionType = null,
LibraryOptions libraryOptions = null) LibraryOptions libraryOptions = null)
{ {
if (fileInfo == null) ArgumentNullException.ThrowIfNull(fileInfo);
{
throw new ArgumentNullException(nameof(fileInfo));
}
var fullPath = fileInfo.FullName; var fullPath = fileInfo.FullName;
@ -1854,10 +1839,7 @@ namespace Emby.Server.Implementations.Library
/// <inheritdoc /> /// <inheritdoc />
public async Task UpdateImagesAsync(BaseItem item, bool forceUpdate = false) public async Task UpdateImagesAsync(BaseItem item, bool forceUpdate = false)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
var outdated = forceUpdate var outdated = forceUpdate
? item.ImageInfos.Where(i => i.Path != null).ToArray() ? item.ImageInfos.Where(i => i.Path != null).ToArray()
@ -2296,10 +2278,7 @@ namespace Emby.Server.Implementations.Library
string viewType, string viewType,
string sortName) string sortName)
{ {
if (parent == null) ArgumentNullException.ThrowIfNull(parent);
{
throw new ArgumentNullException(nameof(parent));
}
var name = parent.Name; var name = parent.Name;
var parentId = parent.Id; var parentId = parent.Id;
@ -2983,10 +2962,7 @@ namespace Emby.Server.Implementations.Library
private void AddMediaPathInternal(string virtualFolderName, MediaPathInfo pathInfo, bool saveLibraryOptions) private void AddMediaPathInternal(string virtualFolderName, MediaPathInfo pathInfo, bool saveLibraryOptions)
{ {
if (pathInfo == null) ArgumentNullException.ThrowIfNull(pathInfo);
{
throw new ArgumentNullException(nameof(pathInfo));
}
var path = pathInfo.Path; var path = pathInfo.Path;
@ -3033,10 +3009,7 @@ namespace Emby.Server.Implementations.Library
public void UpdateMediaPath(string virtualFolderName, MediaPathInfo mediaPath) public void UpdateMediaPath(string virtualFolderName, MediaPathInfo mediaPath)
{ {
if (mediaPath == null) ArgumentNullException.ThrowIfNull(mediaPath);
{
throw new ArgumentNullException(nameof(mediaPath));
}
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath; var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName); var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);

View File

@ -322,10 +322,7 @@ namespace Emby.Server.Implementations.Library
public List<MediaSourceInfo> GetStaticMediaSources(BaseItem item, bool enablePathSubstitution, User user = null) public List<MediaSourceInfo> GetStaticMediaSources(BaseItem item, bool enablePathSubstitution, User user = null)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
var hasMediaSources = (IHasMediaSources)item; var hasMediaSources = (IHasMediaSources)item;

View File

@ -91,10 +91,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
internal static bool IsImageFile(string path, IImageProcessor imageProcessor) internal static bool IsImageFile(string path, IImageProcessor imageProcessor)
{ {
if (path == null) ArgumentNullException.ThrowIfNull(path);
{
throw new ArgumentNullException(nameof(path));
}
var filename = Path.GetFileNameWithoutExtension(path); var filename = Path.GetFileNameWithoutExtension(path);

View File

@ -53,15 +53,9 @@ namespace Emby.Server.Implementations.Library
public void SaveUserData(User user, BaseItem item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken) public void SaveUserData(User user, BaseItem item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken)
{ {
if (userData == null) ArgumentNullException.ThrowIfNull(userData);
{
throw new ArgumentNullException(nameof(userData));
}
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -194,10 +188,7 @@ namespace Emby.Server.Implementations.Library
/// <exception cref="ArgumentNullException"><paramref name="data"/> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="data"/> is <c>null</c>.</exception>
private UserItemDataDto GetUserItemDataDto(UserItemData data) private UserItemDataDto GetUserItemDataDto(UserItemData data)
{ {
if (data == null) ArgumentNullException.ThrowIfNull(data);
{
throw new ArgumentNullException(nameof(data));
}
return new UserItemDataDto return new UserItemDataDto
{ {

View File

@ -1223,10 +1223,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private async Task RecordStream(TimerInfo timer, DateTime recordingEndDate, ActiveRecordingInfo activeRecordingInfo) private async Task RecordStream(TimerInfo timer, DateTime recordingEndDate, ActiveRecordingInfo activeRecordingInfo)
{ {
if (timer == null) ArgumentNullException.ThrowIfNull(timer);
{
throw new ArgumentNullException(nameof(timer));
}
LiveTvProgram programInfo = null; LiveTvProgram programInfo = null;
@ -2347,10 +2344,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private IEnumerable<TimerInfo> GetTimersForSeries(SeriesTimerInfo seriesTimer) private IEnumerable<TimerInfo> GetTimersForSeries(SeriesTimerInfo seriesTimer)
{ {
if (seriesTimer == null) ArgumentNullException.ThrowIfNull(seriesTimer);
{
throw new ArgumentNullException(nameof(seriesTimer));
}
var query = new InternalItemsQuery var query = new InternalItemsQuery
{ {

View File

@ -84,10 +84,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public virtual void Update(T item) public virtual void Update(T item)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
lock (_fileDataLock) lock (_fileDataLock)
{ {
@ -107,10 +104,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public virtual void Add(T item) public virtual void Add(T item)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
lock (_fileDataLock) lock (_fileDataLock)
{ {

View File

@ -44,10 +44,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
public async Task<Stream> GetListingsStream(TunerHostInfo info, CancellationToken cancellationToken) public async Task<Stream> GetListingsStream(TunerHostInfo info, CancellationToken cancellationToken)
{ {
if (info == null) ArgumentNullException.ThrowIfNull(info);
{
throw new ArgumentNullException(nameof(info));
}
if (!info.Url.StartsWith("http", StringComparison.OrdinalIgnoreCase)) if (!info.Url.StartsWith("http", StringComparison.OrdinalIgnoreCase))
{ {

View File

@ -63,10 +63,7 @@ namespace Emby.Server.Implementations.Net
/// <inheritdoc /> /// <inheritdoc />
public ISocket CreateUdpMulticastSocket(IPAddress ipAddress, int multicastTimeToLive, int localPort) public ISocket CreateUdpMulticastSocket(IPAddress ipAddress, int multicastTimeToLive, int localPort)
{ {
if (ipAddress == null) ArgumentNullException.ThrowIfNull(ipAddress);
{
throw new ArgumentNullException(nameof(ipAddress));
}
if (multicastTimeToLive <= 0) if (multicastTimeToLive <= 0)
{ {

View File

@ -35,10 +35,7 @@ namespace Emby.Server.Implementations.Net
public UdpSocket(Socket socket, int localPort, IPAddress ip) public UdpSocket(Socket socket, int localPort, IPAddress ip)
{ {
if (socket == null) ArgumentNullException.ThrowIfNull(socket);
{
throw new ArgumentNullException(nameof(socket));
}
_socket = socket; _socket = socket;
_localPort = localPort; _localPort = localPort;
@ -51,10 +48,7 @@ namespace Emby.Server.Implementations.Net
public UdpSocket(Socket socket, IPEndPoint endPoint) public UdpSocket(Socket socket, IPEndPoint endPoint)
{ {
if (socket == null) ArgumentNullException.ThrowIfNull(socket);
{
throw new ArgumentNullException(nameof(socket));
}
_socket = socket; _socket = socket;
_socket.Connect(endPoint); _socket.Connect(endPoint);

View File

@ -234,10 +234,7 @@ namespace Emby.Server.Implementations.Plugins
/// <returns>Outcome of the operation.</returns> /// <returns>Outcome of the operation.</returns>
public bool RemovePlugin(LocalPlugin plugin) public bool RemovePlugin(LocalPlugin plugin)
{ {
if (plugin == null) ArgumentNullException.ThrowIfNull(plugin);
{
throw new ArgumentNullException(nameof(plugin));
}
if (DeletePlugin(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> /// <param name="plugin">The <see cref="LocalPlugin"/> of the plug to disable.</param>
public void EnablePlugin(LocalPlugin plugin) public void EnablePlugin(LocalPlugin plugin)
{ {
if (plugin == null) ArgumentNullException.ThrowIfNull(plugin);
{
throw new ArgumentNullException(nameof(plugin));
}
if (ChangePluginState(plugin, PluginStatus.Active)) 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> /// <param name="plugin">The <see cref="LocalPlugin"/> of the plug to disable.</param>
public void DisablePlugin(LocalPlugin plugin) public void DisablePlugin(LocalPlugin plugin)
{ {
if (plugin == null) ArgumentNullException.ThrowIfNull(plugin);
{
throw new ArgumentNullException(nameof(plugin));
}
// Update the manifest on disk // Update the manifest on disk
if (ChangePluginState(plugin, PluginStatus.Disabled)) if (ChangePluginState(plugin, PluginStatus.Disabled))
@ -326,10 +317,7 @@ namespace Emby.Server.Implementations.Plugins
public void FailPlugin(Assembly assembly) public void FailPlugin(Assembly assembly)
{ {
// Only save if disabled. // Only save if disabled.
if (assembly == null) ArgumentNullException.ThrowIfNull(assembly);
{
throw new ArgumentNullException(nameof(assembly));
}
var plugin = _plugins.FirstOrDefault(p => p.DllFiles.Contains(assembly.Location)); var plugin = _plugins.FirstOrDefault(p => p.DllFiles.Contains(assembly.Location));
if (plugin == null) if (plugin == null)

View File

@ -92,25 +92,13 @@ namespace Emby.Server.Implementations.ScheduledTasks
/// </exception> /// </exception>
public ScheduledTaskWorker(IScheduledTask scheduledTask, IApplicationPaths applicationPaths, ITaskManager taskManager, ILogger logger) public ScheduledTaskWorker(IScheduledTask scheduledTask, IApplicationPaths applicationPaths, ITaskManager taskManager, ILogger logger)
{ {
if (scheduledTask == null) ArgumentNullException.ThrowIfNull(scheduledTask);
{
throw new ArgumentNullException(nameof(scheduledTask));
}
if (applicationPaths == null) ArgumentNullException.ThrowIfNull(applicationPaths);
{
throw new ArgumentNullException(nameof(applicationPaths));
}
if (taskManager == null) ArgumentNullException.ThrowIfNull(taskManager);
{
throw new ArgumentNullException(nameof(taskManager));
}
if (logger == null) ArgumentNullException.ThrowIfNull(logger);
{
throw new ArgumentNullException(nameof(logger));
}
ScheduledTask = scheduledTask; ScheduledTask = scheduledTask;
_applicationPaths = applicationPaths; _applicationPaths = applicationPaths;
@ -249,10 +237,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
get => _triggers; get => _triggers;
set set
{ {
if (value == null) ArgumentNullException.ThrowIfNull(value);
{
throw new ArgumentNullException(nameof(value));
}
// Cleanup current triggers // Cleanup current triggers
if (_triggers != null) if (_triggers != null)
@ -281,10 +266,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
set set
{ {
if (value == null) ArgumentNullException.ThrowIfNull(value);
{
throw new ArgumentNullException(nameof(value));
}
// This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly // This null check is not great, but is needed to handle bad user input, or user mucking with the config file incorrectly
var triggerList = value.Where(i => i != null).ToArray(); var triggerList = value.Where(i => i != null).ToArray();

View File

@ -665,10 +665,7 @@ namespace Emby.Server.Implementations.Session
{ {
CheckDisposed(); CheckDisposed();
if (info == null) ArgumentNullException.ThrowIfNull(info);
{
throw new ArgumentNullException(nameof(info));
}
var session = GetSession(info.SessionId); var session = GetSession(info.SessionId);
@ -762,10 +759,7 @@ namespace Emby.Server.Implementations.Session
{ {
CheckDisposed(); CheckDisposed();
if (info == null) ArgumentNullException.ThrowIfNull(info);
{
throw new ArgumentNullException(nameof(info));
}
var session = GetSession(info.SessionId); var session = GetSession(info.SessionId);
@ -897,10 +891,7 @@ namespace Emby.Server.Implementations.Session
{ {
CheckDisposed(); CheckDisposed();
if (info == null) ArgumentNullException.ThrowIfNull(info);
{
throw new ArgumentNullException(nameof(info));
}
if (info.PositionTicks.HasValue && info.PositionTicks.Value < 0) if (info.PositionTicks.HasValue && info.PositionTicks.Value < 0)
{ {
@ -1341,15 +1332,9 @@ namespace Emby.Server.Implementations.Session
private static void AssertCanControl(SessionInfo session, SessionInfo controllingSession) private static void AssertCanControl(SessionInfo session, SessionInfo controllingSession)
{ {
if (session == null) ArgumentNullException.ThrowIfNull(session);
{
throw new ArgumentNullException(nameof(session));
}
if (controllingSession == null) ArgumentNullException.ThrowIfNull(controllingSession);
{
throw new ArgumentNullException(nameof(controllingSession));
}
} }
/// <summary> /// <summary>
@ -1688,10 +1673,7 @@ namespace Emby.Server.Implementations.Session
/// </summary> /// </summary>
private BaseItemDto GetItemInfo(BaseItem item, MediaSourceInfo mediaSource) private BaseItemDto GetItemInfo(BaseItem item, MediaSourceInfo mediaSource)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
var dtoOptions = _itemInfoDtoOptions; var dtoOptions = _itemInfoDtoOptions;
@ -1802,10 +1784,7 @@ namespace Emby.Server.Implementations.Session
/// <inheritdoc /> /// <inheritdoc />
public Task<SessionInfo> GetSessionByAuthenticationToken(Device info, string deviceId, string remoteEndpoint, string appVersion) public Task<SessionInfo> GetSessionByAuthenticationToken(Device info, string deviceId, string remoteEndpoint, string appVersion)
{ {
if (info == null) ArgumentNullException.ThrowIfNull(info);
{
throw new ArgumentNullException(nameof(info));
}
var user = info.UserId.Equals(default) var user = info.UserId.Equals(default)
? null ? null

View File

@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem? x, BaseItem? y) public int Compare(BaseItem? x, BaseItem? y)
{ {
if (x == null) ArgumentNullException.ThrowIfNull(x);
{
throw new ArgumentNullException(nameof(x));
}
if (y == null) ArgumentNullException.ThrowIfNull(y);
{
throw new ArgumentNullException(nameof(y));
}
var episode1 = x as Episode; var episode1 = x as Episode;
var episode2 = y as Episode; var episode2 = y as Episode;

View File

@ -23,15 +23,9 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem? x, BaseItem? y) public int Compare(BaseItem? x, BaseItem? y)
{ {
if (x == null) ArgumentNullException.ThrowIfNull(x);
{
throw new ArgumentNullException(nameof(x));
}
if (y == null) ArgumentNullException.ThrowIfNull(y);
{
throw new ArgumentNullException(nameof(y));
}
return (x.CommunityRating ?? 0).CompareTo(y.CommunityRating ?? 0); return (x.CommunityRating ?? 0).CompareTo(y.CommunityRating ?? 0);
} }

View File

@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem? x, BaseItem? y) public int Compare(BaseItem? x, BaseItem? y)
{ {
if (x == null) ArgumentNullException.ThrowIfNull(x);
{
throw new ArgumentNullException(nameof(x));
}
if (y == null) ArgumentNullException.ThrowIfNull(y);
{
throw new ArgumentNullException(nameof(y));
}
return DateTime.Compare(x.DateCreated, y.DateCreated); return DateTime.Compare(x.DateCreated, y.DateCreated);
} }

View File

@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem? x, BaseItem? y) public int Compare(BaseItem? x, BaseItem? y)
{ {
if (x == null) ArgumentNullException.ThrowIfNull(x);
{
throw new ArgumentNullException(nameof(x));
}
if (y == null) ArgumentNullException.ThrowIfNull(y);
{
throw new ArgumentNullException(nameof(y));
}
if (!x.IndexNumber.HasValue && !y.IndexNumber.HasValue) if (!x.IndexNumber.HasValue && !y.IndexNumber.HasValue)
{ {

View File

@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem? x, BaseItem? y) public int Compare(BaseItem? x, BaseItem? y)
{ {
if (x == null) ArgumentNullException.ThrowIfNull(x);
{
throw new ArgumentNullException(nameof(x));
}
if (y == null) ArgumentNullException.ThrowIfNull(y);
{
throw new ArgumentNullException(nameof(y));
}
return string.Compare(x.Name, y.Name, StringComparison.OrdinalIgnoreCase); return string.Compare(x.Name, y.Name, StringComparison.OrdinalIgnoreCase);
} }

View File

@ -31,15 +31,9 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem? x, BaseItem? y) public int Compare(BaseItem? x, BaseItem? y)
{ {
if (x == null) ArgumentNullException.ThrowIfNull(x);
{
throw new ArgumentNullException(nameof(x));
}
if (y == null) ArgumentNullException.ThrowIfNull(y);
{
throw new ArgumentNullException(nameof(y));
}
var levelX = string.IsNullOrEmpty(x.OfficialRating) ? 0 : _localization.GetRatingLevel(x.OfficialRating) ?? 0; var levelX = string.IsNullOrEmpty(x.OfficialRating) ? 0 : _localization.GetRatingLevel(x.OfficialRating) ?? 0;
var levelY = string.IsNullOrEmpty(y.OfficialRating) ? 0 : _localization.GetRatingLevel(y.OfficialRating) ?? 0; var levelY = string.IsNullOrEmpty(y.OfficialRating) ? 0 : _localization.GetRatingLevel(y.OfficialRating) ?? 0;

View File

@ -24,15 +24,9 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem? x, BaseItem? y) public int Compare(BaseItem? x, BaseItem? y)
{ {
if (x == null) ArgumentNullException.ThrowIfNull(x);
{
throw new ArgumentNullException(nameof(x));
}
if (y == null) ArgumentNullException.ThrowIfNull(y);
{
throw new ArgumentNullException(nameof(y));
}
if (!x.ParentIndexNumber.HasValue && !y.ParentIndexNumber.HasValue) if (!x.ParentIndexNumber.HasValue && !y.ParentIndexNumber.HasValue)
{ {

View File

@ -26,15 +26,9 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y) public int Compare(BaseItem x, BaseItem y)
{ {
if (x == null) ArgumentNullException.ThrowIfNull(x);
{
throw new ArgumentNullException(nameof(x));
}
if (y == null) ArgumentNullException.ThrowIfNull(y);
{
throw new ArgumentNullException(nameof(y));
}
return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0); return (x.RunTimeTicks ?? 0).CompareTo(y.RunTimeTicks ?? 0);
} }

View File

@ -26,15 +26,9 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y) public int Compare(BaseItem x, BaseItem y)
{ {
if (x == null) ArgumentNullException.ThrowIfNull(x);
{
throw new ArgumentNullException(nameof(x));
}
if (y == null) ArgumentNullException.ThrowIfNull(y);
{
throw new ArgumentNullException(nameof(y));
}
return string.Compare(x.SortName, y.SortName, StringComparison.OrdinalIgnoreCase); return string.Compare(x.SortName, y.SortName, StringComparison.OrdinalIgnoreCase);
} }

View File

@ -26,15 +26,9 @@ namespace Emby.Server.Implementations.Sorting
/// <returns>System.Int32.</returns> /// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y) public int Compare(BaseItem x, BaseItem y)
{ {
if (x == null) ArgumentNullException.ThrowIfNull(x);
{
throw new ArgumentNullException(nameof(x));
}
if (y == null) ArgumentNullException.ThrowIfNull(y);
{
throw new ArgumentNullException(nameof(y));
}
return AlphanumericComparator.CompareValues(x.Studios.FirstOrDefault(), y.Studios.FirstOrDefault()); return AlphanumericComparator.CompareValues(x.Studios.FirstOrDefault(), y.Studios.FirstOrDefault());
} }

View File

@ -294,10 +294,7 @@ namespace Emby.Server.Implementations.Updates
/// <inheritdoc /> /// <inheritdoc />
public async Task InstallPackage(InstallationInfo package, CancellationToken cancellationToken) public async Task InstallPackage(InstallationInfo package, CancellationToken cancellationToken)
{ {
if (package == null) ArgumentNullException.ThrowIfNull(package);
{
throw new ArgumentNullException(nameof(package));
}
var innerCancellationTokenSource = new CancellationTokenSource(); var innerCancellationTokenSource = new CancellationTokenSource();

View File

@ -25,6 +25,6 @@ namespace Jellyfin.Api.Attributes
/// <param name="template">The route template. May not be null.</param> /// <param name="template">The route template. May not be null.</param>
public HttpSubscribeAttribute(string template) public HttpSubscribeAttribute(string template)
: base(_supportedMethods, template) : base(_supportedMethods, template)
=> ArgumentNullException.ThrowIfNull(template, nameof(template)); => ArgumentNullException.ThrowIfNull(template);
} }
} }

View File

@ -25,6 +25,6 @@ namespace Jellyfin.Api.Attributes
/// <param name="template">The route template. May not be null.</param> /// <param name="template">The route template. May not be null.</param>
public HttpUnsubscribeAttribute(string template) public HttpUnsubscribeAttribute(string template)
: base(_supportedMethods, template) : base(_supportedMethods, template)
=> ArgumentNullException.ThrowIfNull(template, nameof(template)); => ArgumentNullException.ThrowIfNull(template);
} }
} }

View File

@ -145,7 +145,7 @@ namespace Jellyfin.Drawing.Skia
/// <exception cref="SkiaCodecException">The file at the specified path could not be used to generate a codec.</exception> /// <exception cref="SkiaCodecException">The file at the specified path could not be used to generate a codec.</exception>
public string GetImageBlurHash(int xComp, int yComp, string path) public string GetImageBlurHash(int xComp, int yComp, string path)
{ {
ArgumentNullException.ThrowIfNull(path, nameof(path)); ArgumentNullException.ThrowIfNull(path);
if (path.Length == 0) if (path.Length == 0)
{ {

View File

@ -29,10 +29,7 @@ namespace Jellyfin.Drawing.Skia
/// <returns>The image format.</returns> /// <returns>The image format.</returns>
public static SKEncodedImageFormat GetEncodedFormat(string outputPath) public static SKEncodedImageFormat GetEncodedFormat(string outputPath)
{ {
if (outputPath == null) ArgumentNullException.ThrowIfNull(outputPath);
{
throw new ArgumentNullException(nameof(outputPath));
}
var ext = Path.GetExtension(outputPath); var ext = Path.GetExtension(outputPath);

View File

@ -353,10 +353,7 @@ namespace Jellyfin.Networking.Manager
public string GetBindInterface(IPObject source, out int? port) public string GetBindInterface(IPObject source, out int? port)
{ {
port = null; port = null;
if (source == null) ArgumentNullException.ThrowIfNull(source);
{
throw new ArgumentNullException(nameof(source));
}
// Do we have a source? // Do we have a source?
bool haveSource = !source.Address.Equals(IPAddress.None); bool haveSource = !source.Address.Equals(IPAddress.None);
@ -476,10 +473,7 @@ namespace Jellyfin.Networking.Manager
/// <inheritdoc/> /// <inheritdoc/>
public bool IsInLocalNetwork(IPAddress address) public bool IsInLocalNetwork(IPAddress address)
{ {
if (address == null) ArgumentNullException.ThrowIfNull(address);
{
throw new ArgumentNullException(nameof(address));
}
if (address.Equals(IPAddress.None)) if (address.Equals(IPAddress.None))
{ {
@ -499,10 +493,7 @@ namespace Jellyfin.Networking.Manager
/// <inheritdoc/> /// <inheritdoc/>
public bool IsPrivateAddressRange(IPObject address) public bool IsPrivateAddressRange(IPObject address)
{ {
if (address == null) ArgumentNullException.ThrowIfNull(address);
{
throw new ArgumentNullException(nameof(address));
}
// See conversation at https://github.com/jellyfin/jellyfin/pull/3515. // See conversation at https://github.com/jellyfin/jellyfin/pull/3515.
if (TrustAllIP6Interfaces && address.AddressFamily == AddressFamily.InterNetworkV6) if (TrustAllIP6Interfaces && address.AddressFamily == AddressFamily.InterNetworkV6)

View File

@ -201,10 +201,7 @@ namespace Jellyfin.Server.Implementations.Devices
/// <inheritdoc /> /// <inheritdoc />
public bool CanAccessDevice(User user, string deviceId) public bool CanAccessDevice(User user, string deviceId)
{ {
if (user == null) ArgumentNullException.ThrowIfNull(user);
{
throw new ArgumentNullException(nameof(user));
}
if (string.IsNullOrEmpty(deviceId)) if (string.IsNullOrEmpty(deviceId))
{ {

View File

@ -130,10 +130,7 @@ namespace Jellyfin.Server.Implementations.Users
/// <inheritdoc/> /// <inheritdoc/>
public async Task RenameUser(User user, string newName) public async Task RenameUser(User user, string newName)
{ {
if (user == null) ArgumentNullException.ThrowIfNull(user);
{
throw new ArgumentNullException(nameof(user));
}
ThrowIfInvalidUsername(newName); ThrowIfInvalidUsername(newName);
@ -267,10 +264,7 @@ namespace Jellyfin.Server.Implementations.Users
/// <inheritdoc/> /// <inheritdoc/>
public async Task ChangePassword(User user, string newPassword) public async Task ChangePassword(User user, string newPassword)
{ {
if (user == null) ArgumentNullException.ThrowIfNull(user);
{
throw new ArgumentNullException(nameof(user));
}
await GetAuthenticationProvider(user).ChangePassword(user, newPassword).ConfigureAwait(false); await GetAuthenticationProvider(user).ChangePassword(user, newPassword).ConfigureAwait(false);
await UpdateUserAsync(user).ConfigureAwait(false); await UpdateUserAsync(user).ConfigureAwait(false);

View File

@ -69,8 +69,8 @@ namespace Jellyfin.Server.Infrastructure
/// <inheritdoc /> /// <inheritdoc />
protected override Task WriteFileAsync(ActionContext context, PhysicalFileResult result, RangeItemHeaderValue? range, long rangeLength) protected override Task WriteFileAsync(ActionContext context, PhysicalFileResult result, RangeItemHeaderValue? range, long rangeLength)
{ {
ArgumentNullException.ThrowIfNull(context, nameof(context)); ArgumentNullException.ThrowIfNull(context);
ArgumentNullException.ThrowIfNull(result, nameof(result)); ArgumentNullException.ThrowIfNull(result);
if (range != null && rangeLength == 0) if (range != null && rangeLength == 0)
{ {

View File

@ -160,10 +160,7 @@ namespace MediaBrowser.Common.Net
/// <inheritdoc/> /// <inheritdoc/>
public override bool Contains(IPAddress address) public override bool Contains(IPAddress address)
{ {
if (address == null) ArgumentNullException.ThrowIfNull(address);
{
throw new ArgumentNullException(nameof(address));
}
if (address.IsIPv4MappedToIPv6) if (address.IsIPv4MappedToIPv6)
{ {

View File

@ -55,10 +55,7 @@ namespace MediaBrowser.Common.Net
/// <returns>IPAddress.</returns> /// <returns>IPAddress.</returns>
public static (IPAddress Address, byte PrefixLength) NetworkAddressOf(IPAddress address, byte prefixLength) public static (IPAddress Address, byte PrefixLength) NetworkAddressOf(IPAddress address, byte prefixLength)
{ {
if (address == null) ArgumentNullException.ThrowIfNull(address);
{
throw new ArgumentNullException(nameof(address));
}
if (address.IsIPv4MappedToIPv6) if (address.IsIPv4MappedToIPv6)
{ {
@ -109,10 +106,7 @@ namespace MediaBrowser.Common.Net
/// <returns>True if it is.</returns> /// <returns>True if it is.</returns>
public static bool IsIP6(IPAddress address) public static bool IsIP6(IPAddress address)
{ {
if (address == null) ArgumentNullException.ThrowIfNull(address);
{
throw new ArgumentNullException(nameof(address));
}
if (address.IsIPv4MappedToIPv6) if (address.IsIPv4MappedToIPv6)
{ {
@ -129,10 +123,7 @@ namespace MediaBrowser.Common.Net
/// <returns>True if it contains a private address.</returns> /// <returns>True if it contains a private address.</returns>
public static bool IsPrivateAddressRange(IPAddress address) public static bool IsPrivateAddressRange(IPAddress address)
{ {
if (address == null) ArgumentNullException.ThrowIfNull(address);
{
throw new ArgumentNullException(nameof(address));
}
if (!address.Equals(IPAddress.None)) if (!address.Equals(IPAddress.None))
{ {
@ -179,10 +170,7 @@ namespace MediaBrowser.Common.Net
/// </remarks> /// </remarks>
public static bool IsIPv6LinkLocal(IPAddress address) public static bool IsIPv6LinkLocal(IPAddress address)
{ {
if (address == null) ArgumentNullException.ThrowIfNull(address);
{
throw new ArgumentNullException(nameof(address));
}
if (address.IsIPv4MappedToIPv6) if (address.IsIPv4MappedToIPv6)
{ {
@ -226,10 +214,7 @@ namespace MediaBrowser.Common.Net
/// <returns>Byte CIDR representing the mask.</returns> /// <returns>Byte CIDR representing the mask.</returns>
public static byte MaskToCidr(IPAddress mask) public static byte MaskToCidr(IPAddress mask)
{ {
if (mask == null) ArgumentNullException.ThrowIfNull(mask);
{
throw new ArgumentNullException(nameof(mask));
}
byte cidrnet = 0; byte cidrnet = 0;
if (!mask.Equals(IPAddress.Any)) if (!mask.Equals(IPAddress.Any))

View File

@ -61,10 +61,7 @@ namespace MediaBrowser.Common.Net
return false; return false;
} }
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
if (item.IsIPv4MappedToIPv6) if (item.IsIPv4MappedToIPv6)
{ {
@ -96,10 +93,7 @@ namespace MediaBrowser.Common.Net
return false; return false;
} }
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
foreach (var i in source) foreach (var i in source)
{ {
@ -153,10 +147,7 @@ namespace MediaBrowser.Common.Net
/// <returns>Collection{IPObject} object containing the subnets.</returns> /// <returns>Collection{IPObject} object containing the subnets.</returns>
public static Collection<IPObject> AsNetworks(this Collection<IPObject> source) public static Collection<IPObject> AsNetworks(this Collection<IPObject> source)
{ {
if (source == null) ArgumentNullException.ThrowIfNull(source);
{
throw new ArgumentNullException(nameof(source));
}
Collection<IPObject> res = new Collection<IPObject>(); Collection<IPObject> res = new Collection<IPObject>();
@ -239,10 +230,7 @@ namespace MediaBrowser.Common.Net
return new Collection<IPObject>(); return new Collection<IPObject>();
} }
if (target == null) ArgumentNullException.ThrowIfNull(target);
{
throw new ArgumentNullException(nameof(target));
}
Collection<IPObject> nc = new Collection<IPObject>(); Collection<IPObject> nc = new Collection<IPObject>();

View File

@ -164,10 +164,7 @@ namespace MediaBrowser.Common.Plugins
/// <inheritdoc /> /// <inheritdoc />
public virtual void UpdateConfiguration(BasePluginConfiguration configuration) public virtual void UpdateConfiguration(BasePluginConfiguration configuration)
{ {
if (configuration == null) ArgumentNullException.ThrowIfNull(configuration);
{
throw new ArgumentNullException(nameof(configuration));
}
Configuration = (TConfigurationType)configuration; Configuration = (TConfigurationType)configuration;

View File

@ -171,10 +171,7 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="ArgumentNullException">Throws if child is null.</exception> /// <exception cref="ArgumentNullException">Throws if child is null.</exception>
public void AddVirtualChild(BaseItem child) public void AddVirtualChild(BaseItem child)
{ {
if (child == null) ArgumentNullException.ThrowIfNull(child);
{
throw new ArgumentNullException(nameof(child));
}
_virtualChildren.Add(child); _virtualChildren.Add(child);
} }

View File

@ -1101,10 +1101,7 @@ namespace MediaBrowser.Controller.Entities
private MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, BaseItem item, MediaSourceType type) private MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, BaseItem item, MediaSourceType type)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
var protocol = item.PathProtocol; var protocol = item.PathProtocol;
@ -1544,10 +1541,7 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="ArgumentNullException">If user is null.</exception> /// <exception cref="ArgumentNullException">If user is null.</exception>
public bool IsParentalAllowed(User user) public bool IsParentalAllowed(User user)
{ {
if (user == null) ArgumentNullException.ThrowIfNull(user);
{
throw new ArgumentNullException(nameof(user));
}
if (!IsVisibleViaTags(user)) if (!IsVisibleViaTags(user))
{ {
@ -1667,10 +1661,7 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="ArgumentNullException"><paramref name="user" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="user" /> is <c>null</c>.</exception>
public virtual bool IsVisible(User user) public virtual bool IsVisible(User user)
{ {
if (user == null) ArgumentNullException.ThrowIfNull(user);
{
throw new ArgumentNullException(nameof(user));
}
return IsParentalAllowed(user); return IsParentalAllowed(user);
} }
@ -1842,10 +1833,7 @@ namespace MediaBrowser.Controller.Entities
DateTime? datePlayed, DateTime? datePlayed,
bool resetPosition) bool resetPosition)
{ {
if (user == null) ArgumentNullException.ThrowIfNull(user);
{
throw new ArgumentNullException(nameof(user));
}
var data = UserDataManager.GetUserData(user, this); var data = UserDataManager.GetUserData(user, this);
@ -1876,10 +1864,7 @@ namespace MediaBrowser.Controller.Entities
/// <exception cref="ArgumentNullException">Throws if user is null.</exception> /// <exception cref="ArgumentNullException">Throws if user is null.</exception>
public virtual void MarkUnplayed(User user) public virtual void MarkUnplayed(User user)
{ {
if (user == null) ArgumentNullException.ThrowIfNull(user);
{
throw new ArgumentNullException(nameof(user));
}
var data = UserDataManager.GetUserData(user, this); var data = UserDataManager.GetUserData(user, this);
@ -2110,10 +2095,7 @@ namespace MediaBrowser.Controller.Entities
/// <returns>Image index.</returns> /// <returns>Image index.</returns>
public int GetImageIndex(ItemImageInfo image) public int GetImageIndex(ItemImageInfo image)
{ {
if (image == null) ArgumentNullException.ThrowIfNull(image);
{
throw new ArgumentNullException(nameof(image));
}
if (image.Type == ImageType.Chapter) if (image.Type == ImageType.Chapter)
{ {
@ -2320,10 +2302,7 @@ namespace MediaBrowser.Controller.Entities
public virtual bool IsUnplayed(User user) public virtual bool IsUnplayed(User user)
{ {
if (user == null) ArgumentNullException.ThrowIfNull(user);
{
throw new ArgumentNullException(nameof(user));
}
var userdata = UserDataManager.GetUserData(user, this); var userdata = UserDataManager.GetUserData(user, this);

View File

@ -71,15 +71,9 @@ namespace MediaBrowser.Controller.Entities
where T : BaseItem where T : BaseItem
where TU : BaseItem where TU : BaseItem
{ {
if (source == null) ArgumentNullException.ThrowIfNull(source);
{
throw new ArgumentNullException(nameof(source));
}
if (dest == null) ArgumentNullException.ThrowIfNull(dest);
{
throw new ArgumentNullException(nameof(dest));
}
var destProps = typeof(TU).GetProperties().Where(x => x.CanWrite).ToList(); var destProps = typeof(TU).GetProperties().Where(x => x.CanWrite).ToList();

View File

@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Entities
/// <param name="url">Trailer URL.</param> /// <param name="url">Trailer URL.</param>
public static void AddTrailerUrl(this BaseItem item, string url) public static void AddTrailerUrl(this BaseItem item, string url)
{ {
ArgumentNullException.ThrowIfNull(url, nameof(url)); ArgumentNullException.ThrowIfNull(url);
if (url.Length == 0) if (url.Length == 0)
{ {

View File

@ -1023,10 +1023,7 @@ namespace MediaBrowser.Controller.Entities
IServerConfigurationManager configurationManager, IServerConfigurationManager configurationManager,
ICollectionManager collectionManager) ICollectionManager collectionManager)
{ {
if (items == null) ArgumentNullException.ThrowIfNull(items);
{
throw new ArgumentNullException(nameof(items));
}
if (CollapseBoxSetItems(query, queryParent, user, configurationManager)) if (CollapseBoxSetItems(query, queryParent, user, configurationManager))
{ {
@ -1273,20 +1270,14 @@ namespace MediaBrowser.Controller.Entities
public List<BaseItem> GetChildren(User user, bool includeLinkedChildren) public List<BaseItem> GetChildren(User user, bool includeLinkedChildren)
{ {
if (user == null) ArgumentNullException.ThrowIfNull(user);
{
throw new ArgumentNullException(nameof(user));
}
return GetChildren(user, includeLinkedChildren, null); return GetChildren(user, includeLinkedChildren, null);
} }
public virtual List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query) public virtual List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query)
{ {
if (user == null) ArgumentNullException.ThrowIfNull(user);
{
throw new ArgumentNullException(nameof(user));
}
// the true root should return our users root folder children // the true root should return our users root folder children
if (IsPhysicalRoot) if (IsPhysicalRoot)
@ -1367,10 +1358,7 @@ namespace MediaBrowser.Controller.Entities
public virtual IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query) public virtual IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query)
{ {
if (user == null) ArgumentNullException.ThrowIfNull(user);
{
throw new ArgumentNullException(nameof(user));
}
var result = new Dictionary<Guid, BaseItem>(); var result = new Dictionary<Guid, BaseItem>();

View File

@ -11,10 +11,7 @@ namespace MediaBrowser.Controller.Entities
{ {
public static void AddPerson(List<PersonInfo> people, PersonInfo person) public static void AddPerson(List<PersonInfo> people, PersonInfo person)
{ {
if (person == null) ArgumentNullException.ThrowIfNull(person);
{
throw new ArgumentNullException(nameof(person));
}
if (string.IsNullOrEmpty(person.Name)) if (string.IsNullOrEmpty(person.Name))
{ {

View File

@ -40,10 +40,7 @@ namespace MediaBrowser.Controller.IO
throw new ArgumentNullException(nameof(path)); throw new ArgumentNullException(nameof(path));
} }
if (args == null) ArgumentNullException.ThrowIfNull(args);
{
throw new ArgumentNullException(nameof(args));
}
var entries = directoryService.GetFileSystemEntries(path); var entries = directoryService.GetFileSystemEntries(path);

View File

@ -5105,15 +5105,9 @@ namespace MediaBrowser.Controller.MediaEncoding
MediaSourceInfo mediaSource, MediaSourceInfo mediaSource,
string requestedUrl) string requestedUrl)
{ {
if (state == null) ArgumentNullException.ThrowIfNull(state);
{
throw new ArgumentNullException(nameof(state));
}
if (mediaSource == null) ArgumentNullException.ThrowIfNull(mediaSource);
{
throw new ArgumentNullException(nameof(mediaSource));
}
var path = mediaSource.Path; var path = mediaSource.Path;
var protocol = mediaSource.Protocol; var protocol = mediaSource.Protocol;

View File

@ -38,10 +38,7 @@ namespace MediaBrowser.Controller.Net
protected BasePeriodicWebSocketListener(ILogger<BasePeriodicWebSocketListener<TReturnDataType, TStateType>> logger) protected BasePeriodicWebSocketListener(ILogger<BasePeriodicWebSocketListener<TReturnDataType, TStateType>> logger)
{ {
if (logger == null) ArgumentNullException.ThrowIfNull(logger);
{
throw new ArgumentNullException(nameof(logger));
}
Logger = logger; Logger = logger;
} }
@ -77,10 +74,7 @@ namespace MediaBrowser.Controller.Net
/// <returns>Task.</returns> /// <returns>Task.</returns>
public Task ProcessMessageAsync(WebSocketMessageInfo message) public Task ProcessMessageAsync(WebSocketMessageInfo message)
{ {
if (message == null) ArgumentNullException.ThrowIfNull(message);
{
throw new ArgumentNullException(nameof(message));
}
if (message.MessageType == StartType) if (message.MessageType == StartType)
{ {

View File

@ -53,10 +53,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
/// <exception cref="ArgumentNullException">Item is null.</exception> /// <exception cref="ArgumentNullException">Item is null.</exception>
public void Fetch(MetadataResult<T> item, string metadataFile, CancellationToken cancellationToken) public void Fetch(MetadataResult<T> item, string metadataFile, CancellationToken cancellationToken)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
if (string.IsNullOrEmpty(metadataFile)) if (string.IsNullOrEmpty(metadataFile))
{ {

View File

@ -52,10 +52,7 @@ namespace MediaBrowser.MediaEncoding.Attachments
/// <inheritdoc /> /// <inheritdoc />
public async Task<(MediaAttachment Attachment, Stream Stream)> GetAttachment(BaseItem item, string mediaSourceId, int attachmentStreamIndex, CancellationToken cancellationToken) public async Task<(MediaAttachment Attachment, Stream Stream)> GetAttachment(BaseItem item, string mediaSourceId, int attachmentStreamIndex, CancellationToken cancellationToken)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
if (string.IsNullOrWhiteSpace(mediaSourceId)) if (string.IsNullOrWhiteSpace(mediaSourceId))
{ {

View File

@ -15,10 +15,7 @@ namespace MediaBrowser.MediaEncoding.Probing
/// <param name="result">The result.</param> /// <param name="result">The result.</param>
public static void NormalizeFFProbeResult(InternalMediaInfoResult result) public static void NormalizeFFProbeResult(InternalMediaInfoResult result)
{ {
if (result == null) ArgumentNullException.ThrowIfNull(result);
{
throw new ArgumentNullException(nameof(result));
}
if (result.Format?.Tags != null) if (result.Format?.Tags != null)
{ {

View File

@ -120,10 +120,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
async Task<Stream> ISubtitleEncoder.GetSubtitles(BaseItem item, string mediaSourceId, int subtitleStreamIndex, string outputFormat, long startTimeTicks, long endTimeTicks, bool preserveOriginalTimestamps, CancellationToken cancellationToken) async Task<Stream> ISubtitleEncoder.GetSubtitles(BaseItem item, string mediaSourceId, int subtitleStreamIndex, string outputFormat, long startTimeTicks, long endTimeTicks, bool preserveOriginalTimestamps, CancellationToken cancellationToken)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
if (string.IsNullOrWhiteSpace(mediaSourceId)) if (string.IsNullOrWhiteSpace(mediaSourceId))
{ {

View File

@ -29,10 +29,7 @@ namespace MediaBrowser.Model.Cryptography
public PasswordHash(string id, byte[] hash, byte[] salt, Dictionary<string, string> parameters) public PasswordHash(string id, byte[] hash, byte[] salt, Dictionary<string, string> parameters)
{ {
if (id == null) ArgumentNullException.ThrowIfNull(id);
{
throw new ArgumentNullException(nameof(id));
}
if (id.Length == 0) if (id.Length == 0)
{ {

View File

@ -565,10 +565,7 @@ namespace MediaBrowser.Model.Dlna
private StreamInfo BuildVideoItem(MediaSourceInfo item, VideoOptions options) private StreamInfo BuildVideoItem(MediaSourceInfo item, VideoOptions options)
{ {
if (item == null) ArgumentNullException.ThrowIfNull(item);
{
throw new ArgumentNullException(nameof(item));
}
StreamInfo playlistItem = new StreamInfo StreamInfo playlistItem = new StreamInfo
{ {

View File

@ -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> /// <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) public static bool HasProviderId(this IHasProviderIds instance, string name)
{ {
if (instance == null) ArgumentNullException.ThrowIfNull(instance);
{
throw new ArgumentNullException(nameof(instance));
}
return instance.TryGetProviderId(name, out _); 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> /// <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) public static bool TryGetProviderId(this IHasProviderIds instance, string name, [NotNullWhen(true)] out string? id)
{ {
if (instance == null) ArgumentNullException.ThrowIfNull(instance);
{
throw new ArgumentNullException(nameof(instance));
}
if (instance.ProviderIds == null) if (instance.ProviderIds == null)
{ {
@ -121,10 +115,7 @@ namespace MediaBrowser.Model.Entities
/// <param name="value">The value.</param> /// <param name="value">The value.</param>
public static void SetProviderId(this IHasProviderIds instance, string name, string? value) public static void SetProviderId(this IHasProviderIds instance, string name, string? value)
{ {
if (instance == null) ArgumentNullException.ThrowIfNull(instance);
{
throw new ArgumentNullException(nameof(instance));
}
// If it's null remove the key from the dictionary // If it's null remove the key from the dictionary
if (string.IsNullOrEmpty(value)) if (string.IsNullOrEmpty(value))

View File

@ -18,10 +18,7 @@ namespace Jellyfin.Extensions
/// <exception cref="ArgumentNullException">The source is null.</exception> /// <exception cref="ArgumentNullException">The source is null.</exception>
public static bool Contains(this IEnumerable<string> source, ReadOnlySpan<char> value, StringComparison stringComparison) public static bool Contains(this IEnumerable<string> source, ReadOnlySpan<char> value, StringComparison stringComparison)
{ {
if (source == null) ArgumentNullException.ThrowIfNull(source);
{
throw new ArgumentNullException(nameof(source));
}
if (source is IList<string> list) if (source is IList<string> list)
{ {

View File

@ -103,10 +103,7 @@ namespace Jellyfin.Networking.Tests
"[192.158.0.0/16,192.0.0.0/8]")] "[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) public void TestCollections(string settings, string result1, string result2, string result3, string result4, string result5)
{ {
if (settings == null) ArgumentNullException.ThrowIfNull(settings);
{
throw new ArgumentNullException(nameof(settings));
}
var conf = new NetworkConfiguration() 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]")] [InlineData("127.0.0.1", "127.0.0.1/8", "[127.0.0.1/32]")]
public void UnionCheck(string settings, string compare, string result) public void UnionCheck(string settings, string compare, string result)
{ {
if (settings == null) ArgumentNullException.ThrowIfNull(settings);
{
throw new ArgumentNullException(nameof(settings));
}
if (compare == null) ArgumentNullException.ThrowIfNull(compare);
{
throw new ArgumentNullException(nameof(compare));
}
if (result == null) ArgumentNullException.ThrowIfNull(result);
{
throw new ArgumentNullException(nameof(result));
}
var conf = new NetworkConfiguration() var conf = new NetworkConfiguration()
{ {
@ -264,20 +252,11 @@ namespace Jellyfin.Networking.Tests
public void TestCollectionEquality(string source, string dest, string result) public void TestCollectionEquality(string source, string dest, string result)
{ {
if (source == null) ArgumentNullException.ThrowIfNull(source);
{
throw new ArgumentNullException(nameof(source));
}
if (dest == null) ArgumentNullException.ThrowIfNull(dest);
{
throw new ArgumentNullException(nameof(dest));
}
if (result == null) ArgumentNullException.ThrowIfNull(result);
{
throw new ArgumentNullException(nameof(result));
}
var conf = new NetworkConfiguration() var conf = new NetworkConfiguration()
{ {
@ -331,20 +310,11 @@ namespace Jellyfin.Networking.Tests
[InlineData("", "", false, "eth16")] [InlineData("", "", false, "eth16")]
public void TestBindInterfaces(string source, string bindAddresses, bool ipv6enabled, string result) public void TestBindInterfaces(string source, string bindAddresses, bool ipv6enabled, string result)
{ {
if (source == null) ArgumentNullException.ThrowIfNull(source);
{
throw new ArgumentNullException(nameof(source));
}
if (bindAddresses == null) ArgumentNullException.ThrowIfNull(bindAddresses);
{
throw new ArgumentNullException(nameof(bindAddresses));
}
if (result == null) ArgumentNullException.ThrowIfNull(result);
{
throw new ArgumentNullException(nameof(result));
}
var conf = new NetworkConfiguration() 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")] [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) public void TestBindInterfaceOverrides(string source, string lan, string bindAddresses, bool ipv6enabled, string publishedServers, string result)
{ {
if (lan == null) ArgumentNullException.ThrowIfNull(lan);
{
throw new ArgumentNullException(nameof(lan));
}
if (bindAddresses == null) ArgumentNullException.ThrowIfNull(bindAddresses);
{
throw new ArgumentNullException(nameof(bindAddresses));
}
var conf = new NetworkConfiguration() var conf = new NetworkConfiguration()
{ {