[PTRun][System] Sort NetworkInterfaces by IPv4, then IPv6 (#28220)

Updated GetList method to sort by IPv4, then IPv6 adapter interfaces to match test logic
This commit is contained in:
Jeremy Sinclair
2023-09-04 11:16:58 -04:00
committed by GitHub
parent 90e5362385
commit 752c298ef3

View File

@@ -143,15 +143,13 @@ namespace Microsoft.PowerToys.Run.Plugin.System.Components
/// <returns>List containing all network adapters</returns> /// <returns>List containing all network adapters</returns>
internal static List<NetworkConnectionProperties> GetList() internal static List<NetworkConnectionProperties> GetList()
{ {
List<NetworkConnectionProperties> list = new List<NetworkConnectionProperties>(); var interfaces = NetworkInterface.GetAllNetworkInterfaces()
.Where(x => x.NetworkInterfaceType != NetworkInterfaceType.Loopback && x.GetPhysicalAddress() != null)
var interfaces = NetworkInterface.GetAllNetworkInterfaces().Where(x => x.NetworkInterfaceType != NetworkInterfaceType.Loopback && x.GetPhysicalAddress() != null); .Select(i => new NetworkConnectionProperties(i))
foreach (NetworkInterface i in interfaces) .OrderByDescending(i => i.IPv4) // list IPv4 first
{ .ThenBy(i => i.IPv6Primary) // then IPv6
list.Add(new NetworkConnectionProperties(i)); .ToList();
} return interfaces;
return list;
} }
/// <summary> /// <summary>