Refactor Get-RebootFeatureLabels to use generic list and simplify feature label collection

This commit is contained in:
Jeffrey 2026-07-11 20:00:49 +02:00
parent c36639414e
commit 545de05e57
No known key found for this signature in database
3 changed files with 4 additions and 4 deletions

View File

@ -18,7 +18,7 @@ function RestartExplorer {
return
}
$rebootFeatures = @(Get-RebootFeatureLabels)
$rebootFeatures = Get-RebootFeatureLabels
foreach ($displayLabel in $rebootFeatures) {
Write-Host "Warning: '$displayLabel' requires a reboot to take full effect" -ForegroundColor Yellow
}

View File

@ -144,7 +144,7 @@ function Show-ApplyModal {
# Show completion message with reboot instructions if any applied features require reboot
if ($RestartExplorer) {
$rebootFeatures = @(Get-RebootFeatureLabels)
$rebootFeatures = Get-RebootFeatureLabels
if ($rebootFeatures.Count -gt 0) {
foreach ($featureName in $rebootFeatures) {

View File

@ -8,7 +8,7 @@
UndoLabel when available.
#>
function Get-RebootFeatureLabels {
$rebootFeatureLabels = @()
$rebootFeatureLabels = [System.Collections.Generic.List[string]]::new()
$candidateParamKeys = (@($script:Params.Keys) + @($script:UndoParams.Keys)) | Select-Object -Unique
foreach ($paramKey in $candidateParamKeys) {
@ -18,7 +18,7 @@ function Get-RebootFeatureLabels {
$displayLabel = if ($isUndo -and $feature.UndoLabel) { $feature.UndoLabel } else { $feature.Label }
if (-not [string]::IsNullOrWhiteSpace([string]$displayLabel)) {
$rebootFeatureLabels += [string]$displayLabel
[void]$rebootFeatureLabels.Add([string]$displayLabel)
}
}
}