< Summary - Kestrun — Combined Coverage

Information
Class: Private.Assembly.Assert-KrAssemblyLoaded
Assembly: Kestrun.PowerShell.Private
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Assembly/Assert-KrAssemblyLoaded.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 41
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 - 01:25:22 Line coverage: 46.1% (6/13) Total lines: 40 Tag: Kestrun/Kestrun@07f821172e5dc3657f1be7e6818f18d6721cf38a09/04/2025 - 22:37:32 Line coverage: 46.1% (6/13) Total lines: 41 Tag: Kestrun/Kestrun@afb7aadc0a8a42bfa2b51ea62c8a6e2cf63faec610/13/2025 - 16:52:37 Line coverage: 0% (0/13) Total lines: 41 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Private/Assembly/Assert-KrAssemblyLoaded.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Ensures that a .NET assembly is loaded only once.
 4
 5    .DESCRIPTION
 6        Checks the currently loaded assemblies for the specified path. If the
 7        assembly has not been loaded yet, it is added to the current AppDomain.
 8    .PARAMETER AssemblyPath
 9        Path to the assembly file to load.
 10#>
 11function Assert-KrAssemblyLoaded {
 12    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')]
 13    [CmdletBinding()]
 14    [OutputType([bool])]
 15    param (
 16        [Parameter(Mandatory = $true)]
 17        [string]$AssemblyPath
 18    )
 019    if (-not (Test-Path -Path $AssemblyPath -PathType Leaf)) {
 020        throw "Assembly not found at path: $AssemblyPath"
 21    }
 022    $assemblyName = [System.Reflection.AssemblyName]::GetAssemblyName($AssemblyPath).Name
 023    $loaded = [AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.GetName().Name -eq $assemblyName }
 024    if (-not $loaded) {
 025        if ($Verbose) {
 026            Write-Verbose "Loading assembly: $AssemblyPath"
 27        }
 28        try {
 029            Add-Type -LiteralPath $AssemblyPath
 30        } catch {
 031            Write-Error "Failed to load assembly: $AssemblyPath"
 032            return $false
 33        }
 34    } else {
 035        if ($Verbose) {
 036            Write-Verbose "Assembly already loaded: $AssemblyPath"
 37        }
 38    }
 039    return $true
 40}
 41

Methods/Properties

Assert-KrAssemblyLoaded()