From b66b15ea25898f5adcb0ccba77f0a5c27f0ed22e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Apr 2026 17:49:29 +0200 Subject: [PATCH] refactor: remove IsWindows PS 5.1 compatibility shim PSModule targets PowerShell LTS (7.6+) where $IsWindows is a built-in automatic variable. The Desktop edition shim and its PSScriptAnalyzer suppressions are no longer needed. --- src/helpers/Build/Build-PSModuleRootModule.ps1 | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/helpers/Build/Build-PSModuleRootModule.ps1 b/src/helpers/Build/Build-PSModuleRootModule.ps1 index 7247766..02aaa98 100644 --- a/src/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/src/helpers/Build/Build-PSModuleRootModule.ps1 @@ -131,17 +131,6 @@ $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { #endregion - Analyze source files #region - Module header - Add-Content -Path $rootModuleFile -Force -Value @' -[Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSAvoidAssignmentToAutomaticVariable', 'IsWindows', - Justification = 'IsWindows does not exist in PS5.1' -)] -[Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSUseDeclaredVarsMoreThanAssignments', 'IsWindows', - Justification = 'IsWindows does not exist in PS5.1' -)] -'@ - $headerFilePath = Join-Path -Path $ModuleOutputFolder -ChildPath 'header.ps1' if (Test-Path -Path $headerFilePath) { Get-Content -Path $headerFilePath -Raw | Add-Content -Path $rootModuleFile -Force @@ -162,10 +151,6 @@ $script:PSModuleInfo | Format-List | Out-String -Stream | ForEach-Object { Write $scriptName = $script:PSModuleInfo.Name Write-Debug "[$scriptName] - Importing module" -if ($PSEdition -eq 'Desktop') { - $IsWindows = $true -} - '@ #endregion - Module post-header