Skip to content

Replace null-coalescing operators with PS5.1-compatible syntax#443

Merged
HeyItsGilbert merged 4 commits intov2from
copilot/fix-null-coalescing-issue
Feb 12, 2026
Merged

Replace null-coalescing operators with PS5.1-compatible syntax#443
HeyItsGilbert merged 4 commits intov2from
copilot/fix-null-coalescing-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 12, 2026

Plaster v2.0.0-alpha uses the null-coalescing operator (??) introduced in PowerShell 7.0, breaking compatibility with PowerShell 5.1 as specified in the module manifest.

Changes

Write-PlasterLog.ps1

  • Replaced ?? operators with conditional expressions compatible with PS5.1+
# Before
$currentLogLevel = $script:LogLevel ?? 'Information'
$currentLevelValue = $logLevels[$currentLogLevel] ?? 2

# After
$currentLogLevel = if ($null -ne $script:LogLevel) { $script:LogLevel } else { 'Information' }
$currentLevelValue = if ($null -ne $logLevels[$currentLogLevel]) { $logLevels[$currentLogLevel] } else { 2 }

Plaster.psm1

  • Added dot-sourcing for Private and Public function files
  • Implemented selective export of public functions only

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.powershellgallery.com
    • Triggering command: /usr/bin/pwsh pwsh -NoProfile -File ./build.ps1 -Bootstrap (dns block)
    • Triggering command: /usr/bin/pwsh pwsh -NoProfile -Command Register-PSRepository -Default -ErrorAction SilentlyContinue Get-PSRepository (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Plaster v2.0.0-alpha broken on Windows</issue_title>
<issue_description>Hiya,

Sampler uses Plaster and we've noticed on our pipelines that the prerelease version breaks on windows because Write-PlasterLog uses the Null-coalescing operator.

https://github.com/PowerShellOrg/Plaster/blob/v2/Plaster/Private/Write-PlasterLog.ps1#L52-L54

Could you please fix soonish, or would you recommend we pin an old version?</issue_description>

<agent_instructions>Search for any use of null coalescing and remove it. This module must be able to run PS5.1</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix Plaster v2.0.0-alpha for Windows compatibility Replace null-coalescing operators with PS5.1-compatible syntax Feb 12, 2026
Copilot AI requested a review from HeyItsGilbert February 12, 2026 17:05
@HeyItsGilbert HeyItsGilbert changed the base branch from master to v2 February 12, 2026 17:08
@HeyItsGilbert HeyItsGilbert force-pushed the copilot/fix-null-coalescing-issue branch from 3b24123 to 4bde3a8 Compare February 12, 2026 17:12
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 12, 2026

Test Results

  3 files  189 suites   35s ⏱️
210 tests 208 ✅ 2 💤 0 ❌
630 runs  624 ✅ 6 💤 0 ❌

Results for commit e019b41.

♻️ This comment has been updated with latest results.

@HeyItsGilbert HeyItsGilbert marked this pull request as ready for review February 12, 2026 17:20
Copilot AI and others added 3 commits February 12, 2026 09:34
@HeyItsGilbert HeyItsGilbert force-pushed the copilot/fix-null-coalescing-issue branch from 955ce7d to e019b41 Compare February 12, 2026 17:34
Copy link
Copy Markdown
Collaborator

@HeyItsGilbert HeyItsGilbert left a comment

Choose a reason for hiding this comment

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

LGTM

@HeyItsGilbert HeyItsGilbert merged commit a01a711 into v2 Feb 12, 2026
5 checks passed
@HeyItsGilbert HeyItsGilbert deleted the copilot/fix-null-coalescing-issue branch February 12, 2026 17:39
psjamesp added a commit that referenced this pull request Apr 13, 2026
…zed build/test (#449)

## Overview

This PR lands the long-running `v2` branch into `master`, shipping
Plaster **2.0.0-alpha1**. It's a large drop (~50 commits, ~115 files,
+11.5k / -3.2k) and touches nearly every part of the project, so the
sections below break it down by theme rather than by commit.

Target version: `Plaster.psd1` → `ModuleVersion = '2.0.0'`, `Prerelease
= 'alpha1'`.

## Highlights

- **JSON manifest support** — Plaster templates can now be authored as
JSON in addition to XML, with a full `plaster-manifest-v2.json` schema,
bidirectional conversion, and validation.
- **Modular source layout** — the monolithic `Invoke-Plaster.ps1` /
`NewPlasterManifest.ps1` / `GetModuleExtension.ps1` files have been
decomposed into per-function `Public/` and `Private/` files.
- **PowerShell 7.x + cross-platform** — Windows, Linux, macOS all
supported; minimum PS version is now 5.1.
- **Pester 5.x test suite** — large coverage expansion with per-function
tests.
- **Modernized build** — psake + PowerShellBuild + PSDepend, with a
`-Bootstrap` switch for clean CI installs.
- **Publish workflow** rewired end-to-end and validated against
GitHub-hosted runners.

## What changed

### Module architecture
- Split `Plaster/InvokePlaster.ps1` (1500+ lines),
`Plaster/NewPlasterManifest.ps1`, and `Plaster/GetModuleExtension.ps1`
into discrete `Public/` and `Private/` function files.
- New `Plaster/Private/` helpers for things that were previously inline:
`ConvertFrom-JsonManifest`, `ConvertTo-JsonManifest`,
`ConvertFrom-JsonContentAction`, `ConvertTo-JsonContentAction`,
`Copy-FileWithConflictDetection`, `Expand-FileSourceSpec`,
`Get-ManifestsUnderPath`, `Get-PlasterManifestType`,
`Initialize-PredefinedVariables`, `Invoke-ExpressionImpl`,
`Invoke-PlasterOperation`, `New-ConstrainedRunspace`,
`Resolve-ModuleVersionString`, `Resolve-ProcessParameter`,
`Start-Process*`, `Write-PlasterLog`, and friends.
- `Plaster.psm1` / `Plaster.psd1` updated to match the new layout.

### JSON manifest support (new)
- `Plaster/Schema/plaster-manifest-v2.json` — full JSON Schema for v2
manifests.
- JSON ↔ internal-model converters: `ConvertFrom-JsonManifest`,
`ConvertTo-JsonManifest`, plus content-action variants.
- `Get-PlasterManifestType` detects XML vs JSON manifests;
`Test-PlasterManifest` validates both.
- Example JSON manifests under `examples/` (`plasterManifest.json`,
`plasterManifest-validatePattern.json`, `plasterManifest_fr-FR.json`).
- Fixed error handling around file and template actions in JSON flow.

### Cross-platform / PS7
- Minimum PowerShell version raised to 5.1; null-coalescing operators
removed from hot paths for PS5.1 compatibility (#443).
- Default encoding changed from `Default` to `UTF-8-NoBOM`.
- Path separator handling normalized; constrained-runspace compatibility
fixes for PS7.
- Parameter default value storage fixed on non-Windows.

### Tests
- Migrated to **Pester 5.x** (breaking change for test authors).
- New per-function test files: `Get-ModuleExtension.Tests.ps1`,
`Get-PlasterManifestPathForCulture.Tests.ps1`,
`Initialize-PredefinedVariables.Tests.ps1`,
`Resolve-ModuleVersionString.Tests.ps1`,
`New-PlasterManifest.Tests.ps1`, etc.
- Added `Help.tests.ps1`, `Manifest.tests.ps1`, `Meta.tests.ps1`,
`MetaFixers.psm1` (imported from Stucco).
- Large fixture added for module resolution tests
(`tests/Fixtures/ModuleList.xml`).
- Conditional-attribute evaluation tests fixed (#445).

### Build & tooling
- `build.ps1` refactored for cleaner parameter handling, with `-Task`,
`-Bootstrap`, and `-Help` parameter sets.
- `-Bootstrap` provisions PSDepend (pinned to PowerShellGet v2), then
runs a try-import-first-then-install pattern against
`requirements.psd1`.
- `requirements.psd1` pins PSDepend 0.3.8, Pester 5.7.1, psake 4.9.1,
BuildHelpers 2.0.16, PowerShellBuild 0.7.2, PSScriptAnalyzer 1.24.0.
- `psakeFile.ps1` delegates to PowerShellBuild; `CopyDirectories`
configured for `en-US`, `Schema`, `Templates`.
- `debugHarness.ps1` refactored for the new module layout.
- `.vscode/` tasks + settings refreshed; `.markdownlint.json` +
`cspell.json` added.

### CI / publish workflow
- `.github/workflows/publish.yaml` now runs on `windows-latest`, uses
`ModuleFast-action` to pre-stage deps, and invokes `./build.ps1 -Task
Publish -Bootstrap`.
- `.github/workflows/PesterReports.yml` updated permissions and action
versions.
- Dead placeholder \`internal-nuget-repo\` registration removed from the
bootstrap path (was failing \`Register-PSRepository\` URI validation on
GitHub runners).

### Docs
- README rewritten for v2.
- CHANGELOG reformatted to Keep a Changelog.
- Logo updated to make the 2.0 branding clearer.
- Examples directory expanded.

## Breaking changes

- **Minimum PowerShell version** is now 5.1 (was 3.0).
- **Test framework** is Pester 5.x — any downstream tests authored
against Pester 3/4 will need updating.
- **Default encoding** changed to `UTF-8-NoBOM`.
- Internal module layout changed significantly; anything dot-sourcing
Plaster internals by path will break (public API is unchanged).

## Test plan

- [ ] CI green on `v2` (publish workflow dry-run + Pester reports)
- [ ] \`./build.ps1 -Bootstrap -Task Test\` passes locally on Windows PS
5.1
- [ ] \`./build.ps1 -Bootstrap -Task Test\` passes on Windows PS 7
- [ ] Smoke test on Linux / macOS (PS 7)
- [ ] \`Invoke-Plaster\` against an XML manifest still works
(regression)
- [ ] \`Invoke-Plaster\` against a JSON manifest works end-to-end
- [ ] \`Test-PlasterManifest\` validates both XML and JSON manifests
- [ ] Publish workflow successfully pushes \`2.0.0-alpha1\` to PSGallery
when manually dispatched

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plaster v2.0.0-alpha broken on Windows

2 participants