Skip to content

Conversation

raandree
Copy link
Contributor

@raandree raandree commented Oct 8, 2025

Pull Request (PR) description

The formatting in most source files was not according to the guidelines. Fixed formatting with the VSCode Format Document feature.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the file CHANGELOG.md.
    Entry should say what was changed and how that affects users (if applicable), and
    reference the issue being resolved (if applicable).
  • Resource documentation added/updated in README.md.
  • Resource parameter descriptions added/updated in README.md, schema.mof and comment-based
    help.
  • Comment-based help added/updated.
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Community Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
  • New/changed code adheres to DSC Community Style Guidelines.

This change is Reviewable

Copy link

coderabbitai bot commented Oct 8, 2025

Walkthrough

Formatting and style were standardized across the repo (spacing, quoting, negation style). MSFT_xRDGatewayConfiguration and MSFT_xRDServer added/relocated ValidateCustomModeParameters and tightened/changed some Get/Set/Test signatures and validations. Tests and examples were updated for naming/formatting and some mock property names.

Changes

Cohort / File(s) Summary of Changes
Repo formatting & manifests
CHANGELOG.md, .vscode/analyzersettings.psd1, source/xRemoteDesktopSessionHost.psd1, source/Modules/xRemoteDesktopSessionHostCommon.psd1, source/en-US/about_xRemoteDesktopSessionHost.help.txt
Whitespace/indentation and alignment fixes; removed trailing blank line in help; analyzer/manifest reflow; CHANGELOG note added.
Module style normalizations
source/Modules/xRemoteDesktopSessionHostCommon.psm1, source/Modules/*, source/xRemoteDesktopSessionHost.psd1
Minor casing/spacing normalizations (e.g., New-Object casing/spacing), no behavioral changes.
xRDGatewayConfiguration
source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1, tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1
Added helper ValidateCustomModeParameters; tightened Get-TargetResource signature (ConnectionBroker mandatory, added GatewayServer param, ValidateSet for GatewayMode/LogonMethod); refactored validation flow in Set/Get/Test; adjusted warnings/verbose behavior and updated tests/mocks.
xRDServer
source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1, tests/Unit/MSFT_xRDServer.tests.ps1
Introduced/relocated ValidateCustomModeParameters and invoked from Set-TargetResource; added OutputType to Get-TargetResource; standardized quoting/negation and verbose messages; adjusted Add-RDServer diagnostics/error handling; tests reformatted accordingly.
xRDLicense / xRDRemoteApp / xRDCertificate / SessionCollection / SessionCollectionConfiguration / SessionDeployment resources
source/DSCResources/MSFT_xRDLicenseConfiguration/*.psm1, .../MSFT_xRDRemoteApp/*.psm1, .../MSFT_xRDCertificateConfiguration/*.psm1, .../MSFT_xRDSessionCollection/*.psm1, .../MSFT_xRDSessionCollectionConfiguration/*.psm1, .../MSFT_xRDSessionDeployment/*.psm1
Consistent use of -not for negation, single-quoted strings, spacing/ValidateSet/ValidateLength formatting, some hashtable key normalization, ForEach-Object capitalization fixes; primarily cosmetic with no logic change.
Schema whitespace cleanup
.../MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.schema.mof, .../MSFT_xRDConnectionBrokerHAMode/*.schema.mof, .../MSFT_xRDSessionCollection/*.schema.mof, .../MSFT_xRDSessionCollectionConfiguration/*.schema.mof, .../MSFT_xRDSessionDeployment/*.schema.mof
Removed leading blank lines from several .schema.mof files; no schema/member changes.
Examples formatting
source/Examples/Resources/*/*.ps1
Lowercased Configuration/Node to configuration/node, aligned property assignments and spacing; no functional changes.
Unit tests formatting/alignment
tests/Unit/* (many files, e.g., MSFT_xRDCertificateConfiguration.tests.ps1, MSFT_xRDLicenseConfiguration.tests.ps1, MSFT_xRDRemoteApp.tests.ps1, MSFT_xRDSessionCollection.tests.ps1, MSFT_xRDSessionCollectionConfiguration.tests.ps1, MSFT_xRDSessionDeployment.tests.ps1, xRemoteDesktopSessionHost.tests.ps1)
Quote/spacing normalization, Describe/It casing changes, mock property name standardization and minor test-data alignment; test logic/expectations preserved except for textual adjustments to match formatting.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Admin
  participant DSC as DSC Engine
  participant xRDGW as xRDGatewayConfiguration
  participant RDS as RD Cmdlets

  Admin->>DSC: Invoke Set-TargetResource(params)
  DSC->>xRDGW: Set-TargetResource(params)
  xRDGW->>xRDGW: ValidateCustomModeParameters(GatewayMode, ExternalFqdn, LogonMethod, ...)
  alt GatewayMode == 'Custom'
    xRDGW->>RDS: Set-RdDeploymentGatewayConfiguration(GatewayMode, ExternalFqdn, LogonMethod, UseCachedCredentials, BypassLocal, -Force)
    RDS-->>xRDGW: Result / Error
  else GatewayMode != 'Custom'
    xRDGW-->>Admin: Emit warning for ignored Custom-only params
    xRDGW->>RDS: Set-RdDeploymentGatewayConfiguration(GatewayMode, -Force)
    RDS-->>xRDGW: Result / Error
  end
  xRDGW-->>DSC: Return status
  DSC-->>Admin: Completed / Errored
Loading
sequenceDiagram
  autonumber
  actor Admin
  participant DSC as DSC Engine
  participant xRDSrv as xRDServer
  participant RDS as RD Cmdlets

  Admin->>DSC: Invoke Set-TargetResource(Role, GatewayExternalFqdn, ...)
  DSC->>xRDSrv: Set-TargetResource(...)
  xRDSrv->>xRDSrv: ValidateCustomModeParameters(Role, GatewayExternalFqdn)
  alt Role == 'RDS-Gateway' and missing GatewayExternalFqdn
    xRDSrv-->>DSC: Throw validation error
  else Role != 'RDS-Gateway' or FQDN present
    xRDSrv-->>Admin: Possibly warn and ignore non-applicable params
    xRDSrv->>RDS: Add-RDServer(Role, ...)
    RDS-->>xRDSrv: Result / Error
  end
  xRDSrv-->>DSC: Return status
  DSC-->>Admin: Completed / Errored
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Pre-merge checks

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly and concisely indicates that the pull request’s primary focus is correcting formatting issues, which directly matches the extensive formatting changes applied across the codebase.
Linked Issues Check ✅ Passed The pull request directly addresses linked issue #113 by applying formatting fixes across all source files to comply with the DSC Community style guidelines, as evidenced by consistent whitespace, quoting, and alignment adjustments without introducing unrelated functionality.
Out of Scope Changes Check ✅ Passed All modifications are limited to formatting, whitespace alignment, string quoting, and cosmetic consistency across scripts, with no additions of logic, features, or unrelated changes beyond the scope of formatting guidelines.
Description Check ✅ Passed The description explains that most source files were reformatted according to guidelines using VSCode’s Format Document feature, references issue #113, and outlines the changelog update and style guideline adherence tasks, demonstrating clear relevance to the actual changes.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
tests/Unit/MSFT_xRDSessionDeployment.tests.ps1 (1)

75-190: Restore hyphenated Should operators.

The formatter stripped the - from every Should -Be* assertion (e.g., Lines 75, 85, 151, 189). Pester’s dynamic parameters require the hyphen; without it the call becomes Should BeLike/Should Be, which raises “A positional parameter cannot be found that accepts argument…” at runtime and the tests fail. Please revert these to the hyphenated form throughout the file.

-    $serviceWarning | Should BeLike "Failed to start RDMS service. Error: Cannot find any service with service name 'RDMS'*"
+    $serviceWarning | Should -BeLike "Failed to start RDMS service. Error: Cannot find any service with service name 'RDMS'*"
tests/Unit/MSFT_xRDSessionCollection.tests.ps1 (1)

135-147: Replace Assert-MockCalled with Should -Invoke.

The test uses Assert-MockCalled, which violates the guideline. All assertions should use Should -Invoke instead.

As per coding guidelines.

Apply this pattern throughout the file (lines 135, 143, 247, 262, 280, 303, 304, 317):

-                    Assert-MockCalled -CommandName Get-RDSessionCollection -Times 1 -Scope It -ParameterFilter {
+                    Should -Invoke -CommandName Get-RDSessionCollection -Times 1 -Scope It -ParameterFilter {
                         $CollectionName -eq $testCollection[0].Name -and
                         $ConnectionBroker -eq $testConnectionBroker
                     }
tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1 (1)

191-228: Replace Assert-MockCalled with Should -Invoke.

The test uses Assert-MockCalled, which violates the test guidelines. All mock assertions should use Should -Invoke instead.

As per coding guidelines.

Apply this pattern throughout the file (lines 191, 204, 208, 222, 262, 280, 405, 418, 422, 436):

-                    Assert-MockCalled -CommandName Add-RDServer -Times 0 -Scope It
+                    Should -Invoke -CommandName Add-RDServer -Times 0 -Scope It
source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1 (1)

8-72: LGTM! Well-structured validation logic.

The ValidateCustomModeParameters helper function correctly:

  • Validates GatewayMode and related parameters
  • Ensures all required parameters are present for 'Custom' mode
  • Warns about unused parameters for 'DoNotUse' and 'Automatic' modes
  • Improves code maintainability by centralizing validation logic

This is good modularization that follows DSC Community guidelines.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b5bd16 and b27aa64.

📒 Files selected for processing (39)
  • .vscode/analyzersettings.psd1 (1 hunks)
  • CHANGELOG.md (1 hunks)
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1 (3 hunks)
  • source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1 (1 hunks)
  • source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.schema.mof (0 hunks)
  • source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1 (8 hunks)
  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1 (6 hunks)
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 (11 hunks)
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.schema.mof (0 hunks)
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1 (7 hunks)
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1 (5 hunks)
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.schema.mof (0 hunks)
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1 (9 hunks)
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.schema.mof (0 hunks)
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1 (6 hunks)
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.schema.mof (0 hunks)
  • source/Examples/Resources/xRDConnectionBrokerHAMode/1-ConfigureHaMode.ps1 (1 hunks)
  • source/Examples/Resources/xRDGatewayConfiguration/1-CreateGatewayConfiguration.ps1 (1 hunks)
  • source/Examples/Resources/xRDLicenseConfiguration/1-CreateLicenseServer.ps1 (1 hunks)
  • source/Examples/Resources/xRDRemoteApp/1-CreateRemoteApp.ps1 (1 hunks)
  • source/Examples/Resources/xRDServer/1-JoinRDSHost.ps1 (1 hunks)
  • source/Examples/Resources/xRDSessionCollection/1-CreateSessionCollection.ps1 (1 hunks)
  • source/Examples/Resources/xRDSessionCollection/1-xRDSessionCollection_Full.ps1 (1 hunks)
  • source/Examples/Resources/xRDSessionCollectionConfiguration/1-ConfigureSessionCollection.ps1 (1 hunks)
  • source/Examples/Resources/xRDSessionDeployment/1-CreateSessionDeployment.ps1 (1 hunks)
  • source/Examples/Resources/xRDSessionDeployment/1-xRDSessionDeployment_Full.ps1 (1 hunks)
  • source/Modules/xRemoteDesktopSessionHostCommon.psd1 (1 hunks)
  • source/Modules/xRemoteDesktopSessionHostCommon.psm1 (1 hunks)
  • source/en-US/about_xRemoteDesktopSessionHost.help.txt (0 hunks)
  • source/xRemoteDesktopSessionHost.psd1 (2 hunks)
  • tests/Unit/MSFT_xRDCertificateConfiguration.tests.ps1 (8 hunks)
  • tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1 (17 hunks)
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1 (3 hunks)
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1 (7 hunks)
  • tests/Unit/MSFT_xRDServer.tests.ps1 (6 hunks)
  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1 (17 hunks)
  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1 (7 hunks)
  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1 (13 hunks)
  • tests/Unit/xRemoteDesktopSessionHost.tests.ps1 (1 hunks)
💤 Files with no reviewable changes (6)
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.schema.mof
  • source/en-US/about_xRemoteDesktopSessionHost.help.txt
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.schema.mof
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.schema.mof
  • source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.schema.mof
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.schema.mof
🧰 Additional context used
📓 Path-based instructions (8)
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • Command: Public command
  • Function: Private function
  • Resource: DSC class-based resource

Build & Test Workflow Requirements

  • Run PowerShell script files from repository root
  • Setup build and test environment (once per pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File Organization

  • Public commands: source/Public/{CommandName}.ps1
  • Private functions: source/Private/{FunctionName}.ps1
  • Unit tests: tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
  • Integration tests: tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Requirements

  • Follow instructions over existing code patterns
  • Follow PowerShell style and test guideline instructions strictly
  • Always update CHANGELOG.md Unreleased section
  • Localize all strings using string keys; remove any orphaned string keys
  • Check DscResource.Common before creating private functions
  • Separate reusable logic into private functions
  • DSC resources should always be created as class-based resources
  • Add unit tests for all commands/functions/resources
  • Add integration tests for all public commands and resources

Files:

  • source/Examples/Resources/xRDRemoteApp/1-CreateRemoteApp.ps1
  • source/Examples/Resources/xRDServer/1-JoinRDSHost.ps1
  • source/Examples/Resources/xRDConnectionBrokerHAMode/1-ConfigureHaMode.ps1
  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1
  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1
  • source/Examples/Resources/xRDGatewayConfiguration/1-CreateGatewayConfiguration.ps1
  • source/Modules/xRemoteDesktopSessionHostCommon.psm1
  • source/Examples/Resources/xRDSessionCollectionConfiguration/1-ConfigureSessionCollection.ps1
  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • tests/Unit/xRemoteDesktopSessionHost.tests.ps1
  • source/xRemoteDesktopSessionHost.psd1
  • source/Modules/xRemoteDesktopSessionHostCommon.psd1
  • source/Examples/Resources/xRDSessionCollection/1-CreateSessionCollection.ps1
  • tests/Unit/MSFT_xRDServer.tests.ps1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • source/Examples/Resources/xRDSessionCollection/1-xRDSessionCollection_Full.ps1
  • source/Examples/Resources/xRDSessionDeployment/1-xRDSessionDeployment_Full.ps1
  • source/Examples/Resources/xRDLicenseConfiguration/1-CreateLicenseServer.ps1
  • CHANGELOG.md
  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
  • source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1
  • tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/Examples/Resources/xRDSessionDeployment/1-CreateSessionDeployment.ps1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1
{**/*.ps1,**/*.psm1,**/*.psd1}

⚙️ CodeRabbit configuration file

{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell Guidelines

Naming

  • Use descriptive names (3+ characters, no abbreviations)
  • Functions: PascalCase with Verb-Noun format using approved verbs
  • Parameters: PascalCase
  • Variables: camelCase
  • Keywords: lower-case
  • Classes: PascalCase
  • Include scope for script/global/environment variables: $script:, $global:, $env:

File naming

  • Class files: ###.ClassName.ps1 format (e.g. 001.SqlReason.ps1, 004.StartupParameters.ps1)

Formatting

Indentation & Spacing

  • Use 4 spaces (no tabs)
  • One space around operators: $a = 1 + 2
  • One space between type and variable: [String] $name
  • One space between keyword and parenthesis: if ($condition)
  • No spaces on empty lines
  • Try to limit lines to 120 characters

Braces

  • Newline before opening brace (except variable assignments)
  • One newline after opening brace
  • Two newlines after closing brace (one if followed by another brace or continuation)

Quotes

  • Use single quotes unless variable expansion is needed: 'text' vs "text $variable"

Arrays

  • Single line: @('one', 'two', 'three')
  • Multi-line: each element on separate line with proper indentation
  • Do not use the unary comma operator (,) in return statements to force
    an array

Hashtables

  • Empty: @{}
  • Each property on separate line with proper indentation
  • Properties: Use PascalCase

Comments

  • Single line: # Comment (capitalized, on own line)
  • Multi-line: <# Comment #> format (opening and closing brackets on own line), and indent text
  • No commented-out code

Comment-based help

  • Always add comment-based help to all functions and scripts
  • Comment-based help: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class
  • Comment-based help indentation: keywords 4 spaces, text 8 spaces
  • Include examples for all parameter sets and combinations
  • INPUTS: List each pipeline‑accepted type (one per line) with a 1‑line description...

Files:

  • source/Examples/Resources/xRDRemoteApp/1-CreateRemoteApp.ps1
  • source/Examples/Resources/xRDServer/1-JoinRDSHost.ps1
  • source/Examples/Resources/xRDConnectionBrokerHAMode/1-ConfigureHaMode.ps1
  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1
  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1
  • source/Examples/Resources/xRDGatewayConfiguration/1-CreateGatewayConfiguration.ps1
  • source/Modules/xRemoteDesktopSessionHostCommon.psm1
  • source/Examples/Resources/xRDSessionCollectionConfiguration/1-ConfigureSessionCollection.ps1
  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • tests/Unit/xRemoteDesktopSessionHost.tests.ps1
  • source/xRemoteDesktopSessionHost.psd1
  • source/Modules/xRemoteDesktopSessionHostCommon.psd1
  • source/Examples/Resources/xRDSessionCollection/1-CreateSessionCollection.ps1
  • tests/Unit/MSFT_xRDServer.tests.ps1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • source/Examples/Resources/xRDSessionCollection/1-xRDSessionCollection_Full.ps1
  • source/Examples/Resources/xRDSessionDeployment/1-xRDSessionDeployment_Full.ps1
  • source/Examples/Resources/xRDLicenseConfiguration/1-CreateLicenseServer.ps1
  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
  • source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1
  • tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/Examples/Resources/xRDSessionDeployment/1-CreateSessionDeployment.ps1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1
source/**/*.ps1

⚙️ CodeRabbit configuration file

source/**/*.ps1: # Localization Guidelines

Requirements

  • Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages
  • Use localized string keys, not hardcoded strings
  • Assume $script:localizedData is available

String Files

  • Commands/functions: source/en-US/{MyModuleName}.strings.psd1
  • Class resources: source/en-US/{ResourceClassName}.strings.psd1

Key Naming Patterns

  • Format: Verb_FunctionName_Action (underscore separators), e.g. Get_Database_ConnectingToDatabase

String Format

ConvertFrom-StringData @'
    KeyName = Message with {0} placeholder. (PREFIX0001)
'@

String IDs

  • Format: (PREFIX####)
  • PREFIX: First letter of each word in class or function name (SqlSetup → SS, Get-SqlDscDatabase → GSDD)
  • Number: Sequential from 0001

Usage

Write-Verbose -Message ($script:localizedData.KeyName -f $value1)

Files:

  • source/Examples/Resources/xRDRemoteApp/1-CreateRemoteApp.ps1
  • source/Examples/Resources/xRDServer/1-JoinRDSHost.ps1
  • source/Examples/Resources/xRDConnectionBrokerHAMode/1-ConfigureHaMode.ps1
  • source/Examples/Resources/xRDGatewayConfiguration/1-CreateGatewayConfiguration.ps1
  • source/Examples/Resources/xRDSessionCollectionConfiguration/1-ConfigureSessionCollection.ps1
  • source/Examples/Resources/xRDSessionCollection/1-CreateSessionCollection.ps1
  • source/Examples/Resources/xRDSessionCollection/1-xRDSessionCollection_Full.ps1
  • source/Examples/Resources/xRDSessionDeployment/1-xRDSessionDeployment_Full.ps1
  • source/Examples/Resources/xRDLicenseConfiguration/1-CreateLicenseServer.ps1
  • source/Examples/Resources/xRDSessionDeployment/1-CreateSessionDeployment.ps1
tests/[Uu]nit/**/*.[Tt]ests.ps1

⚙️ CodeRabbit configuration file

tests/[Uu]nit/**/*.[Tt]ests.ps1: # Unit Tests Guidelines

  • Test with localized strings: Use InModuleScope -ScriptBlock { $script:localizedData.Key }
  • Mock files: Use $TestDrive variable (path to the test drive)
  • All public commands require parameter set validation tests
  • After modifying classes, always run tests in new session (for changes to take effect)

Test Setup Requirements

Use this exact setup block before Describe:

[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')]
param ()

BeforeDiscovery {
    try
    {
        if (-not (Get-Module -Name 'DscResource.Test'))
        {
            # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task.
            if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable))
            {
                # Redirect all streams to $null, except the error stream (stream 2)
                & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
            }

            # If the dependencies have not been resolved, this will throw an error.
            Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop'
        }
    }
    catch [System.IO.FileNotFoundException]
    {
        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.'
    }
}

BeforeAll {
    $script:moduleName = '{MyModuleName}'

    Import-Module -Name $script:moduleName -Force -ErrorAction 'Stop'

    $PSDefaultParameterValues['InModuleScope:ModuleName'] = $script:moduleName
    $PSDefaultParameterValues['Mock:ModuleName'] = $script:moduleName
    $PSDefaultParameterValues['Should:ModuleName'] = $script:moduleName
}

AfterAll {
    $PSDefaultParameterValues.Remove('InModuleScope:ModuleName')
    $PSDefaultParameterValues.Remove('Mock:ModuleNam...

Files:

  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1
  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1
  • tests/Unit/xRemoteDesktopSessionHost.tests.ps1
  • tests/Unit/MSFT_xRDServer.tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
**/*.[Tt]ests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core Requirements

  • All public commands, private functions and classes must have unit tests
  • All public commands and class-based resources must have integration tests
  • Use Pester v5 syntax only
  • Test code only inside Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions start with 'Should', must not contain 'when'
  • Mock variables prefix: 'mock'

Structure & Scope

  • Public commands: Never use InModuleScope (unless retrieving localized strings)
  • Private functions/class resources: Always use InModuleScope
  • Each class method = separate Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Use -BeTrue/-BeFalse never -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
  • Omit -ModuleName parameter on Pester commands
  • Never use Mock inside `InModuleSc...

Files:

  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1
  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1
  • tests/Unit/xRemoteDesktopSessionHost.tests.ps1
  • tests/Unit/MSFT_xRDServer.tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
source/DSCResources/**/*.psm1

⚙️ CodeRabbit configuration file

source/DSCResources/**/*.psm1: # MOF-based Desired State Configuration (DSC) Resources Guidelines

Required Functions

  • Every DSC resource must define: Get-TargetResource, Set-TargetResource, Test-TargetResource
  • Export using *-TargetResource pattern

Function Return Types

  • Get-TargetResource: Must return hashtable with all resource properties
  • Test-TargetResource: Must return boolean ($true/$false)
  • Set-TargetResource: Must not return anything (void)

Parameter Guidelines

  • Get-TargetResource: Only include parameters needed to retrieve actual current state values
  • Get-TargetResource: Remove non-mandatory parameters that are never used
  • Set-TargetResource and Test-TargetResource: Must have identical parameters
  • Set-TargetResource and Test-TargetResource: Unused mandatory parameters: Add "Not used in <function_name>" to help comment

Required Elements

  • Each function must include Write-Verbose at least once
    • Get-TargetResource: Use verbose message starting with "Getting the current state of..."
    • Set-TargetResource: Use verbose message starting with "Setting the desired state of..."
    • Test-TargetResource: Use verbose message starting with "Determining the current state of..."
  • Use localized strings for all messages (Write-Verbose, Write-Error, etc.)
  • Import localized strings using Get-LocalizedData at module top

Error Handling

Files:

  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
  • source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
  • source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1
**/*.md

⚙️ CodeRabbit configuration file

**/*.md: # Markdown Style Guidelines

  • Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
  • Use 2 spaces for indentation
  • Use '1.' for all items in ordered lists (1/1/1 numbering style)
  • Disable MD013 rule by adding a comment for tables/code blocks exceeding 80 characters
  • Empty lines required before/after code blocks and headings (except before line 1)
  • Escape backslashes in file paths only (not in code blocks)
  • Code blocks must specify language identifiers

Text Formatting

  • Parameters: bold
  • Values/literals: inline code
  • Resource/module/product names: italic
  • Commands/files/paths: inline code

Files:

  • CHANGELOG.md
CHANGELOG.md

⚙️ CodeRabbit configuration file

CHANGELOG.md: # Changelog Guidelines

  • Always update the Unreleased section in CHANGELOG.md
  • Use Keep a Changelog format
  • Describe notable changes briefly, ≤2 items per change type
  • Reference issues using format issue #<issue_number>
  • No empty lines between list items in same section
  • Skip adding entry if same change already exists in Unreleased section
  • No duplicate sections or items in Unreleased section

Files:

  • CHANGELOG.md
🧠 Learnings (19)
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Include the exact Pester setup block before Describe: SuppressMessage attribute with param (); BeforeDiscovery to ensure DscResource.Test is available (fallback to build.ps1 -Tasks 'noop') and Import-Module; BeforeAll to set $script:moduleName, import the module, and set PSDefaultParameterValues for InModuleScope/Mock/Should; AfterAll to remove those defaults and unload the tested module

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1
  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDServer.tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
📚 Learning: 2025-08-09T19:29:36.323Z
Learnt from: johlju
PR: dsccommunity/DscResource.Test#167
File: source/Private/Test-FileContainsClassResource.ps1:44-56
Timestamp: 2025-08-09T19:29:36.323Z
Learning: In the DscResource.Test repository, DSC resource attributes are consistently written as `[DscResource(...)]` rather than using variations like `[DscResourceAttribute()]` or fully qualified names like `[Microsoft.PowerShell.DesiredStateConfiguration.DscResource()]`. The Test-FileContainsClassResource function should focus on detecting the standard `[DscResource(...)]` pattern that is actually used in the codebase.

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource and Test-TargetResource must have identical parameters

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1
  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • tests/Unit/MSFT_xRDServer.tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource must not return anything (void)

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1
  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • tests/Unit/MSFT_xRDServer.tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDCertificateConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource: Write-Verbose message should start with "Setting the desired state of..."

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1
  • tests/Unit/MSFT_xRDServer.tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Test-TargetResource must return a boolean ($true/$false)

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollection.tests.ps1
  • tests/Unit/MSFT_xRDServer.tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
  • source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1
📚 Learning: 2025-09-23T10:20:59.832Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-23T10:20:59.832Z
Learning: Resource class constructor must be: MyResourceName() : base () { } (no $PSScriptRoot parameter)

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Each scenario gets a separate Context block

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use nested Context blocks for complex scenarios

Applied to files:

  • tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Get-TargetResource must return a hashtable containing all resource properties

Applied to files:

  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Export resource functions using the *-TargetResource naming pattern

Applied to files:

  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Every MOF DSC resource module must define the functions: Get-TargetResource, Set-TargetResource, and Test-TargetResource

Applied to files:

  • source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1
  • tests/Unit/MSFT_xRDServer.tests.ps1
  • tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1
  • source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
📚 Learning: 2025-10-04T21:33:23.022Z
Learnt from: dan-hughes
PR: dsccommunity/UpdateServicesDsc#85
File: source/en-US/UpdateServicesDsc.strings.psd1:1-2
Timestamp: 2025-10-04T21:33:23.022Z
Learning: In UpdateServicesDsc (and similar DSC modules), the module-level localization file (source/en-US/<ModuleName>.strings.psd1) can be empty when DSC resources have their own localization files in source/DSCResources/<ResourceName>/en-US/DSC_<ResourceName>.strings.psd1. Automated tests verify localization completeness for resources. Don't flag empty module-level localization files as issues when resources have separate localization.

Applied to files:

  • tests/Unit/MSFT_xRDServer.tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Each of Get-/Set-/Test-TargetResource must include at least one Write-Verbose call

Applied to files:

  • tests/Unit/MSFT_xRDServer.tests.ps1
  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Import localized strings at the top of the module using Get-LocalizedData

Applied to files:

  • source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Get-TargetResource: remove non-mandatory parameters that are never used

Applied to files:

  • tests/Unit/MSFT_xRDRemoteApp.tests.ps1
  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Test-TargetResource: Write-Verbose message should start with "Determining the current state of..."

Applied to files:

  • source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1
  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Get-TargetResource parameters: include only those needed to retrieve actual current state values

Applied to files:

  • source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1
📚 Learning: 2025-09-16T16:34:27.319Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-16T16:34:27.319Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Verbose for high-level execution flow and user-actionable information

Applied to files:

  • source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: dsccommunity.xRemoteDesktopSessionHost (Build Package Module)
🔇 Additional comments (44)
source/Examples/Resources/xRDRemoteApp/1-CreateRemoteApp.ps1 (2)

6-6: Verify lowercase DSC keywords align with project conventions.

The Configuration and Node keywords have been changed to lowercase (configuration, node). While the PR states this follows DSC Community format guidelines, these constructs are typically PascalCase in standard DSC conventions. Please confirm this casing is intentional and consistent with your project's style standards.

Also applies to: 11-11


14-24: LGTM!

Property alignment changes improve readability without altering functionality.

source/Examples/Resources/xRDServer/1-JoinRDSHost.ps1 (2)

6-6: Verify lowercase DSC keywords align with project conventions.

Same concern as in the previous file: Configuration and Node changed to lowercase. Confirm this is consistent with DSC Community guidelines for this project.

Also applies to: 10-10


14-15: LGTM!

Property alignment improves consistency.

source/Examples/Resources/xRDSessionCollectionConfiguration/1-ConfigureSessionCollection.ps1 (2)

6-6: Verify lowercase DSC keywords align with project conventions.

Consistent with other example files, but please confirm the lowercase configuration and node keywords match your DSC Community style standards.

Also applies to: 10-10


13-33: LGTM!

Property alignment enhances readability without functional changes.

source/Examples/Resources/xRDLicenseConfiguration/1-CreateLicenseServer.ps1 (1)

6-6: LGTM with verification.

Formatting changes are consistent with the broader PR. Ensure the lowercase DSC keywords match project standards.

Also applies to: 11-11, 15-16

source/Examples/Resources/xRDSessionDeployment/1-CreateSessionDeployment.ps1 (1)

6-6: LGTM with verification.

All formatting changes are consistent with the PR's objectives. Confirm DSC keyword casing aligns with your style guidelines.

Also applies to: 10-10, 13-13, 15-15

source/Examples/Resources/xRDSessionCollection/1-xRDSessionCollection_Full.ps1 (1)

29-30: LGTM!

Property alignment is consistent with formatting improvements throughout the PR.

tests/Unit/MSFT_xRDSessionCollectionConfiguration.tests.ps1 (3)

1-2: LGTM!

Variable alignment improves readability.

Also applies to: 32-32


55-55: LGTM!

Mock structure formatting is clear and consistent.

Also applies to: 72-72


74-79: LGTM!

Pester syntax updates correctly apply:

  • PascalCase for It and Should commands
  • Single-quote standardization in test descriptions
  • Context naming consistency

All changes are formatting-only with no functional impact.

Also applies to: 82-94, 96-136, 147-153, 155-166, 168-244, 280-332

tests/Unit/xRemoteDesktopSessionHost.tests.ps1 (3)

25-25: LGTM!

Single-quote usage in Describe block aligns with PowerShell guidelines.


27-27: LGTM!

New-Object casing is now consistent with PowerShell conventions.

Also applies to: 33-33, 39-39, 45-45


28-30: LGTM!

Pester syntax updated correctly:

  • PascalCase It and Should commands
  • Proper formatting per Pester v5 guidelines

Also applies to: 34-36, 40-42, 46-48

tests/Unit/MSFT_xRDSessionCollection.tests.ps1 (1)

1-426: LGTM: Formatting improvements are consistent.

The formatting changes (single-quote usage, alignment, spacing) align with the DSC Community Style Guidelines and improve consistency.

source/DSCResources/MSFT_xRDCertificateConfiguration/MSFT_xRDCertificateConfiguration.psm1 (2)

2-5: LGTM: Negation style improvement.

The change from !(Test-...) to -not (Test-...) improves readability and aligns with PowerShell best practices.


73-79: LGTM: Hashtable alignment improvement.

The alignment changes improve code readability while maintaining identical behavior.

source/DSCResources/MSFT_xRDConnectionBrokerHAMode/MSFT_xRDConnectionBrokerHAMode.psm1 (1)

2-5: LGTM: Consistent negation style.

The negation style change is consistent with other resources in the PR and aligns with PowerShell best practices.

source/Examples/Resources/xRDSessionCollection/1-CreateSessionCollection.ps1 (1)

6-19: LGTM: Keyword casing and alignment improvements.

The keyword casing changes (configuration, node) and property alignment align with the PowerShell style guidelines for consistent formatting.

As per coding guidelines.

source/Examples/Resources/xRDGatewayConfiguration/1-CreateGatewayConfiguration.ps1 (1)

6-22: LGTM: Consistent formatting with other examples.

The keyword casing and alignment changes are consistent with other example files in the PR and follow the PowerShell style guidelines.

tests/Unit/MSFT_xRDGatewayConfiguration.tests.ps1 (1)

1-454: LGTM: Formatting improvements are consistent.

The formatting changes (single-quote usage, hashtable alignment, property naming consistency) align with the DSC Community Style Guidelines.

source/DSCResources/MSFT_xRDSessionCollection/MSFT_xRDSessionCollection.psm1 (3)

2-5: LGTM: Consistent negation style.

The negation style change is consistent with other resources in the PR.


29-62: LGTM: Formatting improvements enhance consistency.

The changes to verbose messages (single quotes), Where-Object syntax, and hashtable formatting improve code consistency without altering behavior.


115-137: LGTM: String formatting improvement.

The change to use string interpolation with -f operator is cleaner and aligns with PowerShell best practices.

source/DSCResources/MSFT_xRDSessionDeployment/MSFT_xRDSessionDeployment.psm1 (2)

2-6: LGTM: Consistent OS requirement check.

The negation style change is consistent with other resources in the PR and improves readability.


26-94: LGTM: Comprehensive formatting improvements.

The changes to verbose messages, hashtable formatting, SuppressMessageAttribute syntax, and role literals all align with the PowerShell style guidelines and improve consistency.

source/DSCResources/MSFT_xRDSessionCollectionConfiguration/MSFT_xRDSessionCollectionConfiguration.psm1 (4)

10-13: LGTM! Improved OS requirement check style.

The change from if (!(Test-...)) to if (-not (Test-...)) with single-quoted throw message improves readability and aligns with PowerShell best practices.


26-27: LGTM! Improved parameter attribute formatting.

The added spacing in ValidateLength attributes (e.g., [ValidateLength(1, 256)]) improves readability.

Also applies to: 136-137, 299-300


79-125: LGTM! Improved formatting and consistency.

The changes enhance readability through:

  • Single-quoted verbose messages
  • Aligned hashtable keys
  • Explicit Add calls for UserProfileDisk properties on Windows Server 2016+

The UserProfileDisk configuration block is well-structured and correctly conditional on OS version.


246-254: LGTM! Improved hashtable alignment.

The aligned key-value pairs in the splat hashtable improve code readability.

source/DSCResources/MSFT_xRDServer/MSFT_xRDServer.psm1 (2)

2-5: LGTM! Consistent style improvements.

The changes improve consistency:

  • -not style for OS requirement checks
  • Single-quoted strings in ValidateSet attributes
  • Single-quoted throw messages

Also applies to: 80-80, 161-161, 243-243


178-178: LGTM! Proper validation integration.

The call to ValidateCustomModeParameters correctly validates parameters before proceeding with Add-RDServer operations.

source/DSCResources/MSFT_xRDGatewayConfiguration/MSFT_xRDGatewayConfiguration.psm1 (2)

13-13: LGTM! Consistent ValidateSet formatting.

The single-quoted strings in ValidateSet attributes align with PowerShell style guidelines and improve consistency across the codebase.

Also applies to: 98-100, 175-175, 184-184, 299-299, 304-304


255-265: LGTM! Clear parameter handling for Custom mode.

The explicit splat hashtable with Force and ErrorAction parameters provides clear, maintainable configuration for Custom mode gateway settings.

tests/Unit/MSFT_xRDServer.tests.ps1 (2)

1-2: LGTM! Consistent variable formatting.

The standardized spacing around assignments improves readability.

Also applies to: 32-32


41-44: LGTM! Improved hashtable readability.

The formatted Roles arrays with consistent indentation enhance code clarity.

Also applies to: 79-83, 101-104

tests/Unit/MSFT_xRDRemoteApp.tests.ps1 (1)

1-2: LGTM! Formatting improvements.

The standardized spacing and alignment improve test readability.

Also applies to: 34-34, 39-42

tests/Unit/MSFT_xRDLicenseConfiguration.tests.ps1 (2)

1-2: LGTM! Consistent formatting.

The standardized variable assignments improve readability.

Also applies to: 32-32


52-68: LGTM! Improved mock data formatting.

The single-quoted strings and aligned hashtable keys enhance test clarity.

source/DSCResources/MSFT_xRDLicenseConfiguration/MSFT_xRDLicenseConfiguration.psm1 (2)

2-5: LGTM! Consistent style improvements.

The changes align with PowerShell best practices:

  • -not style for OS checks
  • Single-quoted strings in ValidateSet attributes
  • Single-quoted verbose and throw messages

Also applies to: 26-26, 75-75, 118-118


46-50: LGTM! Improved hashtable formatting.

The unquoted keys and consistent alignment improve readability while maintaining functionality.

source/DSCResources/MSFT_xRDRemoteApp/MSFT_xRDRemoteApp.psm1 (2)

10-13: LGTM! Comprehensive formatting improvements.

The changes enhance consistency:

  • -not style for OS requirement check
  • Spacing in ValidateLength attributes
  • Single-quoted strings in ValidateSet attributes
  • Single-quoted throw message

These align with DSC Community Style Guidelines.

Also applies to: 26-26, 35-35, 42-42, 104-104, 113-113, 120-120, 170-170, 179-179, 186-186


68-92: LGTM! Improved hashtable formatting.

The aligned key-value pairs and consistent spacing enhance readability while maintaining the same return structure.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tests/Unit/MSFT_xRDSessionDeployment.tests.ps1 (2)

1-27: Replace deprecated test setup with required Pester v5 setup blocks.

The test file uses the deprecated Invoke-TestSetup/Invoke-TestCleanup pattern instead of the required Pester v5 setup blocks specified in the coding guidelines. The guidelines mandate using BeforeDiscovery, BeforeAll, and AfterAll blocks with specific structure.

Replace lines 1-27 with the required setup pattern:

-$script:DSCModuleName = 'xRemoteDesktopSessionHost'
-$script:DSCResourceName = 'MSFT_xRDSessionDeployment'
-
-function Invoke-TestSetup
-{
-    try
-    {
-        Import-Module -Name DscResource.Test -Force
-    }
-    catch [System.IO.FileNotFoundException]
-    {
-        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.'
-    }
-
-    $script:testEnvironment = Initialize-TestEnvironment `
-        -DSCModuleName $script:dscModuleName `
-        -DscResourceName $script:dscResourceName `
-        -ResourceType 'Mof' `
-        -TestType 'Unit'
-}
-
-function Invoke-TestCleanup
-{
-    Restore-TestEnvironment -TestEnvironment $script:testEnvironment
-}
-
-Invoke-TestSetup
+[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')]
+param ()
+
+BeforeDiscovery {
+    try
+    {
+        if (-not (Get-Module -Name 'DscResource.Test'))
+        {
+            # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task.
+            if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable))
+            {
+                # Redirect all streams to $null, except the error stream (stream 2)
+                & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
+            }
+
+            # If the dependencies have not been resolved, this will throw an error.
+            Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop'
+        }
+    }
+    catch [System.IO.FileNotFoundException]
+    {
+        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.'
+    }
+}
+
+BeforeAll {
+    $script:moduleName = 'xRemoteDesktopSessionHost'
+
+    Import-Module -Name $script:moduleName -Force -ErrorAction 'Stop'
+
+    $PSDefaultParameterValues['InModuleScope:ModuleName'] = $script:moduleName
+    $PSDefaultParameterValues['Mock:ModuleName'] = $script:moduleName
+    $PSDefaultParameterValues['Should:ModuleName'] = $script:moduleName
+}
+
+AfterAll {
+    $PSDefaultParameterValues.Remove('InModuleScope:ModuleName')
+    $PSDefaultParameterValues.Remove('Mock:ModuleName')
+    $PSDefaultParameterValues.Remove('Should:ModuleName')
+
+    # Unload the module being tested so that it doesn't impact any other tests.
+    Get-Module -Name $script:moduleName -All | Remove-Module -Force
+}

Based on learnings.


70-70: Replace deprecated Assert-MockCalled with Should -Invoke.

The test file uses the deprecated Pester v4 Assert-MockCalled cmdlet. Per coding guidelines, use Should -Invoke instead.

Example conversion for line 70:

-                    Assert-MockCalled -CommandName Get-Service -Times 1
+                    Should -Invoke -CommandName Get-Service -Times 1 -Exactly

Apply similar changes to all Assert-MockCalled calls throughout the file (lines 70, 120, 140, 154, 171, 176, 189).

As per coding guidelines.

Also applies to: 120-120, 140-140, 154-157, 171-176, 189-189

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 16342b7 and d89090b.

📒 Files selected for processing (1)
  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1 (16 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • Command: Public command
  • Function: Private function
  • Resource: DSC class-based resource

Build & Test Workflow Requirements

  • Run PowerShell script files from repository root
  • Setup build and test environment (once per pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File Organization

  • Public commands: source/Public/{CommandName}.ps1
  • Private functions: source/Private/{FunctionName}.ps1
  • Unit tests: tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
  • Integration tests: tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Requirements

  • Follow instructions over existing code patterns
  • Follow PowerShell style and test guideline instructions strictly
  • Always update CHANGELOG.md Unreleased section
  • Localize all strings using string keys; remove any orphaned string keys
  • Check DscResource.Common before creating private functions
  • Separate reusable logic into private functions
  • DSC resources should always be created as class-based resources
  • Add unit tests for all commands/functions/resources
  • Add integration tests for all public commands and resources

Files:

  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
tests/[Uu]nit/**/*.[Tt]ests.ps1

⚙️ CodeRabbit configuration file

tests/[Uu]nit/**/*.[Tt]ests.ps1: # Unit Tests Guidelines

  • Test with localized strings: Use InModuleScope -ScriptBlock { $script:localizedData.Key }
  • Mock files: Use $TestDrive variable (path to the test drive)
  • All public commands require parameter set validation tests
  • After modifying classes, always run tests in new session (for changes to take effect)

Test Setup Requirements

Use this exact setup block before Describe:

[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')]
param ()

BeforeDiscovery {
    try
    {
        if (-not (Get-Module -Name 'DscResource.Test'))
        {
            # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task.
            if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable))
            {
                # Redirect all streams to $null, except the error stream (stream 2)
                & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
            }

            # If the dependencies have not been resolved, this will throw an error.
            Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop'
        }
    }
    catch [System.IO.FileNotFoundException]
    {
        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.'
    }
}

BeforeAll {
    $script:moduleName = '{MyModuleName}'

    Import-Module -Name $script:moduleName -Force -ErrorAction 'Stop'

    $PSDefaultParameterValues['InModuleScope:ModuleName'] = $script:moduleName
    $PSDefaultParameterValues['Mock:ModuleName'] = $script:moduleName
    $PSDefaultParameterValues['Should:ModuleName'] = $script:moduleName
}

AfterAll {
    $PSDefaultParameterValues.Remove('InModuleScope:ModuleName')
    $PSDefaultParameterValues.Remove('Mock:ModuleNam...

Files:

  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
{**/*.ps1,**/*.psm1,**/*.psd1}

⚙️ CodeRabbit configuration file

{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell Guidelines

Naming

  • Use descriptive names (3+ characters, no abbreviations)
  • Functions: PascalCase with Verb-Noun format using approved verbs
  • Parameters: PascalCase
  • Variables: camelCase
  • Keywords: lower-case
  • Classes: PascalCase
  • Include scope for script/global/environment variables: $script:, $global:, $env:

File naming

  • Class files: ###.ClassName.ps1 format (e.g. 001.SqlReason.ps1, 004.StartupParameters.ps1)

Formatting

Indentation & Spacing

  • Use 4 spaces (no tabs)
  • One space around operators: $a = 1 + 2
  • One space between type and variable: [String] $name
  • One space between keyword and parenthesis: if ($condition)
  • No spaces on empty lines
  • Try to limit lines to 120 characters

Braces

  • Newline before opening brace (except variable assignments)
  • One newline after opening brace
  • Two newlines after closing brace (one if followed by another brace or continuation)

Quotes

  • Use single quotes unless variable expansion is needed: 'text' vs "text $variable"

Arrays

  • Single line: @('one', 'two', 'three')
  • Multi-line: each element on separate line with proper indentation
  • Do not use the unary comma operator (,) in return statements to force
    an array

Hashtables

  • Empty: @{}
  • Each property on separate line with proper indentation
  • Properties: Use PascalCase

Comments

  • Single line: # Comment (capitalized, on own line)
  • Multi-line: <# Comment #> format (opening and closing brackets on own line), and indent text
  • No commented-out code

Comment-based help

  • Always add comment-based help to all functions and scripts
  • Comment-based help: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class
  • Comment-based help indentation: keywords 4 spaces, text 8 spaces
  • Include examples for all parameter sets and combinations
  • INPUTS: List each pipeline‑accepted type (one per line) with a 1‑line description...

Files:

  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
**/*.[Tt]ests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core Requirements

  • All public commands, private functions and classes must have unit tests
  • All public commands and class-based resources must have integration tests
  • Use Pester v5 syntax only
  • Test code only inside Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions start with 'Should', must not contain 'when'
  • Mock variables prefix: 'mock'

Structure & Scope

  • Public commands: Never use InModuleScope (unless retrieving localized strings)
  • Private functions/class resources: Always use InModuleScope
  • Each class method = separate Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Use -BeTrue/-BeFalse never -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
  • Omit -ModuleName parameter on Pester commands
  • Never use Mock inside `InModuleSc...

Files:

  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
🧠 Learnings (2)
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Include the exact Pester setup block before Describe: SuppressMessage attribute with param (); BeforeDiscovery to ensure DscResource.Test is available (fallback to build.ps1 -Tasks 'noop') and Import-Module; BeforeAll to set $script:moduleName, import the module, and set PSDefaultParameterValues for InModuleScope/Mock/Should; AfterAll to remove those defaults and unload the tested module

Applied to files:

  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid try/catch/finally for cleanup; use AfterAll or AfterEach

Applied to files:

  • tests/Unit/MSFT_xRDSessionDeployment.tests.ps1
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: dsccommunity.xRemoteDesktopSessionHost (Build Package Module)
🔇 Additional comments (2)
tests/Unit/MSFT_xRDSessionDeployment.tests.ps1 (2)

63-64: LGTM: String literal formatting.

The conversion from double quotes to single quotes for string literals is correct and follows the PowerShell style guideline to "use single quotes unless variable expansion is needed."

Also applies to: 75-76, 124-125, 129-130


398-405: LGTM: Exception handling pattern.

The catch/finally pattern correctly ensures that exceptions are propagated while cleanup is always performed. This is an acceptable approach for test teardown.

@raandree
Copy link
Contributor Author

@johlju, can you have a quick look at this, please. I want to create one or two other PRs for fixing some bugs. Thanks!

@raandree raandree self-assigned this Oct 13, 2025
@raandree raandree added enhancement The issue is an enhancement request. documentation The issue is related to documentation only. labels Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation The issue is related to documentation only. enhancement The issue is an enhancement request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The DSC Community format guidelines are not implemented

1 participant