mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[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:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user