mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-04-01 17:12:09 +00:00
Fix Sorting of Errored Packages by using 'Sort-Object' instead of 'IComparer' approach (#2)
Fixes startup issues in PWSH 7
This commit is contained in:
parent
02d96decd0
commit
a1f3b6daec
@ -36,30 +36,6 @@ class ErroredPackage {
|
||||
}
|
||||
}
|
||||
|
||||
class ErroredPackageComparer : System.Collections.Generic.IComparer[ErroredPackage] {
|
||||
[string]$PropertyName
|
||||
[bool]$Descending = $false
|
||||
|
||||
ErroredPackageComparer([string]$property) {
|
||||
$this.PropertyName = $property
|
||||
}
|
||||
|
||||
ErroredPackageComparer([string]$property, [bool]$descending) {
|
||||
$this.PropertyName = $property
|
||||
$this.Descending = $descending
|
||||
}
|
||||
|
||||
[int]Compare([ErroredPackage]$a, [ErroredPackage]$b) {
|
||||
if ($a.$($this.PropertyName) -eq $b.$($this.PropertyName)) { $res = 0 }
|
||||
elseif ($a.$($this.PropertyName) -lt $b.$($this.PropertyName)) { $res = -1 }
|
||||
else { $res = 1 }
|
||||
|
||||
if ($this.Descending) { $res *= -1 }
|
||||
|
||||
return $res
|
||||
}
|
||||
}
|
||||
|
||||
function Get-FidoLangFromCulture {
|
||||
|
||||
param (
|
||||
@ -223,8 +199,7 @@ function Remove-Packages {
|
||||
Write-Host "$failedCount package(s) could not be removed. Your image will still work fine, however. Below is information on what packages failed to be removed and why."
|
||||
if ($erroredPackages.Count -gt 0)
|
||||
{
|
||||
$ErrorMessageComparer = [ErroredPackageComparer]::new("ErrorMessage")
|
||||
$erroredPackages.Sort($ErrorMessageComparer)
|
||||
$erroredPackages = $erroredPackages | Sort-Object -Property ErrorMessage
|
||||
|
||||
$previousErroredPackage = $erroredPackages[0]
|
||||
$counter = 0
|
||||
|
Loading…
Reference in New Issue
Block a user