< Summary - Kestrun — Combined Coverage

Information
Class: Public.Helper.Expand-KrObject
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Helper/Expand-KrObject.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 16
Coverable lines: 16
Total lines: 72
Line coverage: 0%
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 08/26/2025 - 14:53:17 Line coverage: 0% (0/14) Total lines: 59 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743109/04/2025 - 18:11:31 Line coverage: 0% (0/14) Total lines: 60 Tag: Kestrun/Kestrun@de99e24698289f3f61ac7b73e96092732ae12b0512/18/2025 - 21:41:58 Line coverage: 0% (0/16) Total lines: 72 Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Helper/Expand-KrObject.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Expands an object into a formatted string for display.
 4    .DESCRIPTION
 5        This function takes an object and formats it for display in the console. It includes the type name and the objec
 6        If a label is provided, it prefixes the output with the label.
 7    .PARAMETER InputObject
 8        The object to expand and display. This can be any PowerShell object, including complex types.
 9    .PARAMETER ForegroundColor
 10        The color to use for the output text in the console. If not specified, defaults to the console's current foregro
 11    .PARAMETER Label
 12        An optional label to prefix the output. This can be used to provide context or a name for the object being displ
 13    .PARAMETER PassThru
 14        If specified, the function will return the formatted string instead of writing it to the console.
 15    .EXAMPLE
 16        Expand-KrObject -InputObject $myObject -ForegroundColor Cyan -Label "My Object"
 17        Displays the $myObject with a cyan foreground color and prefixes it with "My Object".
 18    .NOTES
 19        This function is designed to be used in the context of Kestrun for debugging or logging purposes.
 20#>
 21function Expand-KrObject {
 22    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]
 23    [KestrunRuntimeApi('Everywhere')]
 24    [CmdletBinding(defaultParameterSetName = 'Console')]
 25    [OutputType([string])]
 26    param(
 27        [Parameter(Position = 0, ValueFromPipeline = $true)]
 28        [object] $InputObject,
 29
 30        [Parameter(ParameterSetName = 'Console')]
 31        [System.ConsoleColor] $ForegroundColor,
 32
 33        [Parameter()]
 34        [string] $Label,
 35
 36        [Parameter(ParameterSetName = 'PassThru')]
 37        [switch]$PassThru
 38    )
 39
 40    process {
 41
 042        if ($null -eq $InputObject) {
 043            $InputObject = "`tNull Value"
 44        } else {
 045            $type = $InputObject.gettype().FullName
 046            $InputObject = $InputObject | Out-String
 047            $InputObject = "`tTypeName: $type`n$InputObject"
 48        }
 049        if ($Label) {
 050            $InputObject = "`tName: $Label $InputObject"
 51        }
 52
 53        # Return the object if PassThru is specified
 054        if ($PassThru) {
 055            return $InputObject
 56        }
 57
 058        if ($ForegroundColor) {
 059            if ($pipelineValue.Count -gt 1) {
 060                $InputObject | Write-Host -ForegroundColor $ForegroundColor
 61            } else {
 062                Write-Host -Object $InputObject -ForegroundColor $ForegroundColor
 63            }
 64        } else {
 065            if ($pipelineValue.Count -gt 1) {
 066                $InputObject | Write-Host
 67            } else {
 068                Write-Host -Object $InputObject
 69            }
 70        }
 71    }
 72}

Methods/Properties

Expand-KrObject()