mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-01 13:28:27 +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:
@@ -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 disk
|
||||
if (ChangePluginState(plugin, PluginStatus.Disabled))
|
||||
@@ -326,10 +317,7 @@ namespace Emby.Server.Implementations.Plugins
|
||||
public 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)
|
||||
|
||||
Reference in New Issue
Block a user