< Summary - Kestrun — Combined Coverage

Information
Class: Public.SharedState.Get-KrSharedState
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/SharedState/Get-KrSharedState.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
60%
Covered lines: 3
Uncovered lines: 2
Coverable lines: 5
Total lines: 49
Line coverage: 60%
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: 100% (1/1) Total lines: 28 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743109/04/2025 - 22:37:32 Line coverage: 100% (1/1) Total lines: 29 Tag: Kestrun/Kestrun@afb7aadc0a8a42bfa2b51ea62c8a6e2cf63faec611/14/2025 - 12:29:34 Line coverage: 60% (3/5) Total lines: 49 Tag: Kestrun/Kestrun@5e12b09a6838e68e704cd3dc975331b9e680a626

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/SharedState/Get-KrSharedState.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Retrieves the value of a previously defined global variable.
 4.DESCRIPTION
 5    Looks up a variable in the Kestrun global variable table and returns its
 6    value. If the variable does not exist, `$null` is returned.
 7.PARAMETER Server
 8    The Kestrun server instance.
 9.PARAMETER Global
 10    If specified, the variable is retrieved from the global shared state.
 11.PARAMETER Name
 12    Name of the variable to retrieve.
 13    This should be the fully qualified name of the variable, including any
 14    namespaces.
 15.EXAMPLE
 16    Get-KrSharedState -Name "MyVariable"
 17    This retrieves the value of the global variable "MyVariable".
 18.NOTES
 19    This function is part of the Kestrun.SharedState module and is used to retrieve the value of global variables.
 20#>
 21function Get-KrSharedState {
 22    [KestrunRuntimeApi('Everywhere')]
 23    [CmdletBinding(defaultParameterSetName = 'Server')]
 24    param(
 25        [Parameter(ValueFromPipeline = $true, ParameterSetName = 'Server')]
 26        [Kestrun.Hosting.KestrunHost]$Server,
 27
 28        [Parameter(Mandatory = $true, ParameterSetName = 'Global')]
 29        [switch]$Global,
 30
 31        [Parameter(Mandatory)]
 32        [string]$Name
 33    )
 34    begin {
 135        if (-not $Global.IsPresent) {
 36            # Ensure the server instance is resolved
 037            $Server = Resolve-KestrunServer -Server $Server
 38        }
 39    }
 40    process {
 141        if ($Global.IsPresent) {
 42            # Retrieve from server instance
 143            return [Kestrun.SharedState.GlobalStore]::Get($Name)
 44        }
 45        # Retrieve (or $null if not defined)
 046        return $Server.SharedState.Get($Name)
 47    }
 48}
 49

Methods/Properties

Get-KrSharedState()