[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>
internal static List<NetworkConnectionProperties> GetList()
{
List<NetworkConnectionProperties> list = new List<NetworkConnectionProperties>();
var interfaces = NetworkInterface.GetAllNetworkInterfaces().Where(x => x.NetworkInterfaceType != NetworkInterfaceType.Loopback && x.GetPhysicalAddress() != null);
foreach (NetworkInterface i in interfaces)
{
list.Add(new NetworkConnectionProperties(i));
}
return list;
var interfaces = NetworkInterface.GetAllNetworkInterfaces()
.Where(x => x.NetworkInterfaceType != NetworkInterfaceType.Loopback && x.GetPhysicalAddress() != null)
.Select(i => new NetworkConnectionProperties(i))
.OrderByDescending(i => i.IPv4) // list IPv4 first
.ThenBy(i => i.IPv6Primary) // then IPv6
.ToList();
return interfaces;
}
/// <summary>