< Summary - Kestrun — Combined Coverage

Information
Class: Public.Razor.Add-KrRazorPageService
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Razor/Add-KrRazorPageService.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 11
Coverable lines: 11
Total lines: 73
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: 0% (0/11) Total lines: 70 Tag: Kestrun/Kestrun@07f821172e5dc3657f1be7e6818f18d6721cf38a09/04/2025 - 22:37:32 Line coverage: 0% (0/11) Total lines: 71 Tag: Kestrun/Kestrun@afb7aadc0a8a42bfa2b51ea62c8a6e2cf63faec609/08/2025 - 20:34:03 Line coverage: 0% (0/13) Total lines: 77 Tag: Kestrun/Kestrun@3790ee5884494a7a2a829344a47743e0bf492e7210/13/2025 - 16:52:37 Line coverage: 0% (0/11) Total lines: 73 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Razor/Add-KrRazorPageService.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Adds Razor Pages service to the server.
 4    .DESCRIPTION
 5        This cmdlet allows you to register Razor Pages with the Kestrun server.
 6        It can be used to serve dynamic web pages using Razor syntax.
 7    .PARAMETER Server
 8        The Kestrun server instance to which the Razor Pages service will be added.
 9    .PARAMETER Options
 10        The RazorPagesOptions to configure the Razor Pages service.
 11    .PARAMETER RootDirectory
 12        The root directory for the Razor Pages.
 13    .PARAMETER Conventions
 14        An array of page conventions to apply to the Razor Pages.
 15    .PARAMETER PassThru
 16        If specified, the cmdlet will return the modified server instance.
 17    .EXAMPLE
 18        $server | Add-KrRazorPageService -RootDirectory '/Pages' -Conventions $conventions
 19        This example adds Razor Pages service to the server, specifying the root directory and conventions for the pages
 20    .EXAMPLE
 21        $server | Add-KrRazorPageService -Options $options
 22        This example adds Razor Pages service to the server using the specified RazorPagesOptions.
 23    .LINK
 24        https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.razorpages.razorpagesoptions?view=aspnetco
 25    .NOTES
 26        This cmdlet is used to register Razor Pages with the Kestrun server, allowing you to serve dynamic web pages usi
 27#>
 28function Add-KrRazorPageService {
 29    [KestrunRuntimeApi('Definition')]
 30    [CmdletBinding(defaultParameterSetName = 'Items')]
 31    [OutputType([Kestrun.Hosting.KestrunHost])]
 32    param(
 33        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 34        [Kestrun.Hosting.KestrunHost]$Server,
 35
 36        [Parameter(Mandatory = $true, ParameterSetName = 'Options')]
 37        [Microsoft.AspNetCore.Mvc.RazorPages.RazorPagesOptions]$Options,
 38
 39        [Parameter(ParameterSetName = 'Items')]
 40        [string]$RootDirectory,
 41
 42        [Parameter(ParameterSetName = 'Items')]
 43        [Microsoft.AspNetCore.Mvc.ApplicationModels.IPageConvention[]]$Conventions = @(),
 44
 45        [Parameter()]
 46        [switch]$PassThru
 47    )
 48    begin {
 49        # Ensure the server instance is resolved
 050        $Server = Resolve-KestrunServer -Server $Server
 51    }
 52    process {
 053        if ($PSCmdlet.ParameterSetName -eq 'Items') {
 054            $Options = [Microsoft.AspNetCore.Mvc.RazorPages.RazorPagesOptions]::new()
 055            if (-not [string]::IsNullOrWhiteSpace($RootDirectory)) {
 056                $Options.RootDirectory = $RootDirectory
 57            }
 058            if ($Conventions.Count -gt 0) {
 059                foreach ($c in $Conventions) {
 060                    $Options.Conventions.Add($c)
 61                }
 62            }
 63        }
 64
 065        [Kestrun.Hosting.KestrunHostRazorExtensions]::AddRazorPages($Server, $Options) | Out-Null
 66
 067        if ($PassThru.IsPresent) {
 68            # if the PassThru switch is specified, return the modified server instance
 069            return $Server
 70        }
 71    }
 72}
 73

Methods/Properties

Add-KrRazorPageService()