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:
Bond_009
2022-10-06 20:21:23 +02:00
parent 927fe33d3a
commit a9a5fcde81
60 changed files with 155 additions and 617 deletions

View File

@@ -61,10 +61,7 @@ namespace MediaBrowser.Common.Net
return false;
}
if (item == null)
{
throw new ArgumentNullException(nameof(item));
}
ArgumentNullException.ThrowIfNull(item);
if (item.IsIPv4MappedToIPv6)
{
@@ -96,10 +93,7 @@ namespace MediaBrowser.Common.Net
return 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.Net
return new Collection<IPObject>();
}
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}
ArgumentNullException.ThrowIfNull(target);
Collection<IPObject> nc = new Collection<IPObject>();