< Summary - Kestrun — Combined Coverage

Information
Class: Private.Assembly.Get-KrFunctionContextMask
Assembly: Kestrun.PowerShell.Private
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Assembly/Get-KrFunctionContextMask.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
0%
Covered lines: 0
Uncovered lines: 19
Coverable lines: 19
Total lines: 44
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

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Assembly/Get-KrFunctionContextMask.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Retrieves the context mask for a Kestrun function.
 4    .DESCRIPTION
 5        This function takes a Kestrun function and retrieves its context mask, which indicates the
 6        contexts in which the function is applicable (e.g., Definition, Route, Schedule).
 7    .PARAMETER Function
 8        The Kestrun function for which to retrieve the context mask.
 9    .OUTPUTS
 10        [int]
 11        The context mask for the specified function.
 12#>
 13function Get-KrFunctionContextMask {
 14    param([System.Management.Automation.FunctionInfo]$Function)
 15
 016    if (-not $Function.ScriptBlock) { return 0 }
 17
 018    $fnAst = $Function.ScriptBlock.Ast.
 019    Find({ param($n) $n -is [System.Management.Automation.Language.FunctionDefinitionAst] -and $n.Name -eq $Function.Nam
 020    if (-not $fnAst) { return 0 }
 21
 022    $attrs = @()
 023    if ($fnAst.Attributes) { $attrs += $fnAst.Attributes }
 024    if ($fnAst.Body -and $fnAst.Body.ParamBlock -and $fnAst.Body.ParamBlock.Attributes) {
 025        $attrs += $fnAst.Body.ParamBlock.Attributes
 26    }
 27
 028    $kr = $attrs | Where-Object { $_.TypeName.Name -eq 'KestrunRuntimeApi' } | Select-Object -First 1
 029    if (-not $kr) { return 0 }
 30
 031    $txt = (($kr.PositionalArguments + $kr.NamedArguments.Expression) | Where-Object { $_ }).Extent.Text
 32    #|           ForEach-Object { $_.Extent.Text } -join ' '
 033    $mask = switch ($txt) {
 034        "'Everywhere'" { 7 }
 035        "'Runtime'" { 6 }
 036        "'ScheduleAndDefinition'" { 5 }
 037        "'Definition'" { 1 }
 038        "'Route'" { 2 }
 039        "'Schedule'" { 4 }
 40    }
 41
 042    return $mask
 43}
 44

Methods/Properties

Get-KrFunctionContextMask()