Fix .NET 7 compatibility

pull/8147/head
Shadowghost 2 years ago
parent 2c86bd1875
commit 3f6354cdb8

@ -1,10 +1,10 @@
using Microsoft.AspNetCore.HttpOverrides;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.AspNetCore.HttpOverrides;
namespace MediaBrowser.Common.Net namespace MediaBrowser.Common.Net
{ {
@ -131,7 +131,7 @@ namespace MediaBrowser.Common.Net
/// <returns>URI safe conversion of the address.</returns> /// <returns>URI safe conversion of the address.</returns>
public static string FormatIpString(IPAddress? address) public static string FormatIpString(IPAddress? address)
{ {
if (address == null) if (address is null)
{ {
return string.Empty; return string.Empty;
} }
@ -163,7 +163,7 @@ namespace MediaBrowser.Common.Net
{ {
result = new List<IPNetwork>(); result = new List<IPNetwork>();
if (values == null || values.Length == 0) if (values is null || values.Length == 0)
{ {
return false; return false;
} }
@ -182,7 +182,7 @@ namespace MediaBrowser.Common.Net
_ = IPAddress.TryParse(v[0][0..], out address); _ = IPAddress.TryParse(v[0][0..], out address);
} }
if (address != IPAddress.None && address != null) if (address != IPAddress.None && address is not null)
{ {
if (v.Length > 1 && int.TryParse(v[1], out var netmask)) if (v.Length > 1 && int.TryParse(v[1], out var netmask))
{ {
@ -240,7 +240,7 @@ namespace MediaBrowser.Common.Net
_ = IPAddress.TryParse(v[0][0..], out address); _ = IPAddress.TryParse(v[0][0..], out address);
} }
if (address != IPAddress.None && address != null) if (address != IPAddress.None && address is not null)
{ {
if (v.Length > 1 && int.TryParse(v[1], out var netmask)) if (v.Length > 1 && int.TryParse(v[1], out var netmask))
{ {

@ -207,7 +207,7 @@ namespace Jellyfin.Networking.Tests
// Check to see if dns resolution is working. If not, skip test. // Check to see if dns resolution is working. If not, skip test.
_ = NetworkExtensions.TryParseHost(source, out var host); _ = NetworkExtensions.TryParseHost(source, out var host);
if (resultObj != null && host.Length > 0) if (resultObj is not null && host.Length > 0)
{ {
result = resultObj.First().Address.ToString(); result = resultObj.First().Address.ToString();
var intf = nm.GetBindInterface(source, out _); var intf = nm.GetBindInterface(source, out _);
@ -265,7 +265,7 @@ namespace Jellyfin.Networking.Tests
using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>()); using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
NetworkManager.MockNetworkSettings = string.Empty; NetworkManager.MockNetworkSettings = string.Empty;
if (nm.TryParseInterface(result, out List<IPData>? resultObj) && resultObj != null) if (nm.TryParseInterface(result, out List<IPData>? resultObj) && resultObj is not null)
{ {
// Parse out IPAddresses so we can do a string comparison (ignore subnet masks). // Parse out IPAddresses so we can do a string comparison (ignore subnet masks).
result = resultObj.First().Address.ToString(); result = resultObj.First().Address.ToString();

Loading…
Cancel
Save