Skip to content

fix: add PS5.1 SemanticVersion shim so Resolve-ModuleVersionString returns a consistent type #460

@HeyItsGilbert

Description

@HeyItsGilbert

What to build

Resolve-ModuleVersionString currently returns [System.Version] on PS5.1 and [System.Management.Automation.SemanticVersion] on PS6+. The tests assert Should -BeOfType [System.Management.Automation.SemanticVersion] unconditionally, so they fail on PS5.1.

The right fix is to add a PS5.1-compatible SemanticVersion shim — a minimal class defined via Add-Type, loaded only when [System.Management.Automation.SemanticVersion] is not already available. Resolve-ModuleVersionString should use this shim on PS5.1 instead of falling back to [System.Version], so callers and tests receive the same type on both editions without any version-guard branching.

Acceptance criteria

  • A SemanticVersion shim is defined and loaded when running on PS5.1
  • Resolve-ModuleVersionString returns the shim type on PS5.1 and the native type on PS6+
  • Both Resolve-ModuleVersionString tests pass unmodified on PS5.1 and PS7
  • No existing PS7 behaviour changes

Blocked by

None - can start immediately

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions