Modules/businessdev.ALbuild.Apps/Public/Get-BcCodeCoverageSummary.ps1

function Get-BcCodeCoverageSummary {
    <#
    .SYNOPSIS
        Returns the ALbuild code-coverage summary (and per-object lines) without writing report files.
 
    .DESCRIPTION
        A read-only convenience over the coverage data: point it at raw *.dat (with -WorkspaceRoot for the
        honest source-based denominator) or at an existing coverage-summary.json. Returns the same
        { lineCoverage, coveredLines, totalExecutableLines, objectCount, denominatorMode } summary plus the
        per-object breakdown, so agents and scripts can inspect coverage without re-emitting Cobertura/Markdown.
 
    .PARAMETER CoveragePath
        Folder of raw *.dat files (or a single .dat file) from a coverage-enabled test run.
 
    .PARAMETER WorkspaceRoot
        AL source root -- restricts/maps coverage to your app objects and enables the honest denominator.
 
    .PARAMETER SummaryPath
        Alternatively, an existing coverage-summary.json (or its folder) to read back.
 
    .OUTPUTS
        PSCustomObject: Summary, Objects.
    #>

    [CmdletBinding(DefaultParameterSetName = 'Raw')]
    [OutputType([PSCustomObject])]
    param(
        [Parameter(Mandatory, ParameterSetName = 'Raw')] [ValidateNotNullOrEmpty()] [string] $CoveragePath,
        [Parameter(ParameterSetName = 'Raw')] [string] $WorkspaceRoot,
        [Parameter(ParameterSetName = 'Raw')] [ValidateSet('Auto', 'Source', 'CoveredOnly')] [string] $DenominatorMode = 'Auto',
        [Parameter(Mandatory, ParameterSetName = 'Summary')] [ValidateNotNullOrEmpty()] [string] $SummaryPath
    )

    if ($PSCmdlet.ParameterSetName -eq 'Summary') {
        return Resolve-BcCoverageData -SummaryPath $SummaryPath
    }
    $params = @{ CoveragePath = $CoveragePath; DenominatorMode = $DenominatorMode }
    if ($WorkspaceRoot) { $params['WorkspaceRoot'] = $WorkspaceRoot }
    return Resolve-BcCoverageData @params
}