Skip to content

🚀 [Feature]: Support anchors & and aliases * #22

@MariusStorhaug

Description

Anchors and aliases let a YAML document reference the same node multiple times.

Request

ConvertFrom-Yaml should resolve aliases to the anchored node:

defaults: &defaults
  timeout: 30
  retries: 3

production:
  <<: *defaults
  host: prod.example.com

Note: the << merge key is a separate (legacy YAML 1.1) feature and is not part of YAML 1.2.2 core. Decide whether to support it as an opt-in extension.

ConvertTo-Yaml does not need to emit anchors automatically (the spec allows but does not require it). Round-tripping anchors is out of scope for v1.

Spec examples covered

  • Example 2.10 — Node "Sammy Sosa" appears twice
  • Parts of Example 2.27 (Invoice)

Implementation notes

  • Anchor scope is per-document. Multi-document support (separate issue) is a prerequisite for full correctness.
  • Cyclic references should be detected and rejected (or surfaced as an error) since PowerShell objects do not naturally represent graphs.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions