Fix .NET 7 compatibility

This commit is contained in:
Shadowghost 2022-12-07 17:41:32 +01:00
parent 2c86bd1875
commit 3f6354cdb8
3 changed files with 8 additions and 8 deletions

View File

@ -1094,7 +1094,7 @@ namespace Emby.Server.Implementations
{
int? requestPort = request.Host.Port;
if (requestPort == null
|| (requestPort == 80 && string.Equals(request.Scheme, "http", StringComparison.OrdinalIgnoreCase))
|| (requestPort == 80 && string.Equals(request.Scheme, "http", StringComparison.OrdinalIgnoreCase))
|| (requestPort == 443 && string.Equals(request.Scheme, "https", StringComparison.OrdinalIgnoreCase)))
{
requestPort = -1;

View File

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

View File

@ -207,7 +207,7 @@ namespace Jellyfin.Networking.Tests
// Check to see if dns resolution is working. If not, skip test.
_ = 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();
var intf = nm.GetBindInterface(source, out _);
@ -265,7 +265,7 @@ namespace Jellyfin.Networking.Tests
using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
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).
result = resultObj.First().Address.ToString();