Skip to content

Fix New-ModuleManifest formatting issues (#27633)#27717

Open
eevaal wants to merge 1 commit into
PowerShell:masterfrom
eevaal:eevaal-issue-27633-new-modulemanifest-formatting-issues-bb9f04
Open

Fix New-ModuleManifest formatting issues (#27633)#27717
eevaal wants to merge 1 commit into
PowerShell:masterfrom
eevaal:eevaal-issue-27633-new-modulemanifest-formatting-issues-bb9f04

Conversation

@eevaal

@eevaal eevaal commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Fixes the PSScriptAnalyzer violations reported in issue #27633.

Changes

This PR addresses two formatting issues in New-ModuleManifest:

  1. PSAvoidTrailingWhitespace: Removed trailing whitespace on wrapped array lines
  2. PSUseConsistentIndentation: Replaced column-aligned indentation (15 spaces) with consistent indentation (4 spaces)

Modified Methods

QuoteNames(IEnumerable names, StreamWriter streamWriter)

  • Moved quotedString declaration to the beginning for better flow
  • Check line length (newOffset) BEFORE appending the comma-space separator
  • Only append ", " when NOT wrapping to avoid trailing whitespace
  • When wrapping: append just "," (no space), then newline, then 4 spaces for indentation
  • Reset offset to 4 + quotedString.Length on wrapped lines

QuoteModules(IEnumerable moduleSpecs, StreamWriter streamWriter)

  • Changed ", " to "," to avoid trailing whitespace
  • Changed 15-space padding to 4-space padding for consistent indentation

Expected Output

Before

FunctionsToExport = 'FunctionA', 'FunctionB', 
               'FunctionC'
  • ✗ Trailing whitespace after comma
  • ✗ Column-aligned (15 spaces)

After

FunctionsToExport = 'FunctionA', 'FunctionB',
    'FunctionC'
  • ✓ No trailing whitespace
  • ✓ Consistent indentation (4 spaces)

Testing

These changes ensure that the output of New-ModuleManifest complies with PSScriptAnalyzer rules:

  • PSAvoidTrailingWhitespace - No trailing whitespace on any line
  • PSUseConsistentIndentation - Consistent 4-space indentation for continuation lines

Related Issue

Fixes #27633

- Fix PSAvoidTrailingWhitespace: Remove trailing whitespace on wrapped array lines
- Fix PSUseConsistentIndentation: Use 4-space consistent indentation instead of column alignment
- In QuoteNames: Check line length before appending comma-space separator
- In QuoteModules: Replace 15-space column alignment with 4-space indentation

Fixes PowerShell#27633

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 22, 2026 23:00
@eevaal
eevaal requested review from a team and jshigetomi as code owners July 22, 2026 23:00
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates New-ModuleManifest’s manifest-value formatting to address PSScriptAnalyzer formatting rules, but it also introduces a large set of additional new tooling/scripts, tests, docs, and a new UNIX syslog tracing implementation that are not described in the PR metadata.

Changes:

  • Adjust New-ModuleManifest list formatting to avoid trailing whitespace on wrapped lines and use a 4-space continuation indent.
  • Add new UNIX syslog tracing provider implementation (plus generated event-resource support).
  • Add multiple new installer/helper scripts and new/updated test and documentation assets.

Reviewed changes

Copilot reviewed 1 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/ResxGen/ResxGen.ps1 Adds a PowerShell entrypoint script to generate resx/code from an ETW manifest.
tools/installpsh-suse.sh Adds SUSE install helper script.
tools/installpsh-redhat.sh Adds RedHat install helper script.
tools/installpsh-osx.sh Adds macOS install helper script.
tools/installpsh-gentoo.sh Adds Gentoo install helper script.
tools/installpsh-debian.sh Adds Debian-based install helper script.
tools/installpsh-amazonlinux.sh Adds Amazon Linux install helper script.
tools/install-powershell.sh Adds/updates top-level installer dispatcher script (includes commit pinning).
tools/generate-icns.sh Adds helper script for generating .icns from an SVG on macOS.
tools/debug.sh Adds a helper script for launching LLDB with SOS plugin.
test/tools/Modules/HelpersHostCS/HelpersHostCS.psm1 Adds a C#-backed test host module used by tests.
test/shebang/script.ps1 Adds a shebang PowerShell script used for shebang-related testing.
test/powershell/Modules/Microsoft.PowerShell.Security/GetCredential.Tests.ps1 Adds Pester coverage for Get-Credential behavior using a test host.
test/powershell/Host/assets/Read-Host.Output.expect Adds an expect script asset for Read-Host behavior verification.
src/System.Management.Automation/utils/tracing/SysLogProvider.cs Adds a UNIX syslog logging provider implementation.
src/System.Management.Automation/utils/tracing/PSSysLogProvider.cs Adds a syslog-backed LogProvider implementation for UNIX.
src/System.Management.Automation/utils/tracing/PSEtwLogProvider.cs Adds/updates the ETW-backed LogProvider implementation for non-UNIX.
src/System.Management.Automation/engine/Modules/NewModuleManifestCommand.cs Updates wrapping/indent logic to avoid trailing whitespace and column-aligned continuation indentation.
src/System.Management.Automation/CoreCLR/EventResource.cs Adds generated event-resource mapping for UNIX builds.
docs/testing-guidelines/WritingPesterTests.md Adds Pester authoring guidance documentation.
docs/testing-guidelines/testing-guidelines.md Adds/updates general testing guidelines documentation.

Comment on lines +588 to 592
string quotedString = QuoteName(name);

if (first)
{
first = false;
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.

New-ModuleManifest formatting issues

2 participants