Skip to content

Add ValueFromPipeline parameter set to Connect-VisioShape #163

Description

@saveenr

Phase B item from the #150 PSVA gap audit. Standalone since it's back-compat-safe and small.

What

Add a pipeline-friendly parameter set to Connect-VisioShape so star-topology bulk-connect works:

$shapes | Connect-VisioShape -From $sourceShape

Each shape on the pipeline becomes a connector destination from a single named source (the PSVA Add-visShapeConnection -FromShape $src pattern).

Today's shape

[SMA.Parameter(Position = 0, Mandatory = true)] IVisio.Shape[] From { get; set; }
[SMA.Parameter(Position = 1, Mandatory = true)] IVisio.Shape[] To { get; set; }
[SMA.Parameter(Position = 2, Mandatory = false)] IVisio.Master Master { get; set; }

Both From and To are [Parameter] with positions but no ValueFromPipeline = true. The cmdlet works for Connect-VisioShape $src $dst but doesn't bind from a pipeline.

Proposed shape

Add a parameter set that accepts pipeline input on To. Sketch (final shape pending design):

[SMA.Parameter(ParameterSetName = "Positional", Position = 0, Mandatory = true)] public IVisio.Shape[] From { get; set; }
[SMA.Parameter(ParameterSetName = "Positional", Position = 1, Mandatory = true)] public IVisio.Shape[] To { get; set; }

[SMA.Parameter(ParameterSetName = "Pipeline", Mandatory = true)] public IVisio.Shape FromShape { get; set; }
[SMA.Parameter(ParameterSetName = "Pipeline", Mandatory = true, ValueFromPipeline = true)] public IVisio.Shape ToShape { get; set; }

Open design questions to settle in the implementation:

  • Single-source / single-destination per pipeline iteration vs. continuing to accept arrays in the pipeline set?
  • -Master carries through both sets? (Yes, almost certainly.)
  • Begin / Process / End lifecycle: batch into a single ConnectShapes(...) call at End, or call once per pipeline item? Batching is more efficient for large pipelines; per-item is more responsive.

Acceptance

  • New parameter set lands; existing Connect-VisioShape $src $dst calls still work unchanged (positional binding).
  • New regression test in VTest.PowerShell exercises the pipeline pattern: build N shapes, run $shapes | Connect-VisioShape -From $src, assert N connectors created.
  • VisioPowerShell/CHANGELOG.md [Unreleased] entry under "Added".

Effort

S. ~1-2 hours including the test and changelog.

Themed milestone

Milestone D (Cmdlet ergonomics).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions