mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-31 12:58:28 +01:00
Use ArgumentNullException.ThrowIfNull helper method
Did a simple search/replace on the whole repo (except the RSSDP project)
This reduces LOC and should improve performance (methods containing a throw statement don't get inlined)
```
if \((\w+) == null\)
\s+\{
\s+throw new ArgumentNullException\((.*)\);
\s+\}
```
```
ArgumentNullException.ThrowIfNull($1);
```
This commit is contained in:
@@ -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.ScheduledTasks
|
||||
get => _triggers;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
|
||||
// Cleanup current triggers
|
||||
if (_triggers != null)
|
||||
@@ -281,10 +266,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
|
||||
|
||||
set
|
||||
{
|
||||
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 incorrectly
|
||||
var triggerList = value.Where(i => i != null).ToArray();
|
||||
|
||||
Reference in New Issue
Block a user