< Summary - Kestrun — Combined Coverage

Information
Class: Private.Assembly.Resolve-KrCodeLanguageFromPath
Assembly: Kestrun.PowerShell.Private
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Assembly/Resolve-KrCodeLanguageFromPath.ps1
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
62%
Covered lines: 5
Uncovered lines: 3
Coverable lines: 8
Total lines: 51
Line coverage: 62.5%
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 01/21/2026 - 17:07:46 Line coverage: 62.5% (5/8) Total lines: 51 Tag: Kestrun/Kestrun@3f6f61710c7ef7d5953cab578fe699c1e5e01a36

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Assembly/Resolve-KrCodeLanguageFromPath.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Resolves the scripting language from the file extension of the provided path.
 4.DESCRIPTION
 5    This helper function infers the scripting language (CSharp or VBNet) based on the
 6file extension of the given path. It throws an error if the extension is unsupported or missing.
 7.PARAMETER Path
 8    The file path from which to infer the scripting language.
 9.OUTPUTS
 10    [Kestrun.Scripting.ScriptLanguage]
 11    The inferred scripting language.
 12.EXAMPLE
 13    $lang = Resolve-KrCodeLanguageFromPath -Path 'script.cs'
 14    This command infers the scripting language as CSharp from the .cs extension.
 15.EXAMPLE
 16    $lang = Resolve-KrCodeLanguageFromPath -Path 'script.vb'
 17    This command infers the scripting language as VBNet from the .vb extension.
 18.EXAMPLE
 19    $lang = Resolve-KrCodeLanguageFromPath -Path 'script.ps1'
 20    This command infers the scripting language as PowerShell from the .ps1 extension.
 21.EXAMPLE
 22    $lang = Resolve-KrCodeLanguageFromPath -Path 'script.txt'
 23    This command throws an error because .txt is not a supported extension.
 24.EXAMPLE
 25    $lang = Resolve-KrCodeLanguageFromPath -Path 'script'
 26    This command throws an error because there is no file extension to infer the language.
 27.NOTES
 28    This function is used internally by Set-KrServerHttpsOptions to determine the language for client
 29    certificate validation code snippets.
 30#>
 31function Resolve-KrCodeLanguageFromPath {
 32    [CmdletBinding()]
 33    param(
 34        [Parameter(Mandatory)]
 35        [string]$Path
 36    )
 37
 138    $ext = [System.IO.Path]::GetExtension($Path)
 139    if ([string]::IsNullOrWhiteSpace($ext)) {
 040        throw "Unable to infer the language code type: '$Path' has no extension."
 41    }
 42
 143    switch ($ext.ToLowerInvariant()) {
 144        '.cs' { return [Kestrun.Scripting.ScriptLanguage]::CSharp }
 145        '.vb' { return [Kestrun.Scripting.ScriptLanguage]::VBNet }
 046        '.ps1' { return [Kestrun.Scripting.ScriptLanguage]::PowerShell }
 47        default {
 048            throw "Unsupported language code file extension '$ext'."
 49        }
 50    }
 51}