Skip to content

Handle scalar RequiredModules in local repository manifests - #2077

Open
Dimitriy Leontev (dleontev) wants to merge 1 commit into
PowerShell:masterfrom
dleontev:fix/local-requiredmodules-2059
Open

Dimitriy Leontev (dleontev) wants to merge 1 commit into
PowerShell:masterfrom
dleontev:fix/local-requiredmodules-2059

Conversation

@dleontev

Copy link
Copy Markdown

PR Summary

Normalize local module-manifest RequiredModules values with PowerShell's array conversion before reading dependency information. Single module-name strings and single hashtables now follow the same path as arrays, and null values produce an empty dependency list.

Add 12 regression cases covering scalar and array representations, mixed dependencies, empty/null/omitted values and dependency version ranges.

Fixes #2059.

PR Context

PowerShell accepts a single string or hashtable for RequiredModules. The local-repository conversion code previously cast this value to Object[], yielding null for valid scalar values and then failing when enumerating it. This prevented package discovery before Find/Save/Install could continue.

The change follows the normalization approach used by PublishHelper.ParseRequiredModules and preserves the existing dependency-version parsing.

Validation

  • Release build for net472 with the repository's pinned .NET SDK 10.0.403 passed.
  • Against the unmodified build, the affected test file had 12 passing and six failing tests, reproducing the scalar/null failures.
  • With the fix, all 18 tests in PSResourceInfo.Tests.ps1 passed on both PowerShell 7.6.5 and Windows PowerShell 5.1.26100.9818.
  • PSScriptAnalyzer 1.24.0 reports no new findings compared with the upstream test file. Revised tests use the repository's CI tag and exclude ManualValidationOnly.
  • Additional local integration checks execute the public Find/Save/Install cmdlets with synthetic packages. All 25 checks pass on each host, covering scalar strings/hashtables, minimum/exact/ranged dependency versions, an array control, and Save/Install with and without -SkipDependencyCheck.
  • Against the original build, the same integration matrix reproduces the reported null reference in all 20 scalar-input checks on each host; the five array-control checks pass.
  • Integration test installations were redirected into the workspace. Each run's temporary repository registration was removed, and the prior repository-store state was restored.
  • The full multi-service integration suite and non-Windows execution were not run. Upstream CI remains pending.

AI assistance: Codex prepared the code and regression tests and ran the local validation described above.

PR Checklist

  • PR has a meaningful title.
  • Summarized changes.
  • Changed source files retain their copyright/license headers.
  • Author has approved submission of the reviewed patch; this PR is ready for review rather than work in progress.
  • No breaking changes intended.
  • Documentation change is not needed to restore support for existing manifest forms.
  • Added regression tests for the changed behavior.
  • Considered tooling impact: no new parameters or public API changes.

Normalize RequiredModules with PowerShell's array conversion before
reading local-repository dependency metadata. Accept scalar module names
and hashtables while preserving existing array and version behavior.

Add regression coverage for supported dependency representations,
optional values, and version constraints.

Fixes PowerShell#2059.
@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

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues require resolution for the local manifest dependency normalization change.

No open issues 🎉

What changed in this PR

This PR fixes local repository manifest parsing for scalar RequiredModules values, addressing issue #2059 so package discovery can proceed for Find, Save, and Install.

Changes:

  • Uses PowerShell array conversion to normalize scalar and array dependencies, treating null as an empty list.
  • Adds 12 regression cases covering dependency representations, empty/null/omitted values, and version constraints.
File Description
test/​PSResourceInfo.Tests.ps1 Adds regression coverage for dependency normalization and version ranges.
src/​code/​PSResourceInfo.cs Normalizes RequiredModules before enumerating local manifest dependencies.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants