< Summary - Kestrun — Combined Coverage

Information
Class: Private.Yaml.Convert-ListToGenericList
Assembly: Kestrun.PowerShell.Private
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Yaml/Convert-ListToGenericList.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 34
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 10/13/2025 - 16:52:37 Line coverage: 100% (4/4) Total lines: 34 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Yaml/Convert-ListToGenericList.ps1

#LineLine coverage
 1# Portions derived from PowerShell-Yaml (https://github.com/cloudbase/powershell-yaml)
 2# Copyright (c) 2016–2024 Cloudbase Solutions Srl
 3# Licensed under the Apache License, Version 2.0 (Apache-2.0).
 4# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 5# Modifications Copyright (c) 2025 Kestrun Contributors
 6
 7<#
 8.SYNOPSIS
 9    Convert a list (array) to a generic List[object], converting any nested PSObjects to generic objects.
 10.DESCRIPTION
 11    This function takes a list (array) as input and converts it to a System.Collections.Generic.List[object]. It ensures
 12    The order of elements in the list is preserved in the resulting generic list.
 13.PARAMETER Data
 14    The list (array) to convert.
 15.EXAMPLE
 16    $list = @( "Value1", [PSCustomObject]@{ Prop1 = "Val1"; Prop2 = "Val2" } )
 17    $genericList = Convert-ListToGenericList -Data $list
 18    # $genericList is now a List[object] with the same elements, where the second element is a generic object.
 19.NOTES
 20    This function is designed to work with PowerShell 7.0 and above.
 21#>
 22function Convert-ListToGenericList {
 23    param(
 24        [Parameter(Mandatory = $false)]
 25        [array]$Data = @()
 26    )
 127    $ret = [System.Collections.Generic.List[object]]::new()
 328    for ($i = 0; $i -lt $Data.Count; $i++) {
 229        $ret.Add((Convert-PSObjectToGenericObject $Data[$i]))
 30    }
 31    # Return the generic list directly (do NOT wrap in a single-element array) so single-element
 32    # sequences remain proper YAML sequences and do not collapse into mappings during round-trip.
 133    return $ret
 34}

Methods/Properties

Convert-ListToGenericList()