mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-15 18:53: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:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user